예제 #1
0
        public TSIForm(string VIN, DynoCmd dynoCmd, MainSetting mainCfg, ModelLocal db, EnvironmentData envData, Logger log)
        {
            InitializeComponent();
            _lastHeight = Height;
            _VIN        = VIN;
            _dynoCmd    = dynoCmd;
            _mainCfg    = mainCfg;
            _db         = db;
            _envData    = envData;
            _log        = log;
            EmissionInfo ei = new EmissionInfo();

            _db.GetEmissionInfoFromVIN(_VIN, ei);
            _RatedRPM = ei.RatedRPM;

            _dtRealTime = new DataTable("TSIRealTime");
            _dtRealTime.Columns.Add("VIN");
            _dtRealTime.Columns.Add("StartTime");
            _dtRealTime.Columns.Add("TimeSN");
            _dtRealTime.Columns.Add("Step");
            _dtRealTime.Columns.Add("RPM");
            _dtRealTime.Columns.Add("CurrentStageTime");
            _dtRealTime.Columns.Add("Lambda");
            _dtRealTime.Columns.Add("OilTemp");
            _dtRealTime.Columns.Add("HResult");
            _dtRealTime.Columns.Add("LResult");

            _resultData = new TSIResultData();

            _timer           = new System.Timers.Timer(_mainCfg.RealtimeInterval);
            _timer.Elapsed  += OnTimer;
            _timer.AutoReset = true;

            f_result = new TSIResultForm();
        }
예제 #2
0
        public SelfcheckForm(DynoCmd dynoCmd, MainSetting mainCfg, List <bool> selfChecks, EnvironmentData envData, bool bDiesel)
        {
            InitializeComponent();
            _lastHeight = Height;
            _dynoCmd    = dynoCmd;
            _dicResults = new Dictionary <Form, bool>();
            _dicStops   = new Dictionary <Form, bool>();
            _envData    = envData;
            _selfChecks = selfChecks;

            f_gasBoxSelfcheck     = new GasBoxSelfcheckSubForm(_dynoCmd, mainCfg, _dicResults, _dicStops, bDiesel);
            f_flowmeterSelfcheck  = new FlowmeterSelfcheckSubForm(_dynoCmd, mainCfg, _dicResults, _dicStops);
            f_smokerSelfcheck     = new SmokerSelfcheckSubForm(_dynoCmd, mainCfg, _dicResults, _dicStops);
            f_oilTempSelfcheck    = new OilTempSelfcheckSubForm(_dynoCmd, mainCfg, _dicResults, _dicStops);
            f_tachometerSelfcheck = new TachometerSelfcheckSubForm(_dynoCmd, mainCfg, _dicResults, _dicStops);
            f_weatherSelfcheck    = new WeatherSelfcheckSubForm(_dynoCmd, mainCfg, _dicResults, _dicStops, _envData);

            f_gasBoxSelfcheck.SelfcheckDone     += OnSelfcheckDone;
            f_flowmeterSelfcheck.SelfcheckDone  += OnSelfcheckDone;
            f_smokerSelfcheck.SelfcheckDone     += OnSelfcheckDone;
            f_oilTempSelfcheck.SelfcheckDone    += OnSelfcheckDone;
            f_tachometerSelfcheck.SelfcheckDone += OnSelfcheckDone;
            f_weatherSelfcheck.SelfcheckDone    += OnSelfcheckDone;

            _dicResults.Add(f_gasBoxSelfcheck, !selfChecks[0]);
            _dicResults.Add(f_flowmeterSelfcheck, !selfChecks[1]);
            _dicResults.Add(f_smokerSelfcheck, !selfChecks[2]);
            _dicResults.Add(f_oilTempSelfcheck, !selfChecks[3]);
            _dicResults.Add(f_tachometerSelfcheck, !selfChecks[4]);
            _dicResults.Add(f_weatherSelfcheck, !selfChecks[5]);

            _dicStops.Add(f_gasBoxSelfcheck, false);
            _dicStops.Add(f_flowmeterSelfcheck, false);
            _dicStops.Add(f_smokerSelfcheck, false);
            _dicStops.Add(f_oilTempSelfcheck, false);
            _dicStops.Add(f_tachometerSelfcheck, false);
            _dicStops.Add(f_weatherSelfcheck, false);

            _buttonsOrder = new Button[] { btn1GasBox, btn2Flowmeter, btn3Smoker, btn4OilTemp, btn5Tachometer, btn6Weather };
            for (int i = 0; i < selfChecks.Count; i++)
            {
                if (_buttonsOrder.Length > i)
                {
                    _buttonsOrder[i].Enabled = selfChecks[i];
                }
            }

            _dicSubForms = new Dictionary <Button, Form> {
                { btn1GasBox, f_gasBoxSelfcheck },
                { btn2Flowmeter, f_flowmeterSelfcheck },
                { btn3Smoker, f_smokerSelfcheck },
                { btn4OilTemp, f_oilTempSelfcheck },
                { btn5Tachometer, f_tachometerSelfcheck },
                { btn6Weather, f_weatherSelfcheck }
            };
        }
