@@ -15,38 +15,36 @@ namespace BPASmartClient.MorkCL.Server | |||
public void Init(string IP = "", int Port = 502, string PortName = "") | |||
{ | |||
MyModbus = new ModbusTcp(); | |||
MyModbus.Connected = () => | |||
MyModbus.WithModbusTcp(IP, Port).UseConnected(() => | |||
{ | |||
TaskManage.GetInstance.StartLong(new Action(() => | |||
{ | |||
var LB100 = MyModbus.Read<bool[]>("LB100".ToModbusAdd(), 13); | |||
if (LB100.IsSuccess) | |||
MyModbus.Read<bool[]>("LB100".ToModbusAdd(), 13).OnSuccess(s => | |||
{ | |||
InitComplete = LB100.Content[0]; | |||
StatusMode = LB100.Content[1]; | |||
EStop = LB100.Content[2]; | |||
InitComplete = s[0]; | |||
StatusMode = s[1]; | |||
EStop = s[2]; | |||
for (byte i = 0; i < 4; i++) StirFryingLocFB[i] = LB100.Content[i + 3]; | |||
for (byte i = 0; i < 4; i++) StirFryingLocFB[i] = s[i + 3]; | |||
DiningOutLocFB = LB100.Content[7]; | |||
FeedingLocFB = LB100.Content[8]; | |||
WashingPotLocFB = LB100.Content[9]; | |||
DiningOutLocFB = s[7]; | |||
FeedingLocFB = s[8]; | |||
WashingPotLocFB = s[9]; | |||
for (byte i = 0; i < 3; i++) ChannelDisCom[i] = LB100.Content[i + 10]; | |||
} | |||
for (byte i = 0; i < 3; i++) ChannelDisCom[i] = s[i + 10]; | |||
}); | |||
var LW20 = MyModbus.Read<ushort[]>("LW20".ToModbusAdd(), 3); | |||
if (LW20.IsSuccess) | |||
MyModbus.Read<ushort[]>("LW20".ToModbusAdd(), 3).OnSuccess(s => | |||
{ | |||
CurrentTemperature = LW20.Content[0] * 10.0F; | |||
CurrentSpeed = LW20.Content[1]; | |||
HeatingGear = LW20.Content[2]; | |||
} | |||
CurrentTemperature = s[0] * 10.0F; | |||
CurrentSpeed = s[1]; | |||
HeatingGear = s[2]; | |||
}); | |||
Thread.Sleep(10); | |||
}), $"炒锅服务-{IP}", true); | |||
}; | |||
MyModbus.Connect(new ConfigurationOptions() { IpAddress = IP, Port = Port }); | |||
}); | |||
} | |||
} | |||
} |
@@ -15,21 +15,20 @@ namespace BPASmartClient.MorkCL.Server | |||
public void Init(string IP = "", int Port = 502, string PortName = "") | |||
{ | |||
MyModbus = new ModbusRtu(); | |||
MyModbus.Connected = () => | |||
MyModbus.WithModbusRtu(PortName).UseConnected(() => | |||
{ | |||
TaskManage.GetInstance.StartLong(new Action(() => | |||
{ | |||
var box = MyModbus.Read<bool[]>("LB100".ToModbusAdd(), 4); | |||
if (box.IsSuccess) | |||
MyModbus.Read<bool[]>("LB100".ToModbusAdd(), 4).OnSuccess(s => | |||
{ | |||
for (byte i = 0; i < box.Content.Length; i++) BoxDetection[i] = box.Content[i]; | |||
} | |||
var weight = MyModbus.Read<float>("LW20".ToModbusAdd()); | |||
if (weight.IsSuccess) CurrentWeight = weight.Content; | |||
for (byte i = 0; i < s.Length; i++) BoxDetection[i] = s[i]; | |||
}); | |||
MyModbus.Read<float>("LW20".ToModbusAdd()).OnSuccess(s => { CurrentWeight = s; }); | |||
Thread.Sleep(10); | |||
}), $"其它外部设备-{PortName}", true); | |||
}; | |||
MyModbus.Connect(new ConfigurationOptions() { PortName = PortName }); | |||
}); | |||
} | |||
} | |||
} |
@@ -14,15 +14,14 @@ namespace BPASmartClient.MorkCL.Server | |||
public void Init(string IP = "", int Port = 502, string PortName = "") | |||
{ | |||
MyModbus = new ModbusTcp(); | |||
MyModbus.Connected = () => | |||
MyModbus.WithModbusTcp(IP, Port).UseConnected(() => | |||
{ | |||
TaskManage.GetInstance.StartLong(new Action(() => | |||
{ | |||
Thread.Sleep(10); | |||
}), $"压力锅服务-{IP}", true); | |||
}; | |||
MyModbus.Connect(new ConfigurationOptions() { IpAddress = IP, Port = Port }); | |||
}); | |||
} | |||
} | |||
} |
@@ -15,34 +15,30 @@ namespace BPASmartClient.MorkCL.Server | |||
public void Init(string IP = "", int Port = 502, string PortName = "") | |||
{ | |||
MyModbus = new ModbusTcp(); | |||
MyModbus.Connected = () => | |||
MyModbus.WithModbusTcp(IP, Port).UseConnected(() => | |||
{ | |||
TaskManage.GetInstance.StartLong(new Action(() => | |||
{ | |||
var m600 = MyModbus.Read<bool[]>("M600".ToModbusAdd(), 9); | |||
if (m600.IsSuccess) | |||
MyModbus.Read<bool[]>("M600".ToModbusAdd(), 9).OnSuccess(s => | |||
{ | |||
for (byte i = 0; i < 3; i++) | |||
{ | |||
MaterialPouringRequest[i] = m600.Content[i * 3]; | |||
MaterialPouringComplete[i] = m600.Content[i * 3 + 1]; | |||
DiningOutRequest[i] = m600.Content[i * 3 + 2]; | |||
MaterialPouringRequest[i] = s[i * 3]; | |||
MaterialPouringComplete[i] = s[i * 3 + 1]; | |||
DiningOutRequest[i] = s[i * 3 + 2]; | |||
} | |||
} | |||
}); | |||
var m630 = MyModbus.Read<bool[]>("M630".ToModbusAdd(), 12); | |||
if (m630.IsSuccess) | |||
{ | |||
for (byte i = 0; i < m630.Content.Length; i++) WarehousingComplete[i] = m630.Content[i]; | |||
} | |||
MyModbus.Read<bool[]>("M630".ToModbusAdd(), 12).OnSuccess(s => | |||
{ | |||
for (byte i = 0; i < s.Length; i++) WarehousingComplete[i] = s[i]; | |||
}); | |||
var gi = MyModbus.Read<ushort>("GI5".ToModbusAdd(), 1); | |||
if (gi.IsSuccess) TaskFeedback = (RobotMainTask)gi.Content; | |||
MyModbus.Read<ushort>("GI5".ToModbusAdd(), 1).OnSuccess(s => { TaskFeedback = (RobotMainTask)s; }); | |||
Thread.Sleep(10); | |||
}), $"机器人服务-{IP}", true); | |||
}; | |||
MyModbus.Connect(new ConfigurationOptions() { IpAddress = IP, Port = Port }); | |||
}); | |||
} | |||
private void RobotInit() | |||