private void ParseReceiveData(ParsingDataIncommingEventArgs e, List <KeyValuePair <string, string> > itemsToAdd) { if (!e.PostiveResponse || dcmDocument == null || dcmDocument.VdfDocument == null) { return; } DcmConfig.SubFunction subFunction = FindFunction(e.RequestData); if (subFunction == null) { return; } // 执行解析数据 List <byte> data = new List <byte>(); for (int i = subFunction.Prefix.Count; i < e.ResponseData.Count; i++) { data.Add(e.ResponseData[i]); } var message = dcmDocument.VdfDocument.Message(subFunction.Message); foreach (var entry in message.SignalTable) { string value = VdfEncoder.Encode(data, entry.Value, true); itemsToAdd.Add(new KeyValuePair <string, string>(entry.Value.Name, value)); } }
private DcmConfig.SubFunction FindFunction(List <byte> reqData) { DcmConfig.SubFunction subFunction = null; for (int len = reqData.Count; len > 0; len--) { var key = DcmConfig.DcmDocument.GenParsingReceiveKey(reqData, len); if (dcmDocument.ParsingReceiveSubFunctionTable .TryGetValue(key, out subFunction)) { if (subFunction.Prefix.Count == len) { if (subFunction.Message == null) { subFunction = null; } break; } else { subFunction = null; } } } return(subFunction); }