예제 #3
0
 public MainForm(Logger log, Config cfg, ModelLocal db, DynoCmd dynoCmd)
 {
     InitializeComponent();
     _lastHeight = Height;
     _log        = log;
     _cfg        = cfg;
     _db         = db;
     _dynoCmd    = dynoCmd;
     _selfChecks = new List <bool>();
 }
 public OilTempPreheatingSubForm(DynoCmd dynoCmd, MainSetting mainCfg, Dictionary <Form, bool> dicResults)
 {
     InitializeComponent();
     _lastHeight      = Height;
     _dynoCmd         = dynoCmd;
     _mainCfg         = mainCfg;
     _dicResults      = dicResults;
     _timer           = new System.Timers.Timer(_mainCfg.RealtimeInterval);
     _timer.Elapsed  += OnTimer;
     _timer.AutoReset = true;
 }
 public FlowmeterSelfcheckSubForm(DynoCmd dynoCmd, MainSetting mainCfg, Dictionary <Form, bool> dicResults, Dictionary <Form, bool> dicStops)
 {
     InitializeComponent();
     _lastHeight      = Height;
     _dynoCmd         = dynoCmd;
     _mainCfg         = mainCfg;
     _dicResults      = dicResults;
     _dicStops        = dicStops;
     _strStep         = new string[] { "清零", "清零结果", "氧量程检查", "流量检查", "准备完成" };
     _timer           = new System.Timers.Timer(_mainCfg.RealtimeInterval);
     _timer.Elapsed  += OnTimer;
     _timer.AutoReset = true;
 }
예제 #6
0
 public GasBoxSelfcheckSubForm(DynoCmd dynoCmd, MainSetting mainCfg, Dictionary <Form, bool> dicResults, Dictionary <Form, bool> dicStops, bool bDiesel)
 {
     InitializeComponent();
     _lastHeight      = Height;
     _dynoCmd         = dynoCmd;
     _mainCfg         = mainCfg;
     _dicResults      = dicResults;
     _dicStops        = dicStops;
     _bDiesel         = bDiesel;
     _timer           = new System.Timers.Timer(_mainCfg.RealtimeInterval);
     _timer.Elapsed  += OnTimer;
     _timer.AutoReset = true;
 }
예제 #7
0
 public WeatherSelfcheckSubForm(DynoCmd dynoCmd, MainSetting mainCfg, Dictionary <Form, bool> dicResults, Dictionary <Form, bool> dicStops, EnvironmentData envData)
 {
     InitializeComponent();
     _lastHeight      = Height;
     _dynoCmd         = dynoCmd;
     _mainCfg         = mainCfg;
     _dicResults      = dicResults;
     _dicStops        = dicStops;
     _envData         = envData;
     _timer           = new System.Timers.Timer(_mainCfg.RealtimeInterval);
     _timer.Elapsed  += OnTimer;
     _timer.AutoReset = true;
 }
