|
|
@ -32,8 +32,8 @@ public class PlcClient : ModbusTcpMaster
|
|
|
|
if (bytes01 != null)
|
|
|
|
if (bytes01 != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PlcMgr.DataValidityTime = DateTime.Now;
|
|
|
|
PlcMgr.DataValidityTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
|
|
ModbusDecoder.Decode<HostToPlc>(bytes01, PlcMgr.HostToPlcData);
|
|
|
|
ModbusDecoder.Decode<HostToPlc>(bytes01, PlcMgr.HostToPlcData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var bytes02 = master.BatchReadHolderRegister(201, 222);
|
|
|
|
var bytes02 = master.BatchReadHolderRegister(201, 222);
|
|
|
@ -41,14 +41,46 @@ public class PlcClient : ModbusTcpMaster
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PlcMgr.DataValidityTime = DateTime.Now;
|
|
|
|
PlcMgr.DataValidityTime = DateTime.Now;
|
|
|
|
ModbusDecoder.Decode<PlcToHost>(bytes02, PlcMgr.PlcToHostData);
|
|
|
|
ModbusDecoder.Decode<PlcToHost>(bytes02, PlcMgr.PlcToHostData);
|
|
|
|
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec01.Value, it => it.No == "1");
|
|
|
|
if (PlcMgr.PlcToHostData.MaterialDetec01.Value == 1)
|
|
|
|
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec02.Value, it => it.No == "2");
|
|
|
|
_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");
|
|
|
|
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec03.Value, it => it.No == "3");
|
|
|
|
else
|
|
|
|
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec04.Value, it => it.No == "4");
|
|
|
|
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec01.Value, it => it.No == "1");
|
|
|
|
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec05.Value, it => it.No == "5");
|
|
|
|
|
|
|
|
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec06.Value, it => it.No == "6");
|
|
|
|
if (PlcMgr.PlcToHostData.MaterialDetec02.Value == 1)
|
|
|
|
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec07.Value, it => it.No == "7");
|
|
|
|
_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");
|
|
|
|
_binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec08.Value, it => it.No == "8");
|
|
|
|
else
|
|
|
|
|
|
|
|
_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");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var bytes03 = master.BatchReadHolderRegister(701, 10);
|
|
|
|
var bytes03 = master.BatchReadHolderRegister(701, 10);
|
|
|
|