Esempio n. 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();
        }
Esempio n. 2
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>();
 }
Esempio n. 3
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();
        }
Esempio n. 4
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;
 }
Esempio n. 5
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();
        }
Esempio n. 6
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("已经有一个相同的程序在运行了!");
            }
        }
Esempio n. 7
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();
        }