예제 #8
0
 public DynoGlideCheckForm(DynoCmd dynoCmd, MainSetting mainCfg, Logger log, bool bDiesel)
 {
     InitializeComponent();
     _lastHeight      = Height;
     _dynoCmd         = dynoCmd;
     _mainCfg         = mainCfg;
     _log             = log;
     _bDiesel         = bDiesel;
     _dtRTData        = new DataTable("RTData");
     _dtResult        = new DataTable("Result");
     _timer           = new System.Timers.Timer(_mainCfg.RealtimeInterval);
     _timer.Elapsed  += OnTimer;
     _timer.AutoReset = true;
     _dieselIHP       = DieselIHP.IHP30kW;
 }
예제 #9
0
 public SmokerPreheatingSubForm(DynoCmd dynoCmd, MainSetting mainCfg, Dictionary <Form, bool> dicResults)
 {
     InitializeComponent();
     _lastHeight      = Height;
     _dynoCmd         = dynoCmd;
     _mainCfg         = mainCfg;
     _dicResults      = dicResults;
     _timer           = new System.Timers.Timer(_mainCfg.RealtimeInterval);
     _timer.Elapsed  += OnTimer;
     _timer.AutoReset = true;
     _k50Err          = 0;
     _k50             = 0;
     _k70Err          = 0;
     _k70             = 0;
     _bResults        = new bool[] { false, false };
 }
예제 #10
0
        public PreheatingForm(DynoCmd dynoCmd, MainSetting mainCfg)
        {
            InitializeComponent();
            _lastHeight            = Height;
            _dynoCmd               = dynoCmd;
            _dicResults            = new Dictionary <Form, bool>();
            f_dynoPreheating       = new DynoPreheatingSubForm(_dynoCmd, mainCfg, _dicResults);
            f_gasBoxPreheating     = new GasBoxPreheatingSubForm(_dynoCmd, mainCfg, _dicResults);
            f_flowmeterPreheating  = new FlowmeterPreheatingSubForm(_dynoCmd, mainCfg, _dicResults);
            f_smokerPreheating     = new SmokerPreheatingSubForm(_dynoCmd, mainCfg, _dicResults);
            f_weatherPreheating    = new WeatherPreheatingSubForm(_dynoCmd, mainCfg, _dicResults);
            f_tachometerPreheating = new TachometerPreheatingSubForm(_dynoCmd, mainCfg, _dicResults);
            f_oilTempPreheating    = new OilTempPreheatingSubForm(_dynoCmd, mainCfg, _dicResults);

            f_dynoPreheating.PreheatingDone       += OnPreheatingDone;
            f_gasBoxPreheating.PreheatingDone     += OnPreheatingDone;
            f_flowmeterPreheating.PreheatingDone  += OnPreheatingDone;
            f_smokerPreheating.PreheatingDone     += OnPreheatingDone;
            f_weatherPreheating.PreheatingDone    += OnPreheatingDone;
            f_tachometerPreheating.PreheatingDone += OnPreheatingDone;
            f_oilTempPreheating.PreheatingDone    += OnPreheatingDone;

            _dicResults.Add(f_dynoPreheating, false);
            _dicResults.Add(f_gasBoxPreheating, false);
            _dicResults.Add(f_flowmeterPreheating, false);
            _dicResults.Add(f_smokerPreheating, false);
            _dicResults.Add(f_weatherPreheating, false);
            _dicResults.Add(f_tachometerPreheating, false);
            _dicResults.Add(f_oilTempPreheating, false);

            _buttonsOrder = new Button[] { btn1Dyno, btn2GasBox, btn3Flowmeter, btn4Smoker, btn5Weather, btn6Tacho, btn7Oil };

            _dicSubForms = new Dictionary <Button, Form> {
                { btn1Dyno, f_dynoPreheating },
                { btn2GasBox, f_gasBoxPreheating },
                { btn3Flowmeter, f_flowmeterPreheating },
                { btn4Smoker, f_smokerPreheating },
                { btn5Weather, f_weatherPreheating },
                { btn6Tacho, f_tachometerPreheating },
                { btn7Oil, f_oilTempPreheating }
            };
        }
예제 #11
0
        public ASMForm(string VIN, DynoCmd dynoCmd, MainSetting mainCfg, ModelLocal db, EnvironmentData envData, Logger log)
        {
            InitializeComponent();
            _lastHeight = Height;
            _VIN        = VIN;
            _dynoCmd    = dynoCmd;
            _mainCfg    = mainCfg;
            _db         = db;
            _envData    = envData;
            _log        = log;

            _dtRealTime = new DataTable("ASMRealTime");
            _dtRealTime.Columns.Add("VIN");
            _dtRealTime.Columns.Add("StartTime");
            _dtRealTime.Columns.Add("TimeSN");
            _dtRealTime.Columns.Add("Step");
            _dtRealTime.Columns.Add("TestTime");
            _dtRealTime.Columns.Add("WorkingTime");
            _dtRealTime.Columns.Add("RPM");
            _dtRealTime.Columns.Add("Speed");
            _dtRealTime.Columns.Add("Power");
            _dtRealTime.Columns.Add("HC");
            _dtRealTime.Columns.Add("CO");
            _dtRealTime.Columns.Add("NO");
            _dtRealTime.Columns.Add("CO2");
            _dtRealTime.Columns.Add("O2");
            _dtRealTime.Columns.Add("lambda");
            _dtRealTime.Columns.Add("KH");
            _dtRealTime.Columns.Add("DF");
            _dtRealTime.Columns.Add("HCNor");
            _dtRealTime.Columns.Add("CONor");
            _dtRealTime.Columns.Add("NONor");

            _resultData = new ASMResultData();

            _timer           = new System.Timers.Timer(_mainCfg.RealtimeInterval);
            _timer.Elapsed  += OnTimer;
            _timer.AutoReset = true;

            f_result = new ASMResultForm();
        }
