From 6f6438620ffd06d75eac0373246853769e81e396 Mon Sep 17 00:00:00 2001 From: fyf Date: Tue, 10 May 2022 15:22:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AE=BE=E5=A4=87=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=B1=87=E6=80=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BPASmartClient.Device/BaseDevice.cs | 5 ++++- BPASmartClient.IoT/DataVClient.cs | 6 ------ BPASmartClient.MORKSM.BK.PLC/MorksMachine.cs | 6 +++++- BPASmartClient.MorkT/Device_MorkT.cs | 1 + BPASmartClient.Peripheral/BasePeripheral.cs | 4 ++-- BPASmartClient.Peripheral/IPeripheral.cs | 8 ++++++++ BPASmartClient/DeviceInfo.xml | 8 ++++---- 7 files changed, 24 insertions(+), 14 deletions(-) diff --git a/BPASmartClient.Device/BaseDevice.cs b/BPASmartClient.Device/BaseDevice.cs index 9c6db056..e953ad79 100644 --- a/BPASmartClient.Device/BaseDevice.cs +++ b/BPASmartClient.Device/BaseDevice.cs @@ -71,10 +71,13 @@ namespace BPASmartClient.Device { foreach (var peripheral in peripherals) { + string TypeName = peripheral.GetType().FullName.Replace("BPASmartClient.",""); + Status.Update($"{TypeName}.IsConnected", peripheral.IsConnected); + Status.Update($"{TypeName}.IsWork", peripheral.IsWork); foreach (var key in peripheral.GetAllStatus().Keys) { peripheralStatus[key] = peripheral.GetAllStatus()[key]; - Status.Update(key, peripheral.GetAllStatus()[key]); + Status.Update($"{TypeName}.{key}", peripheral.GetAllStatus()[key]); } } Thread.Sleep(100); diff --git a/BPASmartClient.IoT/DataVClient.cs b/BPASmartClient.IoT/DataVClient.cs index c7c45f44..c0236c46 100644 --- a/BPASmartClient.IoT/DataVClient.cs +++ b/BPASmartClient.IoT/DataVClient.cs @@ -139,11 +139,6 @@ namespace BPASmartClient.IoT List dataVNode = new List(); Plugin.GetInstance()?.GetPlugin()?.GetDevices()?.ForEach(device => { - Dictionary keys=new Dictionary(); - keys["电机"] = "正常"; - keys["电机"] = "正常"; - keys["电机"] = "正常"; - keys["电机"] = "正常"; var obj =new { DeviceId=device.DeviceId, @@ -156,7 +151,6 @@ namespace BPASmartClient.IoT Status = device.Status.GetStatus(), }; dataVNode.Add(obj); - dataVNode.Add(obj); dataVNode.Add(obj); dataVNode.Add(obj); dataVNode.Add(obj); dataVNode.Add(obj); dataVNode.Add(obj); dataVNode.Add(obj); }); if (dataVNode.Count > 0) { diff --git a/BPASmartClient.MORKSM.BK.PLC/MorksMachine.cs b/BPASmartClient.MORKSM.BK.PLC/MorksMachine.cs index 4c882315..809c80b8 100644 --- a/BPASmartClient.MORKSM.BK.PLC/MorksMachine.cs +++ b/BPASmartClient.MORKSM.BK.PLC/MorksMachine.cs @@ -26,8 +26,11 @@ namespace BPASmartClient.PLC ThreadManage.GetInstance().StartLong(new Action(() => { - while (modbusTcp.Connected) + IsConnected = modbusTcp.Connected; + if (!IsConnected) IsWork = false; + while (IsConnected) { + IsWork = true; foreach (var par in plcReadParameters) { ushort address = (ushort)modbusTcp.GetAddress(par?.Address); @@ -43,6 +46,7 @@ namespace BPASmartClient.PLC } status[par.Address] = readData; } + Thread.Sleep(500); } Thread.Sleep(1000); diff --git a/BPASmartClient.MorkT/Device_MorkT.cs b/BPASmartClient.MorkT/Device_MorkT.cs index f861f285..0bb48171 100644 --- a/BPASmartClient.MorkT/Device_MorkT.cs +++ b/BPASmartClient.MorkT/Device_MorkT.cs @@ -14,6 +14,7 @@ namespace BPASmartClient.MorkT public override void DoMain() { + } public override void Stop() diff --git a/BPASmartClient.Peripheral/BasePeripheral.cs b/BPASmartClient.Peripheral/BasePeripheral.cs index 2127bd33..065dc03e 100644 --- a/BPASmartClient.Peripheral/BasePeripheral.cs +++ b/BPASmartClient.Peripheral/BasePeripheral.cs @@ -15,11 +15,11 @@ namespace BPASmartClient.Peripheral /// /// 是否已连接 /// - public bool IsConnected { get; protected set; } + public bool IsConnected { get; set; } /// /// 是否工作正常 /// - public bool IsWork { get; protected set; } + public bool IsWork { get; set; } /// /// 归属设备Id /// diff --git a/BPASmartClient.Peripheral/IPeripheral.cs b/BPASmartClient.Peripheral/IPeripheral.cs index d9ccc1c3..582ec026 100644 --- a/BPASmartClient.Peripheral/IPeripheral.cs +++ b/BPASmartClient.Peripheral/IPeripheral.cs @@ -12,6 +12,14 @@ namespace BPASmartClient.Peripheral /// public interface IPeripheral { + /// + /// 是否已连接 + /// + bool IsConnected { get; set; } + /// + /// 是否工作正常 + /// + bool IsWork { get; set; } /// /// 设备ID /// diff --git a/BPASmartClient/DeviceInfo.xml b/BPASmartClient/DeviceInfo.xml index f1bf60f2..e3a3693a 100644 --- a/BPASmartClient/DeviceInfo.xml +++ b/BPASmartClient/DeviceInfo.xml @@ -1,14 +1,14 @@  - @@ -17,7 +17,7 @@ - --> +