public OBDParameterValue getValue(OBDParameter param, bool bEnglishUnits) { if (param.PID.Length > 0) { m_commLog.AddItem("Requesting " + param.PID); } else { m_commLog.AddItem("Requesting " + param.OBDRequest); } if (param.Service == 0) { return(getSpecialValue(param, bEnglishUnits)); } OBDResponseList responses = m_obdDevice.query(param); string strItem1 = "Responses: "; int index1 = 0; if (0 < responses.ResponseCount) { do { strItem1 = strItem1 + string.Format("[{0}] ", responses.GetOBDResponse(index1).Data); ++index1; }while (index1 < responses.ResponseCount); } m_commLog.AddItem(strItem1); OBDParameterValue obdParameterValue = OBDInterpretter.getValue(param, responses, bEnglishUnits); if (obdParameterValue.ErrorDetected) { m_commLog.AddItem("Error Detected!"); return(obdParameterValue); } else { string strItem2 = "Values: "; if ((param.ValueTypes & 2) == 2) { bool num = obdParameterValue.BoolValue; strItem2 = strItem2 + string.Format("[Bool: {0}] ", num.ToString()); } if ((param.ValueTypes & 1) == 1) { double num = obdParameterValue.DoubleValue; strItem2 = strItem2 + string.Format("[Double: {0}] ", num.ToString()); } if ((param.ValueTypes & 4) == 4) { strItem2 += string.Format("[String: {0} / {1}] ", obdParameterValue.StringValue, obdParameterValue.ShortStringValue); } if ((param.ValueTypes & 8) == 8) { string str = strItem2 + "[StringCollection: "; StringEnumerator enumerator = obdParameterValue.StringCollectionValue.GetEnumerator(); if (enumerator.MoveNext()) { do { str = str + enumerator.Current + ", "; }while (enumerator.MoveNext()); } strItem2 = str + "]"; } if ((param.ValueTypes & 32) == 32) { string str = strItem2 + "[BitFlags: "; int index2 = 0; do { str += obdParameterValue.getBitFlag(index2) ? "T" : "F"; ++index2; }while (index2 < 32); strItem2 = str + " ]"; } m_commLog.AddItem(strItem2); return(obdParameterValue); } }
public OBDParameterValue getValue(OBDParameter param, bool bEnglishUnits) { if (param.PID.Length > 0) { m_commLog.AddItem("Requesting " + param.PID); } else { m_commLog.AddItem("Requesting " + param.OBDRequest); } if (param.Service == 0) { return(SpecialValue(param, bEnglishUnits)); } OBDResponseList responses = m_obdDevice.Query(param); string strItem1 = "Responses: "; if (responses.ResponseCount > 0) { int count = 0; do { strItem1 = strItem1 + string.Format("[{0}] ", responses.GetOBDResponse(count).Data); ++count; }while (count < responses.ResponseCount); } m_commLog.AddItem(strItem1); OBDParameterValue obdParameterValue = OBDInterpretter.getValue(param, responses, bEnglishUnits); if (obdParameterValue.ErrorDetected) { m_commLog.AddItem("Error Detected!"); return(obdParameterValue); } else { string values = "Values: "; if ((param.ValueTypes & 0x01) == 0x01) { values = values + string.Format("[Double: {0}] ", obdParameterValue.DoubleValue.ToString()); } if ((param.ValueTypes & 0x02) == 0x02) { values = values + string.Format("[Bool: {0}] ", obdParameterValue.BoolValue.ToString()); } if ((param.ValueTypes & 0x04) == 0x04) { values += string.Format("[String: {0} / {1}] ", obdParameterValue.StringValue, obdParameterValue.ShortStringValue); } if ((param.ValueTypes & 0x08) == 0x08) { values += "[StringCollection: "; foreach (string strx in obdParameterValue.StringCollectionValue) { values = string.Concat(values, strx + ", "); } values += "]"; } if ((param.ValueTypes & 0x20) == 0x20) { values += "[BitFlags: "; for (int idx = 0; idx < 32; idx++) { values += (obdParameterValue.getBitFlag(idx) ? "T" : "F"); } values += " ]"; } m_commLog.AddItem(values); return(obdParameterValue); } }