RTXI  3.0.0
The Real-Time eXperiment Interface Reference Manual
Data Structures | Public Member Functions | Protected Member Functions
IO::Block Class Reference

#include <io.hpp>

Inheritance diagram for IO::Block:
Inheritance graph
Collaboration diagram for IO::Block:
Collaboration graph

Public Member Functions

 Block (std::string blockname, const std::vector< channel_t > &channels, bool isdependent)
 
 Block (const Block &block)=default
 
Blockoperator= (const Block &block)=default
 
 Block (Block &&)=delete
 
Blockoperator= (Block &&)=delete
 
virtual ~Block ()=default
 
std::string getName () const
 
size_t getCount (flags_t type) const
 
std::string getChannelName (IO::flags_t type, size_t index) const
 
std::string getChannelDescription (IO::flags_t type, size_t index) const
 
void writeinput (size_t index, const double &data)
 
const double & readPort (IO::flags_t direction, size_t index)
 
bool dependent () const
 
bool getActive () const
 
void setActive (bool act)
 
void assignID (size_t block_id)
 
size_t getID () const
 

Protected Member Functions

double & readinput (size_t index)
 
void writeoutput (size_t index, const double &data)
 

Detailed Description

Interface class for IO data between RTXI devices and plugins.

Definition at line 78 of file io.hpp.

Constructor & Destructor Documentation

◆ Block() [1/3]

IO::Block::Block(std::string blockname,
const std::vector< channel_t > & channels,
bool isdependent 
)

The constructor needs to be provided with a specification of the channels that will be embedded in this block in the channels parameter. Fields could be IO::INPUT, IO::OUTPUT. It also needs to specify whether the block is dependent on other blocks for real-time scheduling. This base class is not meant to be inherited directly and Widget::Component is recommended instead

Parameters
blocknameThe name of the block.
channelsThe lis of channel specifications for this block.
See also
Widgets::Component
IO::channel_t

Definition at line 29 of file io.cpp.

◆ Block() [2/3]

IO::Block::Block(const Blockblock)
default

◆ Block() [3/3]

IO::Block::Block(Block && )
delete

◆ ~Block()

virtual IO::Block::~Block()
virtualdefault

Member Function Documentation

◆ assignID()

void IO::Block::assignID(size_t block_id)
inline

Assign unique ID to the block. Used by the Real-Time thread

Parameters
block_idThe id to assign to the block

Definition at line 195 of file io.hpp.

◆ dependent()

bool IO::Block::dependent()const
inline

Returns the dependency property of the block

Some blocks are dependent on the output of others. It is crucial for these blocks to be scheduled in real-time to follow their dependencies, or else risk large errors in time dependent calculations.

Returns
True for a dependent IO::Block, false otherwise

Definition at line 173 of file io.hpp.

◆ getActive()

bool IO::Block::getActive()const
inline

Returns activity state of the block

Returns
True for active block, false otherwise

Definition at line 180 of file io.hpp.

◆ getChannelDescription()

std::string IO::Block::getChannelDescription(IO::flags_t type,
size_t index 
)const

Get the description of the specified channel.

Parameters
indexThe channel's index.
Returns
The description of the channel.

Definition at line 58 of file io.cpp.

◆ getChannelName()

std::string IO::Block::getChannelName(IO::flags_t type,
size_t index 
)const

Get the name of the specified channel.

Parameters
typePort type.
indexThe channel's index.
Returns
The name of the channel.

Definition at line 52 of file io.cpp.

◆ getCount()

size_t IO::Block::getCount(IO::flags_t type)const

Get the number of channels of the specified type.

Parameters
typeThe type of the channels to be counted.
Returns
The number of channels of the specified type.

Definition at line 46 of file io.cpp.

◆ getID()

size_t IO::Block::getID()const
inline

Retrieve the assigned id of the block

Returns
The id of the block

Definition at line 202 of file io.hpp.

◆ getName()

std::string IO::Block::getName()const
inline

Get the name of the block.

Returns
The name of the block.

Definition at line 108 of file io.hpp.

◆ operator=() [1/2]

Block& IO::Block::operator=(Block && )
delete

◆ operator=() [2/2]

Block& IO::Block::operator=(const Blockblock)
default

◆ readinput()

double & IO::Block::readinput(size_t index)
protected

Read the input sent to this block. Only the block itself has access.

Reads the buffered values from all external inputs and resets the buffer to zero. This function should only be accessed once per scope or risk getting previously read values overwirten. This function assumes reading input channels.

Parameters
indexThe channel to read the sent input from
Returns
A reference to input value written
See also
IO::Block::writeinput()

Definition at line 70 of file io.cpp.

◆ readPort()

const double & IO::Block::readPort(IO::flags_t direction,
size_t index 
)

Get the values of the specified output channel.

This function can read values from both input and output types. This does not reset the values on the channel

Parameters
indexThe output channel's index.
directionThe channel direction represented by IO::flags_t
Returns
The value of the specified output channel.

Definition at line 85 of file io.cpp.

◆ setActive()

void IO::Block::setActive(bool act)
inline

Sets the activity state of the block. Only used by Real-Time thread

/param act The activity state to set the block to. True if the block is in the active state. False otherwise.

Definition at line 188 of file io.hpp.

◆ writeinput()

void IO::Block::writeinput(size_t index,
const double & data 
)

write the values of the specified input channel.

This function is responsible for writing external values to the specified input channel. Additional writes to input result in adding to existing values in the channel, and is only reset to zero during readinput function call.

Parameters
indexThe input channel's index.
datathe data to push into the block
Returns
The value of the specified input channel.
See also
IO::Block::readinput()

Definition at line 65 of file io.cpp.

◆ writeoutput()

void IO::Block::writeoutput(size_t index,
const double & data 
)
protected

Writes output to specified channel. Only the block itself has access.

Parameters
indexThe channel to write the output to
dataA reference to value to send

Definition at line 80 of file io.cpp.


The documentation for this class was generated from the following files: