diff --git a/DosingSystem/ExcuteControl .cs b/DosingSystem/ExcuteControl .cs index c6ec3085..09a16b7e 100644 --- a/DosingSystem/ExcuteControl .cs +++ b/DosingSystem/ExcuteControl .cs @@ -285,12 +285,6 @@ namespace BPASmartClient.DosingSystem } } - - - - - - /// /// 取消配方 @@ -382,9 +376,6 @@ namespace BPASmartClient.DosingSystem } - public ConcurrentDictionary doDeviceCount = new ConcurrentDictionary(); - - int doDecipeCount = 0; /// /// 关闭上位机需要做的处理。 @@ -580,95 +571,96 @@ namespace BPASmartClient.DosingSystem DeviceStatus nextDevice = new DeviceStatus(); TaskManage.GetInstance.StartLong(() => { - - for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++) + if (RecipeNames.Count>0) { - if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress)) + for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++) { - //90 是中转流水线的IP。 - if (DeviceInquire.GetInstance.devices[i].IpAddress == "192.168.2.90") + if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress)) { - //如果中转线的下一个设备有桶的话,就先把中转线停住。 - if (DeviceInquire.GetInstance.DeviceLists[ DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1) + //90 是中转流水线的IP。 + if (DeviceInquire.GetInstance.devices[i].IpAddress == "192.168.2.90") { - SimensSend.GetInstance.SendSimens.Write("DB1.DBX702.0", 0); + //如果中转线的下一个设备有桶的话,就先把中转线停住。 + if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1) + { + SimensSend.GetInstance.SendSimens.Write("DB1.DBX702.0", 0); + } + else + { + SimensSend.GetInstance.SendSimens.Write("DB1.DBW104", (ushort)1400); + SimensSend.GetInstance.SendSimens.Write("DB1.DBX702.0", 1); + } } - else + if (DeviceInquire.GetInstance.devices[i].IpAddress != $"192.168.2.{Json.Data.BaseParModel.StockCount * 10}") { - SimensSend.GetInstance.SendSimens.Write("DB1.DBW104", (ushort)1400); - SimensSend.GetInstance.SendSimens.Write("DB1.DBX702.0", 1); - } - } - if (DeviceInquire.GetInstance.devices[i].IpAddress != $"192.168.2.{Json.Data.BaseParModel.StockCount * 10}") - { - ushort deviceNum = DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DeviceNum; - string nextIp = ""; - if (DeviceInquire.GetInstance.DeviceLists.TryGetValue($"{Json.Data.BaseParModel.NetworkSegAddress}{(deviceNum+1) * 10}", out nextDevice)&& deviceNum!=0) - { - nextIp = DeviceInquire.GetInstance.DeviceLists.ToList().Find(q => q.Value == nextDevice).Key; - } - if ( nextIp != "") - { - //if (DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.RunStatus == 1 || DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.RunStatus == 3) - //{ - // DeviceParModel deviceSet = Json.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName); - // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSp.ToAdd(), 1000); - // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), 1); - //} - if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1 || DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3) + ushort deviceNum = DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DeviceNum; + string nextIp = ""; + if (DeviceInquire.GetInstance.DeviceLists.TryGetValue($"{Json.Data.BaseParModel.NetworkSegAddress}{(deviceNum + 1) * 10}", out nextDevice) && deviceNum != 0) { - - if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1 && DeviceInquire.GetInstance.DeviceLists[nextIp].deviceStatus.PailArrive == 1) + nextIp = DeviceInquire.GetInstance.DeviceLists.ToList().Find(q => q.Value == nextDevice).Key; + } + if (nextIp != "") + { + //if (DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.RunStatus == 1 || DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.RunStatus == 3) + //{ + // DeviceParModel deviceSet = Json.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName); + // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSp.ToAdd(), 1000); + // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), 1); + //} + if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1 || DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3) { - DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(),(ushort)0); + + if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1 && DeviceInquire.GetInstance.DeviceLists[nextIp].deviceStatus.PailArrive == 1) + { + DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0); + } + else + { + DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSp.ToAdd(), 600); + DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1); + } } else { - DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSp.ToAdd(), 600); - DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1); + DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), 0); + //传送带停止 } + + //DeviceInquire.GetInstance.DeviceLists["192.168.2.130"].modbusTcp.Write(DeviceAddress.TranspportSp.ToAdd(), 1000); + //DeviceInquire.GetInstance.DeviceLists["192.168.2.130"].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), 0); + //else if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i + 1].IpAddress].deviceStatus.PailArrive == 1) + //{ + // //传送带运行 + // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.Start.ToAdd(), (ushort)1); + // DeviceParModel deviceSet = Json.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName); + // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSp.ToAdd(), deviceSet.SendSp); + // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), 1); + //} + } else { DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), 0); - //传送带停止 } - //DeviceInquire.GetInstance.DeviceLists["192.168.2.130"].modbusTcp.Write(DeviceAddress.TranspportSp.ToAdd(), 1000); - //DeviceInquire.GetInstance.DeviceLists["192.168.2.130"].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), 0); - //else if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i + 1].IpAddress].deviceStatus.PailArrive == 1) - //{ - // //传送带运行 - // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.Start.ToAdd(), (ushort)1); - // DeviceParModel deviceSet = Json.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName); - // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSp.ToAdd(), deviceSet.SendSp); - // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), 1); - //} - } else { - DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), 0); - } - - } - else - { - if (SimensSend.GetInstance.sendCtrlModel.SendInfo&& DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json.Data.BaseParModel.StockCount) * 10}"].deviceStatus.PailArrive == 1) - { - DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0); + if (SimensSend.GetInstance.sendCtrlModel.SendInfo && DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json.Data.BaseParModel.StockCount) * 10}"].deviceStatus.PailArrive == 1) + { + DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0); + } + else + { + DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write(DeviceAddress.TranspportSp.ToAdd(), 600); + DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1); + } } - else - { - DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write(DeviceAddress.TranspportSp.ToAdd(), 600); - DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1); - } } } } - - + Thread.Sleep(10); }, "控制传送带");