From 1c4426810c71eead57084be8a18ade8d314dd8c4 Mon Sep 17 00:00:00 2001
From: patrick <patrick.xu@broconcentric.com>
Date: 星期二, 10 十二月 2019 14:24:31 +0800
Subject: [PATCH] 1. 重构项目

---
 src/Bro.Device.AuboRobot/AuboRobotDriver.cs |   33 +++++++++++++++++++++++++--------
 1 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/src/Bro.Device.AuboRobot/AuboRobotDriver.cs b/src/Bro.Device.AuboRobot/AuboRobotDriver.cs
index 02691de..54a3600 100644
--- a/src/Bro.Device.AuboRobot/AuboRobotDriver.cs
+++ b/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
     }
 }

--
Gitblit v1.8.0