public void UpdateThread() { if (!IsPlotting) { return; } do { if (m_obdInterface.ConnectedStatus) { if (sensorsEnable[0]) { OBDParameterValue obdParameterValue = m_obdInterface.GetValue(comboSensor1.Items[sensorsIndex[0]] as OBDParameter, unitsIndex[0] == 0); if (!obdParameterValue.ErrorDetected) { m_arraySensorValues[0].Add(new DatedValue(obdParameterValue.DoubleValue)); UpdateChart(0, chart1); } } if (sensorsEnable[1]) { OBDParameterValue obdParameterValue = m_obdInterface.GetValue(comboSensor2.Items[sensorsIndex[1]] as OBDParameter, unitsIndex[1] == 0); if (!obdParameterValue.ErrorDetected) { m_arraySensorValues[1].Add(new DatedValue(obdParameterValue.DoubleValue)); UpdateChart(1, chart2); } } if (sensorsEnable[2]) { OBDParameterValue obdParameterValue = m_obdInterface.GetValue(comboSensor3.Items[sensorsIndex[2]] as OBDParameter, unitsIndex[2] == 0); if (!obdParameterValue.ErrorDetected) { m_arraySensorValues[2].Add(new DatedValue(obdParameterValue.DoubleValue)); UpdateChart(2, chart3); } } if (sensorsEnable[3]) { OBDParameterValue obdParameterValue = m_obdInterface.GetValue(comboSensor4.Items[sensorsIndex[3]] as OBDParameter, unitsIndex[3] == 0); if (!obdParameterValue.ErrorDetected) { m_arraySensorValues[3].Add(new DatedValue(obdParameterValue.DoubleValue)); UpdateChart(3, chart4); } } } else { Thread.Sleep(300); } } while (IsPlotting); }
private void UpdateThread() { 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); this.Invoke((EventHandler) delegate { scrollTime.Maximum = m_ListLog.Count - 1; scrollTime.Value = scrollTime.Maximum; }); DateTime dateTime = new DateTime(0L); this.Invoke((EventHandler) delegate { 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); } } }
public List <OBDParameterValue> GetValueList(OBDParameter param, bool bEnglishUnits = false) { List <OBDParameterValue> ValueList = new List <OBDParameterValue>(); if (param.PID.Length > 0) { m_log.TraceInfo("Requesting: " + param.PID); } else { m_log.TraceInfo("Requesting: " + param.OBDRequest); } OBDResponseList responses = m_obdDevice.Query(param); string strItem = "Responses: "; if (responses.ErrorDetected) { strItem += "Error Detected!"; OBDParameterValue value = new OBDParameterValue { ErrorDetected = true, StringValue = "Error Detected in OBDResponseList!", ShortStringValue = "ERROR_RESP" }; ValueList.Add(value); m_log.TraceInfo(strItem); return(ValueList); } else { for (int i = 0; i < responses.ResponseCount; i++) { strItem += string.Format("[{0}] ", responses.GetOBDResponse(i).Data); } strItem = strItem.TrimEnd(); m_log.TraceInfo(strItem); } for (int i = 0; i < responses.ResponseCount; i++) { OBDParameterValue obdValue = m_obdInterpreter.GetValue(param, responses.GetOBDResponse(i), bEnglishUnits); if (obdValue.ErrorDetected) { m_log.TraceError("Error Detected in OBDParameterValue!"); } else { m_log.TraceInfo(GetLogString(param, obdValue)); } ValueList.Add(obdValue); } return(ValueList); }
public OBDParameterValue GetValue(string strPID, bool bEnglishUnits = false) { OBDParameter obdParameter = LookupParameter(strPID); if (obdParameter != null) { return(GetValue(obdParameter, bEnglishUnits)); } OBDParameterValue value = new OBDParameterValue { ErrorDetected = true }; return(value); }
public OBDParameterValue GetValue(OBDParameter param, bool bEnglishUnits = false) { if (param.PID.Length > 0) { m_log.TraceInfo("Requesting: " + param.PID); } else { m_log.TraceInfo("Requesting: " + param.OBDRequest); } if (param.Service == 0) { return(SpecialValue(param)); } OBDResponseList responses = m_obdDevice.Query(param); string strItem = "Responses: "; if (responses.ErrorDetected) { strItem += "Error Detected!"; m_log.TraceInfo(strItem); return(new OBDParameterValue { ErrorDetected = true }); } else { for (int i = 0; i < responses.ResponseCount; i++) { strItem += string.Format("[{0}] ", responses.GetOBDResponse(i).Data); } } m_log.TraceInfo(strItem); OBDParameterValue obdValue = m_obdInterpreter.GetValue(param, responses, bEnglishUnits); if (obdValue.ErrorDetected) { m_log.TraceError("Error Detected in OBDParameterValue!"); } else { m_log.TraceInfo(GetLogString(param, obdValue)); } return(obdValue); }
public OBDParameterValue SpecialValue(OBDParameter param) { if (param.Parameter != 0) { return(null); } OBDParameterValue value = new OBDParameterValue(); string respopnse = GetRawResponse("ATRV"); m_log.TraceInfo("Response of \"ATRV\": " + respopnse); if (respopnse != null) { respopnse = respopnse.Replace("V", ""); value.DoubleValue = Utility.Text2Double(respopnse); } return(value); }
private string GetLogString(OBDParameter param, OBDParameterValue obdValue) { string strRet = "Values: "; if ((param.ValueTypes & (int)OBDParameter.EnumValueTypes.Double) == (int)OBDParameter.EnumValueTypes.Double) { strRet += string.Format("[Double: {0}] ", obdValue.DoubleValue.ToString()); } if ((param.ValueTypes & (int)OBDParameter.EnumValueTypes.Bool) == (int)OBDParameter.EnumValueTypes.Bool) { strRet += string.Format("[Bool: {0}] ", obdValue.BoolValue.ToString()); } if ((param.ValueTypes & (int)OBDParameter.EnumValueTypes.String) == (int)OBDParameter.EnumValueTypes.String) { strRet += string.Format("[String: {0}] ", obdValue.StringValue, obdValue.ShortStringValue); } if ((param.ValueTypes & (int)OBDParameter.EnumValueTypes.ListString) == (int)OBDParameter.EnumValueTypes.ListString) { strRet += "[ListString: "; foreach (string strx in obdValue.ListStringValue) { strRet = string.Concat(strRet, strx + ", "); } strRet = strRet.Substring(0, strRet.Length - 2); strRet += "]"; } if ((param.ValueTypes & (int)OBDParameter.EnumValueTypes.ShortString) == (int)OBDParameter.EnumValueTypes.ShortString) { strRet += string.Format("[ShortString: {0}] ", obdValue.ShortStringValue); } if ((param.ValueTypes & (int)OBDParameter.EnumValueTypes.BitFlags) == (int)OBDParameter.EnumValueTypes.BitFlags) { strRet += "[BitFlags: "; for (int idx = 0; idx < 32; idx++) { strRet += (obdValue.GetBitFlag(idx) ? "1" : "0"); } strRet += "]"; } return(strRet); }
private new void Capture() { m_KphValues = new List <DatedValue>(); while (m_bCapture) { OBDParameterValue obdParameterValue = m_obdInterface.GetValue("SAE.VSS"); if (!obdParameterValue.ErrorDetected && obdParameterValue.DoubleValue > 0.0) { if (m_KphValues.Count == 0) { this.BeginInvoke((EventHandler) delegate { StartTimer(); }); } m_KphValues.Add(new DatedValue(obdParameterValue.DoubleValue * m_obdInterface.ActiveProfile.SpeedCalibrationFactor)); this.CalculateTimeslip(); } } this.BeginInvoke((EventHandler) delegate { StopTimer(); btnOpen.Enabled = true; }); }
private void UpdateThread() { 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(this.m_StartTime).TotalSeconds * 0.00027777777777777778; double hours_prev = now.Subtract(this.m_PrevTime).TotalSeconds * 0.00027777777777777778; this.m_PrevTime = now; if (this.radioEnglishUnits.Checked) { this.sensorInstantFuelConsumption.EnglishDisplay = fuel_gallons_hour.ToString("0.000") + " 加仑 / 小时"; this.m_TotalFuelConsumption += hours_prev * fuel_gallons_hour; double total = this.m_TotalFuelConsumption; sensorTotalConsumed.EnglishDisplay = total.ToString("0.00") + " 加仑"; this.sensorAvgFuelConsumption.EnglishDisplay = ((this.m_TotalFuelConsumption / hours_start)).ToString("0.00") + " 加仑 / 小时"; this.m_TotalDistance += hours_prev * speed_miles; this.sensorDistance.EnglishDisplay = m_TotalDistance.ToString("0.00") + " 英里"; this.sensorInstantFuelEconomy.EnglishDisplay = (((1.0 / fuel_gallons_hour) * speed_miles)).ToString("0.00") + " 英里 / 加仑"; double miles_gallon = 0.0; if (this.m_TotalDistance > 0.0) { miles_gallon = this.m_TotalDistance / this.m_TotalFuelConsumption; } this.sensorAvgFuelEconomy.EnglishDisplay = miles_gallon.ToString("0.00") + " 英里 / 加仑"; double cost_per_mile = 0.0; if (miles_gallon > 0.0) { cost_per_mile = ((double)numericFuelCost.Value) * (1.0 / miles_gallon); } this.sensorCostPerMile.Title = "每英里的平均成本"; this.sensorCostPerMile.EnglishDisplay = "$" + cost_per_mile.ToString("0.00"); this.sensorTotalCost.EnglishDisplay = "$" + ((((double)numericFuelCost.Value) * m_TotalFuelConsumption)).ToString("0.00"); } else { this.sensorInstantFuelConsumption.EnglishDisplay = fuel_liters_hour.ToString("0.000") + " 升 / 小时"; this.m_TotalFuelConsumption += hours_prev * fuel_liters_hour; double total = this.m_TotalFuelConsumption; sensorTotalConsumed.EnglishDisplay = total.ToString("0.00") + " 升"; this.sensorAvgFuelConsumption.EnglishDisplay = ((this.m_TotalFuelConsumption / hours_start)).ToString("0.00") + " 升 / 小时"; this.m_TotalDistance += hours_prev * sae_vss_double; this.sensorDistance.EnglishDisplay = m_TotalDistance.ToString("0.00") + " 千米"; this.sensorInstantFuelEconomy.EnglishDisplay = (((1.0 / fuel_liters_hour) * sae_vss_double)).ToString("0.00") + " 千米 / 升"; double kilometers_liter = 0.0; if (this.m_TotalDistance > 0.0) { kilometers_liter = this.m_TotalDistance / this.m_TotalFuelConsumption; } this.sensorAvgFuelEconomy.EnglishDisplay = kilometers_liter.ToString("0.00") + " 千米 / 升"; double cost_per_kilometer = 0.0; if (kilometers_liter > 0.0) { cost_per_kilometer = ((double)numericFuelCost.Value) * (1.0 / kilometers_liter); } this.sensorCostPerMile.Title = "每千米的平均成本"; this.sensorCostPerMile.EnglishDisplay = cost_per_kilometer.ToString("0.00"); this.sensorTotalCost.EnglishDisplay = (((double)numericFuelCost.Value) * m_TotalFuelConsumption).ToString("0.00"); } } } else { Thread.Sleep(300); } } while (m_RunThread); }
public void UpdateTests() { progressBar.Minimum = 0; progressBar.Maximum = 35; OBDParameterValue value; value = m_obdInterface.GetValue("SAE.MISFIRE_SUPPORT"); progressBar.Value = 1; TestStatus status = m_ListConTests[0]; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "不适用"; } else { value = m_obdInterface.GetValue("SAE.MISFIRE_STATUS"); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "完成" : "未完成"; } else { status.Status = "出错"; } } } else { status.Status = "出错"; } value = m_obdInterface.GetValue("SAE.FUEL_SUPPORT"); progressBar.Value = 2; status = m_ListConTests[1]; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "不适用"; } else { value = m_obdInterface.GetValue("SAE.FUEL_STATUS"); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "完成" : "未完成"; } else { status.Status = "出错"; } } } else { status.Status = "出错"; } value = m_obdInterface.GetValue("SAE.CCM_SUPPORT"); progressBar.Value = 3; status = m_ListConTests[2]; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "不适用"; } else { value = m_obdInterface.GetValue("SAE.CCM_STATUS"); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "完成" : "未完成"; } else { status.Status = "出错"; } } } else { status.Status = "出错"; } gridConTests.Refresh(); value = m_obdInterface.GetValue("SAE.CAT_SUPPORT"); progressBar.Value = 4; status = m_ListNonConTests[0]; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "不适用"; } else { value = m_obdInterface.GetValue("SAE.CAT_STATUS"); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "完成" : "未完成"; } else { status.Status = "出错"; } } } else { status.Status = "出错"; } value = m_obdInterface.GetValue("SAE.HCAT_SUPPORT"); progressBar.Value = 5; status = m_ListNonConTests[1]; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "不适用"; } else { value = m_obdInterface.GetValue("SAE.HCAT_STATUS"); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "完成" : "未完成"; } else { status.Status = "出错"; } } } else { status.Status = "出错"; } value = m_obdInterface.GetValue("SAE.EVAP_SUPPORT"); progressBar.Value = 6; status = m_ListNonConTests[2]; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "不适用"; } else { value = m_obdInterface.GetValue("SAE.EVAP_STATUS"); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "完成" : "未完成"; } else { status.Status = "出错"; } } } else { status.Status = "出错"; } value = m_obdInterface.GetValue("SAE.AIR_SUPPORT"); progressBar.Value = 7; status = m_ListNonConTests[3]; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "不适用"; } else { value = m_obdInterface.GetValue("SAE.AIR_STATUS"); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "完成" : "未完成"; } else { status.Status = "出错"; } } } else { status.Status = "出错"; } value = m_obdInterface.GetValue("SAE.AC_SUPPORT"); progressBar.Value = 8; status = m_ListNonConTests[4]; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "不适用"; } else { value = m_obdInterface.GetValue("SAE.AC_STATUS"); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "完成" : "未完成"; } else { status.Status = "出错"; } } } else { status.Status = "出错"; } value = m_obdInterface.GetValue("SAE.O2_SUPPORT"); progressBar.Value = 9; status = m_ListNonConTests[5]; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "不适用"; } else { value = m_obdInterface.GetValue("SAE.O2_STATUS"); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "完成" : "未完成"; } else { status.Status = "出错"; } } } else { status.Status = "出错"; } value = m_obdInterface.GetValue("SAE.O2HTR_SUPPORT"); progressBar.Value = 10; status = m_ListNonConTests[6]; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "不适用"; } else { value = m_obdInterface.GetValue("SAE.O2HTR_STATUS"); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "完成" : "未完成"; } else { status.Status = "出错"; } } } else { status.Status = "出错"; } value = m_obdInterface.GetValue("SAE.EGR_SUPPORT"); progressBar.Value = 11; status = m_ListNonConTests[7]; if (!value.ErrorDetected) { if (!value.BoolValue) { status.Status = "不适用"; } else { value = m_obdInterface.GetValue("SAE.EGR_STATUS"); if (!value.ErrorDetected) { status.Status = value.BoolValue ? "完成" : "未完成"; } else { status.Status = "出错"; } } } else { status.Status = "出错"; } gridNonConTests.Refresh(); if (m_obdInterface.IsParameterSupported("SAE.FUEL1_STATUS")) { value = m_obdInterface.GetValue("SAE.FUEL1_STATUS"); progressBar.Value++; lblFuel1.Text = value.ErrorDetected ? "出错" : value.StringValue; } else { lblFuel1.Text = "不适用"; } if (m_obdInterface.IsParameterSupported("SAE.FUEL2_STATUS")) { value = m_obdInterface.GetValue("SAE.FUEL2_STATUS"); progressBar.Value++; lblFuel2.Text = value.ErrorDetected ? "出错" : value.StringValue; } else { lblFuel2.Text = "不适用"; } if (m_obdInterface.IsParameterSupported("SAE.PTO_STATUS")) { value = m_obdInterface.GetValue("SAE.PTO_STATUS"); progressBar.Value++; lblPTO.Text = value.ErrorDetected ? "出错" : value.StringValue; } else { lblPTO.Text = "不适用"; } if (m_obdInterface.IsParameterSupported("SAE.SECAIR_STATUS")) { value = m_obdInterface.GetValue("SAE.SECAIR_STATUS"); progressBar.Value++; lblAir.Text = value.ErrorDetected ? "出错" : value.StringValue; } else { lblAir.Text = "不适用"; } if (m_obdInterface.IsParameterSupported("SAE.OBD_TYPE")) { value = m_obdInterface.GetValue("SAE.OBD_TYPE"); progressBar.Value++; lblOBD.Text = value.ErrorDetected ? "出错" : value.StringValue; } else { lblOBD.Text = "不适用"; } string strContent = ""; OBDParameter param = new OBDParameter { OBDRequest = "0902", Service = 9, Parameter = 2, ValueTypes = (int)OBDParameter.EnumValueTypes.ListString }; OBDParameterValue val = m_obdInterface.GetValue(param); progressBar.Value++; strContent += "VIN:"; foreach (string item in val.ListStringValue) { strContent += "\n" + item; } param.OBDRequest = "0904"; val = m_obdInterface.GetValue(param); progressBar.Value++; strContent += "\n\nCAL ID:"; foreach (string item in val.ListStringValue) { strContent += "\n" + item; } param.OBDRequest = "0906"; val = m_obdInterface.GetValue(param); progressBar.Value++; strContent += "\n\nCVN:"; foreach (string item in val.ListStringValue) { strContent += "\n" + item; } //param.OBDRequest = "0908"; //param.SubParameter = 0; //val = m_obdInterface.GetValue(param); //progressBar.Value++; //strContent += "\n\nIPT:"; //strContent += "\n" + val.DoubleValue; ////foreach (string item in val.ListStringValue) { //// strContent += "," + Utility.Hex2Int(item); ////} param.OBDRequest = "090A"; val = m_obdInterface.GetValue(param); progressBar.Value++; strContent += "\n\nECU名称:"; foreach (string item in val.ListStringValue) { strContent += "\n" + item; } lblVehicleInfo.Text = strContent; progressBar.Value++; /*string strContent = ""; * string strHeader; * int counter; * * if (m_obd2Interface.IsParameterSupported("SAE.O2B1S1A_PRESENT")) { * strHeader = "PID $13 Bank 1: "; * strContent += strHeader; * counter = 0; * value = m_obd2Interface.GetValue("SAE.O2B1S1A_PRESENT"); * progressBar.Value++; * if (!value.ErrorDetected && value.BoolValue) { * strContent += "传感器 1, "; ++counter; * } * * value = m_obd2Interface.GetValue("SAE.O2B1S2A_PRESENT"); * progressBar.Value++; * if (!value.ErrorDetected && value.BoolValue) { * strContent += "传感器 2, "; ++counter; * } * * value = m_obd2Interface.GetValue("SAE.O2B1S3A_PRESENT"); * progressBar.Value++; * if (!value.ErrorDetected && value.BoolValue) { * strContent += "传感器 3, "; ++counter; * } * * value = m_obd2Interface.GetValue("SAE.O2B1S4A_PRESENT"); * progressBar.Value++; * if (!value.ErrorDetected && value.BoolValue) { * strContent += "传感器 4, "; ++counter; * } * if (counter == 0) { * strContent = strContent.Substring(0, strContent.Length - strHeader.Length); * } else { * strContent = strContent.Substring(0, strContent.Length - 2); * } * * strHeader = "\n\r\nPID $13 Bank 2: "; * strContent += strHeader; * counter = 0; * value = m_obd2Interface.GetValue("SAE.O2B2S1A_PRESENT"); * progressBar.Value++; * if (!value.ErrorDetected && value.BoolValue) { * strContent += "传感器 1, "; ++counter; * } * * value = m_obd2Interface.GetValue("SAE.O2B2S2A_PRESENT"); * progressBar.Value++; * if (!value.ErrorDetected && value.BoolValue) { * strContent += "传感器 2, "; ++counter; * } * * value = m_obd2Interface.GetValue("SAE.O2B2S3A_PRESENT"); * progressBar.Value++; * if (!value.ErrorDetected && value.BoolValue) { * strContent += "传感器 3, "; ++counter; * } * * value = m_obd2Interface.GetValue("SAE.O2B2S4A_PRESENT"); * progressBar.Value++; * if (!value.ErrorDetected && value.BoolValue) { * strContent += "传感器 4, "; ++counter; * } * if (counter == 0) { * strContent = strContent.Substring(0, strContent.Length - strHeader.Length); * } else { * strContent = strContent.Substring(0, strContent.Length - 2); * } * } * * if (m_obd2Interface.IsParameterSupported("SAE.O2B1S1B_PRESENT")) { * strHeader = "\n\r\nPID $1D Bank 1: "; * strContent += strHeader; * counter = 0; * value = m_obd2Interface.GetValue("SAE.O2B1S1B_PRESENT"); * progressBar.Value++; * if (!value.ErrorDetected && value.BoolValue) { * strContent += "传感器 1, "; ++counter; * } * * value = m_obd2Interface.GetValue("SAE.O2B1S2B_PRESENT"); * progressBar.Value++; * if (!value.ErrorDetected && value.BoolValue) { * strContent += "传感器 2, "; ++counter; * } * if (counter == 0) { * strContent = strContent.Substring(0, strContent.Length - strHeader.Length); * } else { * strContent = strContent.Substring(0, strContent.Length - 2); * } * * strHeader = "\n\r\nPID $1D Bank 2: "; * strContent += strHeader; * counter = 0; * value = m_obd2Interface.GetValue("SAE.O2B2S1B_PRESENT"); * progressBar.Value++; * if (!value.ErrorDetected && value.BoolValue) { * strContent += "传感器 1, "; ++counter; * } * * value = m_obd2Interface.GetValue("SAE.O2B2S2B_PRESENT"); * progressBar.Value++; * if (!value.ErrorDetected && value.BoolValue) { * strContent += "传感器 2, "; ++counter; * } * if (counter == 0) { * strContent = strContent.Substring(0, strContent.Length - strHeader.Length); * } else { * strContent = strContent.Substring(0, strContent.Length - 2); * } * * strHeader = "\n\r\nPID $1D Bank 3: "; * strContent += strHeader; * counter = 0; * value = m_obd2Interface.GetValue("SAE.O2B3S1B_PRESENT"); * progressBar.Value++; * if (!value.ErrorDetected && value.BoolValue) { * strContent += "传感器 1, "; ++counter; * } * * value = m_obd2Interface.GetValue("SAE.O2B3S2B_PRESENT"); * progressBar.Value++; * if (!value.ErrorDetected && value.BoolValue) { * strContent += "传感器 2, "; ++counter; * } * if (counter == 0) { * strContent = strContent.Substring(0, strContent.Length - strHeader.Length); * } else { * strContent = strContent.Substring(0, strContent.Length - 2); * } * * strHeader = "\n\r\nPID $1D Bank 4: "; * strContent += strHeader; * counter = 0; * value = m_obd2Interface.GetValue("SAE.O2B4S1B_PRESENT"); * progressBar.Value++; * if (!value.ErrorDetected && value.BoolValue) { * strContent += "传感器 1, "; ++counter; * } * * value = m_obd2Interface.GetValue("SAE.O2B4S2B_PRESENT"); * progressBar.Value++; * if (!value.ErrorDetected && value.BoolValue) { * strContent += "传感器 2, "; ++counter; * } * if (counter == 0) { * strContent = strContent.Substring(0, strContent.Length - strHeader.Length); * } else { * strContent = strContent.Substring(0, strContent.Length - 2); * } * }*/ if (m_obdInterface.GetDevice() == HardwareType.ELM327) { value = m_obdInterface.GetValue("ELM.BATTERY_VOLTAGE"); if (!value.ErrorDetected) { lblBattery.Text = value.DoubleValue.ToString() + " V"; } } else { lblBattery.Text = "不适用"; } progressBar.Value = progressBar.Maximum; }
private void ReadFreezeFrameData() { while (true) { this.BeginInvoke(new Action(() => { freezeFrame.Reset(); })); OBDParameter parameter = m_obdInterface.LookupParameter("SAE.FF_DTC"); if (parameter == null) { MessageBox.Show( "加载SAE.FF_DTC参数时发生错误", "出错", MessageBoxButtons.OK, MessageBoxIcon.Hand ); break; } OBDParameterValue value = m_obdInterface.GetValue(parameter.GetFreezeFrameCopy(m_FrameNumber)); if (value.ErrorDetected) { m_obdInterface.GetLogger().TraceError("Error while requesting SAE.FF_DTC"); MessageBox.Show( "请求SAE.FF_DTC命令时发生错误", "出错", MessageBoxButtons.OK, MessageBoxIcon.Hand ); break; } if (string.Compare(value.StringValue, "P0000") == 0) { MessageBox.Show( string.Format("在 #{0} 帧中,没有发现冻结帧信息", m_FrameNumber), "信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk ); break; } this.BeginInvoke(new Action(() => { 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)); if (!value.ErrorDetected) { this.BeginInvoke(new Action(() => { freezeFrame.FuelSystem1Status = value.StringValue; })); } parameter = m_obdInterface.LookupParameter("SAE.FUEL2_STATUS"); if (parameter == null) { break; } value = m_obdInterface.GetValue(parameter.GetFreezeFrameCopy(m_FrameNumber)); if (!value.ErrorDetected) { this.BeginInvoke(new Action(() => { freezeFrame.FuelSystem2Status = value.StringValue; })); } this.BeginInvoke(new Action(() => { 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)); if (!value.ErrorDetected) { this.BeginInvoke(new Action(() => { freezeFrame.CalculatedLoad = value.DoubleValue; })); } this.BeginInvoke(new Action(() => { 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)); if (!value.ErrorDetected) { this.BeginInvoke(new Action(() => { freezeFrame.EngineCoolantTemp = value.DoubleValue; })); } this.BeginInvoke(new Action(() => { 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)); if (!value.ErrorDetected) { this.BeginInvoke(new Action(() => { freezeFrame.STFT1 = value.DoubleValue; })); } parameter = m_obdInterface.LookupParameter("SAE.STFT3"); if (parameter == null) { break; } value = m_obdInterface.GetValue(parameter.GetFreezeFrameCopy(m_FrameNumber)); if (!value.ErrorDetected) { this.BeginInvoke(new Action(() => { freezeFrame.STFT3 = value.DoubleValue; })); } this.BeginInvoke(new Action(() => { 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)); if (!value.ErrorDetected) { this.BeginInvoke(new Action(() => { freezeFrame.LTFT1 = value.DoubleValue; })); } parameter = m_obdInterface.LookupParameter("SAE.LTFT3"); if (parameter == null) { break; } value = m_obdInterface.GetValue(parameter.GetFreezeFrameCopy(m_FrameNumber)); if (!value.ErrorDetected) { this.BeginInvoke(new Action(() => { freezeFrame.LTFT3 = value.DoubleValue; })); } this.BeginInvoke(new Action(() => { 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)); if (!value.ErrorDetected) { this.BeginInvoke(new Action(() => { freezeFrame.STFT2 = value.DoubleValue; })); } parameter = m_obdInterface.LookupParameter("SAE.STFT4"); if (parameter == null) { break; } value = m_obdInterface.GetValue(parameter.GetFreezeFrameCopy(m_FrameNumber)); if (!value.ErrorDetected) { this.BeginInvoke(new Action(() => { freezeFrame.STFT4 = value.DoubleValue; })); } this.BeginInvoke(new Action(() => { 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)); if (!value.ErrorDetected) { this.BeginInvoke(new Action(() => { freezeFrame.LTFT2 = value.DoubleValue; })); } parameter = m_obdInterface.LookupParameter("SAE.LTFT4"); if (parameter == null) { break; } value = m_obdInterface.GetValue(parameter.GetFreezeFrameCopy(m_FrameNumber)); if (!value.ErrorDetected) { this.BeginInvoke(new Action(() => { freezeFrame.LTFT4 = value.DoubleValue; })); } this.BeginInvoke(new Action(() => { 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)); if (!value.ErrorDetected) { this.BeginInvoke(new Action(() => { freezeFrame.IntakePressure = value.DoubleValue; })); } this.BeginInvoke(new Action(() => { 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)); if (!value.ErrorDetected) { this.BeginInvoke(new Action(() => { freezeFrame.EngineRPM = value.DoubleValue; })); } this.BeginInvoke(new Action(() => { 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)); if (!value.ErrorDetected) { this.BeginInvoke(new Action(() => { freezeFrame.VehicleSpeed = value.DoubleValue; })); } this.BeginInvoke(new Action(() => { 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)); if (!value.ErrorDetected) { this.BeginInvoke(new Action(() => { freezeFrame.SparkAdvance = value.DoubleValue; })); } break; } this.BeginInvoke(new Action(() => { progressBar.Value = progressBar.Maximum; btnRefresh.Enabled = true; btnCancel.Enabled = false; })); }
public bool InitOBD() { bool bRet = true; // 获取ISO15031 Mode01 PID支持情况 OBDParameter param = new OBDParameter(1, 0, 0) { ValueTypes = 32 }; m_listSupportedParameters.Clear(); for (int i = 0; (i * 0x20) < 0x100; i++) { param.Parameter = i * 0x20; OBDParameterValue value = GetValue(param); if (value.ErrorDetected) { bRet = false; break; } foreach (OBDParameter param2 in m_listAllParameters) { if (param2.Parameter > 2 && param2.Parameter > (i * 0x20) && param2.Parameter < ((i + 1) * 0x20) && value.GetBitFlag(param2.Parameter - param.Parameter - 1)) { m_listSupportedParameters.Add(param2); } } if (!value.GetBitFlag(31)) { break; } } if (!bRet) { // 获取ISO27145 PID支持情况 bRet = true; param = new OBDParameter(0x22, 0, 0) { ValueTypes = 32 }; m_listSupportedParameters.Clear(); for (int i = 0; (i * 0x20) < 0x100; i++) { param.Parameter = 0xF400 + i * 0x20; OBDParameterValue value = GetValue(param); if (value.ErrorDetected) { bRet = false; break; } foreach (OBDParameter param2 in m_listAllParameters) { if (param2.Parameter > 2 && param2.Parameter > (i * 0x20) && param2.Parameter < ((i + 1) * 0x20) && value.GetBitFlag(param2.Parameter - param.Parameter - 1)) { m_listSupportedParameters.Add(param2); } } if (!value.GetBitFlag(31)) { break; } } UseISO27145 = bRet; m_log.TraceInfo("Current vehicle support ISO 27145 only!"); } return(bRet); }
private void CollectData() { DisplayStatusMessage("请求MIL状态和故障码数量"); DisplayRequest("0101"); OBDParameterValue value5 = m_obdInterface.GetValue("SAE.MIL"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value5.ErrorDetected) { if (value5.BoolValue) { DisplayDetailMessage("MIL状态: On"); m_bReportForm.ReportPage1.MilStatus = true; } else { DisplayDetailMessage("MIL状态: Off"); m_bReportForm.ReportPage1.MilStatus = false; } } OBDParameterValue value3 = m_obdInterface.GetValue("SAE.DTC_COUNT"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value3.ErrorDetected) { m_bReportForm.ReportPage1.TotalCodes = (int)value3.DoubleValue; DisplayDetailMessage("存储的故障码数量: " + value3.DoubleValue.ToString()); } DisplayStatusMessage("请求存储的故障码列表"); OBDParameterValue value4 = m_obdInterface.GetValue("SAE.STORED_DTCS"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value4.ErrorDetected) { m_bReportForm.ReportPage1.DTCList.Clear(); foreach (string strVal in value4.ListStringValue) { m_bReportForm.ReportPage1.DTCList.Add(strVal); DisplayDetailMessage("存储的故障码: " + strVal); DTC dtc2 = m_obdInterface.GetDTC(strVal); if (dtc2 != null) { m_bReportForm.ReportPage1.DTCDefinitionList.Add(dtc2.Description); } } } DisplayStatusMessage("请求未决故障码列表"); OBDParameterValue value2 = m_obdInterface.GetValue("SAE.PENDING_DTCS"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value2.ErrorDetected) { m_bReportForm.ReportPage1.PendingList.Clear(); foreach (string strVal in value2.ListStringValue) { m_bReportForm.ReportPage1.PendingList.Add(strVal); DisplayDetailMessage("未决故障码: " + strVal); DTC dtc = m_obdInterface.GetDTC(strVal); if (dtc != null) { m_bReportForm.ReportPage1.PendingDefinitionList.Add(dtc.Description); } } } DisplayStatusMessage("检查冻结帧数据"); OBDParameter parameter = m_obdInterface.LookupParameter("SAE.FF_DTC"); if (parameter != null) { OBDParameter freezeFrameCopy = parameter.GetFreezeFrameCopy(0); value2 = m_obdInterface.GetValue(freezeFrameCopy); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value2.ErrorDetected) { m_bReportForm.ReportPage1.FreezeFrameDTC = value2.StringValue; DisplayDetailMessage("找到冻结帧数据 " + value2.StringValue); CollectFreezeFrameData(); } else { m_bReportForm.ReportPage1.FreezeFrameDTC = "P0000"; DisplayDetailMessage("未找到冻结帧数据"); } CollectMonitoringTestData(); this.BeginInvoke((EventHandler) delegate { progressBar.Value = progressBar.Maximum; btnGenerate.Enabled = true; // ReportForm窗体类里需要调用SaveFileDialog.ShowDialog() // 该方法需要调用COM对象(系统中的打开文件通用对话框),故需要调用者线程具有STA模式(单线程单元模式) // 而Task无法显式设置线程模式为STA,故只能在主UI线程里调用ReportForm窗体类 m_bReportForm.ShowDialog(); }); } }
private void CollectMonitoringTestData() { DisplayStatusMessage("读取故障诊断器结果"); OBDParameterValue value23 = m_obdInterface.GetValue("SAE.MISFIRE_SUPPORT"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value23.ErrorDetected) { if (value23.BoolValue) { m_bReportForm.ReportPage1.MisfireMonitorSupported = true; OBDParameterValue value22 = m_obdInterface.GetValue("SAE.MISFIRE_STATUS"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value22.ErrorDetected) { if (value22.BoolValue) { DisplayDetailMessage("失火就绪状态?: 完成"); m_bReportForm.ReportPage1.MisfireMonitorCompleted = true; } else { DisplayDetailMessage("失火就绪状态?: 未完成"); m_bReportForm.ReportPage1.MisfireMonitorCompleted = false; } } } else { DisplayDetailMessage("支持失火?: 不适用"); m_bReportForm.ReportPage1.MisfireMonitorSupported = false; } } OBDParameterValue value21 = m_obdInterface.GetValue("SAE.FUEL_SUPPORT"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value21.ErrorDetected) { if (value21.BoolValue) { m_bReportForm.ReportPage1.FuelSystemMonitorSupported = true; OBDParameterValue value20 = m_obdInterface.GetValue("SAE.FUEL_STATUS"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value20.ErrorDetected) { if (value20.BoolValue) { DisplayDetailMessage("燃油系统就绪状态?: 完成"); m_bReportForm.ReportPage1.FuelSystemMonitorCompleted = true; } else { DisplayDetailMessage("燃油系统就绪状态?: 未完成"); m_bReportForm.ReportPage1.FuelSystemMonitorCompleted = false; } } } else { DisplayDetailMessage("支持燃油系统?: 不适用"); m_bReportForm.ReportPage1.FuelSystemMonitorSupported = false; } } OBDParameterValue value19 = m_obdInterface.GetValue("SAE.CCM_SUPPORT"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value19.ErrorDetected) { if (value19.BoolValue) { m_bReportForm.ReportPage1.ComprehensiveMonitorSupported = true; OBDParameterValue value18 = m_obdInterface.GetValue("SAE.CCM_STATUS"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value18.ErrorDetected) { if (value18.BoolValue) { DisplayDetailMessage("综合部件就绪状态?: 完成"); m_bReportForm.ReportPage1.ComprehensiveMonitorCompleted = true; } else { DisplayDetailMessage("综合部件就绪状态?: 未完成"); m_bReportForm.ReportPage1.ComprehensiveMonitorCompleted = false; } } } else { DisplayDetailMessage("支持综合部件?: 不适用"); m_bReportForm.ReportPage1.ComprehensiveMonitorSupported = false; } } OBDParameterValue value17 = m_obdInterface.GetValue("SAE.CAT_SUPPORT"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value17.ErrorDetected) { if (value17.BoolValue) { m_bReportForm.ReportPage1.CatalystMonitorSupported = true; OBDParameterValue value16 = m_obdInterface.GetValue("SAE.CAT_STATUS"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value16.ErrorDetected) { if (value16.BoolValue) { DisplayDetailMessage("催化器就绪状态?: 完成"); m_bReportForm.ReportPage1.CatalystMonitorCompleted = true; } else { DisplayDetailMessage("催化器就绪状态?: 未完成"); m_bReportForm.ReportPage1.CatalystMonitorCompleted = false; } } } else { DisplayDetailMessage("支持催化器?: 不适用"); m_bReportForm.ReportPage1.CatalystMonitorSupported = false; } } OBDParameterValue value15 = m_obdInterface.GetValue("SAE.HCAT_SUPPORT"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value15.ErrorDetected) { if (value15.BoolValue) { m_bReportForm.ReportPage1.HeatedCatalystMonitorSupported = true; OBDParameterValue value14 = m_obdInterface.GetValue("SAE.HCAT_STATUS"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value14.ErrorDetected) { if (value14.BoolValue) { DisplayDetailMessage("加热催化器就绪状态?: 完成"); m_bReportForm.ReportPage1.HeatedCatalystMonitorCompleted = true; } else { DisplayDetailMessage("加热催化器就绪状态?: 未完成"); m_bReportForm.ReportPage1.HeatedCatalystMonitorCompleted = false; } } } else { DisplayDetailMessage("支持加热催化器?: 不适用"); m_bReportForm.ReportPage1.HeatedCatalystMonitorSupported = false; } } OBDParameterValue value13 = m_obdInterface.GetValue("SAE.EVAP_SUPPORT"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value13.ErrorDetected) { if (value13.BoolValue) { m_bReportForm.ReportPage1.EvapSystemMonitorSupported = true; OBDParameterValue value12 = m_obdInterface.GetValue("SAE.EVAP_STATUS"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value12.ErrorDetected) { if (value12.BoolValue) { DisplayDetailMessage("蒸发系统就绪状态?: 完成"); m_bReportForm.ReportPage1.EvapSystemMonitorCompleted = true; } else { DisplayDetailMessage("蒸发系统就绪状态?: 未完成"); m_bReportForm.ReportPage1.EvapSystemMonitorCompleted = false; } } } else { DisplayDetailMessage("支持蒸发系统?: 不适用"); m_bReportForm.ReportPage1.EvapSystemMonitorSupported = false; } } OBDParameterValue value11 = m_obdInterface.GetValue("SAE.AIR_SUPPORT"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value11.ErrorDetected) { if (value11.BoolValue) { m_bReportForm.ReportPage1.SecondaryAirMonitorSupported = true; OBDParameterValue value10 = m_obdInterface.GetValue("SAE.AIR_STATUS"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value10.ErrorDetected) { if (value10.BoolValue) { DisplayDetailMessage("二次空气系统就绪状态?: 完成"); m_bReportForm.ReportPage1.SecondaryAirMonitorCompleted = true; } else { DisplayDetailMessage("二次空气系统就绪状态?: 未完成"); m_bReportForm.ReportPage1.SecondaryAirMonitorCompleted = false; } } } else { DisplayDetailMessage("支持二次空气系统?: 不适用"); m_bReportForm.ReportPage1.SecondaryAirMonitorSupported = false; } } OBDParameterValue value9 = m_obdInterface.GetValue("SAE.AC_SUPPORT"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value9.ErrorDetected) { if (value9.BoolValue) { m_bReportForm.ReportPage1.RefrigerantMonitorSupported = true; OBDParameterValue value8 = m_obdInterface.GetValue("SAE.AC_STATUS"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value8.ErrorDetected) { if (value8.BoolValue) { DisplayDetailMessage("A/C系统制冷剂就绪状态?: 完成"); m_bReportForm.ReportPage1.RefrigerantMonitorCompleted = true; } else { DisplayDetailMessage("A/C系统制冷剂就绪状态?: 未完成"); m_bReportForm.ReportPage1.RefrigerantMonitorCompleted = false; } } } else { DisplayDetailMessage("支持A/C系统制冷剂?: 不适用"); m_bReportForm.ReportPage1.RefrigerantMonitorSupported = false; } } OBDParameterValue value7 = m_obdInterface.GetValue("SAE.O2_SUPPORT"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value7.ErrorDetected) { if (value7.BoolValue) { m_bReportForm.ReportPage1.OxygenSensorMonitorSupported = true; OBDParameterValue value6 = m_obdInterface.GetValue("SAE.O2_STATUS"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value6.ErrorDetected) { if (value6.BoolValue) { DisplayDetailMessage("氧气传感器就绪状态?: 完成"); m_bReportForm.ReportPage1.OxygenSensorMonitorCompleted = true; } else { DisplayDetailMessage("氧气传感器就绪状态?: 未完成"); m_bReportForm.ReportPage1.OxygenSensorMonitorCompleted = false; } } } else { DisplayDetailMessage("支持氧气传感器?: 不适用"); m_bReportForm.ReportPage1.OxygenSensorMonitorSupported = false; } } OBDParameterValue value5 = m_obdInterface.GetValue("SAE.O2HTR_SUPPORT"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value5.ErrorDetected) { if (value5.BoolValue) { m_bReportForm.ReportPage1.OxygenSensorHeaterMonitorSupported = true; OBDParameterValue value4 = m_obdInterface.GetValue("SAE.O2HTR_STATUS"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value4.ErrorDetected) { if (value4.BoolValue) { DisplayDetailMessage("加热氧气传感器就绪状态?: 完成"); m_bReportForm.ReportPage1.OxygenSensorHeaterMonitorCompleted = true; } else { DisplayDetailMessage("加热氧气传感器就绪状态?: 未完成"); m_bReportForm.ReportPage1.OxygenSensorHeaterMonitorCompleted = false; } } } else { DisplayDetailMessage("支持加热氧气传感器?: 不适用"); m_bReportForm.ReportPage1.OxygenSensorHeaterMonitorSupported = false; } } OBDParameterValue value3 = m_obdInterface.GetValue("SAE.EGR_SUPPORT"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value3.ErrorDetected) { if (value3.BoolValue) { m_bReportForm.ReportPage1.EGRSystemMonitorSupported = true; OBDParameterValue value2 = m_obdInterface.GetValue("SAE.EGR_STATUS"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); if (!value2.ErrorDetected) { if (value2.BoolValue) { DisplayDetailMessage("EGR系统就绪状态?: 完成"); m_bReportForm.ReportPage1.EGRSystemMonitorCompleted = true; } else { DisplayDetailMessage("EGR系统就绪状态?: 未完成"); m_bReportForm.ReportPage1.EGRSystemMonitorCompleted = false; } } } else { DisplayDetailMessage("支持EGR系统?: 不适用"); m_bReportForm.ReportPage1.EGRSystemMonitorSupported = false; } } }
private void CollectFreezeFrameData() { OBDParameter param = m_obdInterface.LookupParameter("SAE.FUEL1_STATUS"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); m_bReportForm.ReportPage1.ShowFuelSystemStatus = false; if (param != null) { param = param.GetFreezeFrameCopy(0); OBDParameterValue value17 = m_obdInterface.GetValue(param); if (!value17.ErrorDetected) { m_bReportForm.ReportPage1.ShowFuelSystemStatus = true; DisplayDetailMessage("燃油系统 1: " + value17.StringValue); m_bReportForm.ReportPage1.FuelSystem1Status = value17.StringValue; } } OBDParameter freezeFrameCopy = m_obdInterface.LookupParameter("SAE.FUEL2_STATUS"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); m_bReportForm.ReportPage1.ShowFuelSystemStatus = false; if (freezeFrameCopy != null) { freezeFrameCopy = freezeFrameCopy.GetFreezeFrameCopy(0); OBDParameterValue value3 = m_obdInterface.GetValue(freezeFrameCopy); if (!value3.ErrorDetected) { m_bReportForm.ReportPage1.ShowFuelSystemStatus = true; DisplayDetailMessage("燃油系统 2: " + value3.StringValue); m_bReportForm.ReportPage1.FuelSystem2Status = value3.StringValue; } } OBDParameter parameter16 = m_obdInterface.LookupParameter("SAE.LOAD_CALC"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); m_bReportForm.ReportPage1.ShowCalculatedLoad = false; if (parameter16 != null) { OBDParameter parameter17 = parameter16.GetFreezeFrameCopy(0); OBDParameterValue value2 = m_obdInterface.GetValue(parameter17); if (!value2.ErrorDetected) { m_bReportForm.ReportPage1.ShowCalculatedLoad = true; DisplayDetailMessage("计算负荷: " + value2.DoubleValue.ToString()); m_bReportForm.ReportPage1.CalculatedLoad = value2.DoubleValue; } } OBDParameter parameter14 = m_obdInterface.LookupParameter("SAE.ECT"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); m_bReportForm.ReportPage1.ShowEngineCoolantTemp = false; if (parameter14 != null) { parameter14 = parameter14.GetFreezeFrameCopy(0); OBDParameterValue value16 = m_obdInterface.GetValue(parameter14); if (!value16.ErrorDetected) { m_bReportForm.ReportPage1.ShowEngineCoolantTemp = true; DisplayDetailMessage("发动机冷却液温度: " + value16.DoubleValue.ToString()); m_bReportForm.ReportPage1.EngineCoolantTemp = value16.DoubleValue; } } OBDParameter parameter13 = m_obdInterface.LookupParameter("SAE.STFT1"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); m_bReportForm.ReportPage1.ShowSTFT13 = false; if (parameter13 != null) { parameter13 = parameter13.GetFreezeFrameCopy(0); OBDParameterValue value15 = m_obdInterface.GetValue(parameter13); if (!value15.ErrorDetected) { m_bReportForm.ReportPage1.ShowSTFT13 = true; DisplayDetailMessage("短时燃油修正 - 组 1: " + value15.DoubleValue.ToString()); m_bReportForm.ReportPage1.STFT1 = value15.DoubleValue; } } OBDParameter parameter12 = m_obdInterface.LookupParameter("SAE.STFT3"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); m_bReportForm.ReportPage1.ShowSTFT13 = false; if (parameter12 != null) { parameter12 = parameter12.GetFreezeFrameCopy(0); OBDParameterValue value14 = m_obdInterface.GetValue(parameter12); if (!value14.ErrorDetected) { m_bReportForm.ReportPage1.ShowSTFT13 = true; DisplayDetailMessage("短时燃油修正 - 组 3: " + value14.DoubleValue.ToString()); m_bReportForm.ReportPage1.STFT3 = value14.DoubleValue; } } OBDParameter parameter11 = m_obdInterface.LookupParameter("SAE.LTFT1"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); m_bReportForm.ReportPage1.ShowLTFT13 = false; if (parameter11 != null) { parameter11 = parameter11.GetFreezeFrameCopy(0); OBDParameterValue value13 = m_obdInterface.GetValue(parameter11); if (!value13.ErrorDetected) { m_bReportForm.ReportPage1.ShowLTFT13 = true; DisplayDetailMessage("长时燃油修正 - 组 1: " + value13.DoubleValue.ToString()); m_bReportForm.ReportPage1.LTFT1 = value13.DoubleValue; } } OBDParameter parameter10 = m_obdInterface.LookupParameter("SAE.LTFT3"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); m_bReportForm.ReportPage1.ShowLTFT13 = false; if (parameter10 != null) { parameter10 = parameter10.GetFreezeFrameCopy(0); OBDParameterValue value12 = m_obdInterface.GetValue(parameter10); if (!value12.ErrorDetected) { m_bReportForm.ReportPage1.ShowLTFT13 = true; DisplayDetailMessage("长时燃油修正 - 组 3: " + value12.DoubleValue.ToString()); m_bReportForm.ReportPage1.LTFT3 = value12.DoubleValue; } } OBDParameter parameter9 = m_obdInterface.LookupParameter("SAE.STFT2"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); m_bReportForm.ReportPage1.ShowSTFT24 = false; if (parameter9 != null) { parameter9 = parameter9.GetFreezeFrameCopy(0); OBDParameterValue value11 = m_obdInterface.GetValue(parameter9); if (!value11.ErrorDetected) { m_bReportForm.ReportPage1.ShowSTFT24 = true; DisplayDetailMessage("短时燃油修正 - 组 2: " + value11.DoubleValue.ToString()); m_bReportForm.ReportPage1.STFT2 = value11.DoubleValue; } } OBDParameter parameter8 = m_obdInterface.LookupParameter("SAE.STFT4"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); m_bReportForm.ReportPage1.ShowSTFT24 = false; if (parameter8 != null) { parameter8 = parameter8.GetFreezeFrameCopy(0); OBDParameterValue value10 = m_obdInterface.GetValue(parameter8); if (!value10.ErrorDetected) { m_bReportForm.ReportPage1.ShowSTFT24 = true; DisplayDetailMessage("短时燃油修正 - 组 4: " + value10.DoubleValue.ToString()); m_bReportForm.ReportPage1.STFT4 = value10.DoubleValue; } } OBDParameter parameter7 = m_obdInterface.LookupParameter("SAE.LTFT2"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); m_bReportForm.ReportPage1.ShowLTFT24 = false; if (parameter7 != null) { parameter7 = parameter7.GetFreezeFrameCopy(0); OBDParameterValue value9 = m_obdInterface.GetValue(parameter7); if (!value9.ErrorDetected) { m_bReportForm.ReportPage1.ShowLTFT24 = true; DisplayDetailMessage("长时燃油修正 - 组 2: " + value9.DoubleValue.ToString()); m_bReportForm.ReportPage1.LTFT2 = value9.DoubleValue; } } OBDParameter parameter6 = m_obdInterface.LookupParameter("SAE.LTFT4"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); m_bReportForm.ReportPage1.ShowLTFT24 = false; if (parameter6 != null) { parameter6 = parameter6.GetFreezeFrameCopy(0); OBDParameterValue value8 = m_obdInterface.GetValue(parameter6); if (!value8.ErrorDetected) { m_bReportForm.ReportPage1.ShowLTFT24 = true; DisplayDetailMessage("长时燃油修正 - 组 4: " + value8.DoubleValue.ToString()); m_bReportForm.ReportPage1.LTFT4 = value8.DoubleValue; } } OBDParameter parameter5 = m_obdInterface.LookupParameter("SAE.MAP"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); m_bReportForm.ReportPage1.ShowIntakePressure = false; if (parameter5 != null) { parameter5 = parameter5.GetFreezeFrameCopy(0); OBDParameterValue value7 = m_obdInterface.GetValue(parameter5); if (!value7.ErrorDetected) { m_bReportForm.ReportPage1.ShowIntakePressure = true; DisplayDetailMessage("进气歧管压力: " + value7.DoubleValue.ToString()); m_bReportForm.ReportPage1.IntakePressure = value7.DoubleValue; } } OBDParameter parameter4 = m_obdInterface.LookupParameter("SAE.RPM"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); m_bReportForm.ReportPage1.ShowEngineRPM = false; if (parameter4 != null) { parameter4 = parameter4.GetFreezeFrameCopy(0); OBDParameterValue value6 = m_obdInterface.GetValue(parameter4); if (!value6.ErrorDetected) { m_bReportForm.ReportPage1.ShowEngineRPM = true; DisplayDetailMessage("发动机转数: " + value6.DoubleValue.ToString()); m_bReportForm.ReportPage1.EngineRPM = value6.DoubleValue; } } OBDParameter parameter3 = m_obdInterface.LookupParameter("SAE.VSS"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); m_bReportForm.ReportPage1.ShowVehicleSpeed = false; if (parameter3 != null) { parameter3 = parameter3.GetFreezeFrameCopy(0); OBDParameterValue value5 = m_obdInterface.GetValue(parameter3); if (!value5.ErrorDetected) { m_bReportForm.ReportPage1.ShowVehicleSpeed = true; DisplayDetailMessage("车辆速度: " + value5.DoubleValue.ToString()); m_bReportForm.ReportPage1.VehicleSpeed = value5.DoubleValue; } } OBDParameter parameter2 = m_obdInterface.LookupParameter("SAE.SPARKADV"); this.BeginInvoke((EventHandler) delegate { progressBar.Value += 1; }); m_bReportForm.ReportPage1.ShowSparkAdvance = false; if (parameter2 != null) { parameter2 = parameter2.GetFreezeFrameCopy(0); OBDParameterValue value4 = m_obdInterface.GetValue(parameter2); if (!value4.ErrorDetected) { m_bReportForm.ReportPage1.ShowSparkAdvance = true; DisplayDetailMessage("点火提前角: " + value4.DoubleValue.ToString()); m_bReportForm.ReportPage1.SparkAdvance = value4.DoubleValue; } } }