From 6428fad15dbe79e30a48ffc9aabe31e03a45426c Mon Sep 17 00:00:00 2001
From: patrick <patrick.xu@broconcentric.com>
Date: 星期四, 05 十二月 2019 12:50:13 +0800
Subject: [PATCH] 1. 添加部分log信息 2. 修改部分机器人动作流程 3. 开放OperationConfig的InputData参数

---
 src/Bro.Device.AuboRobot/AuboRobotConfig.cs |  107 +++++++++++++++++++++++++++++++----------------------
 1 files changed, 63 insertions(+), 44 deletions(-)

diff --git a/src/Bro.Device.AuboRobot/AuboRobotConfig.cs b/src/Bro.Device.AuboRobot/AuboRobotConfig.cs
index 190ee8b..8c70b49 100644
--- a/src/Bro.Device.AuboRobot/AuboRobotConfig.cs
+++ b/src/Bro.Device.AuboRobot/AuboRobotConfig.cs
@@ -1,8 +1,11 @@
 锘縰sing Bro.Common.Base;
 using Bro.Common.Helper;
+using Bro.Common.Model;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
+using System.Drawing.Design;
+using System.Linq;
 
 namespace Bro.Device.AuboRobot
 {
@@ -28,6 +31,16 @@
         [Category("閫氫俊璁剧疆")]
         [Description("鍗忚鍐呭鍒嗛殧瀛楃")]
         public string Seperator { get; set; } = ",";
+
+        [Category("IO鐩戝惉璁剧疆")]
+        [Description("IO鐩戝惉鎿嶄綔閰嶇疆闆嗗悎")]
+        [TypeConverter(typeof(CollectionCountConvert))]
+        [Editor(typeof(ComplexCollectionEditor<MonitorSet>), typeof(UITypeEditor))]
+        public List<MonitorSet> MonitorSetCollection { get; set; } = new List<MonitorSet>();
+
+        [Category("IO鐩戝惉璁剧疆")]
+        [Description("IO鐩戝惉闂撮殧锛屼互ms涓哄崟浣�")]
+        public int ScanInterval { get; set; } = 100;
     }
 
     [Device("AuboRobot", "濂ュ崥鏈哄櫒浜�", EnumHelper.DeviceAttributeType.OperationConfig)]
@@ -45,22 +58,44 @@
 
         public RobotMsgParas Para1 { get; set; } = RobotMsgParas.None;
 
-        public List<string> Paras { get; set; } = new List<string>();
+        public int Para2 { get; set; } = 0;
+
+        /// <summary>
+        /// Paras涓嶅寘鍚玃ara1,Para2鍐呭
+        /// </summary>
+        public List<string> Datas { get; set; } = new List<string>();
 
         public byte[] GetMsgBytes(string seperator, string endChar)
         {
-            List<string> list = new List<string>() { Type.ToString(), ID.ToString() };
+            List<string> list = new List<string>() { ((int)Type).ToString("D2"), ID.ToString("D2") };
 
             if (Type == RobotMsgType.Send)
             {
-                list.Add(Action.ToString());
+                list.Add(((int)Action).ToString("D2"));
 
-                if (Para1 != RobotMsgParas.None)
+                list.Add(((int)Para1).ToString("D2"));
+                list.Add(Para2.ToString("D2"));
+
+                if (Datas == null)
                 {
-                    list.Add(Para1.ToString());
+                    Datas = new List<string>();
                 }
 
-                list.AddRange(Paras);
+                while (Datas.Count < 5)
+                {
+                    Datas.Add("0");
+                }
+
+                list.AddRange(Datas.ConvertAll(s =>
+                {
+                    string res = float.Parse(s).ToString("F7");
+
+                    while (res.Length < 11)
+                    {
+                        res = "0" + res;
+                    }
+                    return res;
+                }));
             }
 
             string msg = string.Join(seperator, list);
@@ -74,31 +109,17 @@
 
             RobotMsg msg = new RobotMsg();
 
-            msg.Type = (RobotMsgType)Enum.Parse(typeof(RobotMsgType), datas[0]);
+            msg.Type = (RobotMsgType)int.Parse(datas[0]);
             msg.ID = int.Parse(datas[1]);
 
             if (msg.Type == RobotMsgType.Send)
             {
-                msg.Action = (RobotMsgAction)Enum.Parse(typeof(RobotMsgAction), datas[2]);
+                msg.Action = (RobotMsgAction)int.Parse(datas[2]);
 
-                if (int.TryParse(datas[3], out int para1))
-                {
-                    msg.Para1 = RobotMsgParas.None;
+                msg.Para1 = (RobotMsgParas)int.Parse(datas[3]);
+                msg.Para2 = int.Parse(datas[4]);
 
-                    for (int i = 3; i < datas.Length; i++)
-                    {
-                        msg.Paras.Add(datas[i]);
-                    }
-                }
-                else
-                {
-                    msg.Para1 = (RobotMsgParas)Enum.Parse(typeof(RobotMsgParas), datas[3]);
-
-                    for (int i = 4; i < datas.Length; i++)
-                    {
-                        msg.Paras.Add(datas[i]);
-                    }
-                }
+                msg.Datas = datas.Skip(5).ToList();
             }
 
             return msg;
@@ -106,38 +127,36 @@
 
         public string GetDisplayText()
         {
-            string msg = $"搴忓彿锛歿ID},{Action.ToString()}_{Para1.ToString()}{(Paras.Count > 0 ? ("_" + string.Join(",", Paras)) : "")}";
+            string msg = $"搴忓彿锛歿ID},{Action.ToString()}_{Para1.ToString()}_{Para2.ToString()}_{(Datas.Count > 0 ? ("_" + string.Join(",", Datas)) : "")}";
             return msg;
         }
     }
 
     public enum RobotMsgType
     {
-        Send,
-        Rec
+        Send = 1,
+        Rec = 2,
     }
 
     public enum RobotMsgAction
     {
-        Move,
-        State,
-        Adjust,
-        IO,
+        Move = 1,
+        Unload = 2,
+        Load = 3,
+        IO = 6,
+        Calibration = 9,
+        StandardPoint = 10,
     }
 
     public enum RobotMsgParas
     {
-        None,
-        LineSnap,
-        Line,
-        Robot,
-        LoadEmptyTraySnap,
-        LoadEmptyTrayDone,
-        LoadFullTraySnap,
-        LoadFullTrayDone,
-        EmptyTrayReady,
-        EmptyTrayEmpty,
-        FullTrayFull,
-        Query,
+        None = 0,
+        Home = 1,
+        LineSnap = 2,
+        EmptyTray = 3,
+        FullTray = 4,
+        UnloadEmptyTraySnap = 5,
+        LoadFullTraySnap = 6,
+        Query = 7,
     }
 }

--
Gitblit v1.8.0