QModbusDeviceIdentification Class
QModbusDeviceIdentification 是一个容器类,用于表示 Modbus 服务器的物理和功能描述。更多内容...
| 头文件: | #include <QModbusDeviceIdentification> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS SerialBus) target_link_libraries(mytarget PRIVATE Qt6::SerialBus) |
| qmake: | QT += serialbus |
公共类型
| enum | ConformityLevel { BasicConformityLevel, RegularConformityLevel, ExtendedConformityLevel, BasicIndividualConformityLevel, RegularIndividualConformityLevel, ExtendedIndividualConformityLevel } |
| enum | ObjectId { VendorNameObjectId, ProductCodeObjectId, MajorMinorRevisionObjectId, VendorUrlObjectId, ProductNameObjectId, …, UndefinedObjectId } |
| enum | ReadDeviceIdCode { BasicReadDeviceIdCode, RegularReadDeviceIdCode, ExtendedReadDeviceIdCode, IndividualReadDeviceIdCode } |
公共函数
| QModbusDeviceIdentification() | |
| QModbusDeviceIdentification::ConformityLevel | conformityLevel() const |
| bool | contains(uint objectId) const |
| bool | insert(uint objectId, const QByteArray &value) |
| bool | isValid() const |
| QList<int> | objectIds() const |
| void | remove(uint objectId) |
| void | setConformityLevel(QModbusDeviceIdentification::ConformityLevel level) |
| QByteArray | value(uint objectId) const |
静态公共成员
| QModbusDeviceIdentification | fromByteArray(const QByteArray &ba) |
详细说明
设备标识接口被建模为由一组可寻址数据元素组成的地址空间。这些数据元素被称为对象,并通过ObjectId 进行标识。
成员类型文档
enum QModbusDeviceIdentification::ConformityLevel
定义了设备的身份识别符合性级别以及支持的访问类型。
| 常量 | 值 | 描述 |
|---|---|---|
QModbusDeviceIdentification::BasicConformityLevel | 0x01 | 基本标识(流访问)。 |
QModbusDeviceIdentification::RegularConformityLevel | 0x02 | 常规标识(流访问)。 |
QModbusDeviceIdentification::ExtendedConformityLevel | 0x03 | 扩展标识(流访问)。 |
QModbusDeviceIdentification::BasicIndividualConformityLevel | 0x81 | 基本识别(流式访问和单次访问)。 |
QModbusDeviceIdentification::RegularIndividualConformityLevel | 0x82 | 常规识别(流访问和单独访问)。 |
QModbusDeviceIdentification::ExtendedIndividualConformityLevel | 0x83 | 扩展标识(流访问和单独访问)。 |
另请参阅 ReadDeviceIdCode 。
enum QModbusDeviceIdentification::ObjectId
此枚举描述了可能存在的服务器对象。该接口由三类对象组成:
基本设备标识。该类别中的所有对象均为必选项。
| 常量 | 值 | 描述 |
|---|---|---|
QModbusDeviceIdentification::VendorNameObjectId | 0x00 | 设备的厂商名称。 |
QModbusDeviceIdentification::ProductCodeObjectId | 0x01 | 设备的產品代码。 |
QModbusDeviceIdentification::MajorMinorRevisionObjectId | 0x02 | 产品版本号。 |
常规设备标识。该类别中的所有对象均为标准定义且可选。
| 常量 | 值 | 描述 |
|---|---|---|
QModbusDeviceIdentification::VendorUrlObjectId | 0x03 | 设备的供应商 URL。 |
QModbusDeviceIdentification::ProductNameObjectId | 0x04 | 设备的产品名称。 |
QModbusDeviceIdentification::ModelNameObjectId | 0x05 | 设备的型号名称。 |
QModbusDeviceIdentification::UserApplicationNameObjectId | 0x06 | 设备的用户应用程序名称。 |
保留范围(即 ReservedObjectId >= ObjectId < ProductDependentObjectId)。请勿使用。
| 常量 | 值 | 描述 |
|---|---|---|
QModbusDeviceIdentification::ReservedObjectId | 0x07 | 保留对象 ID 的第一个值。 |
扩展设备标识。所有这些数据均与设备相关,且为可选。
| 常量 | 值 | 描述 |
|---|---|---|
QModbusDeviceIdentification::ProductDependentObjectId | 0x80 | 产品相关标识符的第一个可能值。 |
QModbusDeviceIdentification::UndefinedObjectId | 0x100 | 请勿使用。 |
enum QModbusDeviceIdentification::ReadDeviceIdCode
定义读取标识请求的访问类型。
流访问:
| 常量 | 值 | 描述 |
|---|---|---|
QModbusDeviceIdentification::BasicReadDeviceIdCode | 0x01 | 用于获取基本设备标识的请求。 |
QModbusDeviceIdentification::RegularReadDeviceIdCode | 0x02 | 用于获取常规设备标识符的请求。 |
QModbusDeviceIdentification::ExtendedReadDeviceIdCode | 0x03 | 用于获取扩展设备标识的请求。 |
单独访问:
| 常量 | 值 | 描述 |
|---|---|---|
QModbusDeviceIdentification::IndividualReadDeviceIdCode | 0x04 | 请求获取一个特定的标识对象。 |
成员函数文档
[constexpr noexcept default] QModbusDeviceIdentification::QModbusDeviceIdentification()
构建了一个无效的 QModbusDeviceIdentification 对象。
QModbusDeviceIdentification::ConformityLevel QModbusDeviceIdentification::conformityLevel() const
返回设备的身份验证符合性级别以及支持的访问类型。
另请参阅 setConformityLevel()。
bool QModbusDeviceIdentification::contains(uint objectId) const
如果给定的objectId 存在对应项,则返回true ;否则返回false 。
另请参阅 ObjectId 。
[static] QModbusDeviceIdentification QModbusDeviceIdentification::fromByteArray(const QByteArray &ba)
将字节数组 `ba ` 转换为 `QModbusDeviceIdentification ` 对象。
注意: 如果在处理字节数组时发生错误,返回的对象可能是空的,甚至可能无效。
另请参阅 isValid()。
bool QModbusDeviceIdentification::insert(uint objectId, const QByteArray &value)
插入一个新条目,其objectId 为,值为value 。如果已经存在一个objectId 的条目,则该条目的值将被替换为value 。
如果value 的大小小于 245 字节,且objectId 小于QModbusDeviceIdentification::UndefinedObjectId ,则返回true 。
另请参阅 ObjectId 。
bool QModbusDeviceIdentification::isValid() const
如果设备标识对象有效,则返回true ;否则返回false 。
如果ProductNameObjectId 、ProductCodeObjectId 和MajorMinorRevisionObjectId 均设置为非空值,则该设备标识对象被视为有效。尽管如此,该对象仍可能包含有效的对象 ID 及相关数据。
注意: 通过默认构造生成的设备标识对象 无效。
QList<int> QModbusDeviceIdentification::objectIds() const
返回一个列表,其中包含QModbusDeviceIdentification 对象中的所有对象ID,按升序排列。
另请参阅 ObjectId 。
void QModbusDeviceIdentification::remove(uint objectId)
删除指定objectId 对应的条目。
另请参阅 ObjectId 。
void QModbusDeviceIdentification::setConformityLevel(QModbusDeviceIdentification::ConformityLevel level)
将设备的身份验证符合性级别和支持的访问类型设置为level 。
另请参阅 conformityLevel()。
QByteArray QModbusDeviceIdentification::value(uint objectId) const
返回与objectId 关联的值。如果不存在具有objectId 的项,则该函数返回一个通过默认构造函数构造的值。
另请参阅 ObjectId 。
© 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.