Esempio n. 1
0
        private void AssertEmptySegmentRequirement(SegmentRequirement segReq)
        {
            // Process segment ID
            Assert.IsNull(segReq.ProcessSegmentIdentifier);

            // Times
            Assert.IsFalse(segReq.EarliestStartTime.HasValue);
            Assert.IsFalse(segReq.LatestEndTime.HasValue);

            // Equipment
            Assert.AreEqual(0, segReq.EquipmentRequirements.Count);

            // Material
            Assert.AreEqual(0, segReq.MaterialRequirements.Count);

            // Segment (nested)
            Assert.AreEqual(0, segReq.SegmentRequirements.Count);
        }
Esempio n. 2
0
        public void ProcProdSched_WriteNonUtcTimes()
        {
            // Expecting an error when there is an attempt to assign a non-UTC timestamp

            var sched = new ProcessProductionSchedule();
            var segm  = new SegmentRequirement();

            AssertDateTimeException(() =>
            {
                sched.CreationDateTime = DateTime.Parse("2020-02-20T13:09:00"); // expecting local kind by default
            }, "DateTime kind must be UTC");

            AssertDateTimeException(() =>
            {
                segm.EarliestStartTime = DateTime.Parse("2020-02-20T13:09:00"); // expecting local kind by default
            }, "DateTime kind must be UTC");

            AssertDateTimeException(() =>
            {
                segm.LatestEndTime = DateTime.Parse("2020-02-20T13:09:00"); // expecting local kind by default
            }, "DateTime kind must be UTC");
        }
Esempio n. 3
0
        public void ProcProdSched_WriteSegmentStartAfterEnd()
        {
            // Segment start must not be after end

            var startTime     = ParseDateTimeInUtc("2020-02-20T14:37:00Z");
            var faultySegment = new SegmentRequirement()
            {
                EarliestStartTime = startTime,
                LatestEndTime     = startTime.AddSeconds(-1) // Before start
            };

            var processProdSched = new ProcessProductionSchedule()
            {
                ProductionSchedules = new List <ProductionSchedule>
                {
                    new ProductionSchedule()
                    {
                        ProductionRequests = new List <ProductionRequest>()
                        {
                            new ProductionRequest()
                            {
                                SegmentRequirements = new List <SegmentRequirement>
                                {
                                    faultySegment
                                }
                            }
                        }
                    }
                }
            };

            // Expecting an error as message serialisation is requested
            AssertDateTimeException(() =>
            {
                processProdSched.ToXmlBytes();
            }, "Start of segment must not be after end");
        }
Esempio n. 4
0
        private ProcessProductionSchedule CreateObjectForTestWrite()
        {
            // Applying identifiers (such as "SEG1") to items to enable a
            // verification that this test implementation has same items
            // as those in other environments, particularly Java.

            // SEG1a Creating a segment requirement
            SegmentRequirement segReq1 = new SegmentRequirement
            {
                ProcessSegmentIdentifier = new IdentifierType("1"),
                EarliestStartTime        = ParseDateTimeInUtc("2019-05-09T13:36:02Z"),
                LatestEndTime            = ParseDateTimeInUtc("2019-05-09T13:37:02Z")
            };

            // EQ1 Add equipment requirement
            EquipmentRequirement eqReq = new EquipmentRequirement()
            {
                Quantities = new List <QuantityValue>()
                {
                    new QuantityValue(true)
                }
            };

            segReq1.EquipmentRequirements.Add(eqReq);

            // MAT1 Add material requirement
            MaterialRequirement matReq = new MaterialRequirement()
            {
                MaterialDefinitionIdentifiers = new List <IdentifierType>()
                {
                    new IdentifierType("slag")
                },

                MaterialLotIdentifiers = new List <IdentifierType>()
                {
                    new IdentifierType("my-lot-1")
                },

                MaterialUse = new MaterialUse(MaterialUseType.Produced),

                Quantities = new List <QuantityValue>()
                {
                    new QuantityValue(12.2)
                    {
                        UnitOfMeasure = "t",
                        Key           = new IdentifierType("my-mat-key")
                    }
                },

                AssemblyRequirements = new List <MaterialRequirement>()
                {
                    new MaterialRequirement()
                    {
                        MaterialDefinitionIdentifiers = new List <IdentifierType>()
                        {
                            new IdentifierType("Ni")
                        }
                    }
                }
            };

            segReq1.MaterialRequirements.Add(matReq);

            // SEG1-1 Add nested segment requirement
            segReq1.SegmentRequirements.Add(new SegmentRequirement()
            {
                EarliestStartTime = ParseDateTimeInUtc("2019-08-29T15:31:38Z")
            });

            // PROD1a Create one production request (for the unit "psc3")
            ProductionRequest request1 = new ProductionRequest
            {
                // PROD1-ID Set identifier
                Identifier = new IdentifierType("some-id"),

                // PROD1-HS Set hierarchy scope
                HierarchyScopeObj = new HierarchyScope(
                    new IdentifierType("psc3"),
                    EquipmentElementLevelType.ProcessCell
                    ),

                SegmentRequirements = new List <SegmentRequirement>()
                {
                    // SEG1b Add segment requirement to production request
                    segReq1,

                    // SEG2 Add another (empty) segment requirement
                    new SegmentRequirement()
                }
            };

            // SCH Create schedule object
            ProductionSchedule schedule = new ProductionSchedule()
            {
                ProductionRequests = new List <ProductionRequest>()
                {
                    // PROD1b Add the production request to schedule
                    request1,

                    // PROD2 Adding another (empty) production request
                    new ProductionRequest()
                }
            };

            // PROPS Creating object to be serialised
            ProcessProductionSchedule testObject1 = new ProcessProductionSchedule()
            {
                // PROPS-CR Set creation time
                CreationDateTime = ParseDateTimeInUtc("2019-05-09T12:20:19Z")
            };

            // Add schedule to the test object
            testObject1.ProductionSchedules.Add(schedule);
            return(testObject1);
        }
