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");