| | |
| | | { |
| | | InitialCalibrationMethod(); |
| | | InitialAllTestMethod(); |
| | | |
| | | InitialDevices(); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | 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) |
| | |
| | | |
| | | 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; |
| | |
| | | config.InputPara = null; |
| | | } |
| | | |
| | | _calibrationMethod.Invoke(Process, new object[] { config }); |
| | | _calibrationMethod.Invoke(Process, new object[] { config, device }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | #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() |
| | | { |
| | |
| | | |
| | | 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; |
| | |
| | | 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"); |