diff --git a/PVDEMCS/.vs/PVDEMCS/DesignTimeBuild/.dtbcache.v2 b/PVDEMCS/.vs/PVDEMCS/DesignTimeBuild/.dtbcache.v2
index be53c24..5a9f804 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/04bd2e4a-139c-41a2-b8ff-22c23badc3b1.vsidx b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/04bd2e4a-139c-41a2-b8ff-22c23badc3b1.vsidx
new file mode 100644
index 0000000..d16173c
Binary files /dev/null and b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/04bd2e4a-139c-41a2-b8ff-22c23badc3b1.vsidx 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
deleted file mode 100644
index 817d7fd..0000000
Binary files a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/08b0d3a2-d015-46bb-adb1-2344026efcd9.vsidx and /dev/null 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
deleted file mode 100644
index 7161145..0000000
Binary files a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/12af3e70-ff1b-476e-bca3-dd8dc2f6df63.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
deleted file mode 100644
index e2ed4c9..0000000
Binary files a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/327aa321-737c-4c40-ae28-dd600023fb55.vsidx and /dev/null differ
diff --git a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/3fdb8c33-a0ee-445b-8718-895fbfd4410d.vsidx b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/3fdb8c33-a0ee-445b-8718-895fbfd4410d.vsidx
new file mode 100644
index 0000000..5f9f876
Binary files /dev/null and b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/3fdb8c33-a0ee-445b-8718-895fbfd4410d.vsidx 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
deleted file mode 100644
index 3b57012..0000000
Binary files a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/7619295f-cfcf-4075-836f-9eb68b3cdcfe.vsidx and /dev/null differ
diff --git a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/76492144-562e-4d4f-852e-d153ee704c8f.vsidx b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/76492144-562e-4d4f-852e-d153ee704c8f.vsidx
new file mode 100644
index 0000000..679d1d7
Binary files /dev/null and b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/76492144-562e-4d4f-852e-d153ee704c8f.vsidx differ
diff --git a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/780bad77-3b41-4ae7-b5ec-e1422c7caeee.vsidx b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/780bad77-3b41-4ae7-b5ec-e1422c7caeee.vsidx
new file mode 100644
index 0000000..13db997
Binary files /dev/null and b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/780bad77-3b41-4ae7-b5ec-e1422c7caeee.vsidx 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
deleted file mode 100644
index 4817d76..0000000
Binary files a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/a0d6e7b5-203b-4507-bbeb-6afaad13d1ec.vsidx and /dev/null differ
diff --git a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/b5a19ed7-50d5-488c-8ece-d32417f62322.vsidx b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/b5a19ed7-50d5-488c-8ece-d32417f62322.vsidx
deleted file mode 100644
index 5272b8b..0000000
Binary files a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/b5a19ed7-50d5-488c-8ece-d32417f62322.vsidx and /dev/null differ
diff --git a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/ebd8713c-f426-4e07-96ed-2a2cf8971804.vsidx b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/ebd8713c-f426-4e07-96ed-2a2cf8971804.vsidx
new file mode 100644
index 0000000..ae48cf8
Binary files /dev/null and b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/ebd8713c-f426-4e07-96ed-2a2cf8971804.vsidx differ
diff --git a/PVDEMCS/.vs/PVDEMCS/FileContentIndex/fc9c3a71-d989-456d-878f-756c3346c678.vsidx b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/fc9c3a71-d989-456d-878f-756c3346c678.vsidx
new file mode 100644
index 0000000..fbbd6de
Binary files /dev/null and b/PVDEMCS/.vs/PVDEMCS/FileContentIndex/fc9c3a71-d989-456d-878f-756c3346c678.vsidx differ
diff --git a/PVDEMCS/.vs/PVDEMCS/v17/.suo b/PVDEMCS/.vs/PVDEMCS/v17/.suo
index b992d31..406c952 100644
Binary files a/PVDEMCS/.vs/PVDEMCS/v17/.suo and b/PVDEMCS/.vs/PVDEMCS/v17/.suo differ
diff --git a/PVDEMCS/PVDEMCS/Controllers/DeviceController.cs b/PVDEMCS/PVDEMCS/Controllers/DeviceController.cs
index f59645e..50c3dae 100644
--- a/PVDEMCS/PVDEMCS/Controllers/DeviceController.cs
+++ b/PVDEMCS/PVDEMCS/Controllers/DeviceController.cs
@@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using PVDEMCS.Common;
using PVDEMCS.Common.Constant;
-using PVDEMCS.Common.Devices;
+using PVDEMCS.Devices;
using PVDEMCS.Services;
using PVDEMCS.Services.Models;
using SharpCompress.Common;
@@ -55,19 +55,23 @@ namespace PVDEMCS.Controllers
///
/// 控制器编号
/// 控制器名称
- ///
+ /// 是否启用
+ /// ///
[HttpGet]
public Result> GetDeviceInfoList(string deviceCode, string deviceName, bool? activated = false)
{
var result = _deviceService.GetDeviceInfoList(deviceCode, deviceName, activated);
- GetDeviceIsConnected(result.Content);
+ if (result.IsSuccess)
+ {
+ GetDeviceIsConnected(result.Content);
+ }
return result;
}
[NonAction]
private void GetDeviceIsConnected(List list)
{
- if (!list.IsNullOrEmpty() && !_deviceRun.GetDeviceIsConnected.IsNullOrEmpty())
+ if (list.IsNullOrEmpty() &&!_deviceRun.GetDeviceIsConnected.IsNullOrEmpty())
{
foreach (var item in list)
{
diff --git a/PVDEMCS/PVDEMCS/Controllers/EquipmentController.cs b/PVDEMCS/PVDEMCS/Controllers/EquipmentController.cs
index c0f9c3c..679cad3 100644
--- a/PVDEMCS/PVDEMCS/Controllers/EquipmentController.cs
+++ b/PVDEMCS/PVDEMCS/Controllers/EquipmentController.cs
@@ -1,9 +1,12 @@
-using Masuit.Tools.Models;
+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.Devices;
using PVDEMCS.Services;
+using PVDEMCS.Services.Impl;
using PVDEMCS.Services.Models;
using System;
@@ -17,6 +20,7 @@ namespace PVDEMCS.Controllers
public class EquipmentController : Controller
{
private IEquipmentService _equipmentService;
+
public EquipmentController(IEquipmentService equipmentService)
{
@@ -36,6 +40,7 @@ namespace PVDEMCS.Controllers
public Result> GetEquipmentPageList(string equipmentName, string equipmentCode, string equipmentType, bool? activated, int page, int size)
{
var result = this._equipmentService.GetEquipmentPageList(equipmentName,equipmentCode,equipmentType,activated,page,size);
+
return result;
}
@@ -49,9 +54,11 @@ namespace PVDEMCS.Controllers
public Result> GetEquipmentList(string equipmentName, string equipmentCode, string equipmentType, bool? activated)
{
var result = this._equipmentService.GetEquipmentList(equipmentName, equipmentCode, equipmentType, activated);
+
return result;
}
+
///
/// 获取设备明显
///
diff --git a/PVDEMCS/PVDEMCS/Controllers/EquipmentRecordController.cs b/PVDEMCS/PVDEMCS/Controllers/EquipmentRecordController.cs
index 6215512..5ca7b7d 100644
--- a/PVDEMCS/PVDEMCS/Controllers/EquipmentRecordController.cs
+++ b/PVDEMCS/PVDEMCS/Controllers/EquipmentRecordController.cs
@@ -17,9 +17,13 @@ namespace PVDEMCS.Controllers
public class EquipmentRecordController : Controller
{
private IEquipmentRecordService _equipmentRecordService;
- public EquipmentRecordController(IEquipmentRecordService equipmentRecordService)
+
+ private IDeviceService _deviceService;
+
+ public EquipmentRecordController(IEquipmentRecordService equipmentRecordService,IDeviceService deviceService)
{
this._equipmentRecordService = equipmentRecordService;
+ this._deviceService = deviceService;
}
#region 设备状态记录
@@ -57,7 +61,7 @@ namespace PVDEMCS.Controllers
var result = _equipmentRecordService.GetEquipmentRecordList(equipmentName, equipmentCode, equipmentType, begTime, endTime);
return result;
}
-
+
///
/// 添加或更新设备状态记录
/// 1.如果设备最新记录状态没有改变则更新结束时间
@@ -91,7 +95,7 @@ namespace PVDEMCS.Controllers
#region 设备记录统计
///
- /// 获取设备状态记录统计分页列表
+ /// 获取设备状态记录统计(日)分页列表
///
/// 设备名称
/// 设备编号
@@ -108,7 +112,7 @@ namespace PVDEMCS.Controllers
}
///
- /// 获取设备状态记录统计列表
+ /// 获取设备状态记录统计(日)列表
///
/// 设备名称
/// 设备编号
@@ -122,6 +126,18 @@ namespace PVDEMCS.Controllers
return result;
}
+ ///
+ /// 获取设备总览
+ ///
+ ///
+ [HttpGet]
+ public Result> GetEquipmentStateView()
+ {
+ var points = _deviceService.GetDevicePointList(activated:true);
+
+ return null;
+ }
+
#endregion
}
}
diff --git a/PVDEMCS/PVDEMCS/Common/Devices/DeviceType.cs b/PVDEMCS/PVDEMCS/Devices/DeviceType.cs
similarity index 95%
rename from PVDEMCS/PVDEMCS/Common/Devices/DeviceType.cs
rename to PVDEMCS/PVDEMCS/Devices/DeviceType.cs
index 29b9a81..80e6900 100644
--- a/PVDEMCS/PVDEMCS/Common/Devices/DeviceType.cs
+++ b/PVDEMCS/PVDEMCS/Devices/DeviceType.cs
@@ -1,4 +1,4 @@
-namespace PVDEMCS.Common.Devices
+namespace PVDEMCS.Devices
{
public sealed class DeviceProtocol
{
diff --git a/PVDEMCS/PVDEMCS/Common/Devices/IDeviceRun.cs b/PVDEMCS/PVDEMCS/Devices/IDeviceRun.cs
similarity index 95%
rename from PVDEMCS/PVDEMCS/Common/Devices/IDeviceRun.cs
rename to PVDEMCS/PVDEMCS/Devices/IDeviceRun.cs
index bb82d1a..a0710aa 100644
--- a/PVDEMCS/PVDEMCS/Common/Devices/IDeviceRun.cs
+++ b/PVDEMCS/PVDEMCS/Devices/IDeviceRun.cs
@@ -3,7 +3,7 @@ using PVDEMCS.Services;
using PVDEMCS.Services.Models;
using System.Threading;
-namespace PVDEMCS.Common.Devices
+namespace PVDEMCS.Devices
{
///
/// 设备运行
diff --git a/PVDEMCS/PVDEMCS/Common/Devices/IPLCCommunicationService.cs b/PVDEMCS/PVDEMCS/Devices/IPLCCommunicationService.cs
similarity index 95%
rename from PVDEMCS/PVDEMCS/Common/Devices/IPLCCommunicationService.cs
rename to PVDEMCS/PVDEMCS/Devices/IPLCCommunicationService.cs
index d613b68..08e6538 100644
--- a/PVDEMCS/PVDEMCS/Common/Devices/IPLCCommunicationService.cs
+++ b/PVDEMCS/PVDEMCS/Devices/IPLCCommunicationService.cs
@@ -8,13 +8,14 @@ using System.Text;
using System.Threading.Tasks;
using HslCommunication.Profinet.Siemens;
using PVDEMCS.Common.DI;
+using PVDEMCS.Common;
-namespace PVDEMCS.Common.Devices
+namespace PVDEMCS.Devices
{
///
/// PLC通信接口
///
- public interface IPLCCommunicationService
+ public interface IPLCCommunicationService
{
///
/// 是否已连接
@@ -108,14 +109,14 @@ namespace PVDEMCS.Common.Devices
///
/// 写入地址
///
- Result Write(string address, Int16 value);
+ Result Write(string address, short value);
///
/// 写入Int32值
///
/// 写入地址
///
- Result Write(string address, Int32 value);
+ Result Write(string address, int value);
///
/// 写入float值
@@ -226,14 +227,14 @@ namespace PVDEMCS.Common.Devices
///
/// 写入地址
///
- Task WriteAsync(string address, Int16 value);
+ Task WriteAsync(string address, short value);
///
/// 写入Int32值
///
/// 写入地址
///
- Task WriteAsync(string address, Int32 value);
+ Task WriteAsync(string address, int value);
///
/// 写入float值
diff --git a/PVDEMCS/PVDEMCS/Common/Devices/Impl/DeviceMonitor.cs b/PVDEMCS/PVDEMCS/Devices/Impl/DeviceMonitor.cs
similarity index 90%
rename from PVDEMCS/PVDEMCS/Common/Devices/Impl/DeviceMonitor.cs
rename to PVDEMCS/PVDEMCS/Devices/Impl/DeviceMonitor.cs
index 07e71fc..8977f80 100644
--- a/PVDEMCS/PVDEMCS/Common/Devices/Impl/DeviceMonitor.cs
+++ b/PVDEMCS/PVDEMCS/Devices/Impl/DeviceMonitor.cs
@@ -1,9 +1,15 @@
using Masuit.Tools;
+using PVDEMCS.Common;
+using PVDEMCS.Common.Devices.Impl;
+using PVDEMCS.Devices;
using PVDEMCS.Services.Models;
using System.Security.Cryptography;
-namespace PVDEMCS.Common.Devices.Impl
+namespace PVDEMCS.Devices.Impl
{
+ ///
+ /// 控制器点位监控
+ ///
public class DeviceMonitor
{
private DeviceInfo deviceInfo;
@@ -14,7 +20,7 @@ namespace PVDEMCS.Common.Devices.Impl
public DeviceMonitor(DeviceInfo deviceInfo)
{
this.deviceInfo = deviceInfo;
- this.devicePoints = new List();
+ devicePoints = new List();
PointMonitor();
}
///
@@ -30,10 +36,10 @@ namespace PVDEMCS.Common.Devices.Impl
///
/// 控制器编号
///
- public string DeviceCode
- {
- get
- {
+ public string DeviceCode
+ {
+ get
+ {
return deviceInfo.DeviceCode;
}
}
@@ -53,7 +59,7 @@ namespace PVDEMCS.Common.Devices.Impl
///
/// 连接状态
///
- public Boolean isConnected
+ public bool isConnected
{
get
{
@@ -64,7 +70,7 @@ namespace PVDEMCS.Common.Devices.Impl
///
/// 监控是否运行
///
- public Boolean IsRun
+ public bool IsRun
{
get { return IsRun; }
}
@@ -85,8 +91,8 @@ namespace PVDEMCS.Common.Devices.Impl
///
public void Init(string address, int port = 0)
{
- this.deviceInfo.Host = address;
- this.deviceInfo.Port = port;
+ deviceInfo.Host = address;
+ deviceInfo.Port = port;
}
///
@@ -131,11 +137,11 @@ namespace PVDEMCS.Common.Devices.Impl
{
if (plcCommunicationService == null)
{
- plcCommunicationService = new S7CommunicationService(this.deviceInfo.Protocol);
+ plcCommunicationService = new S7CommunicationService(deviceInfo.Protocol);
}
if (!plcCommunicationService.isConnected)
{
- var result = await plcCommunicationService.ConnectionAsync(this.deviceInfo.Host, this.deviceInfo.Port);
+ var result = await plcCommunicationService.ConnectionAsync(deviceInfo.Host, deviceInfo.Port);
if (!result.IsSuccess)
{
ErrorMessage?.Invoke(this, "开始PLC连接失败:" + result.Message);
@@ -197,42 +203,42 @@ namespace PVDEMCS.Common.Devices.Impl
var type = point.DataType;
var plcService = plcCommunicationService;
//Boolean
- if (type.Equals(typeof(Boolean)))
+ if (type.Equals(typeof(bool)))
{
var result = await plcService.ReadBoolAsync(point.Address);
GetReturnValue(point, result);
return;
}
//Byte
- if (type.Equals(typeof(Byte)))
+ if (type.Equals(typeof(byte)))
{
var result = await plcService.ReadByteAsync(point.Address);
GetReturnValue(point, result);
return;
}
//Byte
- if (type.Equals(typeof(Byte)))
+ if (type.Equals(typeof(byte)))
{
var result = await plcService.ReadByteAsync(point.Address);
GetReturnValue(point, result);
return;
}
//Int16
- if (type.Equals(typeof(Int16)))
+ if (type.Equals(typeof(short)))
{
var result = await plcService.ReadInt16Async(point.Address);
GetReturnValue(point, result);
return;
}
//Int32
- if (type.Equals(typeof(Int32)))
+ if (type.Equals(typeof(int)))
{
var result = await plcService.ReadInt32Async(point.Address);
GetReturnValue(point, result);
return;
}
//Int64
- if (type.Equals(typeof(Int64)))
+ if (type.Equals(typeof(long)))
{
var result = await plcService.ReadLongAsync(point.Address);
GetReturnValue(point, result);
@@ -246,7 +252,7 @@ namespace PVDEMCS.Common.Devices.Impl
return;
}
//double
- if (type.Equals(typeof(Double)))
+ if (type.Equals(typeof(double)))
{
var result = await plcService.ReadDoubleAsync(point.Address);
GetReturnValue(point, result);
diff --git a/PVDEMCS/PVDEMCS/Common/Devices/Impl/DeviceRun.cs b/PVDEMCS/PVDEMCS/Devices/Impl/DeviceRun.cs
similarity index 88%
rename from PVDEMCS/PVDEMCS/Common/Devices/Impl/DeviceRun.cs
rename to PVDEMCS/PVDEMCS/Devices/Impl/DeviceRun.cs
index 686d3e9..78677aa 100644
--- a/PVDEMCS/PVDEMCS/Common/Devices/Impl/DeviceRun.cs
+++ b/PVDEMCS/PVDEMCS/Devices/Impl/DeviceRun.cs
@@ -1,11 +1,12 @@
using AngleSharp.Css.Dom;
using Masuit.Tools;
using PVDEMCS.Common.Constant;
+using PVDEMCS.Devices;
using PVDEMCS.Services;
using PVDEMCS.Services.Models;
using System.Threading;
-namespace PVDEMCS.Common.Devices.Impl
+namespace PVDEMCS.Devices.Impl
{
///
/// 设备运行
@@ -39,11 +40,11 @@ namespace PVDEMCS.Common.Devices.Impl
///
/// 获取控制器连接状态
///
- public Dictionary GetDeviceIsConnected
+ public Dictionary GetDeviceIsConnected
{
get
{
- return monitors.ToDictionary(f=>f.DeviceCode,f=>f.isConnected);
+ return monitors.ToDictionary(f => f.DeviceCode, f => f.isConnected);
}
}
@@ -56,7 +57,7 @@ namespace PVDEMCS.Common.Devices.Impl
monitors.Clear();
- var result = this.deviceService.GetDeviceInfoList("", "", true);
+ var result = deviceService.GetDeviceInfoList("", "", true);
if (result.IsSuccess)
{
var devices = result.Content;
@@ -140,9 +141,13 @@ namespace PVDEMCS.Common.Devices.Impl
{
var startStop = list.Where(f => f.ActionType == ActionType.StartStop).FirstOrDefault();
var fault = list.Where(f => f.ActionType == ActionType.Fault).FirstOrDefault();
- if (!startStop.IsNullOrEmpty() && !fault.IsNullOrEmpty())
+ if (!startStop.IsNullOrEmpty() &&
+ !fault.IsNullOrEmpty() &&
+ !startStop.ObjectValue.IsNullOrEmpty() &&
+ !fault.ObjectValue.IsNullOrEmpty())
{
var state = EquipmentState.Run;
+
if (fault.GetValue())
{
state = EquipmentState.Alarm;
@@ -151,7 +156,7 @@ namespace PVDEMCS.Common.Devices.Impl
{
state = EquipmentState.Stop;
}
- this.equipmentRecordService.AddUpdateEquipmentRecord(id, state, DateTime.Now);
+ equipmentRecordService.AddUpdateEquipmentRecord(id, state, DateTime.Now);
}
}
}
diff --git a/PVDEMCS/PVDEMCS/Common/Devices/Impl/S7CommunicationService.cs b/PVDEMCS/PVDEMCS/Devices/Impl/S7CommunicationService.cs
similarity index 97%
rename from PVDEMCS/PVDEMCS/Common/Devices/Impl/S7CommunicationService.cs
rename to PVDEMCS/PVDEMCS/Devices/Impl/S7CommunicationService.cs
index 854b862..efbfaa4 100644
--- a/PVDEMCS/PVDEMCS/Common/Devices/Impl/S7CommunicationService.cs
+++ b/PVDEMCS/PVDEMCS/Devices/Impl/S7CommunicationService.cs
@@ -13,8 +13,10 @@ using HslCommunication;
using HslCommunication.Profinet.Siemens;
using HslCommunication.Reflection;
using PVDEMCS.Common.Tools;
+using PVDEMCS.Devices;
+using PVDEMCS.Common;
-namespace PVDEMCS.Common.Devices.Impl
+namespace PVDEMCS.Devices.Impl
{
///
/// PLC通信服务 SiemensS7 smart200 实现
@@ -30,7 +32,8 @@ namespace PVDEMCS.Common.Devices.Impl
public S7CommunicationService(string deviceProtocol)
{
- switch (deviceProtocol) {
+ switch (deviceProtocol)
+ {
case DeviceProtocol.S7_400:
siemensS7Net = new SiemensS7Net(SiemensPLCS.S400);
break;
@@ -49,7 +52,7 @@ namespace PVDEMCS.Common.Devices.Impl
case DeviceProtocol.S7_200Smart:
siemensS7Net = new SiemensS7Net(SiemensPLCS.S200Smart);
break;
- default :
+ default:
throw new ArgumentException($"DeviceProtocol 参数不正确,没有{deviceProtocol}协议");
}
siemensS7Net.ConnectTimeOut = 3000;
@@ -213,7 +216,7 @@ namespace PVDEMCS.Common.Devices.Impl
///
/// 写入地址
///
- public Result Write(string address, Int16 value)
+ public Result Write(string address, short value)
{
var operateResult = siemensS7Net.Write(address, value);
var result = ConvertResult(operateResult);
@@ -225,7 +228,7 @@ namespace PVDEMCS.Common.Devices.Impl
///
/// 写入地址
///
- public Result Write(string address, Int32 value)
+ public Result Write(string address, int value)
{
var operateResult = siemensS7Net.Write(address, value);
var result = ConvertResult(operateResult);
@@ -428,7 +431,7 @@ namespace PVDEMCS.Common.Devices.Impl
///
/// 写入地址
///
- public async Task WriteAsync(string address, Int16 value)
+ public async Task WriteAsync(string address, short value)
{
var operateResult = await siemensS7Net.WriteAsync(address, value);
var result = ConvertResult(operateResult);
@@ -440,7 +443,7 @@ namespace PVDEMCS.Common.Devices.Impl
///
/// 写入地址
///
- public async Task WriteAsync(string address, Int32 value)
+ public async Task WriteAsync(string address, int value)
{
var operateResult = await siemensS7Net.WriteAsync(address, value);
var result = ConvertResult(operateResult);
diff --git a/PVDEMCS/PVDEMCS/Program.cs b/PVDEMCS/PVDEMCS/Program.cs
index c62db98..41d40a5 100644
--- a/PVDEMCS/PVDEMCS/Program.cs
+++ b/PVDEMCS/PVDEMCS/Program.cs
@@ -1,8 +1,8 @@
using Masuit.Tools;
using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models;
-using PVDEMCS.Common.Devices;
using PVDEMCS.Common.DI;
+using PVDEMCS.Devices;
using System.Configuration;
using System.Reflection;
diff --git a/PVDEMCS/PVDEMCS/Services/Impl/DeviceService.cs b/PVDEMCS/PVDEMCS/Services/Impl/DeviceService.cs
index 37966a6..8d80cc9 100644
--- a/PVDEMCS/PVDEMCS/Services/Impl/DeviceService.cs
+++ b/PVDEMCS/PVDEMCS/Services/Impl/DeviceService.cs
@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using PVDEMCS.Common;
using PVDEMCS.Common.Tools;
+using PVDEMCS.Devices;
using PVDEMCS.Services.Models;
using PVDEMCS.Services.Repositories;
using PVDEMCS.Services.Repositories.Entities;
@@ -20,6 +21,7 @@ namespace PVDEMCS.Services.Impl
public DeviceService(IDeviceRepository deviceRepository)
{
this._deviceRepository = deviceRepository;
+
}
#region PLC控制器
diff --git a/PVDEMCS/PVDEMCS/Services/Impl/EquipmentService.cs b/PVDEMCS/PVDEMCS/Services/Impl/EquipmentService.cs
index 5886941..62c1ece 100644
--- a/PVDEMCS/PVDEMCS/Services/Impl/EquipmentService.cs
+++ b/PVDEMCS/PVDEMCS/Services/Impl/EquipmentService.cs
@@ -8,6 +8,8 @@ using PVDEMCS.Common.Constant;
using PVDEMCS.Common.Tools;
using PVDEMCS.Services.Repositories.Entities;
using PVDEMCS.Services.Repositories.Impl;
+using PVDEMCS.Devices;
+using Masuit.Tools;
namespace PVDEMCS.Services.Impl
{
@@ -17,10 +19,12 @@ namespace PVDEMCS.Services.Impl
internal class EquipmentService : IEquipmentService
{
private readonly EquipmentRepository _equipmentRepository;
+ private readonly IDeviceRun _deviceRun;
- public EquipmentService(EquipmentRepository equipmentRepository)
+ public EquipmentService(EquipmentRepository equipmentRepository, IDeviceRun deviceRun)
{
this._equipmentRepository = equipmentRepository;
+ this._deviceRun = deviceRun;
}
///
@@ -36,6 +40,10 @@ namespace PVDEMCS.Services.Impl
public Result> GetEquipmentPageList(string equipmentName, string equipmentCode, string equipmentType, bool? activated, int page, int size)
{
var result = this._equipmentRepository.GetEquipmentPageList(equipmentName, equipmentCode, equipmentType, activated, page, size);
+ if (result.IsSuccess)
+ {
+ GetEquipmentState(result.Content.Data);
+ }
return result;
}
@@ -48,9 +56,50 @@ namespace PVDEMCS.Services.Impl
public Result> GetEquipmentList(string equipmentName, string equipmentCode, string equipmentType, bool? activated)
{
var result = this._equipmentRepository.GetEquipmentList(equipmentName, equipmentCode, equipmentType, activated);
+ if (result.IsSuccess)
+ {
+ GetEquipmentState(result.Content);
+ }
return result;
}
+ ///
+ /// 获取设备状态
+ ///
+ ///
+ private void GetEquipmentState(List equipmentInfos)
+ {
+ var points = _deviceRun.GetDevicePoints;
+ if (!equipmentInfos.IsNullOrEmpty() && !points.IsNullOrEmpty())
+ {
+ foreach (var equipmentInfo in equipmentInfos)
+ {
+ var list = points.Where(f => f.EquipmentId == equipmentInfo.Id).ToList();
+ if (list.Count >= 2)
+ {
+ var startStop = list.Where(f => f.ActionType == ActionType.StartStop).FirstOrDefault();
+ var fault = list.Where(f => f.ActionType == ActionType.Fault).FirstOrDefault();
+ if (!startStop.IsNullOrEmpty() &&
+ !fault.IsNullOrEmpty() &&
+ !startStop.ObjectValue.IsNullOrEmpty() &&
+ !fault.ObjectValue.IsNullOrEmpty())
+ {
+ var state = EquipmentState.Run;
+ if (fault.GetValue())
+ {
+ state = EquipmentState.Alarm;
+ }
+ else if (!startStop.GetValue())
+ {
+ state = EquipmentState.Stop;
+ }
+ equipmentInfo.State = state
+ }
+ }
+ }
+ }
+ }
+
///
/// 获取设备明显
///
diff --git a/PVDEMCS/PVDEMCS/Services/Models/EquipmentStateView.cs b/PVDEMCS/PVDEMCS/Services/Models/EquipmentStateView.cs
new file mode 100644
index 0000000..242d83d
--- /dev/null
+++ b/PVDEMCS/PVDEMCS/Services/Models/EquipmentStateView.cs
@@ -0,0 +1,28 @@
+namespace PVDEMCS.Services.Models
+{
+ ///
+ /// 设备状态总览
+ ///
+ public class EquipmentStateView
+ {
+ ///
+ /// 设备类型:ALL(所有),Ionbond,Balzers,Cemecon
+ ///
+ public string EquipmentType { get; set; }
+
+ ///
+ /// 运行数量
+ ///
+ public int Run { get; set; }
+
+ ///
+ /// 待机数量
+ ///
+ public int Stop { get; set; }
+
+ ///
+ /// 报警数量
+ ///
+ public int Alarm { get; set; }
+ }
+}
diff --git a/PVDEMCS/PVDEMCS/Services/Repositories/Impl/EquipmentRecordRepository.cs b/PVDEMCS/PVDEMCS/Services/Repositories/Impl/EquipmentRecordRepository.cs
index 795c3e6..138d3d0 100644
--- a/PVDEMCS/PVDEMCS/Services/Repositories/Impl/EquipmentRecordRepository.cs
+++ b/PVDEMCS/PVDEMCS/Services/Repositories/Impl/EquipmentRecordRepository.cs
@@ -392,6 +392,9 @@ namespace PVDEMCS.Services.Repositories.Impl
return query;
}
+
+
+
#endregion
}
}
diff --git a/PVDEMCS/PVDEMCS/obj/Debug/net6.0/PVDEMCS.csproj.CoreCompileInputs.cache b/PVDEMCS/PVDEMCS/obj/Debug/net6.0/PVDEMCS.csproj.CoreCompileInputs.cache
index 06779d0..b429c45 100644
--- a/PVDEMCS/PVDEMCS/obj/Debug/net6.0/PVDEMCS.csproj.CoreCompileInputs.cache
+++ b/PVDEMCS/PVDEMCS/obj/Debug/net6.0/PVDEMCS.csproj.CoreCompileInputs.cache
@@ -1 +1 @@
-78dedf078fa663772dbe506cad079b136782b2c8
+48b48bf3defe4d9734e7cdb6fde8131a1931ad8b