public void test_SBMLConvertStrict_convertToL1() { SBMLDocument d = new SBMLDocument(2, 4); Model m = d.createModel(); (m).setMetaId("_m"); Compartment c = m.createCompartment(); c.setId("c"); (c).setSBOTerm(240); Species s = m.createSpecies(); s.setId("s"); s.setCompartment("c"); assertTrue(d.setLevelAndVersion(1, 2, true) == true); assertTrue(d.getLevel() == 1); assertTrue(d.getVersion() == 2); Model m1 = d.getModel(); assertTrue((m1).getMetaId() == ""); Compartment c1 = m1.getCompartment(0); assertTrue((c1).getSBOTerm() == -1); Species s1 = m1.getSpecies(0); assertTrue(s1.getHasOnlySubstanceUnits() == false); d = null; }
public void test_SBMLConvertStrict_convertNonStrictSBO() { SBMLDocument d = new SBMLDocument(2, 4); Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("c"); c.setConstant(false); (c).setSBOTerm(64); assertTrue(d.setLevelAndVersion(2, 3, true) == false); assertTrue(d.getLevel() == 2); assertTrue(d.getVersion() == 4); assertTrue(d.setLevelAndVersion(2, 2, true) == false); assertTrue(d.getLevel() == 2); assertTrue(d.getVersion() == 4); assertTrue(d.setLevelAndVersion(2, 1, true) == true); assertTrue(d.getLevel() == 2); assertTrue(d.getVersion() == 1); Compartment c1 = d.getModel().getCompartment(0); assertTrue((c1).getSBOTerm() == -1); assertTrue(d.setLevelAndVersion(1, 2, true) == true); assertTrue(d.getLevel() == 1); assertTrue(d.getVersion() == 2); Compartment c2 = d.getModel().getCompartment(0); assertTrue((c2).getSBOTerm() == -1); d = null; }
public void test_SBMLConvertStrict_convertNonStrictUnits() { SBMLDocument d = new SBMLDocument(2, 4); Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("c"); c.setConstant(false); Parameter p = m.createParameter(); p.setId("p"); p.setUnits("mole"); ASTNode math = libsbml.parseFormula("p"); Rule ar = m.createAssignmentRule(); ar.setVariable("c"); ar.setMath(math); assertTrue(d.setLevelAndVersion(2, 1, true) == false); assertTrue(d.getLevel() == 2); assertTrue(d.getVersion() == 4); assertTrue(d.setLevelAndVersion(2, 2, true) == false); assertTrue(d.getLevel() == 2); assertTrue(d.getVersion() == 4); assertTrue(d.setLevelAndVersion(2, 3, true) == false); assertTrue(d.getLevel() == 2); assertTrue(d.getVersion() == 4); assertTrue(d.setLevelAndVersion(1, 2, true) == false); assertTrue(d.getLevel() == 2); assertTrue(d.getVersion() == 4); d = null; }
protected internal CurrentModelSelection GetCurrentSelectedPersistentType() { CurrentModelSelection result = new CurrentModelSelection(); result.DocData = Owner.GetModelingDocData(); result.DiagramDocView = Owner.GetDiagramDocView(); result.CurrentSelection = Owner.CurrentSelection; result.IsPersistentTypeSelected = Owner.CurrentSelection.OfType <PersistentShape>().Count() == 1; result.IsCompartmentSelected = Owner.CurrentSelection.OfType <Compartment>().Count() == 1; if (result.IsPersistentTypeSelected || result.IsCompartmentSelected) { if (result.IsPersistentTypeSelected) { result.CurrentPersistentType = Owner.CurrentSelection.OfType <PersistentShape>().Select(shape => shape.ModelElement).OfType <PersistentType>().Single(); } else { Compartment compartment = Owner.CurrentSelection.OfType <Compartment>().Single(); result.CompartmentName = compartment.Name; result.CurrentPersistentType = (PersistentType)compartment.ParentShape.ModelElement; } } return(result); }
public void test_SBMLConvertStrict_convertL1ParamRule() { SBMLDocument d = new SBMLDocument(1, 2); Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("c"); Parameter p = m.createParameter(); p.setId("p"); Parameter p1 = m.createParameter(); p1.setId("p1"); ASTNode math = libsbml.parseFormula("p"); Rule ar = m.createAssignmentRule(); ar.setVariable("p1"); ar.setMath(math); ar.setUnits("mole"); assertTrue(d.setLevelAndVersion(2, 1, true) == true); assertTrue(d.getLevel() == 2); assertTrue(d.getVersion() == 1); Rule r1 = d.getModel().getRule(0); assertTrue(r1.getUnits() == ""); d = null; }
Compartment remove(long n) { IntPtr cPtr = libsbmlPINVOKE.ListOfCompartments_remove__SWIG_0(swigCPtr, n); Compartment ret = (cPtr == IntPtr.Zero) ? null : new Compartment(cPtr, true); return(ret); }
public void test_Compartment() { Compartment c = new Compartment(2, 4); assertEquals(true, c.hasRequiredElements()); c = null; }
public void Graph(Compartment AxisX, Compartment AxisY) { List <string> arguments = new List <string>() { "x" }; Function function = new Function(this.function_expression, arguments); this.chart.Series[0].Points.Clear(); this.chart.ChartAreas[0].AxisX.Maximum = AxisX.Max; this.chart.ChartAreas[0].AxisX.Minimum = AxisX.Min; this.chart.ChartAreas[0].AxisY.Maximum = AxisY.Max; this.chart.ChartAreas[0].AxisY.Minimum = AxisY.Min; this.chart.Series[0].BorderWidth = 3; this.chart.ChartAreas[0].AxisX.Crossing = 0; // <--- These two lines chart.ChartAreas[0].AxisY.Crossing = 0; this.chart.ChartAreas[0].CursorX.IsUserEnabled = true; this.chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; this.chart.ChartAreas[0].AxisX.ScaleView.Zoomable = true; for (int i = (int)AxisX.Min; i <= (int)AxisX.Max; i++) { double functionValue = function.Evaluate(new List <double>() { i }); this.chart.Series[0].Points.AddXY(i, functionValue); this.chart.Series[0].ChartType = SeriesChartType.Line; } }
public void Graph(Compartment AxisX) { this.chart.Series[0].Points.Clear(); this.chart.ChartAreas[0].AxisX.Maximum = AxisX.Max + 1; this.chart.ChartAreas[0].AxisX.Minimum = AxisX.Min - 1; this.chart.ChartAreas[0].AxisY.Maximum = 0; this.chart.ChartAreas[0].AxisY.Minimum = 0; this.chart.Series[0].BorderWidth = 5; this.chart.Legends[0].Name = this.function_expression; for (double i = this.chart.ChartAreas[0].AxisX.Minimum; i <= this.chart.ChartAreas[0].AxisX.Maximum; i += 0.2) { double functionValue = function.Evaluate(new List <double>() { i }); if (functionValue > chart.ChartAreas[0].AxisY.Maximum) { this.chart.ChartAreas[0].AxisY.Maximum = functionValue; } if (functionValue < chart.ChartAreas[0].AxisY.Minimum) { this.chart.ChartAreas[0].AxisY.Minimum = functionValue; } this.chart.Series[0].Points.AddXY(i, functionValue); } }
//[ValidateAntiForgeryToken] public ActionResult Create([Bind(Include = "CompartmentID,CompartmentCode,Capactiy,TrailerID,Description,ModifiedDate,CreatedDate")] Compartment compartment) { if (ModelState.IsValid) { if (compartment.CompartmentID.Equals(0)) { db.Compartments.Add(compartment); db.SaveChanges(); return(RedirectToAction("Index", new { ID = compartment.TrailerID })); } else { db.Entry(compartment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { ID = compartment.TrailerID })); } } else { var errors = ModelState.Values.SelectMany(v => v.Errors); } ViewBag.TrailerID = new SelectList(db.Trailers, "TrailerID", "TrailerCode", compartment.TrailerID); return(View(compartment)); }
public static Compartment CompartmentFromJson(dynamic json) { Compartment Compartment = new Compartment() { name = json.Name }; // Compartments have name of form "Slotnn_Sizenn" Match matches = Regex.Match((string)json.Name, @"Size([0-9]+)"); if (matches.Success) { Compartment.size = Int32.Parse(matches.Groups[1].Value); if (json.Value is JObject) { JToken value; if (json.Value.TryGetValue("module", out value)) { Compartment.module = ModuleFromJson((string)json.Name, json.Value); } } } return(Compartment); }
internal ThawBuffer(Compartment setting, ObjectRegistry reg, SerUnit unit, byte[] data) { this.data = data; this.setting = setting; this.reg = reg; this.unit = unit; }
protected override void Context() { base.Context(); _simulation.RemoveAllBuildingBlockOfType(PKSimBuildingBlockType.Individual); _parameters = new List <IParameter>(); var kidney = new Organ().WithName(CoreConstants.Organ.KIDNEY); var kidney_cell = new Compartment().WithName(CoreConstants.Compartment.INTRACELLULAR).WithParentContainer(kidney); var kid_cell_trans = new Container().WithName(_transporter.Name).WithParentContainer(kidney_cell); var relExp2Param = DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.REL_EXP) .WithParentContainer(kid_cell_trans); relExp2Param.Origin.SimulationId = "Sim"; var liver = new Organ().WithName(CoreConstants.Organ.LIVER); var liver_cell = new Container().WithName(CoreConstants.Compartment.INTRACELLULAR).WithParentContainer(liver); var liver_enz = new Container().WithName(_enzyme.Name).WithParentContainer(liver_cell); var relExp1Param = DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.REL_EXP) .WithParentContainer(liver_enz); relExp1Param.Origin.SimulationId = "Sim"; _referenceConcentrationParam = DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.REFERENCE_CONCENTRATION); _halfLifeLiverParameter = DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.HALF_LIFE_LIVER); _halfLifeLiverIntestineParameter = DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.HALF_LIFE_INTESTINE); _parameters.AddRange(new[] { _halfLifeLiverParameter, _halfLifeLiverIntestineParameter, _referenceConcentrationParam, relExp1Param, relExp2Param }); }
protected override void Context() { base.Context(); _parameters = new List <IParameter>(); var brain = new Organ().WithName(CoreConstants.Organ.BRAIN); var brain_pls = new Compartment().WithName(CoreConstants.Compartment.PLASMA).WithParentContainer(brain); var brain_pls_trans = new Container().WithName(_transporter.Name).WithParentContainer(brain_pls); var relExp2Param = DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.REL_EXP) .WithParentContainer(brain_pls_trans); relExp2Param.Origin.SimulationId = "Sim"; var liver = new Organ().WithName(CoreConstants.Organ.LIVER); var liver_cell = new Container().WithName(CoreConstants.Compartment.INTRACELLULAR).WithParentContainer(liver); var liver_enz = new Container().WithName(_enzyme.Name).WithParentContainer(liver_cell); var relExp1Param = DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.REL_EXP) .WithParentContainer(liver_enz); relExp1Param.Origin.SimulationId = "Sim"; _referenceConcentrationParam = DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.REFERENCE_CONCENTRATION); _halfLifeLiverParameter = DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.HALF_LIFE_LIVER); _halfLifeLiverIntestineParameter = DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.HALF_LIFE_INTESTINE); _parameters.AddRange(new[] { _halfLifeLiverParameter, _halfLifeLiverIntestineParameter, _referenceConcentrationParam, relExp1Param, relExp2Param }); }
protected override void Because() { var model = new Model(3, 1); model.setName("TestModel"); model.setNotes("TestNotes"); model.setMetaId("TestMetaId"); sut.CreateEventsTopContainer(); sut.CreateTopContainer(model); var compartment = new Compartment(3, 1); compartment.setName("Compartment"); compartment.setId("c1"); compartment.setSpatialDimensions(1); compartment.setSize(5); var compartment2 = new Compartment(3, 1); compartment2.setName("Compartment"); compartment2.setId("c2"); compartment2.setSpatialDimensions(2); compartment2.setSize(5); var compartment3 = new Compartment(3, 1); compartment3.setName("Compartment"); compartment3.setId("c3"); compartment3.setSpatialDimensions(3); compartment3.setSize(5); _container = sut.CreateContainerFromCompartment(compartment); _container2 = sut.CreateContainerFromCompartment(compartment2); _container3 = sut.CreateContainerFromCompartment(compartment3); sut.CreateSpatialStructureFromModel(sut._topContainer, model); }
public void test_SBMLConvert_convertToL1_Species_Concentration() { SBMLDocument d = new SBMLDocument(2, 1); Model m = d.createModel(); string sid = "C"; Compartment c = new Compartment(2, 1); Species s = new Species(2, 1); c.setId(sid); c.setSize(1.2); m.addCompartment(c); s.setId("s"); s.setCompartment(sid); s.setInitialConcentration(2.34); m.addSpecies(s); assertTrue(d.setLevelAndVersion(1, 2, true) == true); Species s1 = m.getSpecies(0); assertTrue(s1 != null); assertTrue(("C" == s1.getCompartment())); assertTrue(m.getCompartment("C").getSize() == 1.2); assertTrue(s1.getInitialConcentration() == 2.34); assertTrue(s1.isSetInitialConcentration() == true); d = null; }
Compartment remove(string sid) { IntPtr cPtr = libsbmlPINVOKE.ListOfCompartments_remove__SWIG_1(swigCPtr, sid); Compartment ret = (cPtr == IntPtr.Zero) ? null : new Compartment(cPtr, true); return(ret); }
public void test_SBMLConvert_convertToL3_localParameters() { SBMLDocument d = new SBMLDocument(1, 2); Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("c"); Species s = m.createSpecies(); s.setId("s"); s.setCompartment("c"); Reaction r = m.createReaction(); SpeciesReference sr = r.createReactant(); sr.setSpecies("s"); KineticLaw kl = r.createKineticLaw(); kl.setFormula("s*k"); Parameter p = kl.createParameter(); p.setId("k"); assertTrue(kl.getNumLocalParameters() == 0); assertTrue(d.setLevelAndVersion(3, 1, false) == true); m = d.getModel(); r = m.getReaction(0); kl = r.getKineticLaw(); assertTrue(kl.getNumLocalParameters() == 1); LocalParameter lp = kl.getLocalParameter(0); d = null; }
private static async Task DisplayAudit( AuditClientAsync client, IdentityClient identityClinet, Compartment compartment, string startDate, string endDate, string requestId = "", string pageId = "") { // get Audit Events var listEventsRequest = new ListEventsRequest() { CompartmentId = compartment.Id, StartTime = startDate, EndTime = endDate, Page = pageId }; var events = await client.ListEvents(listEventsRequest); if (!string.IsNullOrEmpty(events.OpcNextPage)) { await DisplayAudit(client, identityClinet, compartment, startDate, endDate, events.OpcRequestId, events.OpcNextPage); } if (events.Items.Count > 0) { Count += events.Items.Count; Console.WriteLine($"enventset: com={compartment.Name}, start={startDate}, end={endDate}, events.Items:{events.Items.Count}"); } }
public void test_SBMLConvert_convertToL3_stoichiometryMath() { SBMLDocument d = new SBMLDocument(2, 1); Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("c"); Species s = m.createSpecies(); s.setId("s"); s.setCompartment("c"); Reaction r = m.createReaction(); SpeciesReference sr = r.createReactant(); sr.setSpecies("s"); StoichiometryMath sm = sr.createStoichiometryMath(); ASTNode ast = libsbml.parseFormula("c*2"); sm.setMath(ast); assertTrue(m.getNumRules() == 0); assertTrue(sr.isSetId() == false); assertTrue(d.setLevelAndVersion(3, 1, false) == true); m = d.getModel(); r = m.getReaction(0); sr = r.getReactant(0); assertTrue(m.getNumRules() == 1); assertTrue(sr.isSetId() == true); Rule rule = m.getRule(0); assertTrue((rule.getVariable() == sr.getId())); d = null; }
/// <summary> /// Gets called whenever a shape is inserted into the diagram. /// This is a good time to setup visuals, because all shapes, /// decorators, compartments, shapefields, etc. have been created. /// </summary> public override void OnShapeInserted() { base.OnShapeInserted(); // Define the font change to make. // In this case, make all decorators show bold, italic, // and bigger sized text. FontSettings fs = new FontSettings(); foreach (ShapeDecorator decorator in this.Decorators) { // Only do this for all of the text decorators in this shape. TextShapeDecorator shapeDec = decorator as TextShapeDecorator; if (shapeDec != null) { shapeDec.StyleSet.OverrideFont(DiagramFonts.ShapeText, fs); } } // make the compartment item text bold. FontSettings fsBold = new FontSettings(); foreach (ShapeElement shape in this.NestedChildShapes) { // Only do this for all of the compartments in this shape. Compartment compartment = shape as Compartment; if (compartment != null) { compartment.StyleSet.OverrideFont(DiagramFonts.ShapeTitle, fsBold); } } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Compartment compartment) { if (id != compartment.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(compartment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompartmentExists(compartment.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(compartment)); }
/// <summary> /// Sélection des propriétes dans la compartiment list /// </summary> /// <param name="view">The view.</param> /// <param name="association">The association.</param> /// <param name="entity">The entity.</param> /// <param name="properties">The properties.</param> private static void SelectProperties(DiagramClientView view, Association association, Entity entity, IList <Property> properties) { IList <PresentationElement> presentations = PresentationViewsSubject.GetPresentation(entity); Debug.Assert(presentations.Count > 0); Compartment compartment = ((CompartmentShape)presentations[0]).FindCompartment("Properties"); Debug.Assert(compartment != null); foreach (ShapeField field in compartment.ShapeFields) { if (field is ListField) { foreach (Property property in properties) { if (property != null) { int index = entity.Properties.IndexOf(property); DiagramItem item = new DiagramItem(compartment, field, new ListItemSubField(index)); if (!view.Selection.Contains(item)) { view.Selection.Add(item); } } } break; } } }
public void test_L3_Compartment_initDefaults() { Compartment c = new Compartment(3, 1); c.setId("A"); assertEquals(true, c.isSetId()); assertEquals(false, c.isSetName()); assertEquals(false, c.isSetSize()); assertEquals(false, c.isSetVolume()); assertEquals(false, c.isSetUnits()); assertEquals(false, c.isSetConstant()); assertEquals(false, c.isSetSpatialDimensions()); c.initDefaults(); assertTrue(("A" == c.getId())); assertTrue(c.getName() == ""); assertTrue(("litre" == c.getUnits())); assertTrue(c.getSpatialDimensions() == 3); assertTrue(c.getSize() == 1); assertTrue(c.getConstant() == true); assertEquals(true, c.isSetId()); assertEquals(false, c.isSetName()); assertEquals(false, c.isSetSize()); assertEquals(false, c.isSetVolume()); assertEquals(true, c.isSetUnits()); assertEquals(true, c.isSetConstant()); assertEquals(true, c.isSetSpatialDimensions()); c = null; }
public void test_L3_Compartment_createWithNS() { XMLNamespaces xmlns = new XMLNamespaces(); xmlns.add("http://www.sbml.org", "testsbml"); SBMLNamespaces sbmlns = new SBMLNamespaces(3, 1); sbmlns.addNamespaces(xmlns); Compartment c = new Compartment(sbmlns); assertTrue(c.getTypeCode() == libsbml.SBML_COMPARTMENT); assertTrue(c.getMetaId() == ""); assertTrue(c.getNotes() == null); assertTrue(c.getAnnotation() == null); assertTrue(c.getLevel() == 3); assertTrue(c.getVersion() == 1); assertTrue(c.getNamespaces() != null); assertTrue(c.getNamespaces().getLength() == 2); assertTrue(c.getId() == ""); assertTrue(c.getName() == ""); assertTrue(c.getUnits() == ""); assertTrue(c.getOutside() == ""); assertEquals(true, isnan(c.getSpatialDimensionsAsDouble())); assertEquals(true, isnan(c.getVolume())); assertTrue(c.getConstant() == true); assertEquals(false, c.isSetId()); assertEquals(false, c.isSetSpatialDimensions()); assertEquals(false, c.isSetName()); assertEquals(false, c.isSetSize()); assertEquals(false, c.isSetVolume()); assertEquals(false, c.isSetUnits()); assertEquals(false, c.isSetOutside()); assertEquals(false, c.isSetConstant()); c = null; }
Compartment get(long n) { IntPtr cPtr = libsbmlPINVOKE.ListOfCompartments_get__SWIG_0(swigCPtr, n); Compartment ret = (cPtr == IntPtr.Zero) ? null : new Compartment(cPtr, false); return(ret); }
/// <summary> /// Gets the compartment status with Json web token credentials. /// Json web token credentials contains enable or disable, if enable then need to provide jwt secret and token. /// </summary> /// <returns> /// List of compartment status with object detection and LED status based requested compartment id's. /// </returns> public CompartmentStatusDto CompartmentStatus(Compartment model) { var compartment = new Compartment(model.TransactionId, model.LockerId, model.CompartmentIds, model.JwtCredentials.IsEnabled, model.JwtCredentials.Secret, model.JwtCredentials.Token); var result = LockerManager.CompartmentStatus(compartment); return(result); }
Compartment get(string sid) { IntPtr cPtr = libsbmlPINVOKE.ListOfCompartments_get__SWIG_2(swigCPtr, sid); Compartment ret = (cPtr == IntPtr.Zero) ? null : new Compartment(cPtr, false); return(ret); }
public Compartment () { aabb = new AABBi(new Vec2i(0,0), new Vec2i(0,0)); color = new Color(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value); isPtr = false; ptrValue = null; }
/// <summary> /// Remember which item the mouse was dragged from. /// We don't create an Action immediately, as this would inhibit the /// inline text editing feature. Instead, we just remember the details /// and will create an Action when/if the mouse moves off this list item. /// </summary> private void Compartment_MouseDown(object sender, DiagramMouseEventArgs e) { Compartment compartment = (Compartment)sender; var compartmentElementToDrag = GetCompartmentElementToDrag(compartment, e.HitDiagramItem.RepresentedElements); dragStartElement = compartmentElementToDrag; compartmentBounds = e.HitDiagramItem.Shape.AbsoluteBoundingBox; }
public void setUp() { string filename = "../../sbml/annotation/test/test-data/annotationL3.xml"; d = libsbml.readSBML(filename); m = d.getModel(); c = m.getCompartment(0); }
internal GState(Compartment setting, string orig, P6any actions) { this.setting = setting; this.actions = (actions == setting.AnyP) ? null : actions; orig_s = orig; orig_a = orig.ToCharArray(); highwater = (orig_a.Length < 100 || !Cursor.HwTrace) ? int.MaxValue : 0; }
public void Combine(Compartment other) { if (other != this) { isPtr = true; ptrValue = other.Instance; other.aabb.FitAABB(ref aabb); } }
internal static Variable DCResult(Compartment s, object r) { if (r == null) return s.AnyMO.typeObj; else if (r is string) return s.MakeStr((string)r); else if (r is int) return s.MakeInt((int)r); else if (r is bool) return ((bool)r) ? s.TrueV : s.FalseV; else if (r is Exception) throw new NieczaException(((Exception)r).Message); else if (r is object[]) { object[] ra = (object[])r; Variable[] ba = new Variable[ra.Length]; for (int i = 0; i < ba.Length; i++) ba[i] = DCResult(s,ra[i]); return s.MakeParcel(ba); } else { string t = (string)RawDowncall("gettype", r); P6any pr = (t == "type") ? TypeP : (t == "sub") ? StaticSubP : (t == "param") ? ParamP : (t == "value") ? ValueP : (t == "unit") ? UnitP : s.AnyMO.typeObj; return Kernel.BoxAnyMO(r, pr.mo); } }
internal Cursor(Compartment setting, P6any proto, string text, P6any actions) : this(new GState(setting, text, actions), proto.mo, null, null, null, 0, null) { }
public static P6any MakeDispatcher(Compartment s, string name, P6any proto, P6any[] cands) { if (proto != null) { SubInfo si = new SubInfo(Kernel.GetInfo(proto)); si.param = new object[] { cands, null }; return Kernel.MakeSub(si, Kernel.GetOuter(proto)); } else { SubInfo si = new SubInfo(s, name, StandardProtoC); si.param = new object[] { cands, null }; si.ltm = new LADDispatcher(); return Kernel.MakeSub(si, null); } }
public void CompartmentElement(Hashtable attrs) { Compartment compartment = new Compartment(this.model, attrs); CompartmentType compartmentType = null; int spatialDimensions = 3; double size = 1; String units = null; // unit enum or user-defined unit Compartment outside = null; Boolean constant = true; if (attrs.Contains("constant")) constant = Boolean.Parse((String)attrs["units"]); if (attrs.Contains("spatialdimensions")) spatialDimensions = (int)(Int32.Parse((String)attrs["spatialdimensions"])); if (attrs.Contains("size")) size = (double)(Double.Parse((String)attrs["size"])); else if (attrs.Contains("volume")) // from SBML Level 1 size = (double)(Double.Parse((String)attrs["volume"])); if (attrs.Contains("units") && this.model.IsUnits((String)attrs["units"])) units = (String)attrs["units"]; else { switch (spatialDimensions) { case 1: units = "length"; break; case 2: units = "area"; break; case 3: units = "volume"; break; } } if (attrs.Contains("compartmenttype")) { String cTypeId = (String)attrs["compartmenttype"]; compartmentType = (CompartmentType)this.model.findObject(cTypeId); } if (attrs.Contains("outside")) { String cId = (String)attrs["outside"]; outside = (Compartment)this.model.findObject(cId); } compartment.AddProperties(compartmentType, spatialDimensions, size, units, outside, constant); this.model.listOfCompartments.Add(compartment); }
private List<SectionElement> GetSectionElementsVisibleInSketch(Section section, Compartment compartment) { try { List<SectionElement> sectionElements = new List<SectionElement>(); Vector3D xAxis = new Vector3D(1, 0, 0); Plane minPlane = new Plane(xAxis, compartment.BoundingBox.MinPoint); Plane maxPlane = new Plane(xAxis, compartment.BoundingBox.MaxPoint); SectionElementsSet sectionElementsSet = section.GetPermanentSectionElementsSet("Plate"); foreach (Plate plate in sectionElementsSet.Elements.Values) { Point3D point = plate.Design.Geometry.Primitive(0).Centroid; if (minPlane.Signal(point) == 1 && maxPlane.Signal(point) == -1) { sectionElements.Add(plate); } } return sectionElements; } catch (Exception ex) { throw new ApplicationException("Section elements visible in skectch cannot be get!", ex); } }
private static void FillTile(AdjacentTiles t) { if ((t.tile.flags & (uint)VesselTile.FLAGS.SOLID_BLOCK) > 0) { t.tile.c0 = null; t.tile.c1 = null; } //take the compartments from left or bottom no matter what in these cases if ((t.bTile != null && t.bTile.Contains(WallTypeMask.OneByTwo)) || (t.brTile != null && t.brTile.Contains(WallTypeMask.OneByTwoFlipped))) { t.tile.c0 = t.bTile.c0.Instance; t.tile.c1 = t.bTile.c1.Instance; return; } if ((t.lTile != null && t.lTile.Contains(WallTypeMask.TwoByOne)) || (t.rTile != null && t.rTile.Contains(WallTypeMask.TwoByOneFlipped))) { t.tile.c0 = t.lTile.c0.Instance; t.tile.c1 = t.lTile.c1.Instance; return; } // //try take from bottom Compartment b = null; if (t.bTile != null) { if ((t.bTile.flags & (uint)VesselTile.FLAGS.SOLID_BLOCK) > 0) b = null; else if (!t.tile.Contains(WallTypeMask.OneByZero)) { //set the appropriate compartment field depending on how "bTile" is cut if ( (t.blTile != null && t.blTile.Contains(WallTypeMask.TwoByOne)) || (t.bTile.Contains(WallTypeMask.OneByOne)) || (t.b2Tile != null && t.b2Tile.Contains(WallTypeMask.OneByTwo))) { b = t.bTile.c1.Instance; //} else if ( // (t.b2rTile != null && t.b2rTile.Contains(WallTypeMask.OneByTwoFlipped)) || // (t.brTile != null && t.brTile.Contains(WallTypeMask.OneByOneFlipped)) || // (t.br2Tile != null && t.br2Tile.Contains(WallTypeMask.TwoByOneFlipped))){ // b = t.bTile.c0.Instance; } else { b = t.bTile.c0.Instance; } } } Compartment l = null; if (t.lTile != null) { if ((t.lTile.flags & (uint)VesselTile.FLAGS.SOLID_BLOCK) > 0) l = null; else if (!t.tile.Contains(WallTypeMask.ZeroByOne)) { l = t.lTile.c0.Instance; } } if ( (t.r2Tile != null && t.r2Tile.Contains(WallTypeMask.TwoByOneFlipped)) || (t.rTile != null && t.rTile.Contains(WallTypeMask.OneByOneFlipped | WallTypeMask.OneByTwoFlipped))) { if (l != null && b != null) { l.Combine(b); } if (b != null) { t.tile.c1 = b; } else if (l != null) { t.tile.c1 = l; } t.tile.c0 = new Compartment(); return; } else if (t.tile.Contains(WallTypeMask.TwoByOne | WallTypeMask.OneByOne | WallTypeMask.OneByTwo)) { if (b == null) { b = new Compartment(); } t.tile.c0 = b; if (l == null) { l = new Compartment(); } t.tile.c1 = l; return; } else { if (l != null && b != null) { l.Combine(b); } l = (l == null) ? b : l; if (l == null) { l = new Compartment(); } t.tile.c0 = l.Instance; } }
public void SetCompartmentFloor(FloorType type, Compartment c) { Vec2i start = ChunkIToTileI(aabb.bl); Vec2i end = ChunkIToTileI(aabb.tr); for (int i = start.y; i < end.y; i++) { for (int j = start.x; j < end.x; j++) { Vec2i tileI = new Vec2i(j, i); VesselTile tile; if ((tile = TryGetTile(tileI)) != null) { bool modified = false; if (tile.c0 != null && tile.c0.Instance == c) { tile.floor0 = type; modified = true; } if (tile.c1 != null && tile.c1.Instance == c) { tile.floor1 = type; modified |= true; } if (modified) { AddModifiedChunk((ServerVC)chunks.Get(TileToChunkI(tileI))); } } } } }
internal static int numcompare_core(Compartment s, Variable a1, P6any o1, Variable a2, P6any o2, bool complex_ok) { int r1, r2; P6any n1 = GetNumber(a1, o1, out r1); P6any n2 = GetNumber(a2, o2, out r2); if (r1 == NR_COMPLEX || r2 == NR_COMPLEX) { if (!complex_ok) throw new NieczaException("Complex numbers are not arithmetically ordered; use cmp if you want an arbitrary order"); Complex v1 = PromoteToComplex(r1, n1); Complex v2 = PromoteToComplex(r2, n2); if (double.IsNaN(v1.re) || double.IsNaN(v1.im) || double.IsNaN(v2.re) || double.IsNaN(v2.im)) return O_IS_UNORD; else if (v1.re != v2.re) return v1.re > v2.re ? O_IS_GREATER : O_IS_LESS; else return v1.im > v2.im ? O_IS_GREATER : v1.im < v2.im ? O_IS_LESS : O_IS_EQUAL; } else if (r1 == NR_FLOAT || r2 == NR_FLOAT) { double d1 = PromoteToFloat(r1, n1); double d2 = PromoteToFloat(r2, n2); if (double.IsNaN(d1) || double.IsNaN(d2)) return O_IS_UNORD; else return d1 > d2 ? O_IS_GREATER : d1 < d2 ? O_IS_LESS : O_IS_EQUAL; } else if (r1 == NR_FATRAT || r2 == NR_FATRAT) { FatRat v1 = PromoteToFatRat(r1, n1); FatRat v2 = PromoteToFatRat(r2, n2); r1 = BigInteger.Compare(v1.num*v2.den, v2.num*v1.den); } else if (r1 == NR_FIXRAT || r2 == NR_FIXRAT) { Rat v1 = PromoteToFixRat(r1, n1); Rat v2 = PromoteToFixRat(r2, n2); r1 = BigInteger.Compare(v1.num*v2.den, v2.num*v1.den); } else if (r1 == NR_BIGINT || r2 == NR_BIGINT) { r1 = BigInteger.Compare(PromoteToBigInt(r1, n1), PromoteToBigInt(r2, n2)); } else r1 = PromoteToFixInt(r1, n1).CompareTo(PromoteToFixInt(r2, n2)); return (r1 > 0) ? O_IS_GREATER : (r1 < 0) ? O_IS_LESS : O_IS_EQUAL; }
// This function implements the actual looping part of autothreading internal static Variable AutoThread(Compartment c, P6any j, Func<Variable,Variable> dgt) { P6opaque j_ = (P6opaque)j; P6any listObj = (P6any) j_.slots[1]; Variable[] list = Kernel.UnboxAny<Variable[]>(listObj); Variable[] nlist = new Variable[list.Length]; for (int i = 0; i < list.Length; i++) { nlist[i] = dgt(list[i]); } P6any newList = Kernel.BoxRaw(nlist, c.ParcelMO); P6opaque newJunc = new P6opaque(c.JunctionMO); newJunc.slots[0] = j_.slots[0]; newJunc.slots[1] = newList; return newJunc; }
internal static object UpCall(Compartment c, params object[] args) { return c.upcall_receiver[args]; }
// Type-check val against any, tracking state appropriately for // junctions. static void CheckSpecialArg(Compartment s, int ix, ref int pivot, ref uint rank, P6any val) { if (val.mo.is_any) { // fine as is } else if (val.mo.HasType(s.JunctionMO)) { int jtype = Kernel.UnboxAny<int>((P6any)(val as P6opaque).slots[0]) / 2; if ((uint)jtype < rank) { rank = (uint)jtype; pivot = ix; } } else { throw new NieczaException("Nominal type check failed for #" + ix + " needed Any got " + val.mo.name); } }
// Unifies the MakeFixRat logic and tries to avoid a huge computation // that will just be rounded away. // Invariant: pow >= 0 static Variable RatPow(Compartment s, BigInteger num, BigInteger den, BigInteger pow) { if (den == -BigInteger.One) { den = BigInteger.One; num = -num; } if (den == BigInteger.One) { // den won't be getting any bigger return s.MakeFixRat(big_pow(num, pow), 1); } // den >= 2 if (pow >= 64) { // Overflow is inevitable. return s.MakeFloat(Math.Pow(RatToFloat(num, den), (double)pow)); } // we might consider detecting smaller overflows, but the penalty // of $int ** 63 is not _that_ huge. return s.MakeFixRat(big_pow(num, pow), big_pow(den, pow)); }
private static int substr_len(Compartment s, Variable v1, int pos, Variable v3) { P6any o1 = v1.Fetch(), o3 = v3.Fetch(); int r3; if (o3.Does(s.CodeMO)) { string s1 = o1.mo.mro_raw_Str.Get(v1); Variable no3 = InvokeSub(o3, s.MakeInt(s1.Length)); r3 = (int)no3.Fetch().mo.mro_raw_Numeric.Get(no3) - pos; } else { r3 = (int)o3.mo.mro_raw_Numeric.Get(v3); } return r3; }
private static int substr_pos(Compartment s, Variable v1, Variable v2) { P6any o1 = v1.Fetch(), o2 = v2.Fetch(); int r2; if (o2.Does(s.CodeMO)) { string s1 = o1.mo.mro_raw_Str.Get(v1); Variable no2 = InvokeSub(o2, s.MakeInt(s1.Length)); r2 = (int)no2.Fetch().mo.mro_raw_Numeric.Get(no2); } else { r2 = (int)o2.mo.mro_raw_Numeric.Get(v2); } return r2; }