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/A032.Config/ConfigFrm.cs |   54 +++++++++++++++++++++++++++++++++---------------------
 1 files changed, 33 insertions(+), 21 deletions(-)

diff --git a/src/A032.Config/ConfigFrm.cs b/src/A032.Config/ConfigFrm.cs
index cb7c154..edefec0 100644
--- a/src/A032.Config/ConfigFrm.cs
+++ b/src/A032.Config/ConfigFrm.cs
@@ -42,6 +42,8 @@
                 {
                     InitialCalibrationMethod();
                     InitialAllTestMethod();
+
+                    InitialDevices();
                 }
             }
         }
@@ -225,7 +227,7 @@
 
         private void OnProcessLog(DateTime dt, string prefix, string msg)
         {
-            RecordMsg(dt.ToString("yyyyMMdd HH:mm:ss") + "\r\n" + prefix + "\r\n" + msg + "\r\n");
+            RecordMsg(dt.ToString("yyyyMMdd HH:mm:ss.fff") + "\r\n" + prefix + "\r\n" + (string.IsNullOrWhiteSpace(msg) ? "" : (msg + "\r\n")));
         }
 
         private void btnStopProcess_Click(object sender, EventArgs e)
@@ -285,7 +287,7 @@
         private void btnStartCalibration_Click(object sender, EventArgs e)
         {
             btnStartCalibration.Enabled = false;
-
+            IDevice device = cboCalibDevices.SelectedItem as IDevice;
             try
             {
                 IOperationConfig config = propCalibrationConfig.SelectedObject as IOperationConfig;
@@ -294,7 +296,7 @@
                     config.InputPara = null;
                 }
 
-                _calibrationMethod.Invoke(Process, new object[] { config });
+                _calibrationMethod.Invoke(Process, new object[] { config, device });
             }
             catch (Exception ex)
             {
@@ -314,6 +316,16 @@
         #region Test
         Dictionary<ProcessMethodAttribute, MethodInfo> _allTestMethod = new Dictionary<ProcessMethodAttribute, MethodInfo>();
         MethodInfo _testMethod = null;
+
+        List<IDevice> _deviceList = new List<IDevice>();
+        private void InitialDevices()
+        {
+            _deviceList = (Process as ProcessControl).GetDeviceList();
+
+            List<ISimpleDevice> list = _deviceList.Select(u => u as ISimpleDevice).ToList();
+            UIHelper.SetCombo(cboCalibDevices, list, "Name", "Id");
+            UIHelper.SetCombo(cboDevices, list, "Name", "Id");
+        }
 
         private void InitialAllTestMethod()
         {
@@ -337,28 +349,29 @@
 
         private void cboTestMethod_SelectedIndexChanged(object sender, EventArgs e)
         {
-            //if (cboTestMethod.SelectedIndex >= 0)
-            //{
-            //    string methodCode = cboTestMethod.SelectedValue.ToString();
-            //    var attr = _allTestMethod.Keys.FirstOrDefault(u => u.MethodCode == methodCode);
-            //    if (attr == null)
-            //        return;
+            if (cboTestMethod.SelectedIndex >= 0)
+            {
+                string methodCode = cboTestMethod.SelectedValue.ToString();
+                var attr = _allTestMethod.Keys.FirstOrDefault(u => u.MethodCode == methodCode);
+                if (attr == null)
+                    return;
 
-            //    _testMethod = _allTestMethod[attr];
+                _testMethod = _allTestMethod[attr];
 
-            //    if (Process.StationConfig.ProcessOpConfigDict.Keys.Contains(methodCode))
-            //    {
-            //        propGridTestMethod.SelectedObject = Process.StationConfig.ProcessOpConfigDict[methodCode];
-            //    }
-            //    else
-            //    {
-            //        MessageBox.Show(@"Config of " + methodCode + @" is not found");
-            //    }
-            //}
+                if (Process.StationConfig.ProcessOpConfigDict.Keys.Contains(methodCode))
+                {
+                    propGridTestMethod.SelectedObject = Process.StationConfig.ProcessOpConfigDict[methodCode];
+                }
+                else
+                {
+                    MessageBox.Show(@"Config of " + methodCode + @" is not found");
+                }
+            }
         }
 
         private void btnManualTrigger_Click(object sender, EventArgs e)
         {
+            IDevice device = cboDevices.SelectedItem as IDevice;
             new Task((m) =>
             {
                 MethodInfo method = m as MethodInfo;
@@ -370,14 +383,13 @@
                     invokeTimes = 1;
                 }
                 ProcessResponse response = null;
-
                 if (invokeTimes == 1)
                 {
                     try
                     {
                         Stopwatch sw = new Stopwatch();
                         sw.Start();
-                        response = method.Invoke(Process, new object[] { propGridTestMethod.SelectedObject as IOperationConfig }) as ProcessResponse;
+                        response = method.Invoke(Process, new object[] { propGridTestMethod.SelectedObject as IOperationConfig, device }) as ProcessResponse;
                         sw.Stop();
 
                         //RecordMsg($"{method.Name}璋冪敤鑰楁椂锛歿sw.ElapsedMilliseconds}ms");

--
Gitblit v1.8.0