private void ParseComment(string strLine) { Regex re = new Regex(@"CM_\s+(?<objType>\S+)?\s*(?<id>\d*)?\s*(?<name>\S*)?\s*""(?<comment>.+)"); string strObjType = re.Match(strLine).Groups["objType"].Value; string strID = re.Match(strLine).Groups["id"].Value; uint iID = 0; if (strID.Length > 0) { iID = uint.Parse(strID); } string name = re.Match(strLine).Groups["name"].Value.Trim(); string comment = re.Match(strLine).Groups["comment"].Value; DBCObjBase commentObj; if (strObjType.Contains("BU_")) { commentObj = _netWork.Nodes[name]; } else if (strObjType.Contains("BO_")) { commentObj = _netWork.GetMessage(iID); } else if (strObjType.Contains("SG_")) { commentObj = _netWork.GetSignal(iID, name); } else { commentObj = _netWork; } if (commentObj == null) { throw new ApplicationException("The ID or/and name of this line comment is error"); } if (comment.EndsWith("\";")) { commentObj.Comment = comment.Substring(0, comment.Length - 2); _mode = new KeyValuePair <DBCObjType, DBCObjBase>(DBCObjType.DBCObjBase, null); } else { commentObj.Comment = comment; _mode = new KeyValuePair <DBCObjType, DBCObjBase>(DBCObjType.DBCObjBase, commentObj); } }
public OBDParameterValue GetPIDValue(uint ID, string strData, string signalName) { OBDParameterValue value2 = new OBDParameterValue(); Message msg = _netWork.GetMessage(ID); if (msg == null && ID < 0x80000000) { msg = _netWork.GetMessage(ID + 0x80000000); } if (msg == null) { value2.ErrorDetected = true; } else { if (msg.SetSignalRawValue(strData)) { value2.Message = msg; foreach (Signal signal in msg.Signals.Values) { signal.DisplayString = _dbc.GetDisplayString(signal, "不适用"); if (signalName == signal.Name || signalName.Length == 0) { int iUsed = signal.TestSignalUesed(); if (iUsed > 0) { value2.DoubleValue = Math.Round(signal.Value, 2); value2.BoolValue = signal.RawValue > 0; foreach (string item in signal.ListString) { value2.ListStringValue.Add(item); } value2.ShortStringValue = signal.DisplayString; value2.StringValue = value2.ShortStringValue; } } } } else { value2.ErrorDetected = true; } } return(value2); }