patrick
2019-12-10 1c4426810c71eead57084be8a18ade8d314dd8c4
src/Bro.Device.AuboRobot/AuboRobotDriver.cs
@@ -67,14 +67,13 @@
            //Query Robot IOs
            //SendMsg(RobotMsgType.Send, 0, true, RobotMsgAction.IO, RobotMsgParas.Query, new List<string>());
            //scanMsg = new RobotMsg();
            //scanMsg.Action = RobotMsgAction.IO;
            //scanMsg.Para1 = RobotMsgParas.Query;
            scanMsg = new RobotMsg();
            scanMsg.Action = RobotMsgAction.IOQuery;
            //Task.Run(() =>
            //{
            //    Monitor();
            //});
            Task.Run(() =>
            {
                Monitor();
            });
        }
        protected override void Stop()
@@ -309,7 +308,7 @@
                    if (errorCode != 0)
                    {
                        var desc = IConfig.RobotWarnings.FirstOrDefault(u => u.WarningCode == errorCode);
                        var desc = IConfig.RobotReplyWarnings.FirstOrDefault(u => u.WarningCode == errorCode);
                        throw new ProcessException($"{Name}{msg.ID}任务反馈异常{errorCode},异常描述:{(desc == null ? "无" : desc.WarningDescription)}");
                    }
@@ -508,6 +507,19 @@
        protected virtual void MonitorCheckAndInvoke(List<int> tempNew, List<int> tempOld)
        {
            IConfig.WarningSetCollection.ForEach(w =>
            {
                if (w.WarningIndex_Word < 0 || w.WarningIndex_Word >= tempNew.Count)
                    return;
                bool isOn = tempNew[w.WarningIndex_Word] == 1;
                if (w.CurrentStatus != isOn)
                {
                    w.CurrentStatus = isOn;
                    OnMonitorAlarm?.BeginInvoke(DateTime.Now, this, w, null, null);
                }
            });
            IConfig.MonitorSetCollection.ForEach(m =>
            {
                if (m.TriggerIndex < 0 || m.TriggerIndex >= tempNew.Count)
@@ -537,6 +549,11 @@
                }
            });
        }
        public virtual void ResetAlarm()
        {
            IConfig.WarningSetCollection.ForEach(u => u.CurrentStatus = !u.TriggerValue);
        }
        #endregion
    }
}