PySide6.QtSerialBus.QModbusDataUnit¶
- class QModbusDataUnit¶
QModbusDataUnit
is a container class representing single bit and16
bit word entries in the Modbus register. More…Synopsis¶
Methods¶
def
__init__()
def
isValid()
def
registerType()
def
setValue()
def
setValueCount()
def
setValues()
def
startAddress()
def
value()
def
valueCount()
def
values()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
QModbusDataUnit
can be used for read and write operations. The entries are addressed viastartAddress()
and thevalueCount()
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 or16
bit based.DiscreteInputs
andCoils
only accept single bits. Therefore0
is interpreted as0
and anything else1
.- class RegisterType¶
This enum describes all supported register types.
Constant
Description
QModbusDataUnit.Invalid
Set by the default constructor, do not use.
QModbusDataUnit.DiscreteInputs
This type of data can be provided by an I/O system.
QModbusDataUnit.Coils
This type of data can be alterable by an application program.
QModbusDataUnit.InputRegisters
This type of data can be provided by an I/O system.
QModbusDataUnit.HoldingRegisters
This type of data can be alterable by an application program.
- __init__()¶
Constructs an empty, invalid
QModbusDataUnit
. Start address is set to-1
and theregisterType
is set toInvalid
.- __init__(type)
- Parameters:
type –
RegisterType
Constructs a unit of data for register
type
. Start address is set to0
, data range and data values are empty.- __init__(type, newStartAddress, newValues)
- Parameters:
type –
RegisterType
newStartAddress – int
newValues – .list of quint16
Constructs a unit of data for register``type``. Start address of the data is set to
address
and the unit’s values todata
. The value count is implied by thedata
size.- __init__(type, newStartAddress, newValueCount)
- Parameters:
type –
RegisterType
newStartAddress – int
newValueCount – int
Constructs a unit of data for register``type``. Start address of the data is set to
address
and the size of the unit tosize
. The entries ofvalues()
are initialized with0
.- isValid()¶
- Return type:
bool
Returns
true
if theQModbusDataUnit
is valid; otherwisefalse
. AQModbusDataUnit
is considered valid if theregisterType()
is notInvalid
and thestartAddress()
is greater than or equal to0
.- registerType()¶
- Return type:
Returns the type of the register.
See also
- setRegisterType(type)¶
- Parameters:
type –
RegisterType
Sets the register
type
.See also
- setStartAddress(newAddress)¶
- Parameters:
newAddress – int
Sets the start
address
of the data unit.See also
- setValue(index, newValue)¶
- Parameters:
index – int
newValue – int
Sets the register at position
index
tovalue
.See also
- setValueCount(newCount)¶
- Parameters:
newCount – int
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 processedvalueCount()
is equal to the size ofvalues()
.See also
- setValues(newValues)¶
- Parameters:
newValues – .list of quint16
Sets the
values
of the data unit.DiscreteInputs
andCoils
tables only accept single bit value, so0
is interpreted as0
and anything else as1
.See also
- startAddress()¶
- Return type:
int
Returns the start address of data unit in the register.
See also
- value(index)¶
- Parameters:
index – int
- Return type:
int
Return the value at position
index
.See also
- valueCount()¶
- Return type:
int
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 ofvalues()
.See also
- values()¶
- Return type:
.list of quint16
Returns the data in the data unit.
DiscreteInputs
andCoils
tables only accept single bit value, so0
is interpreted as0
and anything else as1
.See also