PLC检测没电池时更新SOC为-1

master
CZ 6 months ago
parent 821c6041ef
commit 59a7492a31

@ -41,13 +41,45 @@ public class PlcClient : ModbusTcpMaster
{ {
PlcMgr.DataValidityTime = DateTime.Now; PlcMgr.DataValidityTime = DateTime.Now;
ModbusDecoder.Decode<PlcToHost>(bytes02, PlcMgr.PlcToHostData); ModbusDecoder.Decode<PlcToHost>(bytes02, PlcMgr.PlcToHostData);
if (PlcMgr.PlcToHostData.MaterialDetec01.Value == 1)
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec01.Value && it.BatteryNo == "-1" && it.Soc == (decimal)(-1) && it.Soe == (decimal)(-1) && it.Soh == (decimal)(-1), it => it.No == "1");
else
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec01.Value, it => it.No == "1"); _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec01.Value, it => it.No == "1");
if (PlcMgr.PlcToHostData.MaterialDetec02.Value == 1)
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec02.Value && it.BatteryNo == "-1" && it.Soc == (decimal)(-1) && it.Soe == (decimal)(-1) && it.Soh == (decimal)(-1), it => it.No == "2");
else
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec02.Value, it => it.No == "2"); _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec02.Value, it => it.No == "2");
if (PlcMgr.PlcToHostData.MaterialDetec03.Value == 1)
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec03.Value && it.BatteryNo == "-1" && it.Soc == (decimal)(-1) && it.Soe == (decimal)(-1) && it.Soh == (decimal)(-1), it => it.No == "3");
else
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec03.Value, it => it.No == "3"); _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec03.Value, it => it.No == "3");
if (PlcMgr.PlcToHostData.MaterialDetec04.Value == 1)
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec04.Value && it.BatteryNo == "-1" && it.Soc == (decimal)(-1) && it.Soe == (decimal)(-1) && it.Soh == (decimal)(-1), it => it.No == "4");
else
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec04.Value, it => it.No == "4"); _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec04.Value, it => it.No == "4");
if (PlcMgr.PlcToHostData.MaterialDetec05.Value == 1)
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec05.Value && it.BatteryNo == "-1" && it.Soc == (decimal)(-1) && it.Soe == (decimal)(-1) && it.Soh == (decimal)(-1), it => it.No == "5");
else
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec05.Value, it => it.No == "5"); _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec05.Value, it => it.No == "5");
if (PlcMgr.PlcToHostData.MaterialDetec06.Value == 1)
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec06.Value && it.BatteryNo == "-1" && it.Soc == (decimal)(-1) && it.Soe == (decimal)(-1) && it.Soh == (decimal)(-1), it => it.No == "6");
else
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec06.Value, it => it.No == "6"); _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec06.Value, it => it.No == "6");
if (PlcMgr.PlcToHostData.MaterialDetec07.Value == 1)
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec07.Value && it.BatteryNo == "-1" && it.Soc == (decimal)(-1) && it.Soe == (decimal)(-1) && it.Soh == (decimal)(-1), it => it.No == "7");
else
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec07.Value, it => it.No == "7"); _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec07.Value, it => it.No == "7");
if (PlcMgr.PlcToHostData.MaterialDetec08.Value == 1)
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec08.Value && it.BatteryNo == "-1" && it.Soc == (decimal)(-1) && it.Soe == (decimal)(-1) && it.Soh == (decimal)(-1), it => it.No == "8");
else
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec08.Value, it => it.No == "8"); _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec08.Value, it => it.No == "8");
} }

Loading…
Cancel
Save