Class that represents single modbus cell, it is either coil(bool) or reg(uint16_t).
More...
#include <modbusCell.hpp>
|
constexpr | ModbusCell ()=default |
| Constructs cell with register type equal to 0.
|
|
constexpr | ModbusCell (uint16_t reg) |
| Constructs cell with register value.
|
|
constexpr | ModbusCell (bool coil) |
| Constructs cell with coil value.
|
|
| ModbusCell (const ModbusCell &other) noexcept=default |
|
ModbusCell & | operator= (const ModbusCell &other) noexcept=default |
|
ModbusCell & | operator= (ModbusCell &&other) noexcept=default |
|
bool | isCoil () const |
| Checks if cell is coil.
|
|
bool | isReg () const |
| Checks if cell is register.
|
|
bool & | coil () |
| Returns coil value, changes cell type if necessary.
|
|
uint16_t & | reg () |
| Returns register value, changes cell type if necessary.
|
|
const bool & | coil () const |
| Returns coil value.
|
|
const uint16_t & | reg () const |
| Returns register value.
|
|
std::string | toString () const noexcept |
|
Class that represents single modbus cell, it is either coil(bool) or reg(uint16_t).
◆ ModbusCell() [1/2]
constexpr MB::ModbusCell::ModbusCell |
( |
uint16_t | reg | ) |
|
|
inlineconstexpr |
Constructs cell with register value.
- Parameters
-
◆ ModbusCell() [2/2]
constexpr MB::ModbusCell::ModbusCell |
( |
bool | coil | ) |
|
|
inlineconstexpr |
Constructs cell with coil value.
- Parameters
-
◆ coil() [1/2]
bool & MB::ModbusCell::coil |
( |
| ) |
|
|
inline |
Returns coil value, changes cell type if necessary.
- Returns
- Reference to coil value.
◆ coil() [2/2]
const bool & MB::ModbusCell::coil |
( |
| ) |
const |
|
inline |
Returns coil value.
- Returns
- Reference to coil value.
- Exceptions
-
bad_variant_access | - When cell is of different type as requested. |
◆ initCoil()
static ModbusCell MB::ModbusCell::initCoil |
( |
bool | coil | ) |
|
|
inlinestatic |
Static wrapper for cell construction.
- Parameters
-
- Returns
- New cell.
◆ initReg()
static ModbusCell MB::ModbusCell::initReg |
( |
uint16_t | reg | ) |
|
|
inlinestatic |
Static wrapper for cell construction.
- Parameters
-
- Returns
- New cell.
◆ isCoil()
bool MB::ModbusCell::isCoil |
( |
| ) |
const |
|
inline |
Checks if cell is coil.
- Returns
- Boolean representing result.
◆ isReg()
bool MB::ModbusCell::isReg |
( |
| ) |
const |
|
inline |
Checks if cell is register.
- Returns
- Boolean representing result.
◆ reg() [1/2]
uint16_t & MB::ModbusCell::reg |
( |
| ) |
|
|
inline |
Returns register value, changes cell type if necessary.
- Returns
- Reference to coil value.
◆ reg() [2/2]
const uint16_t & MB::ModbusCell::reg |
( |
| ) |
const |
|
inline |
Returns register value.
- Returns
- Reference to coil value.
- Exceptions
-
bad_variant_access | - When cell is of different type as requested. |
◆ toString()
std::string MB::ModbusCell::toString |
( |
| ) |
const |
|
inlinenoexcept |
Creates string representation of the cell.
- Returns
- String representation.
The documentation for this class was generated from the following file: