QCanUniqueIdDescription Class
QCanUniqueIdDescription 类描述了在QCanBusFrame 中访问唯一标识符的规则。更多内容...
| 头文件: | #include <QCanUniqueIdDescription> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS SerialBus) target_link_libraries(mytarget PRIVATE Qt6::SerialBus) |
| qmake: | QT += serialbus |
| 自: | Qt 6.5 |
| 状态: | 技术预览 |
该类处于技术预览阶段,内容可能会有变动。
公共函数
| QCanUniqueIdDescription() | |
| QCanUniqueIdDescription(const QCanUniqueIdDescription &other) | |
| QCanUniqueIdDescription(QCanUniqueIdDescription &&other) | |
| ~QCanUniqueIdDescription() | |
| quint8 | bitLength() const |
| QSysInfo::Endian | endian() const |
| bool | isValid() const |
| void | setBitLength(quint8 length) |
| void | setEndian(QSysInfo::Endian endian) |
| void | setSource(QtCanBus::DataSource source) |
| void | setStartBit(quint16 bit) |
| QtCanBus::DataSource | source() const |
| quint16 | startBit() const |
| QCanUniqueIdDescription & | operator=(QCanUniqueIdDescription &&other) |
| QCanUniqueIdDescription & | operator=(const QCanUniqueIdDescription &other) |
详细说明
唯一标识符用于区分不同的 CAN 总线帧,并应用适当的QCanMessageDescription对其进行编码或解码。不同的 CAN 协议可以使用 CAN 帧的不同部分作为唯一标识符(例如,DBC 协议将整个 FrameId 作为唯一标识符)。
该类包含一些参数,可灵活地指定 CAN 帧中唯一标识符的位置:
- 将用于提取唯一标识符的帧部分(FrameId 或有效载荷)。
- 唯一标识符的起始位,相对于帧的选定部分。位数从最低有效位(LSB)开始计数。
- 用于表示唯一标识符的位数。
- 用于提取该值的字节序。
请查阅QCanSignalDescription 文档中的“Data Endianness Processing ”部分,了解起始位值如何取决于数据的字节序。该部分描述的方法同样适用于唯一标识符的描述。
唯一标识符的实际值由QtCanBus::UniqueId 类型表示。
另请参阅 QCanMessageDescription 。
成员函数文档
QCanUniqueIdDescription::QCanUniqueIdDescription()
创建一个空的唯一标识符描述。
QCanUniqueIdDescription::QCanUniqueIdDescription(const QCanUniqueIdDescription &other)
使用从other 复制的值,创建一个唯一的标识符描述。
[constexpr noexcept default] QCanUniqueIdDescription::QCanUniqueIdDescription(QCanUniqueIdDescription &&other)
通过从other 中获取数据来创建一个唯一标识符的描述。
注意: 被移动的 QCanUniqueIdDescription对象 只能被销毁或进行赋值。调用除析构函数或赋值运算符之外的其他函数,其效果未定义。
[constexpr noexcept default] QCanUniqueIdDescription::~QCanUniqueIdDescription()
删除此唯一标识符的描述。
quint8 QCanUniqueIdDescription::bitLength() const
返回唯一标识符的位长度。
另请参阅 setBitLength()、startBit() 和setStartBit()。
QSysInfo::Endian QCanUniqueIdDescription::endian() const
返回唯一标识符的数据字节序。
默认情况下,使用LittleEndian 。
另请参阅 setEndian() 和QSysInfo::Endian 。
bool QCanUniqueIdDescription::isValid() const
当该唯一标识符描述有效时,返回true ;否则返回false 。
有效的唯一标识符描述必须具有一个大于零且不超过QtCanBus::UniqueId 类型位数的bitLength()。
另请参阅 bitLength()。
void QCanUniqueIdDescription::setBitLength(quint8 length)
将唯一标识符的位长度设置为length 。
另请参阅 bitLength()、startBit() 和setStartBit()。
void QCanUniqueIdDescription::setEndian(QSysInfo::Endian endian)
将唯一标识符的数据字节序设置为endian 。
另请参阅 endian() 和QSysInfo::Endian 。
void QCanUniqueIdDescription::setSource(QtCanBus::DataSource source)
将唯一标识符的数据源设置为source 。
另请参阅 source() 和QtCanBus::DataSource 。
void QCanUniqueIdDescription::setStartBit(quint16 bit)
将source() 中唯一标识符的起始位设置为bit 。
另请参阅 startBit()、bitLength() 和setBitLength()。
QtCanBus::DataSource QCanUniqueIdDescription::source() const
返回唯一标识符的数据源。
默认情况下,使用 `FrameId `。
另请参阅 setSource() 和QtCanBus::DataSource 。
quint16 QCanUniqueIdDescription::startBit() const
返回source()中唯一标识符的起始位。
另请参阅 setStartBit()、bitLength() 和setBitLength()。
[noexcept] QCanUniqueIdDescription &QCanUniqueIdDescription::operator=(QCanUniqueIdDescription &&other)
将other 中的值通过移动赋值操作赋给此唯一标识符描述。
注意:被 移动源QCanUniqueIdDescription 对象 只能被销毁或被赋值。调用除析构函数或赋值运算符以外的其他函数,其效果未定义。
QCanUniqueIdDescription &QCanUniqueIdDescription::operator=(const QCanUniqueIdDescription &other)
将other 中的值分配给该唯一标识符的描述。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.