diff --git a/BPASmartClient.Device/AlarmAttribute.cs b/BPASmartClient.Device/AlarmAttribute.cs new file mode 100644 index 00000000..3f053bbf --- /dev/null +++ b/BPASmartClient.Device/AlarmAttribute.cs @@ -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; + } + /// + /// 报警信息 + /// + public string AlarmInfo { get; set; } + } +} diff --git a/BPASmartClient.Device/BaseDevice.cs b/BPASmartClient.Device/BaseDevice.cs index aada3f1e..1889ddfc 100644 --- a/BPASmartClient.Device/BaseDevice.cs +++ b/BPASmartClient.Device/BaseDevice.cs @@ -23,6 +23,7 @@ namespace BPASmartClient.Device { } + #region 属性 /// /// 订单物料信息 /// @@ -48,7 +49,14 @@ namespace BPASmartClient.Device /// public string Name { get; set; } + /// + /// 当前订单数量 + /// protected int OrderCount { get; set; } + + /// + /// 设备初始化中 + /// protected bool Initing { get; set; } /// @@ -70,20 +78,27 @@ namespace BPASmartClient.Device /// 设备运行日志 /// public List Log { get; set; } = new List(); + /// /// 设备运行告警与错误 /// public List Error { get; set; } = new List(); + /// + /// 设备变量监控 + /// public List variableMonitors { get; set; } = new List(); - /// /// 外设状态,硬件设备数据 /// protected ConcurrentDictionary peripheralStatus = new ConcurrentDictionary(); + /// + /// 外设设备集合 + /// private List peripherals; + #endregion /// /// 设备过程日志显示 @@ -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 /// 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 }; } diff --git a/BPASmartClient.MorkS/Alarm.cs b/BPASmartClient.MorkS/Alarm.cs new file mode 100644 index 00000000..516afdbb --- /dev/null +++ b/BPASmartClient.MorkS/Alarm.cs @@ -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 + { + /// + /// 煮面机左侧低温报警 + /// PLC ---> M550.0 + /// ModbusTcp --> 1570 + /// + [Alarm("煮面机左侧低温报警")] + public bool MachineLeftLowTemperature { get; set; } + + /// + /// 煮面机左侧低温报警 + /// PLC ---> M550.1 + /// ModbusTcp --> 1571 + /// + [Alarm("煮面机右侧低温报警")] + public bool MachineRightLowTemperature { get; set; } + + /// + /// 供碗1缺碗 + /// PLC ---> M550.2 + /// ModbusTcp --> 1572 + /// + [Alarm("供碗1缺碗")] + public bool Supply1_LossBowl { get; set; } + + /// + /// 供碗2缺碗 + /// PLC ---> M550.3 + /// ModbusTcp --> 1573 + /// + [Alarm("供碗2缺碗")] + public bool Supply2_LossBowl { get; set; } + + /// + /// 供碗1出碗检测异常 + /// PLC ---> M550.4 + /// ModbusTcp --> 1574 + /// + [Alarm("供碗1出碗检测异常")] + public bool Supply1_ErrorOutBowl { get; set; } + + /// + /// 供碗2出碗检测异常 + /// PLC ---> M550.5 + /// ModbusTcp --> 1575 + /// + [Alarm("供碗2出碗检测异常")] + public bool Supply2_ErrorOutBowl { get; set; } + + /// + /// 推碗气缸故障 + /// PLC ---> M550.6 + /// ModbusTcp --> 1576 + /// + [Alarm("推碗气缸故障")] + public bool PushBowlCylinderError { get; set; } + + /// + /// 煮面机通讯异常 + /// PLC ---> M550.7 + /// ModbusTcp --> 1577 + /// + [Alarm("煮面机通讯异常")] + public bool NoodleMacCommunicateError { get; set; } + + /// + /// 配料机通讯异常 + /// PLC ---> M551.0 + /// ModbusTcp --> 1580 + /// + [Alarm("配料机通讯异常")] + public bool DosingMacCommunicateError { get; set; } + + /// + /// 机器人通讯异常 + /// PLC ---> M551.1 + /// ModbusTcp --> 1581 + /// + [Alarm("机器人通讯异常")] + public bool RobotMacCommunicateError { get; set; } + + /// + /// 机器人初始化失败 + /// PLC ---> M551.3 + /// ModbusTcp --> 1583 + /// + [Alarm("机器人初始化失败")] + public bool RobotInitError { get; set; } + + /// + /// 机器人急停 + /// PLC ---> M551.4 + /// ModbusTcp --> 1584 + /// + [Alarm("机器人急停")] + public bool RobotUrgentStop { get; set; } + + /// + /// 机器人不在远程模式 + /// PLC ---> M551.5 + /// ModbusTcp --> 1585 + /// + [Alarm("机器人不在远程模式")] + public bool RobotNotInRemoteMode { get; set; } + + /// + /// 机器人伺服未就绪 + /// PLC ---> M551.6 + /// ModbusTcp --> 1586 + /// + [Alarm("机器人伺服未就绪")] + public bool RobotNotInReady { get; set; } + + /// + /// 机器人本体异常 + /// PLC ---> M551.7 + /// ModbusTcp --> 1587 + /// + [Alarm("机器人本体异常")] + public bool RobotSelfInException { get; set; } + } +} diff --git a/BPASmartClient.MorkS/Control.cs b/BPASmartClient.MorkS/Control.cs index b57bfb64..427376e6 100644 --- a/BPASmartClient.MorkS/Control.cs +++ b/BPASmartClient.MorkS/Control.cs @@ -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((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((bools) => { mORKS.RobotTakeNoodle = bools[0]; diff --git a/BPASmartClient/DeviceInfo.xml b/BPASmartClient/DeviceInfo.xml index 8995c22d..789d3139 100644 --- a/BPASmartClient/DeviceInfo.xml +++ b/BPASmartClient/DeviceInfo.xml @@ -1,6 +1,6 @@  - + - + + --> + + @@ -39,7 +41,7 @@ 127.0.0.1 502 - M,M0.1,1;M,M1.0,8;M,M2.0,9;M,M8.0,4;M,M13.5,1;M,M16.0,7; + 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;