소스 검색

通讯组件修改

JXJAgvReake
pry 1 년 전
부모
커밋
99a6ee5665
4개의 변경된 파일40개의 추가작업 그리고 48개의 파일을 삭제
  1. +18
    -20
      BPASmartClient.Tourism/Server/FryingPanServer.cs
  2. +8
    -9
      BPASmartClient.Tourism/Server/OtherServer.cs
  3. +2
    -3
      BPASmartClient.Tourism/Server/PressureCookerServer.cs
  4. +12
    -16
      BPASmartClient.Tourism/Server/RobotServer.cs

+ 18
- 20
BPASmartClient.Tourism/Server/FryingPanServer.cs 파일 보기

@@ -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 });
});
}
}
}

+ 8
- 9
BPASmartClient.Tourism/Server/OtherServer.cs 파일 보기

@@ -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 });
});
}
}
}

+ 2
- 3
BPASmartClient.Tourism/Server/PressureCookerServer.cs 파일 보기

@@ -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 });
});
}
}
}

+ 12
- 16
BPASmartClient.Tourism/Server/RobotServer.cs 파일 보기

@@ -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()


불러오는 중...
취소
저장