private void AddMaterialRequirement(ItemsControl parent, string name, MsgBiz.MaterialRequirement matReq, int nr) { // Add material requirement var matReqNode = AddNodeToTreeview(parent, name + " " + nr); // Material definition IDs for (int a = 0; a < matReq.MaterialDefinitionIdentifiers.Count; ++a) { AddIdentifier(matReqNode, "MaterialDefinitionID", matReq.MaterialDefinitionIdentifiers[a], a + 1); } // Material lot IDs for (int a = 0; a < matReq.MaterialLotIdentifiers.Count; ++a) { AddIdentifier(matReqNode, "MaterialLotID", matReq.MaterialLotIdentifiers[a], a + 1); } // Material use if (matReq.MaterialUse != null) { AddNodeToTreeview(matReqNode, "MaterialUse", matReq.MaterialUse.Value.ToString()); } // Add quantities for (int a = 0; a < matReq.Quantities.Count; ++a) { AddQuantity(matReqNode, matReq.Quantities[a], a + 1); } // Assembly requirements for (int a = 0; a < matReq.AssemblyRequirements.Count; ++a) { AddMaterialRequirement(matReqNode, "AssemblyRequirement", matReq.AssemblyRequirements[a], a + 1); } }
private byte[] GetProcessProductionSchedule() { try { // Fabricating a message var baseDateTime = DateTime.Now.ToUniversalTime().AddMinutes(30); var materialReq = new MsgBiz.MaterialRequirement() { MaterialDefinitionIdentifiers = new System.Collections.Generic.List <MsgBiz.IdentifierType> { new MsgBiz.IdentifierType("material_x") }, MaterialLotIdentifiers = new System.Collections.Generic.List <MsgBiz.IdentifierType> { new MsgBiz.IdentifierType("batch-119") }, MaterialUse = new MsgBiz.MaterialUse(MsgBiz.MaterialUseType.Produced), Quantities = new System.Collections.Generic.List <MsgBiz.QuantityValue> { new MsgBiz.QuantityValue(41.9) { UnitOfMeasure = "t/h" } } }; var messageObj = new MsgBiz.ProcessProductionSchedule() { ProductionSchedules = new System.Collections.Generic.List <MsgBiz.ProductionSchedule> { new MsgBiz.ProductionSchedule() { ProductionRequests = new System.Collections.Generic.List <MsgBiz.ProductionRequest> { new MsgBiz.ProductionRequest() { Identifier = new MsgBiz.IdentifierType("my-identifier-1"), HierarchyScopeObj = new MsgBiz.HierarchyScope( new MsgBiz.IdentifierType("process_a"), MsgBiz.EquipmentElementLevelType.ProcessCell ), SegmentRequirements = new System.Collections.Generic.List <MsgBiz.SegmentRequirement> { new MsgBiz.SegmentRequirement() { EarliestStartTime = baseDateTime.AddMinutes(1), LatestEndTime = baseDateTime.AddMinutes(30), MaterialRequirements = new System.Collections.Generic.List <MsgBiz.MaterialRequirement> { materialReq } }, new MsgBiz.SegmentRequirement() { EarliestStartTime = baseDateTime.AddMinutes(31), LatestEndTime = baseDateTime.AddMinutes(60) } } }, new MsgBiz.ProductionRequest() { Identifier = new MsgBiz.IdentifierType("my-identifier-2") } } } } }; // String to bytes return(messageObj.ToXmlBytes()); } catch { // Fallback: use empty message return(new byte[0]); } }
private MsgBiz.SegmentRequirement CreateSegmentForSchedule(DateTime start, DateTime end, string id, MsgBiz.MaterialRequirement matReq) { return(new MsgBiz.SegmentRequirement() { EarliestStartTime = start, LatestEndTime = end, ProcessSegmentIdentifier = new MsgBiz.IdentifierType(id), MaterialRequirements = new SysColl.List <MsgBiz.MaterialRequirement>() { matReq } }); }