diff --git a/PVDEMCS/.vs/PVDEMCS/DesignTimeBuild/.dtbcache.v2 b/PVDEMCS/.vs/PVDEMCS/DesignTimeBuild/.dtbcache.v2 index 1277061..be53c24 100644 Binary files a/PVDEMCS/.vs/PVDEMCS/DesignTimeBuild/.dtbcache.v2 and b/PVDEMCS/.vs/PVDEMCS/DesignTimeBuild/.dtbcache.v2 differ diff --git a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/08b0d3a2-d015-46bb-adb1-2344026efcd9.vsidx b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/08b0d3a2-d015-46bb-adb1-2344026efcd9.vsidx new file mode 100644 index 0000000..817d7fd Binary files /dev/null and b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/08b0d3a2-d015-46bb-adb1-2344026efcd9.vsidx differ diff --git a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/12af3e70-ff1b-476e-bca3-dd8dc2f6df63.vsidx b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/12af3e70-ff1b-476e-bca3-dd8dc2f6df63.vsidx new file mode 100644 index 0000000..7161145 Binary files /dev/null and b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/12af3e70-ff1b-476e-bca3-dd8dc2f6df63.vsidx differ diff --git a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/1703dfbf-8d01-4953-9ffd-cbdb2c74d3a4.vsidx b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/1703dfbf-8d01-4953-9ffd-cbdb2c74d3a4.vsidx deleted file mode 100644 index 33c99c0..0000000 Binary files a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/1703dfbf-8d01-4953-9ffd-cbdb2c74d3a4.vsidx and /dev/null differ diff --git a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/1f6357d5-e1ed-4d14-9519-dbdd7c936292.vsidx b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/1f6357d5-e1ed-4d14-9519-dbdd7c936292.vsidx deleted file mode 100644 index 239a375..0000000 Binary files a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/1f6357d5-e1ed-4d14-9519-dbdd7c936292.vsidx and /dev/null differ diff --git a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/327aa321-737c-4c40-ae28-dd600023fb55.vsidx b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/327aa321-737c-4c40-ae28-dd600023fb55.vsidx new file mode 100644 index 0000000..e2ed4c9 Binary files /dev/null and b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/327aa321-737c-4c40-ae28-dd600023fb55.vsidx differ diff --git a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/4c8a62b7-1955-456f-ab0d-bbd71aa1dc88.vsidx b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/4c8a62b7-1955-456f-ab0d-bbd71aa1dc88.vsidx deleted file mode 100644 index 4736153..0000000 Binary files a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/4c8a62b7-1955-456f-ab0d-bbd71aa1dc88.vsidx and /dev/null differ diff --git a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/7619295f-cfcf-4075-836f-9eb68b3cdcfe.vsidx b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/7619295f-cfcf-4075-836f-9eb68b3cdcfe.vsidx new file mode 100644 index 0000000..3b57012 Binary files /dev/null and b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/7619295f-cfcf-4075-836f-9eb68b3cdcfe.vsidx differ diff --git a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/7c7f44d6-1d85-4451-873e-2c4dd21a5c9f.vsidx b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/7c7f44d6-1d85-4451-873e-2c4dd21a5c9f.vsidx deleted file mode 100644 index 6ce266e..0000000 Binary files a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/7c7f44d6-1d85-4451-873e-2c4dd21a5c9f.vsidx and /dev/null differ diff --git a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/a0d6e7b5-203b-4507-bbeb-6afaad13d1ec.vsidx b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/a0d6e7b5-203b-4507-bbeb-6afaad13d1ec.vsidx new file mode 100644 index 0000000..4817d76 Binary files /dev/null and b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/a0d6e7b5-203b-4507-bbeb-6afaad13d1ec.vsidx differ diff --git a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/c6e2453f-dbaa-4f90-9907-a3e4ccef1ed8.vsidx b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/c6e2453f-dbaa-4f90-9907-a3e4ccef1ed8.vsidx deleted file mode 100644 index ea519b0..0000000 Binary files a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/c6e2453f-dbaa-4f90-9907-a3e4ccef1ed8.vsidx and /dev/null differ diff --git a/PVDEMCS/.vs/PVDEMCS/v17/.suo b/PVDEMCS/.vs/PVDEMCS/v17/.suo index 7357aec..b992d31 100644 Binary files a/PVDEMCS/.vs/PVDEMCS/v17/.suo and b/PVDEMCS/.vs/PVDEMCS/v17/.suo differ diff --git a/PVDEMCS/PVDEMCS/Common/Devices/IDeviceRun.cs b/PVDEMCS/PVDEMCS/Common/Devices/IDeviceRun.cs index c9b22c2..bb82d1a 100644 --- a/PVDEMCS/PVDEMCS/Common/Devices/IDeviceRun.cs +++ b/PVDEMCS/PVDEMCS/Common/Devices/IDeviceRun.cs @@ -1,5 +1,7 @@ using PVDEMCS.Common.DI; using PVDEMCS.Services; +using PVDEMCS.Services.Models; +using System.Threading; namespace PVDEMCS.Common.Devices { @@ -8,6 +10,17 @@ namespace PVDEMCS.Common.Devices /// public interface IDeviceRun : IDependency { + + /// + /// 获取所有点位信息 + /// + List GetDevicePoints { get; } + + /// + /// 获取控制器连接状态 + /// + Dictionary GetDeviceIsConnected { get; } + /// /// 开始运行 /// diff --git a/PVDEMCS/PVDEMCS/Common/Devices/Impl/DeviceMonitor.cs b/PVDEMCS/PVDEMCS/Common/Devices/Impl/DeviceMonitor.cs index e66ec0b..07e71fc 100644 --- a/PVDEMCS/PVDEMCS/Common/Devices/Impl/DeviceMonitor.cs +++ b/PVDEMCS/PVDEMCS/Common/Devices/Impl/DeviceMonitor.cs @@ -4,7 +4,7 @@ using System.Security.Cryptography; namespace PVDEMCS.Common.Devices.Impl { - public class DeviceMonitor + public class DeviceMonitor { private DeviceInfo deviceInfo; private IPLCCommunicationService plcCommunicationService; @@ -17,7 +17,6 @@ namespace PVDEMCS.Common.Devices.Impl this.devicePoints = new List(); PointMonitor(); } - /// /// PLC 点位改变触发 /// @@ -28,6 +27,17 @@ namespace PVDEMCS.Common.Devices.Impl /// public event EventHandler ErrorMessage; + /// + /// 控制器编号 + /// + public string DeviceCode + { + get + { + return deviceInfo.DeviceCode; + } + } + /// /// 间隔时间 /// @@ -54,7 +64,7 @@ namespace PVDEMCS.Common.Devices.Impl /// /// 监控是否运行 /// - public Boolean IsRun + public Boolean IsRun { get { return IsRun; } } @@ -95,7 +105,7 @@ namespace PVDEMCS.Common.Devices.Impl /// public void Load(params DevicePoint[] points) { - if (points.IsNullOrEmpty()) + if (points.IsNullOrEmpty()) { throw new ArgumentException($"{nameof(points)}: 不能为空!"); } diff --git a/PVDEMCS/PVDEMCS/Common/Devices/Impl/DeviceRun.cs b/PVDEMCS/PVDEMCS/Common/Devices/Impl/DeviceRun.cs index 70e6a06..686d3e9 100644 --- a/PVDEMCS/PVDEMCS/Common/Devices/Impl/DeviceRun.cs +++ b/PVDEMCS/PVDEMCS/Common/Devices/Impl/DeviceRun.cs @@ -25,6 +25,28 @@ namespace PVDEMCS.Common.Devices.Impl TaskRun(); } + /// + /// 获取所有点位信息 + /// + public List GetDevicePoints + { + get + { + return monitors.SelectMany(f => f.Points).ToList(); + } + } + + /// + /// 获取控制器连接状态 + /// + public Dictionary GetDeviceIsConnected + { + get + { + return monitors.ToDictionary(f=>f.DeviceCode,f=>f.isConnected); + } + } + /// /// 开始运行 /// @@ -54,7 +76,6 @@ namespace PVDEMCS.Common.Devices.Impl } } - /// /// 停止运行 /// diff --git a/PVDEMCS/PVDEMCS/Controllers/DeviceController.cs b/PVDEMCS/PVDEMCS/Controllers/DeviceController.cs index aa91253..f59645e 100644 --- a/PVDEMCS/PVDEMCS/Controllers/DeviceController.cs +++ b/PVDEMCS/PVDEMCS/Controllers/DeviceController.cs @@ -1,9 +1,11 @@ using AngleSharp.Dom; +using Masuit.Tools; using Masuit.Tools.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using PVDEMCS.Common; using PVDEMCS.Common.Constant; +using PVDEMCS.Common.Devices; using PVDEMCS.Services; using PVDEMCS.Services.Models; using SharpCompress.Common; @@ -19,10 +21,12 @@ namespace PVDEMCS.Controllers public class DeviceController : Controller { private IDeviceService _deviceService; + private IDeviceRun _deviceRun; - public DeviceController(IDeviceService deviceService) + public DeviceController(IDeviceService deviceService, IDeviceRun deviceRun) { _deviceService = deviceService; + _deviceRun = deviceRun; } #region PLC控制器 @@ -38,9 +42,14 @@ namespace PVDEMCS.Controllers public Result> GetDevicePageList(string deviceCode, string deviceName, bool? activated, int page, int size = 20) { var result = _deviceService.GetDevicePageList(deviceCode, deviceName, activated, page, size); + if (result.IsSuccess) + { + GetDeviceIsConnected(result.Content.Data); + } return result; } + /// /// 获取PLC控制器列表 /// @@ -51,9 +60,22 @@ namespace PVDEMCS.Controllers public Result> GetDeviceInfoList(string deviceCode, string deviceName, bool? activated = false) { var result = _deviceService.GetDeviceInfoList(deviceCode, deviceName, activated); + GetDeviceIsConnected(result.Content); return result; } + [NonAction] + private void GetDeviceIsConnected(List list) + { + if (!list.IsNullOrEmpty() && !_deviceRun.GetDeviceIsConnected.IsNullOrEmpty()) + { + foreach (var item in list) + { + item.isConnected = _deviceRun.GetDeviceIsConnected[item.DeviceCode]; + } + } + } + /// /// 获取PLC控制器明细 /// @@ -121,6 +143,10 @@ namespace PVDEMCS.Controllers public Result> GetDevicePointPageList(string deviceName, string deviceCode, string equipmentName, string equipmentCode, string equipmentType, string pointCode, string pointName, bool? activated, int page, int size = 20) { var result = _deviceService.GetDevicePointPageList(deviceName, deviceCode, equipmentName, equipmentCode, equipmentType, pointCode, pointName, activated, page, size); + if (result.IsSuccess) + { + GetPointValue(result.Content.Data); + } return result; } @@ -139,9 +165,23 @@ namespace PVDEMCS.Controllers public Result> GetDevicePointList(string deviceName, string deviceCode, string equipmentName, string equipmentCode, string equipmentType, string pointCode, string pointName, bool? activated) { var result = _deviceService.GetDevicePointList(deviceName, deviceCode, equipmentName, equipmentCode, equipmentType, pointCode, pointName, activated); + GetPointValue(result.Content); return result; } + [NonAction] + private void GetPointValue(List list) + { + var points = _deviceRun.GetDevicePoints; + if (!list.IsNullOrEmpty() && !points.IsNullOrEmpty()) + { + foreach (var item in list) + { + item.ObjectValue = points.Where(f => f.PointCode == item.PointCode).Select(f => f.ObjectValue).FirstOrDefault(); + } + } + } + /// /// 获取PLC控制器点位明细 /// @@ -172,7 +212,7 @@ namespace PVDEMCS.Controllers /// /// [HttpPost] - public Result UpdateDevicePoint(DevicePoint entity) + public Result UpdateDevicePoint(DevicePoint entity) { var result = _deviceService.UpdateDevicePoint(entity); return result; @@ -184,7 +224,7 @@ namespace PVDEMCS.Controllers /// /// [HttpPost] - public Result DeleteDevicePoint(string id) + public Result DeleteDevicePoint(string id) { var result = _deviceService.DeleteDevicePoint(id); return result; diff --git a/PVDEMCS/PVDEMCS/Services/Models/DeviceInfo.cs b/PVDEMCS/PVDEMCS/Services/Models/DeviceInfo.cs index 0be70f0..4b37d76 100644 --- a/PVDEMCS/PVDEMCS/Services/Models/DeviceInfo.cs +++ b/PVDEMCS/PVDEMCS/Services/Models/DeviceInfo.cs @@ -47,4 +47,9 @@ public partial class DeviceInfo /// public string Remark { get; set; } + /// + /// 设备连接状态 + /// + public Boolean isConnected { get; set; } + } \ No newline at end of file diff --git a/PVDEMCS/PVDEMCS/bin/Debug/net6.0/PVDEMCS.dll b/PVDEMCS/PVDEMCS/bin/Debug/net6.0/PVDEMCS.dll index 93e2c53..f43b30d 100644 Binary files a/PVDEMCS/PVDEMCS/bin/Debug/net6.0/PVDEMCS.dll and b/PVDEMCS/PVDEMCS/bin/Debug/net6.0/PVDEMCS.dll differ diff --git a/PVDEMCS/PVDEMCS/bin/Debug/net6.0/PVDEMCS.pdb b/PVDEMCS/PVDEMCS/bin/Debug/net6.0/PVDEMCS.pdb index 2ef9e88..8ac971b 100644 Binary files a/PVDEMCS/PVDEMCS/bin/Debug/net6.0/PVDEMCS.pdb and b/PVDEMCS/PVDEMCS/bin/Debug/net6.0/PVDEMCS.pdb differ diff --git a/PVDEMCS/PVDEMCS/bin/Debug/net6.0/PVDEMCS.xml b/PVDEMCS/PVDEMCS/bin/Debug/net6.0/PVDEMCS.xml index 96b83e6..2efc068 100644 --- a/PVDEMCS/PVDEMCS/bin/Debug/net6.0/PVDEMCS.xml +++ b/PVDEMCS/PVDEMCS/bin/Debug/net6.0/PVDEMCS.xml @@ -64,6 +64,16 @@ 设备运行 + + + 获取所有点位信息 + + + + + 获取控制器连接状态 + + 开始运行 @@ -84,6 +94,11 @@ 获取错误相信 + + + 控制器编号 + + 间隔时间 @@ -148,6 +163,16 @@ 设备运行 + + + 获取所有点位信息 + + + + + 获取控制器连接状态 + + 开始运行 @@ -1515,6 +1540,11 @@ 备注 + + + 设备连接状态 + + PLC点位 diff --git a/PVDEMCS/PVDEMCS/obj/Debug/net6.0/PVDEMCS.dll b/PVDEMCS/PVDEMCS/obj/Debug/net6.0/PVDEMCS.dll index 93e2c53..f43b30d 100644 Binary files a/PVDEMCS/PVDEMCS/obj/Debug/net6.0/PVDEMCS.dll and b/PVDEMCS/PVDEMCS/obj/Debug/net6.0/PVDEMCS.dll differ diff --git a/PVDEMCS/PVDEMCS/obj/Debug/net6.0/PVDEMCS.pdb b/PVDEMCS/PVDEMCS/obj/Debug/net6.0/PVDEMCS.pdb index 2ef9e88..8ac971b 100644 Binary files a/PVDEMCS/PVDEMCS/obj/Debug/net6.0/PVDEMCS.pdb and b/PVDEMCS/PVDEMCS/obj/Debug/net6.0/PVDEMCS.pdb differ diff --git a/PVDEMCS/PVDEMCS/obj/Debug/net6.0/PVDEMCS.xml b/PVDEMCS/PVDEMCS/obj/Debug/net6.0/PVDEMCS.xml index 96b83e6..2efc068 100644 --- a/PVDEMCS/PVDEMCS/obj/Debug/net6.0/PVDEMCS.xml +++ b/PVDEMCS/PVDEMCS/obj/Debug/net6.0/PVDEMCS.xml @@ -64,6 +64,16 @@ 设备运行 + + + 获取所有点位信息 + + + + + 获取控制器连接状态 + + 开始运行 @@ -84,6 +94,11 @@ 获取错误相信 + + + 控制器编号 + + 间隔时间 @@ -148,6 +163,16 @@ 设备运行 + + + 获取所有点位信息 + + + + + 获取控制器连接状态 + + 开始运行 @@ -1515,6 +1540,11 @@ 备注 + + + 设备连接状态 + + PLC点位 diff --git a/PVDEMCS/PVDEMCS/obj/Debug/net6.0/ref/PVDEMCS.dll b/PVDEMCS/PVDEMCS/obj/Debug/net6.0/ref/PVDEMCS.dll index 6db3591..4d26d2e 100644 Binary files a/PVDEMCS/PVDEMCS/obj/Debug/net6.0/ref/PVDEMCS.dll and b/PVDEMCS/PVDEMCS/obj/Debug/net6.0/ref/PVDEMCS.dll differ diff --git a/PVDEMCS/PVDEMCS/obj/Debug/net6.0/refint/PVDEMCS.dll b/PVDEMCS/PVDEMCS/obj/Debug/net6.0/refint/PVDEMCS.dll index 6db3591..4d26d2e 100644 Binary files a/PVDEMCS/PVDEMCS/obj/Debug/net6.0/refint/PVDEMCS.dll and b/PVDEMCS/PVDEMCS/obj/Debug/net6.0/refint/PVDEMCS.dll differ