Esempio n. 5
0
        public void ProcProdSched_Write()
        {
            // Serialising, validating and deserialising
            byte[] xmlData = CreateObjectForTestWrite().ToXmlBytes();
            Validate(xmlData);
            ProcessProductionSchedule testObject2 = new ProcessProductionSchedule(xmlData);

            // Assert creation time
            TestCommon.TestHelper.AssertDateTime(ParseDateTimeInUtc("2019-05-09T12:20:19Z"), testObject2.CreationDateTime);

            ProductionSchedule schedule = testObject2.ProductionSchedules[0];

            // Assert request count
            Assert.AreEqual(2, schedule.ProductionRequests.Count);

            // Asserting a production request
            ProductionRequest request1 = schedule.ProductionRequests[0];

            Assert.AreEqual(2, request1.SegmentRequirements.Count);

            // Asserting identifier
            Assert.AreEqual("some-id", request1.Identifier.Value);

            // Asserting a hierarchy scope
            Assert.AreEqual("psc3", request1.HierarchyScopeObj.EquipmentIdentifier.Value);
            Assert.AreEqual(EquipmentElementLevelType.ProcessCell, request1.HierarchyScopeObj.EquipmentElementLevel);

            // Asserting a segment requirement
            SegmentRequirement segReq = request1.SegmentRequirements[0];

            Assert.AreEqual("1", segReq.ProcessSegmentIdentifier.Value);
            AssertDateTime(ParseDateTimeInUtc("2019-05-09T13:36:02Z"), segReq.EarliestStartTime.Value);
            AssertDateTime(ParseDateTimeInUtc("2019-05-09T13:37:02Z"), segReq.LatestEndTime.Value);
            Assert.AreEqual(1, segReq.MaterialRequirements.Count);
            Assert.AreEqual(1, segReq.EquipmentRequirements.Count);

            // Asserting nested segment requirement
            SegmentRequirement segReqNested = segReq.SegmentRequirements[0];

            AssertDateTime(ParseDateTimeInUtc("2019-08-29T15:31:38Z"), segReqNested.EarliestStartTime.Value);

            // Asserting equipment requirement
            EquipmentRequirement eqReq = segReq.EquipmentRequirements[0];

            Assert.AreEqual(1, eqReq.Quantities.Count);
            Assert.IsTrue(eqReq.Quantities[0].TryParseValueAsXmlBoolean());

            MaterialRequirement matReq = segReq.MaterialRequirements[0];

            // Asserting material definition ID
            Assert.AreEqual(1, matReq.MaterialDefinitionIdentifiers.Count);
            Assert.AreEqual("slag", matReq.MaterialDefinitionIdentifiers[0].Value);

            // Asserting a material lot ID
            Assert.AreEqual(1, matReq.MaterialLotIdentifiers.Count);
            Assert.AreEqual("my-lot-1", matReq.MaterialLotIdentifiers[0].Value);

            // Asserting material use
            Assert.AreEqual(MaterialUseType.Produced, matReq.MaterialUse.Value);

            // Asserting a material quantity
            Assert.AreEqual(1, matReq.Quantities.Count);
            QuantityValue quantity = matReq.Quantities[0];

            Assert.AreEqual("12.2", quantity.RawQuantityString);
            Assert.AreEqual(12.2, quantity.TryParseValueAsXmlDouble(), 0.001);
            Assert.AreEqual("t", quantity.UnitOfMeasure);
            Assert.AreEqual(DataType.TypeType.doubleXml, quantity.DataType.Type);
            Assert.AreEqual("my-mat-key", quantity.Key.Value);

            // Asserting an assembly requirement
            Assert.AreEqual(1, matReq.AssemblyRequirements.Count);
            Assert.AreEqual("Ni", matReq.AssemblyRequirements[0].MaterialDefinitionIdentifiers[0].Value);
        }