/// <summary> /// 丢出报警,生产完当前板再做处理 /// </summary> /// <param name="sender"></param> /// <param name="info"></param> private void FireAndDelayHandle(IAlarmSenderable sender, AlarmInfo info) { if (this.delayAlarmDic.TryAdd(info.DateTime, info)) { this.alarmEventQueue.Enqueue(AlarmEvent.Create(sender, info)); } }
/// <summary> /// 丢出报警,立即处理 /// </summary> /// <param name="sender"></param> /// <param name="info"></param> private DialogResult?FireAndShowMsgBox(IAlarmSenderable sender, AlarmInfo info, Dictionary <DialogResult, Action> dic) { //记录报警 this.alarmEventQueue.Enqueue(AlarmEvent.Create(sender, info)); if (!this.MachineInitDone) { return(DialogResult.Cancel); } this.litghtTower.HandleAlarmEvent(AlarmHandleType.ImmediateHandle); // 处理报警 string senderName = ""; if (sender != null) { senderName = sender.Name; } //DialogResult result = new AlarmForm(dic, new List<string> { string.Format("{0}:{1}", senderName, info.Message)}).ShowDialog(); //IAsyncResult ar = this.OnAlarmFormShown?.BeginInvoke(dic, new List<string> { string.Format("{0}:{1}", senderName, info.Message) }, null, null); //DialogResult? result = this.OnAlarmFormShown?.EndInvoke(ar); immediateAlarmInfo = string.Format("{0}:{1}", senderName, info.Message); DialogResult?result = this.OnAlarmFormShown?.Invoke(dic, new List <string> { string.Format("{0}:{1}", senderName, info.Message) }); immediateAlarmInfo = ""; return(result); }
public static AlarmEvent Create(IAlarmSenderable sender, AlarmInfo info) { AlarmEvent alarmEvent = new AlarmEvent() { Sender = sender, Info = info }; return(alarmEvent); }
/// <summary> /// 丢出需要多种处理的报警 /// </summary> /// <param name="sender"></param> /// <param name="info"></param> /// <param name="dic"></param> public DialogResult?Fire(IAlarmSenderable sender, AlarmInfo info, Dictionary <DialogResult, Action> dic) { if (info.HandleType == AlarmHandleType.ImmediateHandle) { return(this.FireAndShowMsgBox(sender, info, dic)); } else { return(DialogResult.Ignore); } }
/// <summary> /// 消除报警 /// </summary> /// <param name="sender"></param> /// <param name="info"></param> public void RemoveAlarm(IAlarmSenderable sender, AlarmInfo info) { if (this.alarmDic.ContainsKey(string.Format("{0}:{1}", sender.ToString(), info.Message))) { Tuple <IAlarmSenderable, AlarmInfo> tuple; this.alarmDic.TryRemove(string.Format("{0}:{1}", sender.ToString(), info.Message), out tuple); if (info.HandleType == AlarmHandleType.AutoAndImmeDiateHandle) { AlarmInfo alarmInfo; this.AutoImmediateAlarmDic.TryRemove(info.Message, out alarmInfo); } if (info.HandleType == AlarmHandleType.AutoAndDelayHandle) { AlarmInfo alarmInfo; this.AutoDelayAlarmDic.TryRemove(info.Message, out alarmInfo); } } }
/// <summary> /// 丢出可消除的报警(如轴状态、报警信号) /// </summary> /// <param name="sender"></param> /// <param name="info"></param> private void FireAndAutoHandle(IAlarmSenderable sender, AlarmInfo info) { if (this.alarmDic.ContainsKey(string.Format("{0}:{1}", sender.ToString(), info.Message))) { return; } else { if (this.alarmDic.TryAdd(string.Format("{0}:{1}", sender.ToString(), info.Message), new Tuple <IAlarmSenderable, AlarmInfo>(sender, info))) { this.alarmEventQueue.Enqueue(AlarmEvent.Create(sender, info)); if (info.HandleType == AlarmHandleType.AutoAndImmeDiateHandle) { this.AutoImmediateAlarmDic.TryAdd(info.Message, info); } if (info.HandleType == AlarmHandleType.AutoAndDelayHandle) { this.AutoDelayAlarmDic.TryAdd(info.Message, info); } } } }
public void Fire(IAlarmSenderable sender, AlarmInfo info) { if (info.HandleType == AlarmHandleType.OnlyRecord) { this.alarmEventQueue.Enqueue(AlarmEvent.Create(sender, info)); } else if (info.HandleType == AlarmHandleType.DelayHandle) { this.FireAndDelayHandle(sender, info); } else if (info.HandleType == AlarmHandleType.AutoHandle || info.HandleType == AlarmHandleType.AutoAndImmeDiateHandle || info.HandleType == AlarmHandleType.AutoAndDelayHandle) { this.FireAndAutoHandle(sender, info); } else if (info.HandleType == AlarmHandleType.ImmediateHandle) { Dictionary <DialogResult, Action> dic = new Dictionary <DialogResult, Action>(); dic.Add(DialogResult.Ignore, new Action(() => { })); this.FireAndShowMsgBox(sender, info, dic); } }