From df455987cd863eb5531c34533d63ed8f4f15230c Mon Sep 17 00:00:00 2001
From: wells.liu <wells.liu@broconcentric.com>
Date: 星期四, 02 七月 2020 20:54:58 +0800
Subject: [PATCH] Merge branch 'master' of http://gitblit.broconcentric.com:8088/r/M071

---
 src/Bro.Common.Device/DeviceBase/MotionCardBase.cs |   77 +++++++++++++++++++++++++++++++++++---
 1 files changed, 70 insertions(+), 7 deletions(-)

diff --git a/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs b/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs
index 271562e..dce4dcd 100644
--- a/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs
+++ b/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs
@@ -156,7 +156,46 @@
 
         public string GetDisplayText()
         {
-            throw new NotImplementedException();
+            string preCheck = "";
+            PreCheckIOCollection.ForEach(i =>
+            {
+                preCheck += i.GetDisplayText() + " ";
+            });
+            if (preCheck != "")
+            {
+                preCheck = " 棰勬锛�" + preCheck;
+            }
+
+            string output = "";
+            IOOutputCollection.ForEach(i =>
+            {
+                output += i.GetDisplayText() + " ";
+            });
+            if (output != "")
+            {
+                output = " 杈撳嚭锛�" + output;
+            }
+            string confirm = "";
+            IOConfirmCollection.ForEach(i =>
+            {
+                confirm += i.GetDisplayText() + " ";
+            }); 
+            if (confirm != "")
+            {
+                confirm = " 纭锛�" + confirm;
+            }
+
+            string moving = "";
+            MovingOps.ForEach(i =>
+            {
+                moving += i.GetDisplayText() + " ";
+            });
+            if (moving != "")
+            {
+                moving = " 杩愬姩锛�" + moving;
+            }
+
+            return (preCheck + output + confirm + moving).Trim();
         }
     }
 
@@ -180,10 +219,31 @@
             return form;
         }
 
-        //protected override object CreateInstance(Type itemType)
-        //{
-        //    return base.CreateInstance(itemType);
-        //}
+        protected override object CreateInstance(Type itemType)
+        {
+            if (itemType == typeof(IORefrenceItem))
+            {
+                IORefrenceItem item = new IORefrenceItem();
+                if ((this.Context.Instance is IOperationConfig opConfig) && !string.IsNullOrWhiteSpace(opConfig.DeviceId))
+                {
+                    using (var scope = GlobalVar.Container.BeginLifetimeScope())
+                    {
+                        List<IDevice> deviceList = scope.Resolve<List<IDevice>>();
+
+                        var device = deviceList.FirstOrDefault(u => u.Id == opConfig.DeviceId);
+
+                        if (device != null && (device is MotionCardBase motionCard))
+                        {
+                            item.IOItemSource = (motionCard.InitialConfig as MotionCardInitialConfigBase).IODefinitionCollection;
+                        }
+                    }
+                }
+
+                return item;
+            }
+
+            return base.CreateInstance(itemType);
+        }
 
         //protected override object[] GetItems(object editValue)
         //{
@@ -217,9 +277,12 @@
 
                     if (device is MotionCardBase motionCard)
                     {
-                        if (value is IORefrenceItem item)
+                        if (value is List<IORefrenceItem> items)
                         {
-                            item.IOItemSource = (motionCard.InitialConfig as MotionCardInitialConfigBase).IODefinitionCollection;
+                            items.ForEach(item =>
+                            {
+                                item.IOItemSource = (motionCard.InitialConfig as MotionCardInitialConfigBase).IODefinitionCollection;
+                            });
                         }
                     }
                 }

--
Gitblit v1.8.0