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 | 保留对象 Ids 的第一个值。 |
扩展设备标识。所有这些数据均取决于设备,为可选项。
常量 | 值 | 说明 |
---|---|---|
QModbusDeviceIdentification::ProductDependentObjectId | 0x80 | 产品相关标识符的第一个可能值。 |
QModbusDeviceIdentification::UndefinedObjectId | 0x100 | 请勿使用。 |
enum QModbusDeviceIdentification::ReadDeviceIdCode
定义读取识别请求的访问类型。
流访问:
常量 | 值 | 说明 |
---|---|---|
QModbusDeviceIdentification::BasicReadDeviceIdCode | 0x01 | 请求获取基本设备标识。 |
QModbusDeviceIdentification::RegularReadDeviceIdCode | 0x02 | 请求获取常规设备标识。 |
QModbusDeviceIdentification::ExtendedReadDeviceIdCode | 0x03 | 请求获取扩展设备标识。 |
单独访问:
常量 | 值 | 说明 |
---|---|---|
QModbusDeviceIdentification::IndividualReadDeviceIdCode | 0x04 | 请求获取一个特定标识对象。 |
成员函数文档
[constexpr noexcept]
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 。
© 2025 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.