|
|
@@ -17,14 +17,18 @@ namespace BPASmartClient.MorkCL.Server |
|
|
|
MyModbus = new ModbusRtu(); |
|
|
|
MyModbus.WithModbusRtu(PortName).UseConnected(() => |
|
|
|
{ |
|
|
|
ModbusRtu myDevice = (ModbusRtu)MyModbus; |
|
|
|
TaskManage.GetInstance.StartLong(new Action(() => |
|
|
|
{ |
|
|
|
MyModbus.Read<bool[]>("LB100".ToModbusAdd(), 4).OnSuccess(s => |
|
|
|
//设置站号 |
|
|
|
myDevice.SlaveAddress = 1; |
|
|
|
|
|
|
|
myDevice.Read<bool[]>("LB100".ToModbusAdd(), 4).OnSuccess(s => |
|
|
|
{ |
|
|
|
for (byte i = 0; i < s.Length; i++) BoxDetection[i] = s[i]; |
|
|
|
}); |
|
|
|
|
|
|
|
MyModbus.Read<float>("LW20".ToModbusAdd()).OnSuccess(s => { CurrentWeight = s; }); |
|
|
|
myDevice.Read<float>("LW20".ToModbusAdd()).OnSuccess(s => { CurrentWeight = s; }); |
|
|
|
|
|
|
|
Thread.Sleep(10); |
|
|
|
}), $"其它外部设备-{PortName}", true); |
|
|
|