示例#1
0
        private void pageToolBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            byte page;

            if (e.Button == page1ToolBarButton)
            {
                page = 0;
            }
            else if (e.Button == page2ToolBarButton)
            {
                page = 1;
            }
            else if (e.Button == page3ToolBarButton)
            {
                page = 2;
            }
            else if (e.Button == page4ToolBarButton)
            {
                page = 3;
            }
            else if (e.Button == exitToolBarButton)
            {
                this.Close();
                return;
            }
            else
            {
                return;
            }
            OBDSensor.GetSingleton().SensorPage(page);
        }
示例#2
0
 private void OBDGauge_Load(object sender, System.EventArgs e)
 {
     OBDSerial.CreateSingleton();
     OBDRead.CreateSingleton();
     OBDSensor.CreateSingleton();
     OBDPrefs.LoadPrefs(mPrefs);
     OBDRead.GetSingleton().Prefs   = mPrefs;
     OBDSensor.GetSingleton().Prefs = mPrefs;
     OBDSensor.GetSingleton().Init();
 }
示例#3
0
        private void preferencesMenuItem_Click(object sender, System.EventArgs e)
        {
            OBDRead.GetSingleton().ReadClose();
            OBDPrefs OBDPrefs = new OBDPrefs(mPrefs);

            OBDPrefs.ShowDialog();
            OBDPrefs.SavePrefs(mPrefs);
            OBDRead.GetSingleton().Prefs   = mPrefs;
            OBDSensor.GetSingleton().Prefs = mPrefs;

            ReadOpen();
        }
示例#4
0
 private void ReadOpen()
 {
     OBDSensor.GetSingleton().SensorUpdateStatus("Initializing...");
     try
     {
         OBDRead.GetSingleton().ReadOpen();
     }
     catch
     {
         System.Windows.Forms.MessageBox.Show("Failed to open serial port.", "Error",
                                              System.Windows.Forms.MessageBoxButtons.OK,
                                              System.Windows.Forms.MessageBoxIcon.Exclamation,
                                              System.Windows.Forms.MessageBoxDefaultButton.Button1);
     }
 }
示例#5
0
        private void tickTimer_Tick(object sender, System.EventArgs e)
        {
            if (OBDSensor.GetSingleton() == null)
            {
                return;
            }
            this.tickTimer.Enabled = false;

            if (mFirstTick)
            {
                mFirstTick = false;
                OBDSensor.GetSingleton().SensorPage(0);
                ReadOpen();
            }
            OBDRead.GetSingleton().ReadHandleTick();

            this.tickTimer.Enabled = true;
        }
示例#6
0
 private void SendSensorQuery()
 {
     byte[] msg = new byte[2];
     if (mActivePids != 0)
     {
         for (;; bitnum++)
         {
             if (bitnum > 31)
             {
                 OBDSensor.GetSingleton().SensorWriteLogRecord();
                 bitnum = 0;
             }
             if ((mActivePids & (1L << (31 - bitnum))) != 0)
             {
                 msg[0] = 1;
                 msg[1] = (byte)++bitnum;
                 SendObd(msg, 2);
                 break;
             }
         }
     }
 }
示例#7
0
 static public void DestroySingleton()
 {
     mOBDSensor.CloseRecordDatabase();
     mOBDSensor.Deinit();
     mOBDSensor = null;
 }
示例#8
0
 static public void CreateSingleton()
 {
     mOBDSensor = new OBDSensor();
 }
示例#9
0
 private void recordingClearMenuItem_Click(object sender, System.EventArgs e)
 {
     OBDSensor.GetSingleton().ClearRecordDatabase();
 }
示例#10
0
 private void defaultLayoutMenuItem_Click(object sender, System.EventArgs e)
 {
     OBDSensor.GetSingleton().GaugeDefaultLayout();
 }
示例#11
0
 private void OBDGauge_Closed(object sender, System.EventArgs e)
 {
     OBDSensor.DestroySingleton();
     OBDRead.DestroySingleton();
     OBDSerial.DestroySingleton();
 }
示例#12
0
		static public void CreateSingleton()
		{
			mOBDSensor = new OBDSensor();
		}
