QModbusDataUnit
is a container class representing single bit and
16
bit word entries in the Modbus register.
更多...
头: | #include <QModbusDataUnit> |
qmake: | QT += serialbus |
Since: | Qt 5.8 |
enum | RegisterType { Invalid, DiscreteInputs, Coils, InputRegisters, HoldingRegisters } |
QModbusDataUnit () | |
QModbusDataUnit (QModbusDataUnit::RegisterType type ) | |
QModbusDataUnit (QModbusDataUnit::RegisterType type , int address , quint16 size ) | |
QModbusDataUnit (QModbusDataUnit::RegisterType type , int address , const QVector<quint16> & data ) | |
bool | isValid () const |
QModbusDataUnit::RegisterType | registerType () const |
void | setRegisterType (QModbusDataUnit::RegisterType type ) |
void | setStartAddress (int address ) |
void | setValue (int index , quint16 value ) |
void | setValueCount (uint newCount ) |
void | setValues (const QVector<quint16> & 值 ) |
int | startAddress () const |
quint16 | value (int index ) const |
uint | valueCount () const |
QVector<quint16> | values () const |
typedef | QModbusDataUnitMap |
QModbusDataUnit
is a container class representing single bit and
16
bit word entries in the Modbus register.
QModbusDataUnit can be used for read and write operations. The entries are addressed via startAddress () 和 valueCount () number of contiguous entries. registerType () determines which register is used for the operations. Note that some registers are read-only registers.
The actual
values
() are either single bit or
16
bit based.
QModbusDataUnit::DiscreteInputs
and
QModbusDataUnit::Coils
only accept single bits. Therefore
0
is interpreted as
0
and anything else
1
.
This enum describes all supported register types.
常量 | 值 | 描述 |
---|---|---|
QModbusDataUnit::Invalid
|
0
|
Set by the default constructor, do not use. |
QModbusDataUnit::DiscreteInputs
|
1
|
This type of data can be provided by an I/O system. |
QModbusDataUnit::Coils
|
2
|
This type of data can be alterable by an application program. |
QModbusDataUnit::InputRegisters
|
3
|
This type of data can be provided by an I/O system. |
QModbusDataUnit::HoldingRegisters
|
4
|
This type of data can be alterable by an application program. |
构造空的,无效
QModbusDataUnit
. Start address is set to
-1
和
registerType
被设为
QModbusDataUnit::Invalid
.
Constructs a unit of data for register
type
. Start address is set to
0
, data range and data values are empty.
Constructs a unit of data for register
type
. Start address of the data is set to
address
and the size of the unit to
size
. The entries of
values
() are initialized with
0
.
Constructs a unit of data for register type . Start address of the data is set to address and the unit's values to data . The value count is implied by the data 尺寸。
返回
true
若
QModbusDataUnit
is valid; otherwise
false
。
QModbusDataUnit
is considered valid if the
registerType
() is not
QModbusDataUnit::Invalid
和
startAddress
() is greater than or equal to
0
.
Returns the type of the register.
另请参阅 setRegisterType () 和 QModbusDataUnit::RegisterType .
Sets the register type .
另请参阅 registerType () 和 QModbusDataUnit::RegisterType .
Sets the start address of the data unit.
另请参阅 startAddress ().
Sets the register at position index to value .
另请参阅 value ().
Sets the size of the requested register's data block to newCount .
This may be different from values () size as this function is used to indicated the size of a data request. Only once the data request has been processed valueCount () is equal to the size of values ().
另请参阅 valueCount ().
设置
值
of the data unit.
QModbusDataUnit::DiscreteInputs
and
QModbusDataUnit::Coils
tables only accept single bit value, so
0
is interpreted as
0
and anything else as
1
.
另请参阅 values ().
Returns the start address of data unit in the register.
另请参阅 setStartAddress ().
Return the value at position index .
另请参阅 setValue ().
Returns the size of the requested register's data block or the size of data read from the device.
This function may not always return a count that equals values () size. Since this class is used to request data from the remote data register, the valueCount() can be used to indicate the size of the requested register's data block. Once the request has been processed, the valueCount() is equal to the size of values ().
另请参阅 setValueCount ().
Returns the data in the data unit.
QModbusDataUnit::DiscreteInputs
and
QModbusDataUnit::Coils
tables only accept single bit value, so
0
is interpreted as
0
and anything else as
1
.
另请参阅 setValues ().
同义词 QMap < QModbusDataUnit::RegisterType , QModbusDataUnit >.
该 typedef 在 Qt 5.8 引入。