From 1c4426810c71eead57084be8a18ade8d314dd8c4 Mon Sep 17 00:00:00 2001 From: patrick <patrick.xu@broconcentric.com> Date: 星期二, 10 十二月 2019 14:24:31 +0800 Subject: [PATCH] 1. 重构项目 --- src/A032.Config/ConfigFrm.cs | 86 ++++++++++++++++++++++++++----------------- 1 files changed, 52 insertions(+), 34 deletions(-) diff --git a/src/A032.Config/ConfigFrm.cs b/src/A032.Config/ConfigFrm.cs index 29bb85e..f83c982 100644 --- a/src/A032.Config/ConfigFrm.cs +++ b/src/A032.Config/ConfigFrm.cs @@ -22,6 +22,7 @@ using Bro.Common.UI; using Bro.Common.PubSub; using static Bro.Common.Helper.EnumHelper; +using Bro.Device.HikCamera; namespace M065.Config { @@ -41,6 +42,8 @@ { InitialCalibrationMethod(); InitialAllTestMethod(); + + InitialDevices(); } } } @@ -224,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) @@ -264,27 +267,27 @@ private void cboCalibrationMethod_SelectedIndexChanged(object sender, EventArgs e) { - //if (cboCalibrationMethod.SelectedIndex >= 0) - //{ - // string methodCode = cboCalibrationMethod.SelectedValue.ToString(); + if (cboCalibrationMethod.SelectedIndex >= 0) + { + string methodCode = cboCalibrationMethod.SelectedValue.ToString(); - // _calibrationMethod = _calibrationMethodDict[_calibrationMethodDict.Keys.FirstOrDefault(u => u.MethodCode == methodCode)]; + _calibrationMethod = _calibrationMethodDict[_calibrationMethodDict.Keys.FirstOrDefault(u => u.MethodCode == methodCode)]; - // if (Process.StationConfig.ProcessOpConfigDict.Keys.Contains(methodCode)) - // { - // propCalibrationConfig.SelectedObject = Process.StationConfig.ProcessOpConfigDict[methodCode]; - // } - // else - // { - // MessageBox.Show(@"Config of " + methodCode + @" is not found"); - // } - //} + if (Process.StationConfig.ProcessOpConfigDict.Keys.Contains(methodCode)) + { + propCalibrationConfig.SelectedObject = Process.StationConfig.ProcessOpConfigDict[methodCode]; + } + else + { + MessageBox.Show(@"Config of " + methodCode + @" is not found"); + } + } } private void btnStartCalibration_Click(object sender, EventArgs e) { btnStartCalibration.Enabled = false; - + IDevice device = cboCalibDevices.SelectedItem as IDevice; try { IOperationConfig config = propCalibrationConfig.SelectedObject as IOperationConfig; @@ -293,7 +296,7 @@ config.InputPara = null; } - _calibrationMethod.Invoke(Process, new object[] { config }); + _calibrationMethod.Invoke(Process, new object[] { config, device }); } catch (Exception ex) { @@ -313,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).DeviceList; + + 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() { @@ -336,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; @@ -369,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"); @@ -727,5 +740,10 @@ chkContinueMode.Checked = false; } } + + private void button1_Click(object sender, EventArgs e) + { + (Process as ProcessControl).Robot_Monitor_FullTrayFull(new OperationConfigBase() { InputPara = new List<int>() { 1 } }, new HikCameraDriver { Id = "3680EBF8-D9F8-4E14-8B0D-6E53BE3BB96D" }); + } } } -- Gitblit v1.8.0