Esempio n. 1
0
    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;
    }
Esempio n. 2
0
        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());
        }
Esempio n. 3
0
 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());
        }
Esempio n. 5
0
        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.");
        }
Esempio n. 6
0
        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());
        }
Esempio n. 7
0
 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);
        }
Esempio n. 9
0
        public void GTSExamplesTest06()
        {
            // Create empty instance of GTS
            GTS labourDay = new GTS();

            labourDay.NullFlavor = NullFlavor.Other;
            Console.WriteLine(labourDay);
            Assert.IsTrue(labourDay.Validate());
        }
Esempio n. 10
0
 private IMyTextPanel GetPanel()
 {
     if (_panel == null)
     {
         _panel = GTS.GetBlockWithName(_name) as IMyTextPanel;
         InitPanel();
     }
     return(_panel);
 }
Esempio n. 11
0
        /// <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);
        }
Esempio n. 12
0
        public void GTSExamplesTest04()
        {
            // Create empty instance of GTS
            GTS labourDay = new GTS();

            labourDay.NullFlavor = null;

            Console.WriteLine(labourDay);
            Assert.IsFalse(labourDay.Validate());
        }
Esempio n. 13
0
        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());
        }
Esempio n. 14
0
 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;
 }
Esempio n. 15
0
        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"
                            );
        }
Esempio n. 16
0
 public IMyMotorStator GetRotor()
 {
     if (_motor == null)
     {
         _motor = GTS.GetBlockWithName(GetRotorName()) as IMyMotorStator;
         if (_motor != null)
         {
             Init();
         }
     }
     return(_motor);
 }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        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\""));
        }
Esempio n. 19
0
        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);
        }
Esempio n. 20
0
        /// <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);
        }
Esempio n. 21
0
        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());
        }
Esempio n. 22
0
        public void GTSExamplesTest04()
        {
            // Create empty instance of GTS
            GTS labourDay = new GTS();
            labourDay.NullFlavor = null;

            Console.WriteLine(labourDay);
            Assert.IsFalse(labourDay.Validate());
        }
Esempio n. 23
0
 public Block(string stringId)
 {
     block = GTS.GetBlockWithName(stringId);
 }
Esempio n. 24
0
        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.");
        }
Esempio n. 25
0
        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());
        }
Esempio n. 26
0
 public void UpdateFromGrid() => GTS.GetBlocksOfType <IMySolarPanel>(_panels, solarPanel => _rotors.Count(rotor => rotor.GetRotor() != null && solarPanel.CubeGrid == rotor.GetRotor().TopGrid) > 0);
Esempio n. 27
0
 public void Add(GTS gts)
 {
     _context.GTSs.Add(gts);
 }
Esempio n. 28
0
        /// <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);
        }
Esempio n. 29
0
        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());
        }
Esempio n. 30
0
        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());
        }
Esempio n. 31
0
 public void GTSExamplesTest06()
 {
     // Create empty instance of GTS
     GTS labourDay = new GTS();
     labourDay.NullFlavor = NullFlavor.Other;
     Console.WriteLine(labourDay);
     Assert.IsTrue(labourDay.Validate());
 }
Esempio n. 32
0
 public void UpdateFromGrid() => GTS.GetBlocksOfType <IMyBatteryBlock>(_batteries, _filter);
Esempio n. 33
0
        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);
        }