示例#13
0
 private void moveToPage4MenuItem_Click(object sender, System.EventArgs e)
 {
     OBDSensor.GetSingleton().GaugeMoveToPage(3);
 }
示例#14
0
 private void OBDGauge_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     OBDSensor.GetSingleton().SensorSelectRow(e.X, e.Y);
 }
示例#15
0
 private void OBDGauge_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
 {
     OBDSensor.GetSingleton().SensorRedraw();
 }
示例#16
0
        private void SwitchMode(eMode mode)
        {
            mTicks = DateTime.Now;
            mMode  = mode;
            if (OBDSensor.GetSingleton() != null)
            {
                OBDSensor.GetSingleton().SensorUpdateStatus("Mode: " + mMode);
            }
            switch (mMode)
            {
            case eMode.MODE_NULL:
                // do nothing
                break;

            case eMode.MODE_INIT:
                mSupportedPids = 0;
                mNeedInit      = true;
                if (mPrefs.Interface == eInterface.INTERFACE_MULTIPLEX)
                {
                    SwitchMode(eMode.MODE_READ_PIDS);
                }
                else
                {
                    SendAsciiElm("ATZ\r");
                }
                break;

            case eMode.MODE_SET_TIMEOUT:
                SendSetTimeout();
                break;

            case eMode.MODE_ECHO_OFF:
                SendAsciiElm("ATE0\r");
                break;

            case eMode.MODE_LINEFEED_OFF:
                SendAsciiElm("ATL0\r");
                break;

            case eMode.MODE_READ_PIDS:
                SendPidQuery();
                break;

            case eMode.MODE_READ_SENSORS:
                break;

            case eMode.MODE_READ_MIL:
                break;

            case eMode.MODE_READ_ACTIVE_CODES:
                SendActiveCodeQuery();
                break;

            case eMode.MODE_READ_PENDING_CODES:
                SendPendingCodeQuery();
                break;

            case eMode.MODE_CLEAR_CODES:
                SendClearCodesCommand();
                break;
            }
        }
示例#17
0
        private void ReadObd(byte[] message, int start, int length)
        {
            if (length == 0)
            {
                return;
            }
            switch (message[start])
            {
            case 0x41:             // sensor report
                if (length < 3)
                {
                    return;
                }
                switch (message[start + 1])
                {
                case 0x00:                 // supported PIDs
                    if (length < 6)
                    {
                        return;
                    }
                    mSupportedPids = BytesToUInt32(message, start + 2);
                    mActivePids    = 0;
                    OBDSensor.GetSingleton().SensorInit(mSupportedPids);
                    SwitchMode(eMode.MODE_READ_SENSORS);
                    break;

                case 0x01:                 // trouble codes count
                    if (length < 3)
                    {
                        return;
                    }
                    if (OBDCodes.GetSingleton() != null)
                    {
                        OBDCodes.GetSingleton().CodesSetMIL((message[start + 2] & 0x80) != 0);
                    }
                    break;

                default:
                    mTicks = DateTime.Now;
                    OBDSensor.GetSingleton().SensorReceiveElmObd(message, start, length);
                    break;
                }
                break;

            case 0x43:             // active trouble codes
                if (OBDCodes.GetSingleton() != null)
                {
                    OBDCodes.GetSingleton().CodesReceiveElmObd(message, length);
                }
                break;

            case 0x47:             // pending trouble codes
                if (OBDCodes.GetSingleton() != null)
                {
                    OBDCodes.GetSingleton().CodesReceiveElmObd(message, length);
                }
                break;

            case 0x44:             // clear trouble codes
                if (OBDCodes.GetSingleton() != null)
                {
                    OBDCodes.GetSingleton().CodesSetClearCodes();
                }
                break;
            }
        }
示例#18
0
 private void removeMenuItem_Click(object sender, System.EventArgs e)
 {
     OBDSensor.GetSingleton().GaugeRemove();
 }
示例#19
0
		static public void DestroySingleton()
		{
			mOBDSensor.CloseRecordDatabase();
			mOBDSensor.Deinit();
			mOBDSensor = null;
		}
示例#20
0
 private void clearHistoryMenuItem_Click(object sender, System.EventArgs e)
 {
     OBDSensor.GetSingleton().SensorClear();
 }