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); }
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(); }
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(); }
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); } }
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; }
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; } } } }
static public void DestroySingleton() { mOBDSensor.CloseRecordDatabase(); mOBDSensor.Deinit(); mOBDSensor = null; }
static public void CreateSingleton() { mOBDSensor = new OBDSensor(); }
private void recordingClearMenuItem_Click(object sender, System.EventArgs e) { OBDSensor.GetSingleton().ClearRecordDatabase(); }
private void defaultLayoutMenuItem_Click(object sender, System.EventArgs e) { OBDSensor.GetSingleton().GaugeDefaultLayout(); }
private void OBDGauge_Closed(object sender, System.EventArgs e) { OBDSensor.DestroySingleton(); OBDRead.DestroySingleton(); OBDSerial.DestroySingleton(); }
private void moveToPage4MenuItem_Click(object sender, System.EventArgs e) { OBDSensor.GetSingleton().GaugeMoveToPage(3); }
private void OBDGauge_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { OBDSensor.GetSingleton().SensorSelectRow(e.X, e.Y); }
private void OBDGauge_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { OBDSensor.GetSingleton().SensorRedraw(); }
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; } }
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; } }
private void removeMenuItem_Click(object sender, System.EventArgs e) { OBDSensor.GetSingleton().GaugeRemove(); }
private void clearHistoryMenuItem_Click(object sender, System.EventArgs e) { OBDSensor.GetSingleton().SensorClear(); }