示例#1
0
 /// <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));
     }
 }
示例#2
0
        /// <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);
        }
示例#3
0
        public static AlarmEvent Create(IAlarmSenderable sender, AlarmInfo info)
        {
            AlarmEvent alarmEvent = new AlarmEvent()
            {
                Sender = sender,
                Info   = info
            };

            return(alarmEvent);
        }
示例#4
0
 /// <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);
     }
 }
示例#5
0
        /// <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);
                }
            }
        }
示例#6
0
 /// <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);
             }
         }
     }
 }
示例#7
0
 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);
     }
 }