CAN作用域优化

This commit is contained in:
hsc
2026-07-06 11:37:09 +08:00
parent 6c2b975999
commit aec0044595
4 changed files with 95 additions and 57 deletions

View File

@@ -34,6 +34,11 @@ namespace ZLGUSBCANFD
private readonly uint _deviceIndex; // 设备索引
private readonly int _maxChannels; // 动态通道数
/// <summary>
/// 当前 CAN 卡专属的 DBC 解析器,按通道隔离报文数据库。
/// </summary>
public ZLGDBCParser DBCParser { get; }
/// <summary>
/// 事件:当接收到 CAN/CANFD 报文并且通过 DBC 成功解析后触发
/// 参数uint 通道号 (0,1,2,3), ZDBC.DBCMessage 解析后的DBC消息结构体
@@ -51,6 +56,7 @@ namespace ZLGUSBCANFD
_dbcHandles = new uint[_maxChannels];
_isDbcLoadedArray = new bool[_maxChannels];
_channelLocks = new object[_maxChannels];
DBCParser = new ZLGDBCParser(_maxChannels);
for (int i = 0; i < _maxChannels; i++)
{
@@ -185,7 +191,7 @@ namespace ZLGUSBCANFD
{
_dbcHandles[] = chDbcHandle;
_isDbcLoadedArray[] = true;
ZLGDBCParser.ParseAndLoadToDatabase(chDbcHandle, 0);
DBCParser.ParseAndLoadToDatabase(chDbcHandle, (int));
}
else
{