Exemple #1
0
 private void OnPreheatingDone(object sender, PreheatingDoneEventArgs e)
 {
     if (e.Result)
     {
         if (sender is Form form)
         {
             var keys  = _dicSubForms.Where(kv => kv.Value == form).Select(kv => kv.Key);
             int index = 0;
             for (int i = 0; i < _buttonsOrder.Length; i++)
             {
                 if (_buttonsOrder[i] == keys.FirstOrDefault())
                 {
                     index = i + 1;
                 }
             }
             if (index < _buttonsOrder.Length)
             {
                 Invoke((EventHandler) delegate {
                     _buttonsOrder[index - 1].BackColor = Color.Lime;
                     _buttonsOrder[index].PerformClick();
                 });
             }
             else
             {
                 Close();
             }
         }
     }
 }
        private void BtnDone_Click(object sender, EventArgs e)
        {
            _timer.Enabled = false;
            if (_mainCfg.OilTemp.ErrStd < Convert.ToDouble(lblErrAbs.Text))
            {
                _dicResults[this] = false;
                lblResult.Text    = "失败";
            }
            else
            {
                _dicResults[this] = true;
                lblResult.Text    = "成功";
            }
            double gasTemp    = Convert.ToDouble(lblGasTemp.Text);
            double dieselTemp = Convert.ToDouble(lblDieselTemp.Text);
            double temp       = Math.Max(gasTemp, dieselTemp);
            SaveOilThermometerPreheatSelfCheckParams cmdParams = new SaveOilThermometerPreheatSelfCheckParams {
                ClientID           = _dynoCmd.ClientID,
                OilTemperatureData = Math.Max(gasTemp, dieselTemp).ToString(),
                TempDataIn         = _mainCfg.OilTemp.TempStd.ToString(),
                AbsError           = lblErrAbs.Text,
                ReError            = lblErrRel.Text,
                Result             = lblResult.Text
            };

            if (!_dynoCmd.SaveOilThermometerPreheatSelfCheckCmd(cmdParams, out string errMsg))
            {
                MessageBox.Show("执行保存油温计预热数据命令失败", "执行命令出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            PreheatingDoneEventArgs args = new PreheatingDoneEventArgs {
                Result = _dicResults[this]
            };

            PreheatingDone?.Invoke(this, args);
        }
        private void BtnDone_Click(object sender, EventArgs e)
        {
            _timer.Enabled    = false;
            _dicResults[this] = _bResults[0] && _bResults[1];
            lblResult.Text    = _dicResults[this] ? "成功" : "失败";
            SaveSmokerPreheatSelfCheckDataParams cmdParams = new SaveSmokerPreheatSelfCheckDataParams {
                ClientID           = _dynoCmd.ClientID,
                Smoker70LabelValue = _mainCfg.Smoker.K70Std,
                Smoker70TestValue  = _k70,
                Smoker70Ratio      = _k70Err,
                Smoker50LabelValue = _mainCfg.Smoker.K50Std,
                Smoker50TestValue  = _k50,
                Smoker50Ratio      = _k50Err,
                StartTime          = _startTime,
                EndTime            = DateTime.Now,
                Result             = lblResult.Text
            };

            if (!_dynoCmd.SaveSmokerPreheatSelfCheckDataCmd(cmdParams, out string errMsg))
            {
                MessageBox.Show("执行保存烟度计预热数据命令失败", "执行命令出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            PreheatingDoneEventArgs args = new PreheatingDoneEventArgs {
                Result = _dicResults[this]
            };

            PreheatingDone?.Invoke(this, args);
        }
        private void OnTimer(object source, System.Timers.ElapsedEventArgs e)
        {
            GetDynoPreheatRealTimeDataAckParams ackParams = new GetDynoPreheatRealTimeDataAckParams();

            if (_dynoCmd.GetDynoPreheatRealTimeDataCmd(ref ackParams, out string errMsg) && ackParams != null)
            {
                if (_timer != null && _timer.Enabled)
                {
                    try {
                        Invoke((EventHandler) delegate {
                            if (ackParams.msg != null && ackParams.msg.Length > 0)
                            {
                                lblMsg.Text = ackParams.msg;
                            }
                            lblSpeed.Text = ackParams.speed.ToString("F");
                        });
                    } catch (ObjectDisposedException) {
                        // 关闭窗口后仍有一定几率会进入主UI线程,此时访问界面元素会引发此异常,直接忽略即可
                    }
                    // 指示测功机曾转起来过
                    if (ackParams.speed > 10)
                    {
                        _bCanStop = true;
                    }
                    if (ackParams.dynoPreheat || (ackParams.speed < 0.01 && _bCanStop))
                    {
                        _timer.Enabled    = false;
                        _dicResults[this] = true;
                        try {
                            Invoke((EventHandler) delegate {
                                btnBeamDown.Enabled = false;
                                btnBeamUp.Enabled   = true;
                                btnStart.Enabled    = true;
                                btnStop.Enabled     = false;
                                lblMsg.Text         = "测功机预热成功结束";
                                btnBeamUp.PerformClick();
                            });
                        } catch (ObjectDisposedException) {
                            // 关闭窗口后仍有一定几率会进入主UI线程,此时访问界面元素会引发此异常,直接忽略即可
                        }
                        SaveDynoPreheatDataParams cmdParams = new SaveDynoPreheatDataParams {
                            ClientID  = _dynoCmd.ClientID,
                            StartTime = _startTime,
                            EndTime   = DateTime.Now,
                            Operator  = _mainCfg.Name
                        };
                        if (!_dynoCmd.SaveDynoPreheatDataCmd(cmdParams, out errMsg))
                        {
                            MessageBox.Show("执行保存测功机预热数据命令失败", "执行命令出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        PreheatingDoneEventArgs args = new PreheatingDoneEventArgs {
                            Result = _dicResults[this]
                        };
                        PreheatingDone?.Invoke(this, args);
                    }
                }
            }
        }
Exemple #5
0
        private void OnTimer(object source, System.Timers.ElapsedEventArgs e)
        {
            GetTachometerCheckRealTimeDataAckParams ackParams = new GetTachometerCheckRealTimeDataAckParams();

            if (_dynoCmd.GetTachometerCheckRealTimeDataCmd(ref ackParams, out string errMsg) && ackParams != null)
            {
                if (_timer != null && _timer.Enabled)
                {
                    try {
                        Invoke((EventHandler) delegate {
                            lblGasRPM.Text    = ackParams.RPM.ToString();
                            lblDieselRPM.Text = ackParams.CYRPM.ToString();
                        });
                    } catch (ObjectDisposedException) {
                        // 关闭窗口后仍有一定几率会进入主UI线程,此时访问界面元素会引发此异常,直接忽略即可
                    }
                    if (ackParams.RPM > 0 || ackParams.CYRPM > 0)
                    {
                        if (++_counter >= OK_COUNTER)
                        {
                            _timer.Enabled    = false;
                            _dicResults[this] = true;
                            try {
                                Invoke((EventHandler) delegate {
                                    lblMsg.Text       = "转速计预热成功";
                                    lblGasRPM.Text    = "--";
                                    lblDieselRPM.Text = "--";
                                    lblResult.Text    = _dicResults[this] ? "成功" : "失败";
                                });
                            } catch (ObjectDisposedException) {
                                // 关闭窗口后仍有一定几率会进入主UI线程,此时访问界面元素会引发此异常,直接忽略即可
                            }
                            SaveTachometerCheckParams cmdParams = new SaveTachometerCheckParams {
                                ClientID  = _dynoCmd.ClientID,
                                StartTime = _startTime,
                                EndTime   = DateTime.Now,
                                IdleSpeed = ackParams.RPM > ackParams.CYRPM ? ackParams.RPM : ackParams.CYRPM,
                                CommCheck = _bCommResult ? "1" : "2",
                                Result    = lblResult.Text
                            };
                            if (!_dynoCmd.SaveTachometerCheckCmd(cmdParams, out errMsg))
                            {
                                MessageBox.Show("执行保存转速计预热数据命令失败", "执行命令出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            PreheatingDoneEventArgs args = new PreheatingDoneEventArgs {
                                Result = _dicResults[this]
                            };
                            PreheatingDone?.Invoke(this, args);
                        }
                    }
                }
            }
        private void OnTimer(object source, System.Timers.ElapsedEventArgs e)
        {
            GetFlowmeterCheckRealTimeDataAckParams ackParams = new GetFlowmeterCheckRealTimeDataAckParams();

            if (_dynoCmd.GetFlowmeterCheckRealTimeDataCmd(false, ref ackParams, out string errMsg) && ackParams != null)
            {
                if (_timer != null && _timer.Enabled)
                {
                    try {
                        Invoke((EventHandler) delegate {
                            if (ackParams.msg != null && ackParams.msg.Length > 0)
                            {
                                lblMsg.Text = ackParams.msg;
                            }
                            lblFlow.Text        = ackParams.Flow.ToString("F");
                            lblDiluteO2.Text    = ackParams.Temperature.ToString("F");
                            lblTemperature.Text = ackParams.Pressure.ToString("F");
                            lblPressure.Text    = ackParams.DiluteO2.ToString("F");
                            if (ackParams.FlowCheckResult != null && ackParams.FlowCheckResult.Length > 0)
                            {
                                lblFlowCheck.Text = ackParams.FlowCheckResult;
                            }
                            if (ackParams.O2SpanCheckResult != null && ackParams.O2SpanCheckResult.Length > 0)
                            {
                                lblO2SpanCheck.Text = ackParams.O2SpanCheckResult;
                            }
                            if (ackParams.TempeCheckResult != null && ackParams.TempeCheckResult.Length > 0)
                            {
                                lblTempeCheck.Text = ackParams.TempeCheckResult;
                            }
                            if (ackParams.PressureCheckResult != null && ackParams.PressureCheckResult.Length > 0)
                            {
                                lblPressureCheck.Text = ackParams.PressureCheckResult;
                            }
                            if (ackParams.FlowmeterCheckResult != null && ackParams.FlowmeterCheckResult.Length > 0)
                            {
                                lblResult.Text = ackParams.FlowmeterCheckResult;
                            }
                        });
                    } catch (ObjectDisposedException) {
                        // 关闭窗口后仍有一定几率会进入主UI线程,此时访问界面元素会引发此异常,直接忽略即可
                    }
                    switch (_step)
                    {
                    case 0:
                        DoStep(ref ackParams);
                        break;

                    case 1:
                        DoStep(ref ackParams);
                        break;

                    case 2:
                        DoStep(ref ackParams);
                        break;

                    case 3:
                        DoStep(ref ackParams);
                        break;
                    }
                    foreach (int item in _iResults)
                    {
                        if (item < 0)
                        {
                            _timer.Enabled = false;
                            try {
                                Invoke((EventHandler) delegate {
                                    lblMsg.Text         = "流量计预热失败!";
                                    lblFlow.Text        = "--";
                                    lblDiluteO2.Text    = "--";
                                    lblTemperature.Text = "--";
                                    lblPressure.Text    = "--";
                                });
                            } catch (ObjectDisposedException) {
                                // 关闭窗口后仍有一定几率会进入主UI线程,此时访问界面元素会引发此异常,直接忽略即可
                            }
                            break;
                        }
                    }
                    int iResult = 0;
                    if (_step > 3)
                    {
                        foreach (int item in _iResults)
                        {
                            iResult += item;
                        }
                        if (iResult >= 4 && ackParams.FlowmeterCheckResult == "成功")
                        {
                            _timer.Enabled    = false;
                            _dicResults[this] = true;
                            try {
                                Invoke((EventHandler) delegate {
                                    lblMsg.Text         = "流量计预热成功";
                                    lblFlow.Text        = "--";
                                    lblDiluteO2.Text    = "--";
                                    lblTemperature.Text = "--";
                                    lblPressure.Text    = "--";
                                });
                            } catch (ObjectDisposedException) {
                                // 关闭窗口后仍有一定几率会进入主UI线程,此时访问界面元素会引发此异常,直接忽略即可
                            }
                            PreheatingDoneEventArgs args = new PreheatingDoneEventArgs {
                                Result = _dicResults[this]
                            };
                            PreheatingDone?.Invoke(this, args);
                        }
                    }
                }
            }
        }