Пример #1
0
        public AdvancedForm(OBDIfEx obdIfEX, OBDTest obdTest)
        {
            InitializeComponent();
            _obdIfEx = obdIfEX;
            _obdTest = obdTest;
            _obdIfEx.OBDIf.OnConnect    += new OBDInterface.__Delegate_OnConnect(On_OBD_Connect);
            _obdIfEx.OBDIf.OnDisconnect += new OBDInterface.__Delegate_OnDisconnect(On_OBD_Disconnect);

            _originFont = buttonDefaultFontStyle.Font;
            _boldFont   = new Font(_originFont, FontStyle.Bold);

            StatusLabelConnStatus.ForeColor = Color.Red;
            StatusLabelConnStatus.Text      = "OBD通讯接口未连接";
            StatusLabelDeviceName.Text      = "未获取到设备名";
            StatusLabelCommProtocol.Text    = _obdIfEx.OBDIf.GetProtocol().ToString();
            StatusLabelDeviceType.Text      = _obdIfEx.OBDIf.GetDevice().ToString().Replace("ELM327", "SH-VCI-302U");
            if (_obdIfEx.OBDIf.DllSettings != null)
            {
                if (_obdIfEx.OBDIf.DllSettings.AutoDetect)
                {
                    StatusLabelPort.Text        = "自动探测";
                    StatusLabelAppProtocol.Text = "自动探测";
                }
                else
                {
                    StatusLabelPort.Text        = _obdIfEx.OBDIf.DllSettings.ComPortName;
                    StatusLabelAppProtocol.Text = _obdIfEx.OBDIf.DllSettings.StandardName;
                }
            }

            InitSubForm();
            this.Text = "SH_OBD - Ver " + MainFileVersion.AssemblyVersion;
        }
Пример #2
0
 public OBDTestForm(OBDIfEx obdIfEx, OBDTest obdTest)
 {
     InitializeComponent();
     _obdIfEx = obdIfEx;
     _obdTest = obdTest;
     btnStartOBDTest.Enabled = false;
 }
Пример #3
0
        public OBDStartForm()
        {
            InitializeComponent();
            this.Text     += " Ver(Main/Dll): " + MainFileVersion.AssemblyVersion + "/" + DllVersion <SH_OBD_Dll> .AssemblyVersion;
            _bCanOBDTest   = true;
            _lastHeight    = this.Height;
            _serialRecvBuf = "";
            _obdIfEx       = new OBDIfEx();
            if (_obdIfEx.StrLoadConfigResult.Length > 0)
            {
                _obdIfEx.StrLoadConfigResult += "是否要以默认配置运行程序?点击\"否\":将会退出程序。";
                DialogResult result = MessageBox.Show(_obdIfEx.StrLoadConfigResult, "加载配置文件出错", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.No)
                {
                    Environment.Exit(0);
                }
            }
            _obdTest   = new OBDTest(_obdIfEx);
            _backColor = lblVIN.BackColor;
            if (_obdIfEx.ScannerPortOpened)
            {
                _obdIfEx._sp.DataReceived += new SerialPortClass.SerialPortDataReceiveEventArgs(SerialDataReceived);
            }
            _obdTest.OBDTestStart     += new Action(OnOBDTestStart);
            _obdTest.SetupColumnsDone += new Action(OnSetupColumnsDone);
            _obdTest.WriteDbStart     += new Action(OnWriteDbStart);
            _obdTest.WriteDbDone      += new Action(OnWriteDbDone);
            _obdTest.UploadDataStart  += new Action(OnUploadDataStart);
            _obdTest.UploadDataDone   += new Action(OnUploadDataDone);
#if !DEBUG
            // 删除WebService上传接口缓存dll
            string dllPath = ".\\" + _obdIfEx.DBandMES.WSMES.Name + ".dll";
            try {
                if (File.Exists(dllPath))
                {
                    File.Delete(dllPath);
                }
            } catch (Exception ex) {
                _obdIfEx.Log.TraceError("Delete WebService dll file failed: " + ex.Message);
            }
#endif
            // 测试本地数据库连接是否正常
            Task.Factory.StartNew(TestNativeDatabase);

            // 定时上传以前上传失败的数据
            _timer           = new System.Timers.Timer(_obdIfEx.OBDResultSetting.UploadInterval * 60 * 1000);
            _timer.Elapsed  += new System.Timers.ElapsedEventHandler(OnTimeUpload);
            _timer.AutoReset = true;
            _timer.Enabled   = true;
        }