/// <summary> /// The runtime of this method is configured in the <see cref="Program"/> class. /// </summary> public void Update(object sender, EventArgs e) { ELM327Manager.Run(); // Needs a valid configuration from the database. if (OBDConfig == null) { return; } if (OBDConfig.IsLoggingToDb) { UpdateDatabase(); } else { // Used when not storing to db. if (ELM327Manager.Storage == null) { ELM327Manager.SetStorage(1); } } UpdateBrowser(); }
/// <summary> /// Updates the database. /// </summary> private void UpdateDatabase() { // Exit. Application doesn't have a valid OBD device. if (ELM327Manager.RequestType != RequestType.DataStream) { return; } // Create storage. if (ELM327Manager.Storage == null) { int sessionId = OBDSql.GetSession(OBDConfig.CarId); // Do not use try/catch. Let the program crash if it fails to retrieve session id. ELM327Manager.SetStorage(sessionId); } // Insert to database when the threshold is reached. if (ELM327Manager.Storage.Rows.Count >= OBDSql.StorageThreshold) { OBDSql.Insert(ELM327Manager.Storage); } }
public LoggingForm() { InitializeComponent(); InitializeBrowser(); InitializeDatabase(); // Setup ELM327Manager and application logger. Logger = new Logger(); ELM327Manager = new ELM327Manager(); ELM327Manager.LogHandler += LoggingForm_OnLogReceived; // Register desirable commands to log. ELM327Manager.RegisterCommand <IP04EngineCoolantTemp>(); ELM327Manager.RegisterCommand <IP05EngineLoad>(); ELM327Manager.RegisterCommand <IP0CEngineRPM>(); ELM327Manager.RegisterCommand <IP0DVehicleSpeed>(); ELM327Manager.RegisterCommand <IP0FIntakeAirTemp>(); ELM327Manager.RegisterCommand <IP2CCommandedEGR>(); ELM327Manager.RegisterCommand <IP2DEGRError>(); ELM327Manager.RegisterCommand <IP33AbsBarometricPressure>(); }