API
xtChannels< _numChannels > Struct Template Reference

Utility class for managing Acromag xt12XX digital I/O channels. More...

#include <xtChannels.hpp>

Inheritance diagram for xtChannels< _numChannels >:
Inheritance graph
Collaboration diagram for xtChannels< _numChannels >:
Collaboration graph

Public Member Functions

 xtChannels ()
 c'tor More...
 
int setInputOnly (size_t chNo)
 Set a channel to be input only. More...
 
int setChannel (size_t chNo)
 Set a channel to true. More...
 
int clearChannel (size_t chNo)
 Set a channel to false. More...
 
int clearAll ()
 Clear all channels. More...
 
int setRegisters (uint16_t registers[numRegisters])
 Set registers based on current channel states. More...
 
int readRegisters (uint16_t registers[numRegisters])
 Read channel states from the registers. More...
 
int channel (size_t chNo)
 Gets the current state of a channel. More...
 

Static Public Attributes

static constexpr int numChannels = _numChannels
 The number of channels controlled by the device. More...
 
static constexpr int numRegisters = _numChannels/4
 The number of registers needed for the number of channels. More...
 

Protected Attributes

bool m_channels [numChannels]
 The state of the channels. More...
 
bool m_inputOnly [numChannels]
 Control which channels can not be set to output. More...
 

Detailed Description

template<int _numChannels>
struct xtChannels< _numChannels >

Utility class for managing Acromag xt12XX digital I/O channels.

Reads and writes input "registers" (uint16_t) for modbus protocol.

Template Parameters
_numChannelsis the number of channels controlled by this device.

Definition at line 22 of file xtChannels.hpp.

Constructor & Destructor Documentation

◆ xtChannels()

template<int numChannels>
xtChannels< numChannels >::xtChannels

c'tor

Sets m_channels and m_inputOnly to false.

Definition at line 100 of file xtChannels.hpp.

Member Function Documentation

◆ channel()

template<int numChannels>
int xtChannels< numChannels >::channel ( size_t  chNo)

Gets the current state of a channel.

Returns
0 if channel is not set
1 if channel is set
-1 on error
Parameters
[in]chNothe channel to retrieve

Definition at line 193 of file xtChannels.hpp.

Referenced by MagAOX::app::xt1121Ctrl::channelSetCallback(), MagAOX::app::xt1121Ctrl::getState(), and xtChannels_test::SCENARIO().

◆ clearAll()

template<int numChannels>
int xtChannels< numChannels >::clearAll

Clear all channels.

Returns
0 on success
-1 on error

Definition at line 146 of file xtChannels.hpp.

Referenced by xtChannels_test::SCENARIO().

◆ clearChannel()

template<int numChannels>
int xtChannels< numChannels >::clearChannel ( size_t  chNo)

Set a channel to false.

Returns
0 on success
-1 on error
Parameters
[in]chNothe channel to clear

Definition at line 136 of file xtChannels.hpp.

Referenced by MagAOX::app::xt1121Ctrl::channelSetCallback().

◆ readRegisters()

template<int numChannels>
int xtChannels< numChannels >::readRegisters ( uint16_t  registers[numRegisters])

Read channel states from the registers.

This changes m_channels as they are read.

Returns
0 on success
-1 on error
Parameters
[in]registersthe array of registers to read

Definition at line 178 of file xtChannels.hpp.

Referenced by MagAOX::app::xt1121Ctrl::getState(), and xtChannels_test::SCENARIO().

◆ setChannel()

template<int numChannels>
int xtChannels< numChannels >::setChannel ( size_t  chNo)

Set a channel to true.

Returns
0 on success
-1 on error
Parameters
[in]chNothe channel to set

Definition at line 110 of file xtChannels.hpp.

Referenced by MagAOX::app::xt1121Ctrl::channelSetCallback(), and xtChannels_test::SCENARIO().

◆ setInputOnly()

template<int numChannels>
int xtChannels< numChannels >::setInputOnly ( size_t  chNo)

Set a channel to be input only.

A channel which is input only will not be sent as an output to the device regardless of its state in m_channels.

Returns
0 on success
-1 on error
Parameters
[in]chNothe channel to set to input only

Definition at line 126 of file xtChannels.hpp.

Referenced by MagAOX::app::xt1121Ctrl::loadConfig(), and xtChannels_test::SCENARIO().

◆ setRegisters()

template<int numChannels>
int xtChannels< numChannels >::setRegisters ( uint16_t  registers[numRegisters])

Set registers based on current channel states.

Respects input only settings.

Returns
0 on success
-1 on error
Parameters
[out]registersthe array of registers to set

Definition at line 154 of file xtChannels.hpp.

Referenced by MagAOX::app::xt1121Ctrl::channelSetCallback(), and xtChannels_test::SCENARIO().

Member Data Documentation

◆ m_channels

template<int _numChannels>
bool xtChannels< _numChannels >::m_channels[numChannels]
protected

The state of the channels.

Definition at line 29 of file xtChannels.hpp.

◆ m_inputOnly

template<int _numChannels>
bool xtChannels< _numChannels >::m_inputOnly[numChannels]
protected

Control which channels can not be set to output.

Definition at line 31 of file xtChannels.hpp.

◆ numChannels

template<int _numChannels>
constexpr int xtChannels< _numChannels >::numChannels = _numChannels
staticconstexpr

The number of channels controlled by the device.

Definition at line 24 of file xtChannels.hpp.

◆ numRegisters

template<int _numChannels>
constexpr int xtChannels< _numChannels >::numRegisters = _numChannels/4
staticconstexpr

The number of registers needed for the number of channels.

Definition at line 26 of file xtChannels.hpp.

Referenced by MagAOX::app::xt1121Ctrl::channelSetCallback(), and MagAOX::app::xt1121Ctrl::getState().


The documentation for this struct was generated from the following file: