自制CANTool_DBC_Layout仿制_布局读取Signal(三)
1、读取DBC中解析格式空格问题报错解决方法
原来解析方式:BO_ 258 EPS_CANFD_StrWhlASts: 8 Test
有的DBC中数据格式:BO_ 80 GW_50: 8 GW (多了一个空格)
解析匹配规则修订为:
string MessageRegex = @"BO_\s+(\d+)\s+(\w+)\s*:\s*(\d+)\s+(\w+)";
2、使用C#自制DBC布局--UI
3、使用C#自制DBC布局--代码
#region DBC To TreeView
private void bt_OpenDBCFilepath_Click(object sender, EventArgs e)
{
tB_DBCFilepath.Text = dBCLayoutDAL.LoadDbc();
if (tB_DBCFilepath.Text != null || tB_DBCFilepath.Text != "")
{
XmlDocument xmlDocument = dbcXmlExporter.ExportToXml(dBCLayoutDAL.dBCReader.dbc);
dbcXmlExporter.ImportToTreeView(xmlDocument, this.treeViewDirectory);
}
}
#endregion
#region DBC Layout
private void treeViewDirectory_DoubleClick(object sender, EventArgs e)
{
// 获取选择的节点
TreeNode selectedNode = treeViewDirectory.SelectedNode;
//获取ID
int returnID = dBCLayoutDAL.TreeView_Find_DBC_ID(selectedNode);
//获取message
if (returnID != -1)
{
Model.Message messageMacthID = dBCLayoutDAL.dBCReader.GetMatchingMessage((uint)returnID);
if (messageMacthID.DLC <= 8)
{
dBCLayoutDAL.InitCANLayout(dataGridViewCAN);
dBCLayoutDAL.SetCANLayout(messageMacthID, this.dataGridViewCAN);
}
else
{
dBCLayoutDAL.InitCANFDLayout(dataGridViewCAN);
dBCLayoutDAL.SetCANFDLayout(messageMacthID, this.dataGridViewCAN);
}
}
}
#endregion
4、后记
下一步DBC比对工具