Modbus cpp 0.1
All Classes Namespaces Functions Enumerations Pages
Public Member Functions | Static Public Member Functions | List of all members
MB::ModbusCell Class Reference

Class that represents single modbus cell, it is either coil(bool) or reg(uint16_t). More...

#include <modbusCell.hpp>

Public Member Functions

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
 
ModbusCelloperator= (const ModbusCell &other) noexcept=default
 
ModbusCelloperator= (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
 

Static Public Member Functions

static ModbusCell initReg (uint16_t reg)
 Static wrapper for cell construction.
 
static ModbusCell initCoil (bool coil)
 Static wrapper for cell construction.
 

Detailed Description

Class that represents single modbus cell, it is either coil(bool) or reg(uint16_t).

Constructor & Destructor Documentation

◆ ModbusCell() [1/2]

constexpr MB::ModbusCell::ModbusCell ( uint16_t reg)
inlineconstexpr

Constructs cell with register value.

Parameters
reg- Register value.

◆ ModbusCell() [2/2]

constexpr MB::ModbusCell::ModbusCell ( bool coil)
inlineconstexpr

Constructs cell with coil value.

Parameters
coil- Coil value.

Member Function Documentation

◆ 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
coil- Requested value.
Returns
New cell.

◆ initReg()

static ModbusCell MB::ModbusCell::initReg ( uint16_t reg)
inlinestatic

Static wrapper for cell construction.

Parameters
reg- Requested value.
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: