From b4ac5ccdb184ab08ddd35edc952e3ec0474c8c50 Mon Sep 17 00:00:00 2001
From: xcd <834800634@qq.com>
Date: 星期四, 02 七月 2020 11:32:53 +0800
Subject: [PATCH] 修改运动/板卡接口返回值类型

---
 src/Bro.Common.Device/Interface/IMotion.cs    |    5 +-
 src/Bro.M071.Process/M071Process.cs           |    9 ++--
 src/Bro.M071.Process/M071Models.cs            |    2 
 src/Bro.Common.Model/Model/ResponseMessage.cs |   49 ++++++------------------
 src/Bro.Common.Device/DeviceBase/PLCBase.cs   |    2 
 5 files changed, 23 insertions(+), 44 deletions(-)

diff --git a/src/Bro.Common.Device/DeviceBase/PLCBase.cs b/src/Bro.Common.Device/DeviceBase/PLCBase.cs
index fca8154..0c44685 100644
--- a/src/Bro.Common.Device/DeviceBase/PLCBase.cs
+++ b/src/Bro.Common.Device/DeviceBase/PLCBase.cs
@@ -281,7 +281,7 @@
             return locations;
         }
 
-        public bool MoveToPoint(IOperationConfig opConfig)
+        public ResponseMessage MoveToPoint(IOperationConfig opConfig)
         {
             throw new NotImplementedException();
         }
diff --git a/src/Bro.Common.Device/Interface/IMotion.cs b/src/Bro.Common.Device/Interface/IMotion.cs
index cf4415f..272a71a 100644
--- a/src/Bro.Common.Device/Interface/IMotion.cs
+++ b/src/Bro.Common.Device/Interface/IMotion.cs
@@ -1,5 +1,6 @@
 锘縰sing Bro.Common.Helper;
 using Bro.Common.Interface;
+using Bro.Common.Model;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -20,7 +21,7 @@
         /// </summary>
         /// <param name="opConfig">杩愬姩閰嶇疆</param>
         /// <returns>true锛氭甯哥粨鏉� false锛氬紓甯哥粨鏉�</returns>
-        bool MoveToPoint(IOperationConfig opConfig);
+        ResponseMessage MoveToPoint(IOperationConfig opConfig);
     }
 
     /// <summary>
@@ -33,7 +34,7 @@
         /// </summary>
         /// <param name="config"></param>
         /// <returns></returns>
-        bool Run(IOperationConfig config);
+        ResponseMessage Run(IOperationConfig config);
     }
 
     public class AxisInfo : IComplexDisplay
diff --git a/src/Bro.Common.Model/Model/ResponseMessage.cs b/src/Bro.Common.Model/Model/ResponseMessage.cs
index 61d5ffe..3f13f70 100644
--- a/src/Bro.Common.Model/Model/ResponseMessage.cs
+++ b/src/Bro.Common.Model/Model/ResponseMessage.cs
@@ -11,55 +11,32 @@
 
         public bool Result { get; set; } = true;
 
-        public Info Info { get; set; } = new Info();
+        public string Message { get; set; }
 
         public string DataJson { get; set; }
 
         public void GetMessageFromException(Exception ex)
         {
-            //if (ex is ICustomizdException)
-            //{
-            //    ICustomizdException ie = ex as ICustomizdException;
-            //    Code = (int)ie.Level;
-            //    Info = ie.Info;
-            //}
-            //else if (ex is DbEntityValidationException)
-            //{
-            //    DbEntityValidationException deve = ex as DbEntityValidationException;
-            //    Code = 9992;
-            //    deve.EntityValidationErrors.ToList().ForEach(error =>
-            //    {
-            //        DbEntityValidationResult temp = error as DbEntityValidationResult;
-            //        temp.ValidationErrors.ToList().ForEach(err =>
-            //        {
-            //            Info.Title += (err.ErrorMessage + ";");
-            //        });
-            //    });
-
-            //    Info.Title.TrimEnd(';');
-            //    Info.Detail = ex.GetExceptionMessage();
-            //}
-            //else
             {
                 Code = 9999;
-                Info = new Info("绯荤粺鏈鐞嗗紓甯革紝璇疯仈绯荤鐞嗗憳", ex.GetExceptionMessage());
+                Message = ex.GetExceptionMessage();
             }
 
             Result = false;
         }
     }
 
-    public class Info
-    {
-        public Info() { }
+    //public class Info
+    //{
+    //    public Info() { }
 
-        public Info(string _title, string _detail = "")
-        {
-            Title = _title;
-            Detail = _detail;
-        }
-        public string Title { get; set; }
+    //    public Info(string _title, string _detail = "")
+    //    {
+    //        Title = _title;
+    //        Detail = _detail;
+    //    }
+    //    public string Title { get; set; }
 
-        public string Detail { get; set; }
-    }
+    //    public string Detail { get; set; }
+    //}
 }
diff --git a/src/Bro.M071.Process/M071Models.cs b/src/Bro.M071.Process/M071Models.cs
index 4789b6e..8c15fde 100644
--- a/src/Bro.M071.Process/M071Models.cs
+++ b/src/Bro.M071.Process/M071Models.cs
@@ -75,7 +75,7 @@
     {
         public string GetDisplayText()
         {
-            return (IsEnabled ? "" : "绂佺敤 ") + Name + " " + string.Join(" ", Destination.Select(u => u.GetDisplayText())) + " " + CameraOp.GetDisplayText();
+            return (IsEnabled ? "" : "绂佺敤 ") + Name + " " + MotionOp.GetDisplayText() + " " + CameraOp.GetDisplayText();
         }
 
         public List<string> GetHalconToolPathList()
diff --git a/src/Bro.M071.Process/M071Process.cs b/src/Bro.M071.Process/M071Process.cs
index 61f3aee..dfab5fa 100644
--- a/src/Bro.M071.Process/M071Process.cs
+++ b/src/Bro.M071.Process/M071Process.cs
@@ -201,18 +201,19 @@
                   {
                       _pauseHandle.WaitHandle.WaitOne();
 
-                      IDevice device = DeviceCollection.FirstOrDefault(u => u.Id == s.MotionDevice);
+                      IDevice device = DeviceCollection.FirstOrDefault(u => u.Id == s.MotionOp.Device);
                       if (device == null)
                           throw new ProcessException($"{s.Name}鎷嶇収鐐逛綅鏈缃繍鍔ㄨ澶�");
 
-                      IMotion motionDevice = device as IMotion;
+                      IMotionCard motionDevice = device as IMotionCard;
 
                       if (motionDevice == null)
                           throw new ProcessException($"{s.Name}鎷嶇収鐐逛綅璁剧疆{device.Name}涓嶆槸杩愬姩璁惧");
 
-                      if (!motionDevice.MoveToPoint(null))
+                      var response = motionDevice.Run(s.MotionOp.OpConfig);
+                      if (!response.Result)
                       {
-                          throw new ProcessException("杩愬姩涓", null, ExceptionLevel.Info);
+                          throw new ProcessException($"{device.Name}寮傚父锛寋response.Message}", null, ExceptionLevel.Info);
                       }
 
                       CameraBase camera = DeviceCollection.FirstOrDefault(u => u.Id == s.CameraOp.Device) as CameraBase;

--
Gitblit v1.8.0