diff --git a/BPASmartClient.Model/物料数据/MaterialDeliveryEvent.cs b/BPASmartClient.Model/物料数据/MaterialDeliveryEvent.cs new file mode 100644 index 00000000..39139f02 --- /dev/null +++ b/BPASmartClient.Model/物料数据/MaterialDeliveryEvent.cs @@ -0,0 +1,17 @@ +using BPA.Message; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model.物料数据 +{ + public class MaterialDeliveryEvent : BaseEvent + { + /// + /// 物料信息 + /// + public OrderMaterialDelivery orderMaterialDelivery { get; set; } = new OrderMaterialDelivery(); + } +} diff --git a/BPASmartClient.Model/物料数据/RecipeBomEvent.cs b/BPASmartClient.Model/物料数据/RecipeBomEvent.cs new file mode 100644 index 00000000..9c9ad4c4 --- /dev/null +++ b/BPASmartClient.Model/物料数据/RecipeBomEvent.cs @@ -0,0 +1,17 @@ +using BPA.Message; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model.物料数据 +{ + public class RecipeBomEvent : BaseEvent + { + /// + /// 配方数据 + /// + public RecipeBoms recipeBoms { get; set; } = new RecipeBoms(); + } +} diff --git a/BPASmartClient.MorkS/Control.cs b/BPASmartClient.MorkS/Control.cs index f847d89a..d26928ba 100644 --- a/BPASmartClient.MorkS/Control.cs +++ b/BPASmartClient.MorkS/Control.cs @@ -23,16 +23,19 @@ namespace BPASmartClient.MorkS /// /// 订单物料信息 /// - public OrderMaterialDelivery orderMaterialDelivery { get; set; } = new OrderMaterialDelivery(); + private OrderMaterialDelivery orderMaterialDelivery { get; set; } = new OrderMaterialDelivery(); /// /// 配方数据信息 /// - public RecipeBoms recipeBoms { get; set; } = new RecipeBoms(); + private RecipeBoms recipeBoms { get; set; } = new RecipeBoms(); int OrderCount; bool Initing; public override void StartMain() { - + DataParse(); + ReadPLCData(); + Main(); + //初始化中 } public override void Stop() @@ -42,12 +45,12 @@ namespace BPASmartClient.MorkS private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) { - //EventBus.EventBus.GetInstance().Publish(new); + EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Id = DeviceId, Status = oRDER_STATUS, SubOrderId = subid }); } private void ReadData(string address, ushort len = 1, Action action = null) { - EventBus.EventBus.GetInstance().Publish(new ReadModel() { Address = address, Length = len }, (o) => + EventBus.EventBus.GetInstance().Publish(new ReadModel() { Id = DeviceId, Address = address, Length = len }, (o) => { if (o != null && o.Length > 0 && o[0] is bool[] bools) { @@ -56,7 +59,7 @@ namespace BPASmartClient.MorkS }); } - private void ReadData() + private void ReadPLCData() { ThreadManage.GetInstance().StartLong(new Action(() => { @@ -127,13 +130,13 @@ namespace BPASmartClient.MorkS //alarm.RobotSelfInException = bools[15]; })); - EventBus.EventBus.GetInstance().Publish(new ReadModel() { Address = "VW372", Length = 1 }, (o) => + EventBus.EventBus.GetInstance().Publish(new ReadModel() { Id = DeviceId, Address = "VW372", Length = 1 }, (o) => + { + if (o != null && o.Length > 0 && o[0] is ushort value) { - if (o != null && o.Length > 0 && o[0] is ushort value) - { - mORKS.TurntableFeedbackloc = value; - } - }); + mORKS.TurntableFeedbackloc = value; + } + }); //var ResLoc = ModbusTcpHelper.GetInstance.Read(286, ReadType.HoldingRegisters); //if (ResLoc != null) @@ -145,15 +148,14 @@ namespace BPASmartClient.MorkS //} Thread.Sleep(500); - }), "ReadPLCData"); + }), "ReadPLCData", true); } /// /// 数据解析 /// - public void DataParse(T order) + private void DataParse() { - EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle) { if (@event == null) return; @@ -163,8 +165,8 @@ namespace BPASmartClient.MorkS MessageLog.GetInstance.Show($"接收到{OrderCount}次订单"); foreach (var item in order.MorkOrder.GoodBatchings) { - //var res = Json.Data.orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); - var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); + //var res = Json.Data.orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); + var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); if (res != null) { if (ushort.TryParse(res.BatchingLoc, out ushort loc)) @@ -479,7 +481,7 @@ namespace BPASmartClient.MorkS private void WriteData(string address, object value) { - EventBus.EventBus.GetInstance().Publish(new WriteModel() { Address = address, Value = value }); + EventBus.EventBus.GetInstance().Publish(new WriteModel() { Id = DeviceId, Address = address, Value = value }); } ///