diff --git a/Aucma.Scada.Business/InStoreTaskHandle.cs b/Aucma.Scada.Business/InStoreTaskHandle.cs index 6c4cccf4..41271ad4 100644 --- a/Aucma.Scada.Business/InStoreTaskHandle.cs +++ b/Aucma.Scada.Business/InStoreTaskHandle.cs @@ -255,8 +255,7 @@ namespace Aucma.Scada.Business { if (_plc != null) { - if (_plc.IsConnected) - { + do { //读取PLC应答字为2时,上位机清空写入的入库内容 @@ -275,11 +274,7 @@ namespace Aucma.Scada.Business } Thread.Sleep(500); } while (isFlag); - } - else - { - logHelper.Info($"仓库{appConfig.shellStoreCode};PLC未连接"); - } + } else { @@ -309,8 +304,7 @@ namespace Aucma.Scada.Business if (_plc != null) { - if (_plc.IsConnected) - { + if (_plc.readInt32ByAddress(plcConfig.in_liner_answer) == 1) { @@ -332,11 +326,7 @@ namespace Aucma.Scada.Business result = 2; logHelper.PlcLog("内胆应答字为2,下发新任务plc未就绪"); } - } - else - { - logHelper.Info($"仓库{taskInfo.storeCode};PLC未连接"); - } + } else { @@ -366,8 +356,7 @@ namespace Aucma.Scada.Business if (_plc != null) { - if (_plc.IsConnected) - { + do { //读取PLC应答字为2时,上位机清空写入的入库内容 @@ -392,11 +381,7 @@ namespace Aucma.Scada.Business Thread.Sleep(1000); } while (isFlag); - } - else - { - logHelper.Info($"仓库{appConfig.linerStoreCode};PLC未连接"); - } + } else { @@ -429,8 +414,7 @@ namespace Aucma.Scada.Business { if (_plc != null) { - if (_plc.IsConnected) - { + do { //读取PLC入库任务完成 @@ -447,11 +431,7 @@ namespace Aucma.Scada.Business Thread.Sleep(1000); } while (isFlag); - } - else - { - logHelper.Info($"仓库{appConfig.shellStoreCode};PLC未连接"); - } + } else { @@ -481,8 +461,7 @@ namespace Aucma.Scada.Business IPlc _plc = _plcDictionary[appConfig.linerStoreCode]; if (_plc != null) { - if (_plc.IsConnected) - { + do { //读取PLC入库任务完成 @@ -500,11 +479,7 @@ namespace Aucma.Scada.Business Thread.Sleep(1000); } while (isFlag); - } - else - { - logHelper.Info($"仓库{appConfig.linerStoreCode};PLC未连接"); - } + } else { @@ -666,12 +641,11 @@ namespace Aucma.Scada.Business if (_plc != null) { - if (_plc.IsConnected) - { + spaceInfo.spaceStock = _plc.readInt32ByAddress(spaceAddress.onStore); spaceInfo.onRouteAmount = _plc.readInt32ByAddress(spaceAddress.onRoute); // spaceInfo.spaceStatus = _plc.readInt32ByAddress(spaceAddress.spaceStatus); - } + } return spaceInfo; @@ -690,8 +664,7 @@ namespace Aucma.Scada.Business if (_plc != null) { - if (_plc.IsConnected) - { + var spaceStock = _plc.readInt32ByAddress(spaceAddress.onStore); var onRouteAmount = _plc.readInt32ByAddress(spaceAddress.onRoute); @@ -705,7 +678,7 @@ namespace Aucma.Scada.Business _plc.writeInt32ByAddress(spaceAddress.onRoute, onRouteAmount + 1); } - } + } } } diff --git a/Aucma.Scada.Business/OutStoreTaskHandle.cs b/Aucma.Scada.Business/OutStoreTaskHandle.cs index 7396933e..176cf8f2 100644 --- a/Aucma.Scada.Business/OutStoreTaskHandle.cs +++ b/Aucma.Scada.Business/OutStoreTaskHandle.cs @@ -114,8 +114,7 @@ namespace Aucma.Scada.Business if (_plc != null) { - if (_plc.IsConnected) - { + if (_plc.readInt32ByAddress(plcConfig.out_shell_answer) == 1) { @@ -135,11 +134,7 @@ namespace Aucma.Scada.Business result = 2; logHelper.Info("应答字为2,下发新任务plc未就绪"); } - } - else - { - logHelper.Info($"仓库{taskInfo.storeCode};PLC未连接"); - } + } else { @@ -167,8 +162,7 @@ namespace Aucma.Scada.Business { if (_plc != null) { - if (_plc.IsConnected) - { + do { //读取PLC应答字为2时,上位机清空写入的出库内容 @@ -187,11 +181,7 @@ namespace Aucma.Scada.Business Thread.Sleep(500); } while (isFlag); - } - else - { - logHelper.Info($"仓库{appConfig.shellStoreCode};PLC未连接"); - } + } else { @@ -268,8 +258,7 @@ namespace Aucma.Scada.Business if (_plc != null) { - if (_plc.IsConnected) - { + if (_plc.readInt32ByAddress(plcConfig.out_liner_answer) == 1) { @@ -290,11 +279,7 @@ namespace Aucma.Scada.Business logHelper.Info("内胆应答字为2,下发新任务plc未就绪"); } - } - else - { - logHelper.Info($"仓库{taskInfo.storeCode};PLC未连接"); - } + } else { @@ -322,8 +307,7 @@ namespace Aucma.Scada.Business if (_plc != null) { - if (_plc.IsConnected) - { + do { @@ -344,11 +328,7 @@ namespace Aucma.Scada.Business Thread.Sleep(500); } while (isFlag); - } - else - { - logHelper.Info($"仓库{appConfig.linerStoreCode};PLC未连接"); - } + } else { @@ -374,8 +354,7 @@ namespace Aucma.Scada.Business IPlc _plc = _plcDictionary[appConfig.linerStoreCode]; if (_plc != null) { - if (_plc.IsConnected) - { + do { //读取PLC出库任务完成 @@ -394,11 +373,7 @@ namespace Aucma.Scada.Business Thread.Sleep(1000); } while (isFlag); - } - else - { - logHelper.Info($"仓库{appConfig.linerStoreCode};PLC未连接"); - } + } else { @@ -550,12 +525,11 @@ namespace Aucma.Scada.Business if (_plc != null) { - if (_plc.IsConnected) - { + spaceInfo.spaceStock = _plc.readInt32ByAddress(spaceAddress.onStore); spaceInfo.onRouteAmount = _plc.readInt32ByAddress(spaceAddress.onRoute); // spaceInfo.spaceStatus = _plc.readInt32ByAddress(spaceAddress.spaceStatus); - } + } return spaceInfo; @@ -574,14 +548,13 @@ namespace Aucma.Scada.Business if (_plc != null) { - if (_plc.IsConnected) - { + var spaceStock = _plc.readInt32ByAddress(spaceAddress.onStore); //var onRouteAmount = _plc.readInt32ByAddress(spaceAddress.onRoute); _plc.writeInt32ByAddress(spaceAddress.onStore, spaceStock - 1); - } + } } }