private new void Capture(object state) { m_RpmValues = new List <DatedValue>(); m_KphValues = new List <DatedValue>(); OBDParameterValue value; DatedValue d_value; while (m_Capture) { value = m_obdInterface.getValue("SAE.RPM", true); if (!value.ErrorDetected) { d_value = new DatedValue(value.DoubleValue); d_value.Date = DateTime.Now; if (Convert.ToDecimal(d_value.Value) >= numFromRPM.Value && Convert.ToDecimal(d_value.Value) <= numToRPM.Value) { m_RpmValues.Add(d_value); value = m_obdInterface.getValue("SAE.VSS", false); if (!value.ErrorDetected) { d_value = new DatedValue(value.DoubleValue * (double)m_obdInterface.ActiveProfile.SpeedCalibrationFactor); d_value.Date = DateTime.Now; m_KphValues.Add(d_value); } m_Capture = false; } } } Calculate(); btnOpen.Enabled = true; }
private new void Capture(object state) { m_arrRpmValues = new ArrayList(); m_arrKphValues = new ArrayList(); bool flag = false; if (m_bCapture) { do { OBDParameterValue obdParameterValue1 = m_obdInterface.getValue("SAE.RPM", true); if (!obdParameterValue1.ErrorDetected) { DatedValue datedValue1 = new DatedValue(obdParameterValue1.DoubleValue); DateTime now1 = DateTime.Now; datedValue1.Date = now1; Decimal num1 = numFromRPM.Value; Decimal num2 = new Decimal(); num2 = new Decimal(datedValue1.Value); if (num2 >= num1) { Decimal num3 = numToRPM.Value; Decimal num4 = new Decimal(); num4 = new Decimal(datedValue1.Value); if (num4 <= num3) { m_arrRpmValues.Add((object)datedValue1); OBDParameterValue obdParameterValue2 = m_obdInterface.getValue("SAE.VSS", false); if (!obdParameterValue2.ErrorDetected) { float num5 = m_obdInterface.GetActiveProfile().SpeedCalibrationFactor; DatedValue datedValue2 = new DatedValue(obdParameterValue2.DoubleValue * (double)num5); DateTime now2 = DateTime.Now; datedValue2.Date = now2; m_arrKphValues.Add((object)datedValue2); } flag = true; goto label_9; } } if (flag) { m_bCapture = false; } } label_9 :; }while (m_bCapture); } Calculate(); btnOpen.Enabled = true; }
public void ReadCodes() { m_ListDTC.Clear(); m_ListPending.Clear(); m_ListPermanent.Clear(); OBDParameterValue value; value = m_obdInterface.getValue("SAE.MIL", true); if (!value.ErrorDetected) { SetMilStatus(value.BoolValue); } value = m_obdInterface.getValue("SAE.DTC_COUNT", true); if (!value.ErrorDetected) { SetDTCTotal((int)value.DoubleValue); } value = m_obdInterface.getValue("SAE.STORED_DTCS", true); if (!value.ErrorDetected) { foreach (string dtc in value.StringCollectionValue) { m_ListDTC.Add(m_obdInterface.GetDTC(dtc)); } } value = m_obdInterface.getValue("SAE.PENDING_DTCS", true); if (!value.ErrorDetected) { foreach (string dtc in value.StringCollectionValue) { m_ListPending.Add(m_obdInterface.GetDTC(dtc)); } } value = m_obdInterface.getValue("SAE.PERMANENT_DTCS", true); if (!value.ErrorDetected) { foreach (string dtc in value.StringCollectionValue) { m_ListPermanent.Add(m_obdInterface.GetDTC(dtc)); } } }
private void UpdateThread(object state) { if (!bRunThread) { return; } do { if (m_obdInterface.getConnectedStatus() && bLogging) { IEnumerator enumerator = panelDisplay.Controls.GetEnumerator(); if (enumerator.MoveNext()) { do { SensorDisplayControl sensorDisplayControl = (SensorDisplayControl)enumerator.Current; OBDParameter obdParameter = (OBDParameter)sensorDisplayControl.Tag; OBDParameterValue obdParameterValue = m_obdInterface.getValue(obdParameter, radioDisplayEnglish.Checked); if (!obdParameterValue.ErrorDetected) { string str = obdParameter.EnglishUnitLabel; if (!radioDisplayEnglish.Checked) { str = obdParameter.MetricUnitLabel; } double num1 = obdParameterValue.DoubleValue; double num2 = obdParameterValue.DoubleValue; SensorLogItem sensorLogItem = new SensorLogItem(obdParameter.Name, num2.ToString(), str, num1.ToString(), str); SensorMonitorForm.m_arrayListLog.Add((object)sensorLogItem); scrollTime.Maximum = SensorMonitorForm.m_arrayListLog.Count - 1; scrollTime.Value = scrollTime.Maximum; DateTime dateTime = new DateTime(); dateTime = new DateTime(0L); TimeSpan timeSpan = sensorLogItem.Time.Subtract(m_dtStartTime); lblTimeElapsed.Text = dateTime.Add(timeSpan).ToString("mm:ss.fff", DateTimeFormatInfo.InvariantInfo); if (radioDisplayEnglish.Checked) { double num3 = obdParameterValue.DoubleValue; sensorDisplayControl.EnglishDisplay = num3.ToString() + " " + obdParameter.EnglishUnitLabel; } else { double num3 = obdParameterValue.DoubleValue; sensorDisplayControl.MetricDisplay = num3.ToString() + " " + obdParameter.MetricUnitLabel; } } }while (enumerator.MoveNext()); } } else { Thread.Sleep(300); } }while (bRunThread); }
private void ConnectThreadNew(object state) { ShowConnectingLabel(); if (m_OBDInterface.CommSettings.AutoDetect) { if (m_OBDInterface.initDeviceAuto()) { m_OBDInterface.logItem("Connection Established!"); ShowConnectedLabel(); OBDParameter param = new OBDParameter(); param.OBDRequest = "0902"; param.Service = 9; param.Parameter = 2; param.ValueTypes = 4; m_OBDInterface.getValue(param, true); } else { MessageBox.Show("ProScan failed to find a compatible OBD-II interface attached to this computer.\r\n\r\nPlease verify that no other application is currently using the required port.", "Auto Detection Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); m_OBDInterface.logItem("Failed to find a compatible OBD-II interface."); ShowDisconnectedLabel(); } } else { int baudRate = m_OBDInterface.CommSettings.BaudRate; int comPort = m_OBDInterface.CommSettings.ComPort; if (m_OBDInterface.initDevice( m_OBDInterface.CommSettings.HardwareIndex, comPort, baudRate, m_OBDInterface.CommSettings.ProtocolIndex )) { m_OBDInterface.logItem("Connection Established!"); ShowConnectedLabel(); } else { MessageBox.Show( string.Format(@"ProScan failed to find a compatible OBD-II interface attached to {0} at baud rate {1} bps. Please verify that no other application is currently using the required port and that the baud rate is correct.", m_OBDInterface.CommSettings.ComPortName, m_OBDInterface.CommSettings.BaudRate ), "Connection Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation ); m_OBDInterface.logItem("Failed to find a compatible OBD-II interface."); ShowDisconnectedLabel(); } } }
private void UpdateThread(object state) { while (IsRunThread) { if (m_obdInterface.ConnectedStatus && IsLogging) { foreach (SensorDisplayControl control in panelDisplay.Controls) { OBDParameter param = (OBDParameter)control.Tag; OBDParameterValue value = m_obdInterface.getValue(param, radioDisplayEnglish.Checked); if (!value.ErrorDetected) { string text = param.EnglishUnitLabel; if (!radioDisplayEnglish.Checked) { text = param.MetricUnitLabel; } SensorLogItem sensorLogItem = new SensorLogItem( param.Name, value.DoubleValue.ToString(), text, value.DoubleValue.ToString(), text); m_ListLog.Add(sensorLogItem); scrollTime.Maximum = m_ListLog.Count - 1; scrollTime.Value = scrollTime.Maximum; DateTime dateTime = new DateTime(0L); lblTimeElapsed.Text = dateTime.Add(sensorLogItem.Time.Subtract(m_dtStartTime)).ToString("mm:ss.fff", DateTimeFormatInfo.InvariantInfo); text = value.DoubleValue.ToString(); if (radioDisplayEnglish.Checked) { control.EnglishDisplay = text + " " + param.EnglishUnitLabel; } else { control.MetricDisplay = text + " " + param.MetricUnitLabel; } } } } else { Thread.Sleep(300); } } }
private new void Capture(object state) { m_KphValues = new List <DatedValue>(); if (m_bCapture) { do { OBDParameterValue obdParameterValue = m_obdInterface.getValue("SAE.VSS", false); if (!obdParameterValue.ErrorDetected && obdParameterValue.DoubleValue > 0.0) { if (m_KphValues.Count == 0) { TrackForm.thisForm.BeginInvoke((Delegate)TrackForm.CallStartTimer); } m_KphValues.Add(new DatedValue(obdParameterValue.DoubleValue * (double)m_obdInterface.ActiveProfile.SpeedCalibrationFactor)); TrackForm.thisForm.CalculateTimeslip(); } }while (m_bCapture); } TrackForm.thisForm.BeginInvoke((Delegate)TrackForm.CallStopTimer); btnOpen.Enabled = true; }
private void ReadTestResults() { o2TestResultsControl1.Reset(); progressBar.Maximum = 12; progressBar.Value = 0; if (!m_obdInterface.getValue("SAE.O2_SUPPORT", true).ErrorDetected) { OBDParameterValue obdParameterValue1 = m_obdInterface.getValue("SAE.O2_STATUS", true); if (!obdParameterValue1.ErrorDetected && obdParameterValue1.BoolValue) { progressBar.Increment(1); int selectedSensorId = getSelectedSensorID(); int num = 0; sbyte[] arrayType0x529830f3 = new sbyte[10]; do { arrayType0x529830f3[num] = 1; ++num; }while (num < 10); progressBar.Increment(1); if (arrayType0x529830f3[0] != 0) { OBDParameterValue obdParameterValue2 = m_obdInterface.getValue(new OBDParameter(5, 1, 0, selectedSensorId), true); if (!obdParameterValue2.ErrorDetected) { o2TestResultsControl1.TestValue01 = obdParameterValue2.DoubleValue; } OBDParameterValue obdParameterValue3 = m_obdInterface.getValue(new OBDParameter(5, 1, 1, selectedSensorId), true); if (!obdParameterValue3.ErrorDetected) { o2TestResultsControl1.TestMinimum01 = obdParameterValue3.DoubleValue; } OBDParameterValue obdParameterValue4 = m_obdInterface.getValue(new OBDParameter(5, 1, 2, selectedSensorId), true); if (!obdParameterValue4.ErrorDetected) { o2TestResultsControl1.TestMaximum01 = obdParameterValue4.DoubleValue; } } progressBar.Increment(1); if (arrayType0x529830f3[1] != 0) { OBDParameterValue obdParameterValue2 = m_obdInterface.getValue(new OBDParameter(5, 2, 0, selectedSensorId), true); if (!obdParameterValue2.ErrorDetected) { o2TestResultsControl1.TestValue02 = obdParameterValue2.DoubleValue; } OBDParameterValue obdParameterValue3 = m_obdInterface.getValue(new OBDParameter(5, 2, 1, selectedSensorId), true); if (!obdParameterValue3.ErrorDetected) { o2TestResultsControl1.TestMinimum02 = obdParameterValue3.DoubleValue; } OBDParameterValue obdParameterValue4 = m_obdInterface.getValue(new OBDParameter(5, 2, 2, selectedSensorId), true); if (!obdParameterValue4.ErrorDetected) { o2TestResultsControl1.TestMaximum02 = obdParameterValue4.DoubleValue; } } progressBar.Increment(1); if (arrayType0x529830f3[2] != 0) { OBDParameterValue obdParameterValue2 = m_obdInterface.getValue(new OBDParameter(5, 3, 0, selectedSensorId), true); if (!obdParameterValue2.ErrorDetected) { o2TestResultsControl1.TestValue03 = obdParameterValue2.DoubleValue; } OBDParameterValue obdParameterValue3 = m_obdInterface.getValue(new OBDParameter(5, 3, 1, selectedSensorId), true); if (!obdParameterValue3.ErrorDetected) { o2TestResultsControl1.TestMinimum03 = obdParameterValue3.DoubleValue; } OBDParameterValue obdParameterValue4 = m_obdInterface.getValue(new OBDParameter(5, 3, 2, selectedSensorId), true); if (!obdParameterValue4.ErrorDetected) { o2TestResultsControl1.TestMaximum03 = obdParameterValue4.DoubleValue; } } progressBar.Increment(1); if (arrayType0x529830f3[3] != 0) { OBDParameterValue obdParameterValue2 = m_obdInterface.getValue(new OBDParameter(5, 4, 0, selectedSensorId), true); if (!obdParameterValue2.ErrorDetected) { o2TestResultsControl1.TestValue04 = obdParameterValue2.DoubleValue; } OBDParameterValue obdParameterValue3 = m_obdInterface.getValue(new OBDParameter(5, 4, 1, selectedSensorId), true); if (!obdParameterValue3.ErrorDetected) { o2TestResultsControl1.TestMinimum04 = obdParameterValue3.DoubleValue; } OBDParameterValue obdParameterValue4 = m_obdInterface.getValue(new OBDParameter(5, 4, 2, selectedSensorId), true); if (!obdParameterValue4.ErrorDetected) { o2TestResultsControl1.TestMaximum04 = obdParameterValue4.DoubleValue; } } progressBar.Increment(1); if (arrayType0x529830f3[4] != 0) { OBDParameterValue obdParameterValue2 = m_obdInterface.getValue(new OBDParameter(5, 5, 0, selectedSensorId), true); if (!obdParameterValue2.ErrorDetected) { o2TestResultsControl1.TestValue05 = obdParameterValue2.DoubleValue; } OBDParameterValue obdParameterValue3 = m_obdInterface.getValue(new OBDParameter(5, 5, 1, selectedSensorId), true); if (!obdParameterValue3.ErrorDetected) { o2TestResultsControl1.TestMinimum05 = obdParameterValue3.DoubleValue; } OBDParameterValue obdParameterValue4 = m_obdInterface.getValue(new OBDParameter(5, 5, 2, selectedSensorId), true); if (!obdParameterValue4.ErrorDetected) { o2TestResultsControl1.TestMaximum05 = obdParameterValue4.DoubleValue; } } progressBar.Increment(1); if (arrayType0x529830f3[5] != 0) { OBDParameterValue obdParameterValue2 = m_obdInterface.getValue(new OBDParameter(5, 6, 0, selectedSensorId), true); if (!obdParameterValue2.ErrorDetected) { o2TestResultsControl1.TestValue06 = obdParameterValue2.DoubleValue; } OBDParameterValue obdParameterValue3 = m_obdInterface.getValue(new OBDParameter(5, 6, 1, selectedSensorId), true); if (!obdParameterValue3.ErrorDetected) { o2TestResultsControl1.TestMinimum06 = obdParameterValue3.DoubleValue; } OBDParameterValue obdParameterValue4 = m_obdInterface.getValue(new OBDParameter(5, 6, 2, selectedSensorId), true); if (!obdParameterValue4.ErrorDetected) { o2TestResultsControl1.TestMaximum06 = obdParameterValue4.DoubleValue; } } progressBar.Increment(1); if (arrayType0x529830f3[6] != 0) { OBDParameterValue obdParameterValue2 = m_obdInterface.getValue(new OBDParameter(5, 7, 0, selectedSensorId), true); if (!obdParameterValue2.ErrorDetected) { o2TestResultsControl1.TestValue07 = obdParameterValue2.DoubleValue; } OBDParameterValue obdParameterValue3 = m_obdInterface.getValue(new OBDParameter(5, 7, 1, selectedSensorId), true); if (!obdParameterValue3.ErrorDetected) { o2TestResultsControl1.TestMinimum07 = obdParameterValue3.DoubleValue; } OBDParameterValue obdParameterValue4 = m_obdInterface.getValue(new OBDParameter(5, 7, 2, selectedSensorId), true); if (!obdParameterValue4.ErrorDetected) { o2TestResultsControl1.TestMaximum07 = obdParameterValue4.DoubleValue; } } progressBar.Increment(1); if (arrayType0x529830f3[7] != 0) { OBDParameterValue obdParameterValue2 = m_obdInterface.getValue(new OBDParameter(5, 8, 0, selectedSensorId), true); if (!obdParameterValue2.ErrorDetected) { o2TestResultsControl1.TestValue08 = obdParameterValue2.DoubleValue; } OBDParameterValue obdParameterValue3 = m_obdInterface.getValue(new OBDParameter(5, 8, 1, selectedSensorId), true); if (!obdParameterValue3.ErrorDetected) { o2TestResultsControl1.TestMinimum08 = obdParameterValue3.DoubleValue; } OBDParameterValue obdParameterValue4 = m_obdInterface.getValue(new OBDParameter(5, 8, 2, selectedSensorId), true); if (!obdParameterValue4.ErrorDetected) { o2TestResultsControl1.TestMaximum08 = obdParameterValue4.DoubleValue; } } progressBar.Increment(1); if (arrayType0x529830f3[8] != 0) { OBDParameterValue obdParameterValue2 = m_obdInterface.getValue(new OBDParameter(5, 9, 0, selectedSensorId), true); if (!obdParameterValue2.ErrorDetected) { o2TestResultsControl1.TestValue09 = obdParameterValue2.DoubleValue; } OBDParameterValue obdParameterValue3 = m_obdInterface.getValue(new OBDParameter(5, 9, 1, selectedSensorId), true); if (!obdParameterValue3.ErrorDetected) { o2TestResultsControl1.TestMinimum09 = obdParameterValue3.DoubleValue; } OBDParameterValue obdParameterValue4 = m_obdInterface.getValue(new OBDParameter(5, 9, 2, selectedSensorId), true); if (!obdParameterValue4.ErrorDetected) { o2TestResultsControl1.TestMaximum09 = obdParameterValue4.DoubleValue; } } progressBar.Increment(1); if (arrayType0x529830f3[9] != 0) { OBDParameterValue obdParameterValue2 = m_obdInterface.getValue(new OBDParameter(5, 10, 0, selectedSensorId), true); if (!obdParameterValue2.ErrorDetected) { o2TestResultsControl1.TestValue0A = obdParameterValue2.DoubleValue; } OBDParameterValue obdParameterValue3 = m_obdInterface.getValue(new OBDParameter(5, 10, 1, selectedSensorId), true); if (!obdParameterValue3.ErrorDetected) { o2TestResultsControl1.TestMinimum0A = obdParameterValue3.DoubleValue; } OBDParameterValue obdParameterValue4 = m_obdInterface.getValue(new OBDParameter(5, 10, 2, selectedSensorId), true); if (!obdParameterValue4.ErrorDetected) { o2TestResultsControl1.TestMaximum0A = obdParameterValue4.DoubleValue; } } progressBar.Value = progressBar.Maximum; return; } } MessageBox.Show("This vehicle either does not support oxygen sensor monitoring, or the monitoring test has not yet been completed.", "Unsupported", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); }
public void UpdateTests() { progressBar.Minimum = 0; progressBar.Maximum = 25; gridConTests.Visible = false; gridNonConTests.Visible = false; OBDParameterValue value; value = m_obd2Interface.getValue("SAE.MISFIRE_SUPPORT", true); progressBar.Value = 1; TestStatus status = m_arrayListConTests[0] as TestStatus; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "Not Supported"; } else { value = m_obd2Interface.getValue("SAE.MISFIRE_STATUS", true); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "Complete" : "Incomplete"; } else { status.Status = "ERROR"; } } } else { status.Status = "ERROR"; } value = m_obd2Interface.getValue("SAE.FUEL_SUPPORT", true); progressBar.Value = 2; status = m_arrayListConTests[1] as TestStatus; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "Not Supported"; } else { value = m_obd2Interface.getValue("SAE.FUEL_STATUS", true); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "Complete" : "Incomplete"; } else { status.Status = "ERROR"; } } } else { status.Status = "ERROR"; } value = m_obd2Interface.getValue("SAE.CCM_SUPPORT", true); progressBar.Value = 3; status = m_arrayListConTests[2] as TestStatus; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "Not Supported"; } else { value = m_obd2Interface.getValue("SAE.CCM_STATUS", true); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "Complete" : "Incomplete"; } else { status.Status = "ERROR"; } } } else { status.Status = "ERROR"; } value = m_obd2Interface.getValue("SAE.CAT_SUPPORT", true); progressBar.Value = 4; status = m_arrayListNonConTests[0] as TestStatus; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "Not Supported"; } else { value = m_obd2Interface.getValue("SAE.CAT_STATUS", true); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "Complete" : "Incomplete"; } else { status.Status = "ERROR"; } } } else { status.Status = "ERROR"; } value = m_obd2Interface.getValue("SAE.HCAT_SUPPORT", true); progressBar.Value = 5; status = m_arrayListNonConTests[1] as TestStatus; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "Not Supported"; } else { value = m_obd2Interface.getValue("SAE.HCAT_STATUS", true); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "Complete" : "Incomplete"; } else { status.Status = "ERROR"; } } } else { status.Status = "ERROR"; } value = m_obd2Interface.getValue("SAE.EVAP_SUPPORT", true); progressBar.Value = 6; status = m_arrayListNonConTests[2] as TestStatus; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "Not Supported"; } else { value = m_obd2Interface.getValue("SAE.EVAP_STATUS", true); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "Complete" : "Incomplete"; } else { status.Status = "ERROR"; } } } else { status.Status = "ERROR"; } value = m_obd2Interface.getValue("SAE.AIR_SUPPORT", true); progressBar.Value = 7; status = m_arrayListNonConTests[3] as TestStatus; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "Not Supported"; } else { value = m_obd2Interface.getValue("SAE.AIR_STATUS", true); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "Complete" : "Incomplete"; } else { status.Status = "ERROR"; } } } else { status.Status = "ERROR"; } value = m_obd2Interface.getValue("SAE.AC_SUPPORT", true); progressBar.Value = 8; status = m_arrayListNonConTests[4] as TestStatus; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "Not Supported"; } else { value = m_obd2Interface.getValue("SAE.AC_STATUS", true); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "Complete" : "Incomplete"; } else { status.Status = "ERROR"; } } } else { status.Status = "ERROR"; } value = m_obd2Interface.getValue("SAE.O2_SUPPORT", true); progressBar.Value = 9; status = m_arrayListNonConTests[5] as TestStatus; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "Not Supported"; } else { value = m_obd2Interface.getValue("SAE.O2_STATUS", true); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "Complete" : "Incomplete"; } else { status.Status = "ERROR"; } } } else { status.Status = "ERROR"; } value = m_obd2Interface.getValue("SAE.O2HTR_SUPPORT", true); progressBar.Value = 10; status = m_arrayListNonConTests[6] as TestStatus; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "Not Supported"; } else { value = m_obd2Interface.getValue("SAE.O2HTR_STATUS", true); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "Complete" : "Incomplete"; } else { status.Status = "ERROR"; } } } else { status.Status = "ERROR"; } value = m_obd2Interface.getValue("SAE.EGR_SUPPORT", true); progressBar.Value = 11; status = m_arrayListNonConTests[7] as TestStatus; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "Not Supported"; } else { value = m_obd2Interface.getValue("SAE.EGR_STATUS", true); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "Complete" : "Incomplete"; } else { status.Status = "ERROR"; } } } else { status.Status = "ERROR"; } gridConTests.Visible = true; gridNonConTests.Visible = true; if (m_obd2Interface.isParameterSupported("SAE.FUEL1_STATUS")) { value = m_obd2Interface.getValue("SAE.FUEL1_STATUS", true); progressBar.Value++; lblFuel1.Text = value.ErrorDetected ? "ERROR" : value.StringValue; } else { lblFuel1.Text = "Not Supported"; } if (m_obd2Interface.isParameterSupported("SAE.FUEL2_STATUS")) { value = m_obd2Interface.getValue("SAE.FUEL2_STATUS", true); progressBar.Value++; lblFuel2.Text = value.ErrorDetected ? "ERROR" : value.StringValue; } else { lblFuel2.Text = "Not Supported"; } if (m_obd2Interface.isParameterSupported("SAE.PTO_STATUS")) { value = m_obd2Interface.getValue("SAE.PTO_STATUS", true); progressBar.Value++; lblPTO.Text = value.ErrorDetected ? "ERROR" : value.StringValue; } else { lblPTO.Text = "Not Supported"; } if (m_obd2Interface.isParameterSupported("SAE.SECAIR_STATUS")) { value = m_obd2Interface.getValue("SAE.SECAIR_STATUS", true); progressBar.Value++; lblAir.Text = value.ErrorDetected ? "ERROR" : value.StringValue; } else { lblAir.Text = "Not Supported"; } if (m_obd2Interface.isParameterSupported("SAE.OBD_TYPE")) { value = m_obd2Interface.getValue("SAE.OBD_TYPE", true); progressBar.Value++; lblOBD.Text = value.ErrorDetected ? "ERROR" : value.StringValue; } else { lblOBD.Text = "Not Supported"; } string str = ""; if (m_obd2Interface.isParameterSupported("SAE.O2B1S1A_PRESENT")) { value = m_obd2Interface.getValue("SAE.O2B1S1A_PRESENT", true); progressBar.Value++; if (!value.ErrorDetected && value.BoolValue) { str = str + "Bank 1 Sensor 1\n"; } value = m_obd2Interface.getValue("SAE.O2B1S2A_PRESENT", true); progressBar.Value++; if (!value.ErrorDetected && value.BoolValue) { str = str + "Bank 1 Sensor 2\n"; } value = m_obd2Interface.getValue("SAE.O2B1S3A_PRESENT", true); progressBar.Value++; if (!value.ErrorDetected && value.BoolValue) { str = str + "Bank 1 Sensor 3\n"; } value = m_obd2Interface.getValue("SAE.O2B1S4A_PRESENT", true); progressBar.Value++; if (!value.ErrorDetected && value.BoolValue) { str = str + "Bank 1 Sensor 4\n"; } value = m_obd2Interface.getValue("SAE.O2B2S1A_PRESENT", true); progressBar.Value++; if (!value.ErrorDetected && value.BoolValue) { str = str + "Bank 2 Sensor 1\n"; } value = m_obd2Interface.getValue("SAE.O2B2S2A_PRESENT", true); progressBar.Value++; if (!value.ErrorDetected && value.BoolValue) { str = str + "Bank 2 Sensor 2\n"; } value = m_obd2Interface.getValue("SAE.O2B2S3A_PRESENT", true); progressBar.Value++; if (!value.ErrorDetected && value.BoolValue) { str = str + "Bank 2 Sensor 3\n"; } value = m_obd2Interface.getValue("SAE.O2B2S4A_PRESENT", true); progressBar.Value++; if (!value.ErrorDetected && value.BoolValue) { str = str + "Bank 2 Sensor 4\n"; } } if (m_obd2Interface.isParameterSupported("SAE.O2B1S1B_PRESENT")) { value = m_obd2Interface.getValue("SAE.O2B1S1B_PRESENT", true); progressBar.Value++; if (!value.ErrorDetected && value.BoolValue) { str = str + "Bank 1 Sensor 1\n"; } value = m_obd2Interface.getValue("SAE.O2B1S2B_PRESENT", true); progressBar.Value++; if (!value.ErrorDetected && value.BoolValue) { str = str + "Bank 1 Sensor 2\n"; } value = m_obd2Interface.getValue("SAE.O2B2S1B_PRESENT", true); progressBar.Value++; if (!value.ErrorDetected && value.BoolValue) { str = str + "Bank 2 Sensor 1\n"; } value = m_obd2Interface.getValue("SAE.O2B2S2B_PRESENT", true); progressBar.Value++; if (!value.ErrorDetected && value.BoolValue) { str = str + "Bank 2 Sensor 2\n"; } value = m_obd2Interface.getValue("SAE.O2B3S1B_PRESENT", true); progressBar.Value++; if (!value.ErrorDetected && value.BoolValue) { str = str + "Bank 3 Sensor 1\n"; } value = m_obd2Interface.getValue("SAE.O2B3S2B_PRESENT", true); progressBar.Value++; if (!value.ErrorDetected && value.BoolValue) { str = str + "Bank 3 Sensor 2\n"; } value = m_obd2Interface.getValue("SAE.O2B4S1B_PRESENT", true); progressBar.Value++; if (!value.ErrorDetected && value.BoolValue) { str = str + "Bank 4 Sensor 1\n"; } value = m_obd2Interface.getValue("SAE.O2B4S2B_PRESENT", true); progressBar.Value++; if (!value.ErrorDetected && value.BoolValue) { str = str + "Bank 4 Sensor 2\n"; } } lblOxygen.Text = str; progressBar.Value++; if (m_obd2Interface.getDevice() == 1) { value = m_obd2Interface.getValue("ELM.BATTERY_VOLTAGE", true); if (!value.ErrorDetected) { lblBattery.Text = value.DoubleValue.ToString() + " V"; } } else { lblBattery.Text = "Not Supported"; } progressBar.Value = progressBar.Maximum; }
private void UpdateThread(object sender) { if (bRunThread) { do { if (m_obdInterface.getConnectedStatus() && m_isWorking) { OBDParameterValue value3 = m_obdInterface.getValue("SAE.MAF", false); OBDParameterValue value2 = m_obdInterface.getValue("SAE.VSS", false); if (!value3.ErrorDetected && !value2.ErrorDetected) { double doubleValue = value2.DoubleValue; double num8 = doubleValue * 0.621371192; double num4 = ((value3.DoubleValue * 0.068027210884353748) * 3600.0) * 0.0013020833333333333; double num7 = num4 * 0.264172052; DateTime now = DateTime.Now; double num6 = now.Subtract(m_FuelEconomyForm.dtStartTime).TotalSeconds * 0.00027777777777777778; double num = now.Subtract(m_FuelEconomyForm.dtPrevTime).TotalSeconds * 0.00027777777777777778; m_FuelEconomyForm.dtPrevTime = now; if (m_FuelEconomyForm.radioEnglishUnits.Checked) { m_FuelEconomyForm.sensorInstantFuelConsumption.EnglishDisplay = num7.ToString("0.000") + " gallons/hour"; m_FuelEconomyForm.dTotalFuelConsumption += num * num7; sensorTotalConsumed.EnglishDisplay = m_FuelEconomyForm.dTotalFuelConsumption.ToString("0.00") + " gallons"; m_FuelEconomyForm.sensorAvgFuelConsumption.EnglishDisplay = ((m_FuelEconomyForm.dTotalFuelConsumption / num6)).ToString("0.00") + " gallons/hour"; m_FuelEconomyForm.dTotalDistance += num * num8; m_FuelEconomyForm.sensorDistance.EnglishDisplay = dTotalDistance.ToString("0.00") + " miles"; m_FuelEconomyForm.sensorInstantFuelEconomy.EnglishDisplay = (((1.0 / num7) * num8)).ToString("0.00") + " miles/gallon"; double num3 = 0.0; if (m_FuelEconomyForm.dTotalDistance > 0.0) { num3 = m_FuelEconomyForm.dTotalDistance / m_FuelEconomyForm.dTotalFuelConsumption; } m_FuelEconomyForm.sensorAvgFuelEconomy.EnglishDisplay = num3.ToString("0.00") + " miles/gallon"; double num14 = 0.0; if (num3 > 0.0) { num14 = ((double)numericFuelCost.Value) * (1.0 / num3); } m_FuelEconomyForm.sensorCostPerMile.Title = "Average Cost Per Mile"; m_FuelEconomyForm.sensorCostPerMile.EnglishDisplay = "$" + num14.ToString("0.00"); m_FuelEconomyForm.sensorTotalCost.EnglishDisplay = "$" + ((((double)numericFuelCost.Value) * dTotalFuelConsumption)).ToString("0.00"); } else { m_FuelEconomyForm.sensorInstantFuelConsumption.EnglishDisplay = num4.ToString("0.000") + " liters/hour"; m_FuelEconomyForm.dTotalFuelConsumption += num * num4; sensorTotalConsumed.EnglishDisplay = m_FuelEconomyForm.dTotalFuelConsumption.ToString("0.00") + " liters"; m_FuelEconomyForm.sensorAvgFuelConsumption.EnglishDisplay = ((m_FuelEconomyForm.dTotalFuelConsumption / num6)).ToString("0.00") + " liters/hour"; m_FuelEconomyForm.dTotalDistance += num * doubleValue; m_FuelEconomyForm.sensorDistance.EnglishDisplay = dTotalDistance.ToString("0.00") + " kilometers"; m_FuelEconomyForm.sensorInstantFuelEconomy.EnglishDisplay = (((1.0 / num4) * doubleValue)).ToString("0.00") + " kilometers/liter"; double num2 = 0.0; if (m_FuelEconomyForm.dTotalDistance > 0.0) { num2 = m_FuelEconomyForm.dTotalDistance / m_FuelEconomyForm.dTotalFuelConsumption; } m_FuelEconomyForm.sensorAvgFuelEconomy.EnglishDisplay = num2.ToString("0.00") + " kilometers/liter"; double num11 = 0.0; if (num2 > 0.0) { num11 = ((double)numericFuelCost.Value) * (1.0 / num2); } m_FuelEconomyForm.sensorCostPerMile.Title = "Average Cost Per Kilometer"; m_FuelEconomyForm.sensorCostPerMile.EnglishDisplay = num11.ToString("0.00"); m_FuelEconomyForm.sensorTotalCost.EnglishDisplay = (((double)numericFuelCost.Value) * dTotalFuelConsumption).ToString("0.00"); } } } else { Thread.Sleep(300); } }while (bRunThread); } }
private void ReadTestResults() { o2TestResultsControl1.Reset(); progressBar.Maximum = 12; progressBar.Value = 0; if (!m_obdInterface.getValue("SAE.O2_SUPPORT", true).ErrorDetected) { OBDParameterValue value; value = m_obdInterface.getValue("SAE.O2_STATUS", true); if (!value.ErrorDetected && value.BoolValue) { progressBar.Increment(1); int selectedSensorId = getSelectedSensorID(); progressBar.Increment(1); value = m_obdInterface.getValue(new OBDParameter(5, 1, 0, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestValue01 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 1, 1, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMinimum01 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 1, 2, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMaximum01 = value.DoubleValue; } progressBar.Increment(1); value = m_obdInterface.getValue(new OBDParameter(5, 2, 0, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestValue02 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 2, 1, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMinimum02 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 2, 2, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMaximum02 = value.DoubleValue; } progressBar.Increment(1); value = m_obdInterface.getValue(new OBDParameter(5, 3, 0, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestValue03 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 3, 1, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMinimum03 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 3, 2, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMaximum03 = value.DoubleValue; } progressBar.Increment(1); value = m_obdInterface.getValue(new OBDParameter(5, 4, 0, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestValue04 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 4, 1, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMinimum04 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 4, 2, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMaximum04 = value.DoubleValue; } progressBar.Increment(1); value = m_obdInterface.getValue(new OBDParameter(5, 5, 0, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestValue05 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 5, 1, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMinimum05 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 5, 2, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMaximum05 = value.DoubleValue; } progressBar.Increment(1); value = m_obdInterface.getValue(new OBDParameter(5, 6, 0, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestValue06 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 6, 1, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMinimum06 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 6, 2, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMaximum06 = value.DoubleValue; } progressBar.Increment(1); value = m_obdInterface.getValue(new OBDParameter(5, 7, 0, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestValue07 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 7, 1, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMinimum07 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 7, 2, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMaximum07 = value.DoubleValue; } progressBar.Increment(1); value = m_obdInterface.getValue(new OBDParameter(5, 8, 0, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestValue08 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 8, 1, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMinimum08 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 8, 2, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMaximum08 = value.DoubleValue; } progressBar.Increment(1); value = m_obdInterface.getValue(new OBDParameter(5, 9, 0, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestValue09 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 9, 1, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMinimum09 = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 9, 2, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMaximum09 = value.DoubleValue; } progressBar.Increment(1); value = m_obdInterface.getValue(new OBDParameter(5, 10, 0, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestValue0A = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 10, 1, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMinimum0A = value.DoubleValue; } value = m_obdInterface.getValue(new OBDParameter(5, 10, 2, selectedSensorId), true); if (!value.ErrorDetected) { o2TestResultsControl1.TestMaximum0A = value.DoubleValue; } progressBar.Value = progressBar.Maximum; return; } } MessageBox.Show( "This vehicle either does not support oxygen sensor monitoring, or the monitoring test has not yet been completed.", "Unsupported", MessageBoxButtons.OK, MessageBoxIcon.Asterisk ); }
private void ReadFreezeFrameData(object state) { freezeFrame.Reset(); progressBar.Value = 0; OBDParameter parameter = m_obdInterface.lookupParameter("SAE.FF_DTC"); if (parameter != null) { OBDParameter freezeFrameCopy = parameter.GetFreezeFrameCopy(m_iFrameNumber); OBDParameterValue value2 = m_obdInterface.getValue(freezeFrameCopy, true); if (value2.ErrorDetected) { MessageBox.Show("An error was encountered while requesting SAE.FF_DTC", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); m_obdInterface.logItem("Error while requesting SAE.FF_DTC"); progressBar.Value = progressBar.Maximum; } else { bool flag = false; if (string.Compare(value2.StringValue, "P0000") != 0) { freezeFrame.DTC = value2.StringValue; flag = true; } progressBar.Increment(progressBar.Step); if (m_bKeepReading) { if (flag) { parameter = m_obdInterface.lookupParameter("SAE.FUEL1_STATUS"); if (parameter == null) { return; } OBDParameter param = parameter.GetFreezeFrameCopy(m_iFrameNumber); OBDParameterValue value17 = m_obdInterface.getValue(param, true); if (!value17.ErrorDetected) { freezeFrame.FuelSystem1Status = value17.StringValue; } parameter = m_obdInterface.lookupParameter("SAE.FUEL2_STATUS"); if (parameter == null) { return; } OBDParameter parameter16 = parameter.GetFreezeFrameCopy(m_iFrameNumber); OBDParameterValue value16 = m_obdInterface.getValue(parameter16, true); if (!value16.ErrorDetected) { freezeFrame.FuelSystem2Status = value16.StringValue; } progressBar.Increment(progressBar.Step); if (!m_bKeepReading) { return; } parameter = m_obdInterface.lookupParameter("SAE.LOAD_CALC"); if (parameter == null) { return; } OBDParameter parameter15 = parameter.GetFreezeFrameCopy(m_iFrameNumber); OBDParameterValue value15 = m_obdInterface.getValue(parameter15, true); if (!value15.ErrorDetected) { freezeFrame.CalculatedLoad = value15.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_bKeepReading) { return; } parameter = m_obdInterface.lookupParameter("SAE.ECT"); if (parameter == null) { return; } OBDParameter parameter14 = parameter.GetFreezeFrameCopy(m_iFrameNumber); OBDParameterValue value14 = m_obdInterface.getValue(parameter14, true); if (!value14.ErrorDetected) { freezeFrame.EngineCoolantTemp = value14.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_bKeepReading) { return; } parameter = m_obdInterface.lookupParameter("SAE.STFT1"); if (parameter == null) { return; } OBDParameter parameter13 = parameter.GetFreezeFrameCopy(m_iFrameNumber); OBDParameterValue value13 = m_obdInterface.getValue(parameter13, true); if (!value13.ErrorDetected) { freezeFrame.STFT1 = value13.DoubleValue; } parameter = m_obdInterface.lookupParameter("SAE.STFT3"); if (parameter == null) { return; } OBDParameter parameter12 = parameter.GetFreezeFrameCopy(m_iFrameNumber); OBDParameterValue value12 = m_obdInterface.getValue(parameter12, true); if (!value12.ErrorDetected) { freezeFrame.STFT3 = value12.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_bKeepReading) { return; } parameter = m_obdInterface.lookupParameter("SAE.LTFT1"); if (parameter == null) { return; } OBDParameter parameter11 = parameter.GetFreezeFrameCopy(m_iFrameNumber); OBDParameterValue value11 = m_obdInterface.getValue(parameter11, true); if (!value11.ErrorDetected) { freezeFrame.LTFT1 = value11.DoubleValue; } parameter = m_obdInterface.lookupParameter("SAE.LTFT3"); if (parameter == null) { return; } OBDParameter parameter10 = parameter.GetFreezeFrameCopy(m_iFrameNumber); OBDParameterValue value10 = m_obdInterface.getValue(parameter10, true); if (!value10.ErrorDetected) { freezeFrame.LTFT3 = value10.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_bKeepReading) { return; } parameter = m_obdInterface.lookupParameter("SAE.STFT2"); if (parameter == null) { return; } OBDParameter parameter9 = parameter.GetFreezeFrameCopy(m_iFrameNumber); OBDParameterValue value9 = m_obdInterface.getValue(parameter9, true); if (!value9.ErrorDetected) { freezeFrame.STFT2 = value9.DoubleValue; } parameter = m_obdInterface.lookupParameter("SAE.STFT4"); if (parameter == null) { return; } OBDParameter parameter8 = parameter.GetFreezeFrameCopy(m_iFrameNumber); OBDParameterValue value8 = m_obdInterface.getValue(parameter8, true); if (!value8.ErrorDetected) { freezeFrame.STFT4 = value8.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_bKeepReading) { return; } parameter = m_obdInterface.lookupParameter("SAE.LTFT2"); if (parameter == null) { return; } OBDParameter parameter7 = parameter.GetFreezeFrameCopy(m_iFrameNumber); OBDParameterValue value7 = m_obdInterface.getValue(parameter7, true); if (!value7.ErrorDetected) { freezeFrame.LTFT2 = value7.DoubleValue; } parameter = m_obdInterface.lookupParameter("SAE.LTFT4"); if (parameter == null) { return; } OBDParameter parameter6 = parameter.GetFreezeFrameCopy(m_iFrameNumber); OBDParameterValue value6 = m_obdInterface.getValue(parameter6, true); if (!value6.ErrorDetected) { freezeFrame.LTFT4 = value6.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_bKeepReading) { return; } parameter = m_obdInterface.lookupParameter("SAE.MAP"); if (parameter == null) { return; } OBDParameter parameter5 = parameter.GetFreezeFrameCopy(m_iFrameNumber); OBDParameterValue value5 = m_obdInterface.getValue(parameter5, true); if (!value5.ErrorDetected) { freezeFrame.IntakePressure = value5.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_bKeepReading) { return; } parameter = m_obdInterface.lookupParameter("SAE.RPM"); if (parameter == null) { return; } OBDParameter parameter4 = parameter.GetFreezeFrameCopy(m_iFrameNumber); OBDParameterValue value4 = m_obdInterface.getValue(parameter4, true); if (!value4.ErrorDetected) { freezeFrame.EngineRPM = value4.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_bKeepReading) { return; } parameter = m_obdInterface.lookupParameter("SAE.VSS"); if (parameter == null) { return; } OBDParameter parameter3 = parameter.GetFreezeFrameCopy(m_iFrameNumber); OBDParameterValue value3 = m_obdInterface.getValue(parameter3, true); if (!value3.ErrorDetected) { freezeFrame.VehicleSpeed = value3.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_bKeepReading) { return; } parameter = m_obdInterface.lookupParameter("SAE.SPARKADV"); if (parameter == null) { return; } freezeFrameCopy = parameter.GetFreezeFrameCopy(m_iFrameNumber); value2 = m_obdInterface.getValue(freezeFrameCopy, true); if (!value2.ErrorDetected) { freezeFrame.SparkAdvance = value2.DoubleValue; } progressBar.Increment(progressBar.Step); } else { MessageBox.Show(string.Format("No freeze frame information found at frame #{0}.", m_iFrameNumber), "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } progressBar.Value = progressBar.Maximum; btnRefresh.Enabled = true; btnCancel.Enabled = false; } } } }
private void ReadFreezeFrameData(object state) { for (; ;) { freezeFrame.Reset(); OBDParameter parameter = m_obdInterface.LookupParameter("SAE.FF_DTC"); if (parameter == null) { MessageBox.Show( "An error was encountered while requesting SAE.FF_DTC", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand ); break; } OBDParameterValue value = m_obdInterface.getValue(parameter.GetFreezeFrameCopy(m_FrameNumber), true); if (value.ErrorDetected) { MessageBox.Show( "An error was encountered while requesting SAE.FF_DTC", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand ); m_obdInterface.logItem("Error while requesting SAE.FF_DTC"); break; } if (string.Compare(value.StringValue, "P0000") == 0) { MessageBox.Show( string.Format("No freeze frame information found at frame #{0}.", m_FrameNumber), "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk ); break; } progressBar.Value = 0; freezeFrame.DTC = value.StringValue; parameter = m_obdInterface.LookupParameter("SAE.FUEL1_STATUS"); if (parameter == null) { break; } value = m_obdInterface.getValue(parameter.GetFreezeFrameCopy(m_FrameNumber), true); if (!value.ErrorDetected) { freezeFrame.FuelSystem1Status = value.StringValue; } parameter = m_obdInterface.LookupParameter("SAE.FUEL2_STATUS"); if (parameter == null) { break; } value = m_obdInterface.getValue(parameter.GetFreezeFrameCopy(m_FrameNumber), true); if (!value.ErrorDetected) { freezeFrame.FuelSystem2Status = value.StringValue; } progressBar.Increment(progressBar.Step); if (!m_KeepReading) { break; } parameter = m_obdInterface.LookupParameter("SAE.LOAD_CALC"); if (parameter == null) { break; } value = m_obdInterface.getValue(parameter.GetFreezeFrameCopy(m_FrameNumber), true); if (!value.ErrorDetected) { freezeFrame.CalculatedLoad = value.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_KeepReading) { break; } parameter = m_obdInterface.LookupParameter("SAE.ECT"); if (parameter == null) { break; } value = m_obdInterface.getValue(parameter.GetFreezeFrameCopy(m_FrameNumber), true); if (!value.ErrorDetected) { freezeFrame.EngineCoolantTemp = value.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_KeepReading) { break; } parameter = m_obdInterface.LookupParameter("SAE.STFT1"); if (parameter == null) { break; } value = m_obdInterface.getValue(parameter.GetFreezeFrameCopy(m_FrameNumber), true); if (!value.ErrorDetected) { freezeFrame.STFT1 = value.DoubleValue; } parameter = m_obdInterface.LookupParameter("SAE.STFT3"); if (parameter == null) { break; } value = m_obdInterface.getValue(parameter.GetFreezeFrameCopy(m_FrameNumber), true); if (!value.ErrorDetected) { freezeFrame.STFT3 = value.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_KeepReading) { break; } parameter = m_obdInterface.LookupParameter("SAE.LTFT1"); if (parameter == null) { break; } value = m_obdInterface.getValue(parameter.GetFreezeFrameCopy(m_FrameNumber), true); if (!value.ErrorDetected) { freezeFrame.LTFT1 = value.DoubleValue; } parameter = m_obdInterface.LookupParameter("SAE.LTFT3"); if (parameter == null) { break; } value = m_obdInterface.getValue(parameter.GetFreezeFrameCopy(m_FrameNumber), true); if (!value.ErrorDetected) { freezeFrame.LTFT3 = value.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_KeepReading) { break; } parameter = m_obdInterface.LookupParameter("SAE.STFT2"); if (parameter == null) { break; } value = m_obdInterface.getValue(parameter.GetFreezeFrameCopy(m_FrameNumber), true); if (!value.ErrorDetected) { freezeFrame.STFT2 = value.DoubleValue; } parameter = m_obdInterface.LookupParameter("SAE.STFT4"); if (parameter == null) { break; } value = m_obdInterface.getValue(parameter.GetFreezeFrameCopy(m_FrameNumber), true); if (!value.ErrorDetected) { freezeFrame.STFT4 = value.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_KeepReading) { break; } parameter = m_obdInterface.LookupParameter("SAE.LTFT2"); if (parameter == null) { break; } value = m_obdInterface.getValue(parameter.GetFreezeFrameCopy(m_FrameNumber), true); if (!value.ErrorDetected) { freezeFrame.LTFT2 = value.DoubleValue; } parameter = m_obdInterface.LookupParameter("SAE.LTFT4"); if (parameter == null) { break; } value = m_obdInterface.getValue(parameter.GetFreezeFrameCopy(m_FrameNumber), true); if (!value.ErrorDetected) { freezeFrame.LTFT4 = value.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_KeepReading) { break; } parameter = m_obdInterface.LookupParameter("SAE.MAP"); if (parameter == null) { break; } value = m_obdInterface.getValue(parameter.GetFreezeFrameCopy(m_FrameNumber), true); if (!value.ErrorDetected) { freezeFrame.IntakePressure = value.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_KeepReading) { break; } parameter = m_obdInterface.LookupParameter("SAE.RPM"); if (parameter == null) { break; } value = m_obdInterface.getValue(parameter.GetFreezeFrameCopy(m_FrameNumber), true); if (!value.ErrorDetected) { freezeFrame.EngineRPM = value.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_KeepReading) { break; } parameter = m_obdInterface.LookupParameter("SAE.VSS"); if (parameter == null) { break; } value = m_obdInterface.getValue(parameter.GetFreezeFrameCopy(m_FrameNumber), true); if (!value.ErrorDetected) { freezeFrame.VehicleSpeed = value.DoubleValue; } progressBar.Increment(progressBar.Step); if (!m_KeepReading) { break; } parameter = m_obdInterface.LookupParameter("SAE.SPARKADV"); if (parameter == null) { break; } value = m_obdInterface.getValue(parameter.GetFreezeFrameCopy(m_FrameNumber), true); if (!value.ErrorDetected) { freezeFrame.SparkAdvance = value.DoubleValue; } break; } progressBar.Value = progressBar.Maximum; btnRefresh.Enabled = true; btnCancel.Enabled = false; }
private void UpdateThread(object sender) { if (!m_RunThread) { return; } do { if (m_obdInterface.ConnectedStatus && IsWorking) { OBDParameterValue sae_maf = m_obdInterface.getValue("SAE.MAF", false); OBDParameterValue sae_vss = m_obdInterface.getValue("SAE.VSS", false); if (!sae_maf.ErrorDetected && !sae_vss.ErrorDetected) { double sae_vss_double = sae_vss.DoubleValue; double speed_miles = sae_vss_double * 0.621371192; double fuel_liters_hour = ((sae_maf.DoubleValue * 0.068027210884353748) * 3600.0) * 0.0013020833333333333; double fuel_gallons_hour = fuel_liters_hour * 0.264172052; DateTime now = DateTime.Now; double hours_start = now.Subtract(m_FuelEconomyForm.m_StartTime).TotalSeconds * 0.00027777777777777778; double hours_prev = now.Subtract(m_FuelEconomyForm.m_PrevTime).TotalSeconds * 0.00027777777777777778; m_FuelEconomyForm.m_PrevTime = now; if (m_FuelEconomyForm.radioEnglishUnits.Checked) { m_FuelEconomyForm.sensorInstantFuelConsumption.EnglishDisplay = fuel_gallons_hour.ToString("0.000") + " gallons/hour"; m_FuelEconomyForm.m_TotalFuelConsumption += hours_prev * fuel_gallons_hour; double total = m_FuelEconomyForm.m_TotalFuelConsumption; sensorTotalConsumed.EnglishDisplay = total.ToString("0.00") + " gallons"; m_FuelEconomyForm.sensorAvgFuelConsumption.EnglishDisplay = ((m_FuelEconomyForm.m_TotalFuelConsumption / hours_start)).ToString("0.00") + " gallons/hour"; m_FuelEconomyForm.m_TotalDistance += hours_prev * speed_miles; m_FuelEconomyForm.sensorDistance.EnglishDisplay = m_TotalDistance.ToString("0.00") + " miles"; m_FuelEconomyForm.sensorInstantFuelEconomy.EnglishDisplay = (((1.0 / fuel_gallons_hour) * speed_miles)).ToString("0.00") + " miles/gallon"; double miles_gallon = 0.0; if (m_FuelEconomyForm.m_TotalDistance > 0.0) { miles_gallon = m_FuelEconomyForm.m_TotalDistance / m_FuelEconomyForm.m_TotalFuelConsumption; } m_FuelEconomyForm.sensorAvgFuelEconomy.EnglishDisplay = miles_gallon.ToString("0.00") + " miles/gallon"; double cost_per_mile = 0.0; if (miles_gallon > 0.0) { cost_per_mile = ((double)numericFuelCost.Value) * (1.0 / miles_gallon); } m_FuelEconomyForm.sensorCostPerMile.Title = "Average Cost Per Mile"; m_FuelEconomyForm.sensorCostPerMile.EnglishDisplay = "$" + cost_per_mile.ToString("0.00"); m_FuelEconomyForm.sensorTotalCost.EnglishDisplay = "$" + ((((double)numericFuelCost.Value) * m_TotalFuelConsumption)).ToString("0.00"); } else { m_FuelEconomyForm.sensorInstantFuelConsumption.EnglishDisplay = fuel_liters_hour.ToString("0.000") + " liters/hour"; m_FuelEconomyForm.m_TotalFuelConsumption += hours_prev * fuel_liters_hour; double total = m_FuelEconomyForm.m_TotalFuelConsumption; sensorTotalConsumed.EnglishDisplay = total.ToString("0.00") + " liters"; m_FuelEconomyForm.sensorAvgFuelConsumption.EnglishDisplay = ((m_FuelEconomyForm.m_TotalFuelConsumption / hours_start)).ToString("0.00") + " liters/hour"; m_FuelEconomyForm.m_TotalDistance += hours_prev * sae_vss_double; m_FuelEconomyForm.sensorDistance.EnglishDisplay = m_TotalDistance.ToString("0.00") + " kilometers"; m_FuelEconomyForm.sensorInstantFuelEconomy.EnglishDisplay = (((1.0 / fuel_liters_hour) * sae_vss_double)).ToString("0.00") + " kilometers/liter"; double kilometers_liter = 0.0; if (m_FuelEconomyForm.m_TotalDistance > 0.0) { kilometers_liter = m_FuelEconomyForm.m_TotalDistance / m_FuelEconomyForm.m_TotalFuelConsumption; } m_FuelEconomyForm.sensorAvgFuelEconomy.EnglishDisplay = kilometers_liter.ToString("0.00") + " kilometers/liter"; double cost_per_kilometer = 0.0; if (kilometers_liter > 0.0) { cost_per_kilometer = ((double)numericFuelCost.Value) * (1.0 / kilometers_liter); } m_FuelEconomyForm.sensorCostPerMile.Title = "Average Cost Per Kilometer"; m_FuelEconomyForm.sensorCostPerMile.EnglishDisplay = cost_per_kilometer.ToString("0.00"); m_FuelEconomyForm.sensorTotalCost.EnglishDisplay = (((double)numericFuelCost.Value) * m_TotalFuelConsumption).ToString("0.00"); } } } else { Thread.Sleep(300); } }while (m_RunThread); }
public void ReadCodes() { arrayListDTC.Clear(); arrayListPending.Clear(); arrayListPermanent.Clear(); OBDParameterValue value6 = m_obdInterface.getValue("SAE.MIL", true); if (!value6.ErrorDetected) { SetMilStatus(value6.BoolValue); } OBDParameterValue value5 = m_obdInterface.getValue("SAE.DTC_COUNT", true); if (!value5.ErrorDetected) { SetDTCTotal((int)value5.DoubleValue); } OBDParameterValue value4 = m_obdInterface.getValue("SAE.STORED_DTCS", true); if (!value4.ErrorDetected) { StringEnumerator enumerator3 = value4.StringCollectionValue.GetEnumerator(); if (enumerator3.MoveNext()) { do { string current = enumerator3.Current; DTC dtc3 = m_obdInterface.getDTC(current); arrayListDTC.Add(dtc3); }while (enumerator3.MoveNext()); } } OBDParameterValue value3 = m_obdInterface.getValue("SAE.PENDING_DTCS", true); if (!value3.ErrorDetected) { StringEnumerator enumerator2 = value3.StringCollectionValue.GetEnumerator(); if (enumerator2.MoveNext()) { do { string strDTC = enumerator2.Current; DTC dtc2 = m_obdInterface.getDTC(strDTC); arrayListPending.Add(dtc2); }while (enumerator2.MoveNext()); } } OBDParameterValue value2 = m_obdInterface.getValue("SAE.PERMANENT_DTCS", true); if (!value2.ErrorDetected) { StringEnumerator enumerator = value2.StringCollectionValue.GetEnumerator(); if (enumerator.MoveNext()) { do { string str = enumerator.Current; DTC dtc = m_obdInterface.getDTC(str); arrayListPermanent.Add(dtc); }while (enumerator.MoveNext()); } } }