public override OBDResponseList parse(OBDParameter param, string response) { if (response != null) { if (response.Length < 1) response = ""; } else response = ""; OBDResponseList obdResponseList = new OBDResponseList(response); response = strip(response); if (errorCheck(response)) { obdResponseList.ErrorDetected = true; return obdResponseList; } else { ArrayList arrayList1 = split(response); arrayList1.Sort(); ArrayList arrayList2 = new ArrayList(); ArrayList arrayList3 = new ArrayList(); arrayList3.Add(arrayList1[0]); arrayList2.Add((object)arrayList3); string str1 = (string)arrayList1[0]; if (str1.Length < OBDParser_ISO14230_4_KWP.HEADER_LENGTH) { obdResponseList.ErrorDetected = true; return obdResponseList; } else { string strB = str1.Substring(0, OBDParser_ISO14230_4_KWP.HEADER_LENGTH); int index1 = 1; if (1 < arrayList1.Count) { do { string str2 = (string)arrayList1[index1]; if (str2.Length >= OBDParser_ISO14230_4_KWP.HEADER_LENGTH) { if (str2.Substring(0, OBDParser_ISO14230_4_KWP.HEADER_LENGTH).CompareTo(strB) == 0) { arrayList3.Add((object)str2); } else { arrayList3 = new ArrayList(); arrayList3.Add(arrayList1[index1]); arrayList2.Add((object)arrayList3); strB = str2.Substring(0, OBDParser_ISO14230_4_KWP.HEADER_LENGTH); } ++index1; } else goto label_14; } while (index1 < arrayList1.Count); goto label_15; label_14: obdResponseList.ErrorDetected = true; return obdResponseList; } label_15: int index2 = 0; if (0 < arrayList2.Count) { do { OBDResponse response1 = new OBDResponse(); ArrayList arrayList4 = (ArrayList)arrayList2[index2]; int dataStartIndex = getDataStartIndex(param); string str2 = (string)arrayList4[0]; int num1 = -2 - dataStartIndex; int length1 = str2.Length + num1; response1.Header = str2.Substring(0, OBDParser_ISO14230_4_KWP.HEADER_LENGTH); response1.Data = length1 > 0 ? str2.Substring(dataStartIndex, length1) : ""; int index3 = 1; if (1 < arrayList4.Count) { int num2 = num1; do { string str3 = (string)arrayList4[index3]; int length2 = str3.Length + num2; string str4 = length2 > 0 ? str3.Substring(dataStartIndex, length2) : ""; response1.Data = response1.Data + str4; ++index3; } while (index3 < arrayList4.Count); } obdResponseList.AddOBDResponse(response1); ++index2; } while (index2 < arrayList2.Count); } return obdResponseList; } } }
public override OBDResponseList parse(OBDParameter param, string response) { if (response != null) { if (response.Length < 1) { response = ""; } } else { response = ""; } OBDResponseList obdResponseList = new OBDResponseList(response); response = strip(response); if (errorCheck(response)) { obdResponseList.ErrorDetected = true; return(obdResponseList); } else { ArrayList arrayList1 = split(response); arrayList1.Sort(); ArrayList arrayList2 = new ArrayList(); ArrayList arrayList3 = new ArrayList(); arrayList3.Add(arrayList1[0]); arrayList2.Add((object)arrayList3); string str1 = (string)arrayList1[0]; if (str1.Length < OBDParser_ISO14230_4_KWP.HEADER_LENGTH) { obdResponseList.ErrorDetected = true; return(obdResponseList); } else { string strB = str1.Substring(0, OBDParser_ISO14230_4_KWP.HEADER_LENGTH); int index1 = 1; if (1 < arrayList1.Count) { do { string str2 = (string)arrayList1[index1]; if (str2.Length >= OBDParser_ISO14230_4_KWP.HEADER_LENGTH) { if (str2.Substring(0, OBDParser_ISO14230_4_KWP.HEADER_LENGTH).CompareTo(strB) == 0) { arrayList3.Add((object)str2); } else { arrayList3 = new ArrayList(); arrayList3.Add(arrayList1[index1]); arrayList2.Add((object)arrayList3); strB = str2.Substring(0, OBDParser_ISO14230_4_KWP.HEADER_LENGTH); } ++index1; } else { goto label_14; } }while (index1 < arrayList1.Count); goto label_15; label_14: obdResponseList.ErrorDetected = true; return(obdResponseList); } label_15: int index2 = 0; if (0 < arrayList2.Count) { do { OBDResponse response1 = new OBDResponse(); ArrayList arrayList4 = (ArrayList)arrayList2[index2]; int dataStartIndex = getDataStartIndex(param); string str2 = (string)arrayList4[0]; int num1 = -2 - dataStartIndex; int length1 = str2.Length + num1; response1.Header = str2.Substring(0, OBDParser_ISO14230_4_KWP.HEADER_LENGTH); response1.Data = length1 > 0 ? str2.Substring(dataStartIndex, length1) : ""; int index3 = 1; if (1 < arrayList4.Count) { int num2 = num1; do { string str3 = (string)arrayList4[index3]; int length2 = str3.Length + num2; string str4 = length2 > 0 ? str3.Substring(dataStartIndex, length2) : ""; response1.Data = response1.Data + str4; ++index3; }while (index3 < arrayList4.Count); } obdResponseList.AddOBDResponse(response1); ++index2; }while (index2 < arrayList2.Count); } return(obdResponseList); } } }
public OBDResponseList Parse(OBDParameter param, string response, int headLen) { if (string.IsNullOrEmpty(response)) { response = ""; } OBDResponseList responseList = new OBDResponseList(response); response = Strip(response); response = ErrorFilter(response); if (ErrorCheck(response)) { responseList.ErrorDetected = true; return(responseList); } List <string> legalLines = SplitByCR(response); legalLines = GetLegalLines(param, legalLines, headLen); List <string> lines = new List <string>(); foreach (string item in legalLines) { if (item.Length > 0 && item.Length < headLen) { // 过滤数据帧总长小于帧头长度的错误数据 continue; } string strNRC = GetNRC(item, headLen); if (strNRC.Length == 0) { lines.Add(item); } else if (strNRC == "78") { responseList.Pending = true; } } if (lines.Count == 0) { if (responseList.Pending) { responseList.RawResponse = "PENDING"; return(responseList); } else { responseList.ErrorDetected = true; return(responseList); } } lines.Sort(); List <List <string> > groups = new List <List <string> >(); List <string> group = new List <string> { lines[0] }; groups.Add(group); if (lines[0].Length < headLen) { responseList.ErrorDetected = true; return(responseList); } string header = lines[0].Substring(0, headLen); for (int i = 1; i < lines.Count; i++) { if (lines[i].Length >= headLen) { if (lines[i].Substring(0, headLen).CompareTo(header) == 0) { group.Add(lines[i]); } else { group = new List <string> { lines[i] }; groups.Add(group); header = lines[i].Substring(0, headLen); } } else { responseList.ErrorDetected = true; return(responseList); } } for (int i = 0; i < groups.Count; i++) { OBDResponse obd_response = new OBDResponse(); bool bIsMultiline = false; if (groups[i].Count > 1) { bIsMultiline = true; } int dataStartIndex = GetDataStartIndex(headLen, param, bIsMultiline); int length1 = groups[i][0].Length - dataStartIndex - 2; obd_response.Header = groups[i][0].Substring(0, headLen); obd_response.Data = length1 > 0 ? groups[i][0].Substring(dataStartIndex, length1) : ""; for (int j = 1; j < groups[i].Count; j++) { int length2 = groups[i][j].Length - dataStartIndex - 2; obd_response.Data += (length2 > 0 ? groups[i][j].Substring(dataStartIndex, length2) : ""); } responseList.AddOBDResponse(obd_response); } return(responseList); }