Browse Source

临时更新

样式分支
taoye 2 years ago
parent
commit
2e22082692
2 changed files with 17 additions and 22 deletions
  1. +2
    -2
      FryPot_DosingSystem/App.xaml.cs
  2. +15
    -20
      FryPot_DosingSystem/Control/DeviceOperate.cs

+ 2
- 2
FryPot_DosingSystem/App.xaml.cs View File

@@ -25,7 +25,7 @@ namespace FryPot_DosingSystem
public partial class App : Application
{
public static Window MainWindow;
protected override void OnStartup(StartupEventArgs e)
protected override async void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
SystemHelper.GetInstance.CreateDesktopShortcut();
@@ -39,7 +39,7 @@ namespace FryPot_DosingSystem
{
mv.Show();
MessageLog.GetInstance.ShowUserLog("用户登录");
Task.Run(new Action(() => { DeviceOperate deviceOperate = DeviceOperate.GetInstance; }));//开启实时PLC数据读取
await Task.Run(()=> { DeviceOperate deviceOperate = DeviceOperate.GetInstance; });//开启实时PLC数据读取
DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序
HubHelper.GetInstance.Connect("192.168.1.20", 8089);
AlarmHelper<AlarmInfo>.Init();//报警实时监控


+ 15
- 20
FryPot_DosingSystem/Control/DeviceOperate.cs View File

@@ -171,31 +171,26 @@ namespace FryPot_DosingSystem.Control
if (devices.Devices.Count > 0)
{

try


for (int i = 0; i < devices.Devices.Count; i++)
{
for (int i = 0; i < devices.Devices.Count; i++)
string Ip = devices.Devices[i].Ip;
string Port = devices.Devices[i].Port;
string DeviceName = devices.Devices[i].DeviceName;
switch (DeviceName)
{
string Ip = devices.Devices[i].Ip;
string Port = devices.Devices[i].Port;
string DeviceName = devices.Devices[i].DeviceName;
switch (DeviceName)
{
case "滚筒输送线": modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("滚筒线PLC连接成功"); break;
case "炒锅1": fryOneModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("1号炒锅PLC连接成功"); break;
case "炒锅2": fryTwoModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("2号炒锅PLC连接成功"); break;
case "炒锅3": fryThreeModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("3号炒锅PLC连接成功"); break;
case "炒锅4": fryFourModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("4号炒锅PLC连接成功"); break;
case "炒锅5": fryFiveModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("5号炒锅PLC连接成功"); break;
}

case "滚筒输送线": modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("滚筒线PLC连接成功"); break;
case "炒锅1": fryOneModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("1号炒锅PLC连接成功"); break;
case "炒锅2": fryTwoModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("2号炒锅PLC连接成功"); break;
case "炒锅3": fryThreeModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("3号炒锅PLC连接成功"); break;
case "炒锅4": fryFourModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("4号炒锅PLC连接成功"); break;
case "炒锅5": fryFiveModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("5号炒锅PLC连接成功"); break;
}
}
catch (Exception)
{
MessageLog.GetInstance.ShowRunLog("PLC连接失败");

}


}
}
}


Loading…
Cancel
Save