@@ -0,0 +1,21 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Device | |||
{ | |||
[AttributeUsage(AttributeTargets.Property)] | |||
public class AlarmAttribute : Attribute | |||
{ | |||
public AlarmAttribute(string Info) | |||
{ | |||
AlarmInfo = Info; | |||
} | |||
/// <summary> | |||
/// 报警信息 | |||
/// </summary> | |||
public string AlarmInfo { get; set; } | |||
} | |||
} |
@@ -23,6 +23,7 @@ namespace BPASmartClient.Device | |||
{ | |||
} | |||
#region 属性 | |||
/// <summary> | |||
/// 订单物料信息 | |||
/// </summary> | |||
@@ -48,7 +49,14 @@ namespace BPASmartClient.Device | |||
/// </summary> | |||
public string Name { get; set; } | |||
/// <summary> | |||
/// 当前订单数量 | |||
/// </summary> | |||
protected int OrderCount { get; set; } | |||
/// <summary> | |||
/// 设备初始化中 | |||
/// </summary> | |||
protected bool Initing { get; set; } | |||
/// <summary> | |||
@@ -70,20 +78,27 @@ namespace BPASmartClient.Device | |||
/// 设备运行日志 | |||
/// </summary> | |||
public List<object> Log { get; set; } = new List<object>(); | |||
/// <summary> | |||
/// 设备运行告警与错误 | |||
/// </summary> | |||
public List<object> Error { get; set; } = new List<object>(); | |||
/// <summary> | |||
/// 设备变量监控 | |||
/// </summary> | |||
public List<VariableMonitor> variableMonitors { get; set; } = new List<VariableMonitor>(); | |||
/// <summary> | |||
/// 外设状态,硬件设备数据 | |||
/// </summary> | |||
protected ConcurrentDictionary<string, object> peripheralStatus = new ConcurrentDictionary<string, object>(); | |||
/// <summary> | |||
/// 外设设备集合 | |||
/// </summary> | |||
private List<IPeripheral> peripherals; | |||
#endregion | |||
/// <summary> | |||
/// 设备过程日志显示 | |||
@@ -137,10 +152,9 @@ namespace BPASmartClient.Device | |||
DoMain(); | |||
GetGvlStatus(); | |||
InitResetTask(); | |||
InitTask(); | |||
} | |||
private void GetGvlStatus() | |||
{ | |||
this.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).ToList().ForEach(item => | |||
@@ -206,34 +220,19 @@ namespace BPASmartClient.Device | |||
/// <param name="alarmHelper"></param> | |||
private void AlarmMonitoring(IAlarm alarm, AlarmHelper alarmHelper) | |||
{ | |||
//ThreadManage.GetInstance().StartLong(new Action(() => | |||
//{ | |||
if (alarm != null) | |||
if (alarm == null) return; | |||
foreach (var item in alarm.GetType().GetProperties()) | |||
{ | |||
foreach (var item in alarm.GetType().GetProperties()) | |||
var res = item.GetValue(alarm); | |||
if (res != null && res is bool blen) | |||
{ | |||
var res = item.GetValue(alarm); | |||
if (res != null) | |||
if (item.CustomAttributes.Count() > 0 && item.CustomAttributes.ElementAt(0)?.ConstructorArguments.Count() > 0) | |||
{ | |||
if (res is bool blen) | |||
{ | |||
if (item.CustomAttributes.Count() > 0) | |||
{ | |||
if (item.CustomAttributes.ElementAt(0)?.ConstructorArguments.Count() > 0) | |||
{ | |||
var info = item.CustomAttributes.ElementAt(0)?.ConstructorArguments.ElementAt(0).Value; | |||
if (info != null) | |||
{ | |||
alarmHelper.EdgeAlarm(blen, info.ToString()); | |||
} | |||
} | |||
} | |||
} | |||
var info = item.CustomAttributes.ElementAt(0)?.ConstructorArguments.ElementAt(0).Value; | |||
if (info != null) alarmHelper.EdgeAlarm(blen, info.ToString()); | |||
} | |||
} | |||
} | |||
// Thread.Sleep(500); | |||
//}), $"报警检测监控:{DeviceId}"); | |||
} | |||
private void InitResetTask() | |||
@@ -439,7 +438,6 @@ namespace BPASmartClient.Device | |||
public object GetError() | |||
{ | |||
object time= GetPropertyValue(Error[0], "Time"); | |||
return new { data = Error }; | |||
} | |||
@@ -0,0 +1,132 @@ | |||
using BPASmartClient.Device; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.MorkS | |||
{ | |||
public class Alarm : IAlarm | |||
{ | |||
/// <summary> | |||
/// 煮面机左侧低温报警 | |||
/// PLC ---> M550.0 | |||
/// ModbusTcp --> 1570 | |||
/// </summary> | |||
[Alarm("煮面机左侧低温报警")] | |||
public bool MachineLeftLowTemperature { get; set; } | |||
/// <summary> | |||
/// 煮面机左侧低温报警 | |||
/// PLC ---> M550.1 | |||
/// ModbusTcp --> 1571 | |||
/// </summary> | |||
[Alarm("煮面机右侧低温报警")] | |||
public bool MachineRightLowTemperature { get; set; } | |||
/// <summary> | |||
/// 供碗1缺碗 | |||
/// PLC ---> M550.2 | |||
/// ModbusTcp --> 1572 | |||
/// </summary> | |||
[Alarm("供碗1缺碗")] | |||
public bool Supply1_LossBowl { get; set; } | |||
/// <summary> | |||
/// 供碗2缺碗 | |||
/// PLC ---> M550.3 | |||
/// ModbusTcp --> 1573 | |||
/// </summary> | |||
[Alarm("供碗2缺碗")] | |||
public bool Supply2_LossBowl { get; set; } | |||
/// <summary> | |||
/// 供碗1出碗检测异常 | |||
/// PLC ---> M550.4 | |||
/// ModbusTcp --> 1574 | |||
/// </summary> | |||
[Alarm("供碗1出碗检测异常")] | |||
public bool Supply1_ErrorOutBowl { get; set; } | |||
/// <summary> | |||
/// 供碗2出碗检测异常 | |||
/// PLC ---> M550.5 | |||
/// ModbusTcp --> 1575 | |||
/// </summary> | |||
[Alarm("供碗2出碗检测异常")] | |||
public bool Supply2_ErrorOutBowl { get; set; } | |||
/// <summary> | |||
/// 推碗气缸故障 | |||
/// PLC ---> M550.6 | |||
/// ModbusTcp --> 1576 | |||
/// </summary> | |||
[Alarm("推碗气缸故障")] | |||
public bool PushBowlCylinderError { get; set; } | |||
/// <summary> | |||
/// 煮面机通讯异常 | |||
/// PLC ---> M550.7 | |||
/// ModbusTcp --> 1577 | |||
/// </summary> | |||
[Alarm("煮面机通讯异常")] | |||
public bool NoodleMacCommunicateError { get; set; } | |||
/// <summary> | |||
/// 配料机通讯异常 | |||
/// PLC ---> M551.0 | |||
/// ModbusTcp --> 1580 | |||
/// </summary> | |||
[Alarm("配料机通讯异常")] | |||
public bool DosingMacCommunicateError { get; set; } | |||
/// <summary> | |||
/// 机器人通讯异常 | |||
/// PLC ---> M551.1 | |||
/// ModbusTcp --> 1581 | |||
/// </summary> | |||
[Alarm("机器人通讯异常")] | |||
public bool RobotMacCommunicateError { get; set; } | |||
/// <summary> | |||
/// 机器人初始化失败 | |||
/// PLC ---> M551.3 | |||
/// ModbusTcp --> 1583 | |||
/// </summary> | |||
[Alarm("机器人初始化失败")] | |||
public bool RobotInitError { get; set; } | |||
/// <summary> | |||
/// 机器人急停 | |||
/// PLC ---> M551.4 | |||
/// ModbusTcp --> 1584 | |||
/// </summary> | |||
[Alarm("机器人急停")] | |||
public bool RobotUrgentStop { get; set; } | |||
/// <summary> | |||
/// 机器人不在远程模式 | |||
/// PLC ---> M551.5 | |||
/// ModbusTcp --> 1585 | |||
/// </summary> | |||
[Alarm("机器人不在远程模式")] | |||
public bool RobotNotInRemoteMode { get; set; } | |||
/// <summary> | |||
/// 机器人伺服未就绪 | |||
/// PLC ---> M551.6 | |||
/// ModbusTcp --> 1586 | |||
/// </summary> | |||
[Alarm("机器人伺服未就绪")] | |||
public bool RobotNotInReady { get; set; } | |||
/// <summary> | |||
/// 机器人本体异常 | |||
/// PLC ---> M551.7 | |||
/// ModbusTcp --> 1587 | |||
/// </summary> | |||
[Alarm("机器人本体异常")] | |||
public bool RobotSelfInException { get; set; } | |||
} | |||
} |
@@ -21,8 +21,7 @@ namespace BPASmartClient.MorkS | |||
{ | |||
public override DeviceClientType DeviceType => DeviceClientType.MORKS; | |||
GVL_MORKS mORKS = new GVL_MORKS(); | |||
//int OrderCount; | |||
//bool Initing; | |||
Alarm alarm = new Alarm(); | |||
public override void DoMain() | |||
{ | |||
@@ -114,6 +113,25 @@ namespace BPASmartClient.MorkS | |||
//ThreadManage.GetInstance().StartLong(new Action(() => | |||
//{ | |||
GetStatus("M550.0", new Action<bool[]>((bools) => | |||
{ | |||
alarm.MachineLeftLowTemperature = bools[0]; | |||
alarm.MachineRightLowTemperature = bools[1]; | |||
alarm.Supply1_LossBowl = bools[2]; | |||
alarm.Supply2_LossBowl = bools[3]; | |||
alarm.Supply1_ErrorOutBowl = bools[4]; | |||
alarm.Supply2_ErrorOutBowl = bools[5]; | |||
alarm.PushBowlCylinderError = bools[6]; | |||
alarm.NoodleMacCommunicateError = bools[7]; | |||
alarm.DosingMacCommunicateError = bools[8]; | |||
alarm.RobotMacCommunicateError = bools[9]; | |||
alarm.RobotInitError = bools[11]; | |||
alarm.RobotUrgentStop = bools[12]; | |||
alarm.RobotNotInRemoteMode = bools[13]; | |||
alarm.RobotNotInReady = bools[14]; | |||
alarm.RobotSelfInException = bools[15]; | |||
})); | |||
GetStatus("M0.3", new Action<bool[]>((bools) => | |||
{ | |||
mORKS.RobotTakeNoodle = bools[0]; | |||
@@ -1,6 +1,6 @@ | |||
<?xml version="1.0" encoding="utf-8" ?> | |||
<BPADevices> | |||
<Device Name="MorkT" Module="BPASmartClient.MorkT.Device_MorkT" DeviceId="1"> | |||
<!--<Device Name="MorkT" Module="BPASmartClient.MorkT.Device_MorkT" DeviceId="1"> | |||
<Peripherals> | |||
<Peripheral Module="BPASmartClient.Lebai.LebaiRobot"> | |||
<Parameters> | |||
@@ -17,20 +17,22 @@ | |||
</Parameters> | |||
</Peripheral> | |||
</Peripherals> | |||
</Device> | |||
</Device>--> | |||
<Device Name="MorkF" Module="BPASmartClient.MorkF.Control_MorkF" DeviceId="2"> | |||
<!--<Device Name="MorkF" Module="BPASmartClient.MorkF.Control_MorkF" DeviceId="2"> | |||
<Peripherals> | |||
<Peripheral Module="BPASmartClient.PLC.MorksMachine"> | |||
<Parameters> | |||
<IpAddress>127.0.0.1</IpAddress> | |||
<Port>502</Port> | |||
<!--<PLCReadAddress>M,M0.3,3;M,M100.0,16;M,M235.0,1;M,M102.0,7;M,M103.0,6;VW,VW372,1</PLCReadAddress>--> | |||
--> | |||
<!--<PLCReadAddress>M,M0.3,3;M,M100.0,16;M,M235.0,1;M,M102.0,7;M,M103.0,6;VW,VW372,1</PLCReadAddress>--> | |||
<!-- | |||
<PLCReadAddress>M,M0.1,1;M,M1.0,8;M,M2.0,9;M,M8.0,4;M,M13.5,1;M,M16.0,7;</PLCReadAddress> | |||
</Parameters> | |||
</Peripheral> | |||
</Peripherals> | |||
</Device> | |||
</Device>--> | |||
<Device Name="Morks" Module="BPASmartClient.MorkS.Control" DeviceId="3"> | |||
<Peripherals> | |||
@@ -39,7 +41,7 @@ | |||
<IpAddress>127.0.0.1</IpAddress> | |||
<Port>502</Port> | |||
<!--<PLCReadAddress>M,M0.3,3;M,M100.0,16;M,M235.0,1;M,M102.0,7;M,M103.0,6;VW,VW372,1</PLCReadAddress>--> | |||
<PLCReadAddress>M,M0.1,1;M,M1.0,8;M,M2.0,9;M,M8.0,4;M,M13.5,1;M,M16.0,7;</PLCReadAddress> | |||
<PLCReadAddress>M,M550.0,16;M,M0.1,1;M,M1.0,8;M,M2.0,9;M,M8.0,4;M,M13.5,1;M,M16.0,7;</PLCReadAddress> | |||
</Parameters> | |||
</Peripheral> | |||
</Peripherals> | |||