PySide6.QtSerialBus.QModbusDataUnit¶
- class QModbusDataUnit¶
- QModbusDataUnitis a container class representing single bit and- 16bit 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¶- QModbusDataUnitcan be used for read and write operations. The entries are addressed via- startAddress()and the- 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- 16bit based.- DiscreteInputsand- Coilsonly accept single bits. Therefore- 0is interpreted as- 0and anything else- 1.- 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- -1and the- registerTypeis set to- Invalid.- __init__(type)
- Parameters:
- type – - RegisterType
 
 - Constructs a unit of data for register - type. Start address is set to- 0, 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 - addressand the unit’s values to- data. The value count is implied by the- datasize.- __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 - addressand the size of the unit to- size. The entries of- values()are initialized with- 0.- isValid()¶
- Return type:
- bool 
 
 - Returns - trueif the- QModbusDataUnitis valid; otherwise- false. A- QModbusDataUnitis considered valid if the- registerType()is not- Invalidand the- startAddress()is greater than or equal to- 0.- 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 - addressof the data unit.- See also - setValue(index, newValue)¶
- Parameters:
- index – int 
- newValue – int 
 
 
 - Sets the register at position - indexto- value.- 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 processed- valueCount()is equal to the size of- values().- See also - setValues(newValues)¶
- Parameters:
- newValues – .list of quint16 
 
 - Sets the - valuesof the data unit.- DiscreteInputsand- Coilstables only accept single bit value, so- 0is interpreted as- 0and anything else as- 1.- 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 of- values().- See also - values()¶
- Return type:
- .list of quint16 
 
 - Returns the data in the data unit. - DiscreteInputsand- Coilstables only accept single bit value, so- 0is interpreted as- 0and anything else as- 1.- See also