예제 #12
0
 public VehicleLoginForm(ModelLocal db, DynoCmd dynoCmd, MainSetting mainCfg, Logger log)
 {
     InitializeComponent();
     _lastHeight = Height;
     _db         = db;
     _dynoCmd    = dynoCmd;
     _mainCfg    = mainCfg;
     _log        = log;
     if (_mainCfg.ScannerPort.Length > 0)
     {
         _sp = new SerialPortClass(
             _mainCfg.ScannerPort,
             _mainCfg.ScannerBaud,
             Parity.None,
             8,
             StopBits.One
             );
         try {
             _sp.OpenPort();
             _sp.DataReceived += SerialDataReceived;
         } catch (Exception ex) {
             _log.TraceError("Open serial port error: " + ex.Message);
             MessageBox.Show("打开串口扫码枪出错", "初始化错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     _serialRecvBuf = string.Empty;
     if (_mainCfg.DynoParamIP.Length > 0)
     {
         try {
             _dynoParamRecver = new DynoParamRecv(_mainCfg.DynoParamIP, _mainCfg.DynoParamPort);
             _dynoParamRecver.DynoParamRecvEvent += OnDynoParamRecv;
             _dynoParamRecvFlag = new ManualResetEvent(true);
         } catch (Exception ex) {
             _log.TraceError("Connect to dyno parameter server error: " + ex.Message);
             MessageBox.Show("无法连接到测功机参数服务端软件", "初始化错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     VI     = new VehicleInfo();
     EI     = new EmissionInfo();
     _carID = -1;
 }
예제 #13
0
        public LugdownForm(string VIN, DynoCmd dynoCmd, MainSetting mainCfg, ModelLocal db, EnvironmentData envData, Logger log)
        {
            InitializeComponent();
            _lastHeight = Height;
            _VIN        = VIN;
            _dynoCmd    = dynoCmd;
            _mainCfg    = mainCfg;
            _db         = db;
            _envData    = envData;
            _log        = log;
            EmissionInfo ei = new EmissionInfo();

            _db.GetEmissionInfoFromVIN(_VIN, ei);
            _RatedRPM     = ei.RatedRPM;
            _MaxRPM       = -1;
            _canGetMaxRpm = false;

            _dtRealTime = new DataTable("LugdownRealTime");
            _dtRealTime.Columns.Add("VIN");
            _dtRealTime.Columns.Add("StartTime");
            _dtRealTime.Columns.Add("TimeSN");
            _dtRealTime.Columns.Add("RPM");
            _dtRealTime.Columns.Add("Speed");
            _dtRealTime.Columns.Add("Power");
            _dtRealTime.Columns.Add("Torque");
            _dtRealTime.Columns.Add("K");
            _dtRealTime.Columns.Add("CO2");
            _dtRealTime.Columns.Add("NOx");

            _resultData = new LDResultData();

            _timer           = new System.Timers.Timer(_mainCfg.RealtimeInterval);
            _timer.Elapsed  += OnTimer;
            _timer.AutoReset = true;

            f_result = new LDResultForm();
        }
예제 #14
0
        static void Main()
        {
            System.Threading.Mutex run = new System.Threading.Mutex(true, "Dyno_Geely", out bool runone);
            if (runone)
            {
                run.ReleaseMutex();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Logger     log     = new Logger("Main", ".\\log", EnumLogLevel.LogLevelAll, true, 100);
                Config     cfg     = null;
                ModelLocal db      = null;
                DynoCmd    dynoCmd = null;

                // 显示加载窗口
                LoadingForm frmLoading = new LoadingForm();
                frmLoading.BackgroundWorkAction = () => {
                    try {
                        //设置连接字符串
                        frmLoading.CurrentMsg = new KeyValuePair <int, string>(1, "正在加载配置...");
                        cfg = new Config(log);

                        frmLoading.CurrentMsg = new KeyValuePair <int, string>(20, "正在初始化本地数据库...");
                        db = new ModelLocal(cfg.Main.Data.Native, LibBase.DataBaseType.SQLServer, log);
                        try {
                            db.TestConnect();
                        } catch (Exception ex) {
                            log.TraceError("Can't connect with dyno database: " + ex.Message);
                            MessageBox.Show("无法与本地数据库通讯,请检查设置\n" + ex.Message, "初始化错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        frmLoading.CurrentMsg = new KeyValuePair <int, string>(40, "正在初始化测功机客户端...");
                        dynoCmd = new DynoCmd(cfg);
                        if (!dynoCmd.ConnectServer())
                        {
                            log.TraceError("Can't connect to Dyno server");
                            MessageBox.Show("无法与测功机服务器建立连接,请检查设置", "初始化错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        dynoCmd.SafeClose();

                        frmLoading.CurrentMsg = new KeyValuePair <int, string>(60, "正在登录测功机服务器...");
                        if (!dynoCmd.LoginCmd(out string errMsg))
                        {
                            log.TraceError("Can't login Dyno server");
                            MessageBox.Show("无法登录测功机服务器,请检查设置," + errMsg, "初始化错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        frmLoading.CurrentMsg = new KeyValuePair <int, string>(80, "正在设置测功机服务器配置...");
                        SetDataBaseInitInfoParams cmdParams = new SetDataBaseInitInfoParams()
                        {
                            ClientID     = dynoCmd.ClientID,
                            ServerName   = cfg.Main.Data.Native.IP + "," + cfg.Main.Data.Native.Port,
                            DataBaseName = cfg.Main.Data.Native.DBName,
                            UID          = cfg.Main.Data.Native.UserName,
                            PWD          = cfg.Main.Data.Native.PassWord
                        };
                        bool bChange = false;
                        GetDataBaseInitInfoAckParams ackParams = new GetDataBaseInitInfoAckParams();
                        if (dynoCmd.GetDataBaseInitInfoCmd(ref ackParams, out errMsg))
                        {
                            if (ackParams.ServerName != cmdParams.ServerName)
                            {
                                bChange |= true;
                            }
                            if (ackParams.DataBaseName != cmdParams.DataBaseName)
                            {
                                bChange |= true;
                            }
                            if (ackParams.UID != cmdParams.UID)
                            {
                                bChange |= true;
                            }
                            if (ackParams.PWD != cmdParams.PWD)
                            {
                                bChange |= true;
                            }
                            if (bChange)
                            {
                                if (!dynoCmd.SetDataBaseInitInfoCmd(cmdParams, out errMsg))
                                {
                                    MessageBox.Show("无法获取测功机服务器数据库配置," + errMsg, "初始化错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("无法获取测功机服务器数据库配置," + errMsg, "初始化错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        frmLoading.CurrentMsg = new KeyValuePair <int, string>(100, "初始化完成");
                    } catch (Exception ex) {
                        MessageBox.Show(ex.Message, "初始化错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        log.TraceError("Loading error: " + ex.Message);
                        Application.Exit();
                        Process.GetCurrentProcess().Kill();
                    }
                };
                // 必须在BackgroundWorkAction设置之后调用ShowDialog(),否则无效果
                frmLoading.ShowDialog();

                Application.Run(new MainForm(log, cfg, db, dynoCmd));
            }
            else
            {
                MessageBox.Show("已经有一个相同的程序在运行了!");
            }
        }
예제 #15
0
        public VMASForm(string VIN, DynoCmd dynoCmd, MainSetting mainCfg, ModelLocal db, EnvironmentData envData, Logger log)
        {
            InitializeComponent();
            _lastHeight = Height;
            _VIN        = VIN;
            _dynoCmd    = dynoCmd;
            _mainCfg    = mainCfg;
            _db         = db;
            _envData    = envData;
            _log        = log;
            _rangeScale = 3;
            _speedRange = 3;
            _speedMax   = 0 + _speedRange * _rangeScale;
            _speedMin   = 0 + _speedRange * _rangeScale;
            _speedStart = 0 + _speedRange;
            _speedEnd   = 0 - _speedRange;
            _XPosition  = 0;

            _dtRealTime = new DataTable("VMASRealTime");
            _dtRealTime.Columns.Add("VIN");
            _dtRealTime.Columns.Add("StartTime");
            _dtRealTime.Columns.Add("TimeSN");
            _dtRealTime.Columns.Add("Speed");
            _dtRealTime.Columns.Add("RPM");
            _dtRealTime.Columns.Add("SpeedOverTime");
            _dtRealTime.Columns.Add("Power");
            _dtRealTime.Columns.Add("HC");
            _dtRealTime.Columns.Add("NO");
            _dtRealTime.Columns.Add("CO");
            _dtRealTime.Columns.Add("CO2");
            _dtRealTime.Columns.Add("O2");
            _dtRealTime.Columns.Add("DilutionO2");
            _dtRealTime.Columns.Add("EnvO2");
            _dtRealTime.Columns.Add("DilutionRatio");
            _dtRealTime.Columns.Add("Flow");

            _dtSpeeds = new DataTable();
            _dtSpeeds.Columns.Add(_mainCfg.VMASSpeed.Columns[0].ToString());
            _dtSpeeds.Columns.Add(_mainCfg.VMASSpeed.Columns[1].ToString());
            _dtSpeeds.Columns.Add(_mainCfg.VMASSpeed.Columns[2].ToString());
            _dtSpeeds.Columns.Add(_mainCfg.VMASSpeed.Columns[3].ToString());
            _dtSpeeds.Columns.Add("Speed");

            for (int i = 0; i < _mainCfg.VMASSpeed.Rows.Count; i++)
            {
                DataRow dr = _dtSpeeds.NewRow();
                if (_mainCfg.VMASSpeed.Rows[i][1].ToString().Length > 0)
                {
                    dr[0] = _mainCfg.VMASSpeed.Rows[i][0];
                    dr[1] = _mainCfg.VMASSpeed.Rows[i][1];
                    dr[2] = _mainCfg.VMASSpeed.Rows[i][2];
                    dr[3] = _mainCfg.VMASSpeed.Rows[i][3];
                }
                _dtSpeeds.Rows.Add(dr);
            }

            _resultData = new VMASResultData();

            _timer           = new System.Timers.Timer(_mainCfg.RealtimeInterval);
            _timer.Elapsed  += OnTimer;
            _timer.AutoReset = true;

            f_result = new VMASResultForm();
        }