public ProgBlock() : base() { List <IMyTerminalBlock> pbs = new List <IMyTerminalBlock>(); GTS.GetBlocksOfType <IMyProgrammableBlock>(pbs, (block) => (block as IMyProgrammableBlock).IsRunning); block = pbs.Count == 1 ? pbs[0] as IMyProgrammableBlock : null; }
public void GTSExamplesTest01() { // Create a periodic interval with first week of all Septembers PIVL <TS> firstWeekofSept = new PIVL <TS> ( new IVL <TS>( new TS(new DateTime(2011, 09, 01), DatePrecision.Day), new TS(new DateTime(2011, 09, 08), DatePrecision.Day) ), new PQ(1, "a") ); // Create a periodic interval of all mondays PIVL <TS> mondays = new PIVL <TS> ( new TS(new DateTime(2011, 01, 03), DatePrecision.Day).ToIVL(), new PQ(1, "wk") ); // Intersect to get labour day GTS labourDay = new GTS( QSI <TS> .CreateQSI( firstWeekofSept, mondays ) ); labourDay.NullFlavor = null; Console.WriteLine(labourDay); Assert.IsTrue(labourDay.Validate()); }
public void Change(GTS oldGts, GTS newGts) { oldGts.CompanyId = newGts.CompanyId; oldGts.DangerKindId = newGts.DangerKindId; oldGts.Name = newGts.Name; oldGts.Purpose = newGts.Purpose; }
public void ConstructingEIVLTest01() { // An hour after meal EIVL <TS> hourAfterMeal = new EIVL <TS>( DomainTimingEventType.Meal, new IVL <PQ>(new PQ(1, "h")) ); EIVL <TS> eivl1 = new EIVL <TS>( DomainTimingEventType.Meal, new IVL <PQ>( new PQ(1, "h") // high ) ); // 1-2 hours before sleep EIVL <TS> beforeSleep = new EIVL <TS>( DomainTimingEventType.HourOfSleep, new IVL <PQ>(new PQ(-2, "h"), new PQ(-1, "h")) ); // Construct instructions as a union of the two GTS instructionTime = new GTS(); instructionTime.Hull = QSU <TS> .CreateQSU( hourAfterMeal, beforeSleep ); Assert.IsTrue(eivl1.Validate()); Assert.IsTrue(hourAfterMeal.Validate()); Assert.IsTrue(beforeSleep.Validate()); Assert.IsTrue(instructionTime.Validate()); }
public void GTSTSCTORTest() { TS tsDate = new TS(new DateTime(2010, 05, 01)); GTS gtsInstance = new GTS(new IVL <TS>(tsDate)); Assert.AreEqual(typeof(IVL <TS>), gtsInstance.Hull.GetType()); //throw new NotImplementedException("GTS(TS) constructor does not exist."); }
public void GTSIVLCTORTest() { // interval from May 1, 2010 to May 10, 2010 IVL <TS> tenDays = new IVL <TS>(DateTime.Parse("2010/05/1"), DateTime.Parse("2010/05/10")); GTS gtsInstance = new GTS(tenDays); Assert.AreEqual(typeof(IVL <TS>), gtsInstance.Hull.GetType()); }
public StructuredDosageLines() { this.moodCode = new CSImpl(); this.text = new STImpl(); this.effectiveTime = new GTSImpl(); this.doseQuantity = new URGImpl <PQ, PhysicalQuantity>(); this.rateQuantity = new URGImpl <PQ, PhysicalQuantity>(); }
/// <summary> /// Parse the object from <paramref name="s"/> /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse ANYFormatter anyFormatter = new ANYFormatter(); GTS retVal = anyFormatter.Parse <GTS>(s, result); // Is there any need to continue? if (retVal.NullFlavor != null) { return(retVal); } // Now determine the type of GTS string typeName = s.GetAttribute("type", "http://www.w3.org/2001/XMLSchema-instance"); IDatatypeFormatter formatter; // Parse the type switch (typeName) { case "IVL_TS": formatter = new IVLFormatter(); break; case "PIVL_TS": formatter = new PIVLFormatter(); break; case "EIVL_TS": formatter = new EIVLFormatter(); break; case "SXPR_TS": formatter = new SXPRFormatter(); break; case "SXCM_TS": formatter = new SXCMFormatter(); break; default: result.AddResultDetail(new NotSupportedChoiceResultDetail(ResultDetailType.Error, String.Format("Cannot parse a GTS Hull of type '{0}'", typeName), s.ToString(), null)); return(null); } // Graph the Hull formatter.Host = this.Host; formatter.GenericArguments = new Type[] { typeof(TS) }; retVal.Hull = formatter.Parse(s, result) as SXCM <TS>; // Correct the flavor, the flavor of the hull becomes the flavor of the object retVal.Flavor = retVal.Flavor ?? retVal.Hull.Flavor; retVal.Hull.Flavor = null; retVal.NullFlavor = retVal.NullFlavor ?? (retVal.Hull.NullFlavor != null ? retVal.Hull.NullFlavor.Clone() as CS <NullFlavor> : null); retVal.Hull.NullFlavor = null; // Set the details return(retVal); }
public void GTSExamplesTest06() { // Create empty instance of GTS GTS labourDay = new GTS(); labourDay.NullFlavor = NullFlavor.Other; Console.WriteLine(labourDay); Assert.IsTrue(labourDay.Validate()); }
private IMyTextPanel GetPanel() { if (_panel == null) { _panel = GTS.GetBlockWithName(_name) as IMyTextPanel; InitPanel(); } return(_panel); }
/// <summary> /// Graph the object <paramref name="o"/> to <paramref name="s"/> /// </summary> public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // Cast the object to GTS GTS instance = o as GTS; // Hull instance corrections if (instance.Hull != null) { if (instance.Hull.NullFlavor != null) { instance.NullFlavor = instance.NullFlavor ?? instance.Hull.NullFlavor; instance.Hull.NullFlavor = null; result.AddResultDetail(new PropertyValuePropagatedResultDetail(ResultDetailType.Warning, "Hull.NullFlavor", "NullFlavor", instance.NullFlavor, s.ToString())); } if (instance.Hull.Flavor != null) { instance.Flavor = instance.Flavor ?? instance.Hull.Flavor; instance.Hull.Flavor = null; result.AddResultDetail(new PropertyValuePropagatedResultDetail(ResultDetailType.Warning, "Hull.Flavor", "Flavor", instance.Flavor, s.ToString())); } } ANYFormatter anyFormatter = new ANYFormatter(); // Graph the base anyFormatter.Graph(s, o as ANY, result); // Determine what type of hull we have if (instance.NullFlavor != null) // Null flavor specified, no hull will be graphed { return; } else if (instance.Hull == null) { result.AddResultDetail(new ResultDetail(ResultDetailType.Error, "Cannot graph a GTS with a Null Hull", s.ToString())); return; } object instanceHull = instance.Hull; if (instanceHull.GetType().Name.StartsWith("QS")) { instanceHull = instanceHull.GetType().GetMethod("TranslateToSXPR").Invoke(instanceHull, null); } string xsiTypeName = Util.CreateXSITypeName(instanceHull.GetType()); s.WriteAttributeString("xsi", "type", DatatypeFormatter.NS_XSI, xsiTypeName); // Output the formatting var hostResult = this.Host.Graph(s, (IGraphable)instanceHull); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); }
public void GTSExamplesTest04() { // Create empty instance of GTS GTS labourDay = new GTS(); labourDay.NullFlavor = null; Console.WriteLine(labourDay); Assert.IsFalse(labourDay.Validate()); }
public void GTSPIVLCTORTest() { PIVL <TS> everyTwoDays = new PIVL <TS>( // this is every other day new IVL <TS>(DateTime.Parse("2010/05/1"), DateTime.Parse("2010/05/10")), new PQ((decimal)2.0, "d")); GTS gtsInstance = new GTS(everyTwoDays); Assert.AreEqual(typeof(PIVL <TS>), gtsInstance.Hull.GetType()); }
public GTSModel(GTS gts) { this.GTSId = gts.GTSId; this.Name = gts.Name; this.Purpose = gts.Purpose; this.SafetyDeclarationIds = (gts.SafetyDeclarations != null) ? gts.SafetyDeclarations.Select(sd => sd.SafetyDeclarationId).ToList() : new List <int>(); this.DangerKindId = gts.DangerKindId; this.CompanyId = gts.CompanyId; }
public virtual void ShouldParseNullFlavor() { XmlNode node = CreateNode("<effectiveTime nullFlavor=\"NI\"></effectiveTime>"); ParseContext context = ParseContextImpl.Create("GTS.BOUNDEDPIVL", typeof(GeneralTimingSpecification), SpecificationVersion .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, null, null, false); GTS gts = (GTS) new GtsBoundedPivlElementParser().Parse(context, node, this.xmlResult); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.NO_INFORMATION, gts.NullFlavor, "null flavor" ); }
public IMyMotorStator GetRotor() { if (_motor == null) { _motor = GTS.GetBlockWithName(GetRotorName()) as IMyMotorStator; if (_motor != null) { Init(); } } return(_motor); }
public GTS GetGTS() { var gts = new GTS(); gts.CompanyId = this.CompanyId; gts.DangerKindId = this.DangerKindId; gts.Name = this.Name; gts.Purpose = this.Purpose; if (this.GTSId.HasValue) { gts.GTSId = this.GTSId.Value; } return(gts); }
public void GTSTestXsiOutputSXPR_TS_Test() { // Constrct a GTS GTS test = SXPR <TS> .CreateSXPR( new IVL <TS>(DateTime.Now), new PIVL <TS>(new IVL <TS>(DateTime.Now), new PQ(1, "d")) ); String xml = R1SerializationHelper.SerializeAsString(test, Formatters.XML.Datatypes.R1.DatatypeFormatterCompatibilityMode.ClinicalDocumentArchitecture); Assert.IsTrue(xml.Contains("xsi:type=\"SXPR_TS\"")); Assert.IsTrue(xml.Contains("xsi:type=\"IVL_TS\"")); Assert.IsTrue(xml.Contains("xsi:type=\"PIVL_TS\"")); }
public void GTSExamplesTest03() { // Create a periodic interval with first week of all Septembers PIVL <TS> firstWeekofSept = new PIVL <TS> ( new IVL <TS>( new TS(new DateTime(2011, 09, 01), DatePrecision.Day), new TS(new DateTime(2011, 09, 08), DatePrecision.Day) ), new PQ(1, "a") ); // Create a periodic interval of all mondays PIVL <TS> mondays = new PIVL <TS>( new IVL <TS>( new TS(new DateTime(2011, 02, 03), DatePrecision.Day) ), new PQ(1, "wk") ); // Create a second periodic interval of all mondays PIVL <TS> mondays2 = new PIVL <TS>( new TS(new DateTime(2011, 01, 03), DatePrecision.Day).ToIVL(), new PQ(1, "wk") ); // Intersect to get labour day GTS labourDay = new GTS( QSI <TS> .CreateQSI( firstWeekofSept, mondays ) ); // Intersect to get labour day GTS labourDay2 = new GTS( QSI <TS> .CreateQSI( firstWeekofSept, mondays2 ) ); Console.WriteLine(mondays); Console.WriteLine(mondays2); Assert.AreNotEqual(labourDay, labourDay2); }
/// <summary> /// Graph the object <paramref name="o"/> onto <paramref name="s"/> /// </summary> public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result) { // Cast the object to GTS GTS instance = o as GTS; // Hull instance corrections if (instance.Hull != null) { if (instance.NullFlavor != null) { instance.Hull.NullFlavor = instance.Hull.NullFlavor ?? instance.NullFlavor; result.AddResultDetail(new PropertyValuePropagatedResultDetail(ResultDetailType.Warning, "NullFlavor", "Hull.NullFlavor", instance.Hull.NullFlavor, s.ToString())); } if (instance.Flavor != null) { instance.Hull.Flavor = instance.Hull.Flavor ?? instance.Flavor; result.AddResultDetail(new PropertyValuePropagatedResultDetail(ResultDetailType.Warning, "Flavor", "Hull.Flavor", instance.Hull.Flavor, s.ToString())); } } else { result.AddResultDetail(new ResultDetail(ResultDetailType.Error, "Cannot graph a GTS instance with a null Hull", s.ToString())); return; } // Map QSET/SXPR/SXCM object instanceHull = instance.Hull; if (instanceHull is SXPR <TS> ) { instanceHull = (instanceHull as SXPR <TS>).TranslateToQSET(); } // Emit the type name string xsiTypeName = Util.CreateXSITypeName(instanceHull.GetType()); s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, xsiTypeName); // Host results var hostResult = this.Host.Graph(s, (IGraphable)instanceHull); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); }
public void GTSPIVLCTORTest() { PIVL<TS> everyTwoDays = new PIVL<TS>( // this is every other day new IVL<TS>(DateTime.Parse("2010/05/1"), DateTime.Parse("2010/05/10")), new PQ((decimal)2.0, "d")); GTS gtsInstance = new GTS(everyTwoDays); Assert.AreEqual(typeof(PIVL<TS>), gtsInstance.Hull.GetType()); }
public Block(string stringId) { block = GTS.GetBlockWithName(stringId); }
public void GTSTSCTORTest() { TS tsDate = new TS(new DateTime(2010, 05, 01)); GTS gtsInstance = new GTS(new IVL<TS>(tsDate)); Assert.AreEqual(typeof(IVL<TS>), gtsInstance.Hull.GetType()); //throw new NotImplementedException("GTS(TS) constructor does not exist."); }
public void GTSIVLCTORTest() { // interval from May 1, 2010 to May 10, 2010 IVL<TS> tenDays = new IVL<TS>(DateTime.Parse("2010/05/1"), DateTime.Parse("2010/05/10")); GTS gtsInstance = new GTS(tenDays); Assert.AreEqual(typeof(IVL<TS>), gtsInstance.Hull.GetType()); }
public void UpdateFromGrid() => GTS.GetBlocksOfType <IMySolarPanel>(_panels, solarPanel => _rotors.Count(rotor => rotor.GetRotor() != null && solarPanel.CubeGrid == rotor.GetRotor().TopGrid) > 0);
public void Add(GTS gts) { _context.GTSs.Add(gts); }
/// <summary> /// Graph the object <paramref name="o"/> to <paramref name="s"/> /// </summary> public override void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // Cast the object to GTS GTS instance = o as GTS; // Hull instance corrections if (instance.Hull != null) { if (instance.Hull.NullFlavor != null) { instance.NullFlavor = instance.NullFlavor ?? instance.Hull.NullFlavor; instance.Hull.NullFlavor = null; result.AddResultDetail(new PropertyValuePropagatedResultDetail(ResultDetailType.Warning, "Hull.NullFlavor", "NullFlavor", instance.NullFlavor, s.ToString())); } if (instance.Hull.Flavor != null) { instance.Flavor = instance.Flavor ?? instance.Hull.Flavor; instance.Hull.Flavor = null; result.AddResultDetail(new PropertyValuePropagatedResultDetail(ResultDetailType.Warning, "Hull.Flavor", "Flavor", instance.Flavor, s.ToString())); } } // Graph the base base.Graph(s, o as ANY, result); // Determine what type of hull we have if (instance.NullFlavor != null) // Null flavor specified, no hull will be graphed { return; } else if (instance.Hull == null) { result.AddResultDetail(new MandatoryElementMissingResultDetail(ResultDetailType.Error, "Cannot graph a GTS with a Null Hull", s.ToString())); return; } object instanceHull = instance.Hull; if (instanceHull.GetType().Name.StartsWith("QS")) { instanceHull = instanceHull.GetType().GetMethod("TranslateToSXPR").Invoke(instanceHull, null); } // Not for CDA: // FIX: We use GetType comparison because IS has side effects in that all IVL, PIVL, etc. are instances. if (result.CompatibilityMode == DatatypeFormatterCompatibilityMode.ClinicalDocumentArchitecture && (instanceHull.GetType().Equals(typeof(SXCM <TS>)))) { ; } else { string xsiTypeName = Util.CreateXSITypeName(instanceHull.GetType()); s.WriteAttributeString("xsi", "type", DatatypeFormatter.NS_XSI, xsiTypeName); } // Output the formatting var hostResult = this.Host.Graph(s, (IGraphable)instanceHull); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); }
public void ConstructingEIVLTest01() { // An hour after meal EIVL<TS> hourAfterMeal = new EIVL<TS>( DomainTimingEventType.Meal, new IVL<PQ>(new PQ(1, "h")) ); EIVL<TS> eivl1 = new EIVL<TS>( DomainTimingEventType.Meal, new IVL<PQ>( new PQ(1, "h") // high ) ); // 1-2 hours before sleep EIVL<TS> beforeSleep = new EIVL<TS>( DomainTimingEventType.HourOfSleep, new IVL<PQ>( new PQ(-2, "h"), new PQ(-1, "h") ) ); // Construct instructions as a union of the two GTS instructionTime = new GTS(); instructionTime.Hull = QSU<TS>.CreateQSU( hourAfterMeal, beforeSleep ); Assert.IsTrue(eivl1.Validate()); Assert.IsTrue(hourAfterMeal.Validate()); Assert.IsTrue(beforeSleep.Validate()); Assert.IsTrue(instructionTime.Validate()); }
public void GTSExamplesTest01() { // Create a periodic interval with first week of all Septembers PIVL<TS> firstWeekofSept = new PIVL<TS> ( new IVL<TS>( new TS(new DateTime(2011, 09, 01), DatePrecision.Day), new TS(new DateTime(2011, 09, 08), DatePrecision.Day) ), new PQ (1, "a") ); // Create a periodic interval of all mondays PIVL<TS> mondays = new PIVL<TS> ( new TS(new DateTime(2011, 01, 03), DatePrecision.Day).ToIVL(), new PQ(1, "wk") ); // Intersect to get labour day GTS labourDay = new GTS( QSI<TS>.CreateQSI( firstWeekofSept, mondays ) ); labourDay.NullFlavor = null; Console.WriteLine(labourDay); Assert.IsTrue(labourDay.Validate()); }
public void UpdateFromGrid() => GTS.GetBlocksOfType <IMyBatteryBlock>(_batteries, _filter);
public void GTSExamplesTest03() { // Create a periodic interval with first week of all Septembers PIVL<TS> firstWeekofSept = new PIVL<TS> ( new IVL<TS>( new TS(new DateTime(2011, 09, 01), DatePrecision.Day), new TS(new DateTime(2011, 09, 08), DatePrecision.Day) ), new PQ(1, "a") ); // Create a periodic interval of all mondays PIVL<TS> mondays = new PIVL<TS>( new IVL<TS>( new TS(new DateTime(2011, 02, 03), DatePrecision.Day) ), new PQ(1, "wk") ); // Create a second periodic interval of all mondays PIVL<TS> mondays2 = new PIVL<TS>( new TS(new DateTime(2011, 01, 03), DatePrecision.Day).ToIVL(), new PQ(1, "wk") ); // Intersect to get labour day GTS labourDay = new GTS( QSI<TS>.CreateQSI( firstWeekofSept, mondays ) ); // Intersect to get labour day GTS labourDay2 = new GTS( QSI<TS>.CreateQSI( firstWeekofSept, mondays2 ) ); Console.WriteLine(mondays); Console.WriteLine(mondays2); Assert.AreNotEqual(labourDay, labourDay2); }