Control Libraries 7.4.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
state_representation::DigitalIOState Class Reference
Inheritance diagram for state_representation::DigitalIOState:
state_representation::IOState< bool > state_representation::State

Public Member Functions

 DigitalIOState ()
 Empty constructor for a digital IO state.
 
 DigitalIOState (const std::string &name, unsigned int nb_ios=0)
 Constructor with name and number of digital IOs provided.
 
 DigitalIOState (const std::string &name, const std::vector< std::string > &io_names)
 Constructor with name and list of digital IO names provided.
 
 DigitalIOState (const DigitalIOState &state)
 Copy constructor of a digital IO state.
 
DigitalIOStateoperator= (const DigitalIOState &state)
 Copy assignment operator that has to be defined to the custom assignment operator.
 
bool is_true (const std::string &name) const
 Check if a digital IO is true by its name, if it exists.
 
bool is_true (unsigned int io_index) const
 Check if a digital IO is true by its index, if it exists.
 
bool is_false (const std::string &name) const
 Check if a digital IO is false by its name, if it exists.
 
bool is_false (unsigned int io_index) const
 Check if a digital IO is false by its index, if it exists.
 
void set_true (const std::string &name)
 Set the a digital IO to true by its name.
 
void set_true (unsigned int io_index)
 Set the a digital IO to true by its index.
 
void set_false (const std::string &name)
 Set the a digital IO to false by its name.
 
void set_false (unsigned int io_index)
 Set the a digital IO to false by its index.
 
DigitalIOState copy () const
 Return a copy of the digital IO state.
 
void reset () override
 Reset the object to a post-construction state.
 
void set_false ()
 Set all digital IOs false.
 
- Public Member Functions inherited from state_representation::IOState< bool >
unsigned int get_size () const
 Getter of the size.
 
const std::vector< std::string > & get_names () const
 Getter of the names.
 
unsigned int get_io_index (const std::string &io_name) const
 Get IO index by the name of the IO, if it exists.
 
bool get_value (const std::string &name) const
 Get the value of an IO by its name, if it exists.
 
bool get_value (unsigned int io_index) const
 Get the value of an IO by its index, if it exists.
 
Eigen::Vector< bool, Eigen::Dynamic > data () const
 Returns the values of the IO state as an Eigen vector.
 
Eigen::Array< bool, Eigen::Dynamic, 1 > array () const
 Returns the values of the IO state an Eigen array.
 
void set_names (unsigned int nb_ios)
 Setter of the names from the number of IOs.
 
void set_names (const std::vector< std::string > &names)
 Setter of the names from a list of IO names.
 
void set_value (bool value, const std::string &name)
 Set the value of an IO by its name.
 
void set_value (bool value, unsigned int io_index)
 Set the value of an IO by its index.
 
void set_data (const Eigen::Vector< bool, Eigen::Dynamic > &data)
 Set the values of the IO state from a single Eigen vector.
 
void set_data (const std::vector< bool > &data)
 Set the values of the IO state from a single std vector.
 
void set_data (const std::vector< double > &data)
 Set the data of the state from a std vector.
 
void set_data (const std::vector< bool > &data)
 
bool is_incompatible (const State &state) const override
 Check if the IO group is incompatible for operations with the state given as argument.
 
std::vector< bool > to_std_vector () const
 Return the IO values as a std vector.
 
std::vector< double > to_std_vector () const
 
std::vector< bool > to_std_vector () const
 
- Public Member Functions inherited from state_representation::State
 State ()
 Empty constructor.
 
 State (const std::string &name)
 Constructor with name specification.
 
 State (const State &state)
 Copy constructor from another state.
 
virtual ~State ()=default
 Virtual destructor.
 
Stateoperator= (const State &state)
 Copy assignment operator that has to be defined to the custom assignment operator.
 
const StateTypeget_type () const
 Getter of the type attribute.
 
const std::string & get_name () const
 Getter of the name attribute.
 
bool is_empty () const
 Getter of the empty attribute.
 
const std::chrono::time_point< std::chrono::steady_clock > & get_timestamp () const
 Getter of the timestamp attribute.
 
virtual void set_name (const std::string &name)
 Setter of the name attribute.
 
void reset_timestamp ()
 Reset the timestamp attribute to now.
 
virtual void set_data (const Eigen::VectorXd &data)
 Set the data of the state from an Eigen vector.
 
virtual void set_data (const Eigen::MatrixXd &data)
 Set the data of the state from an Eigen matrix.
 
double get_age () const
 Get the age of the state, i.e. the time since the last modification.
 
bool is_deprecated (double time_delay) const
 Check if the state is deprecated given a certain time delay.
 
template<typename DurationT >
bool is_deprecated (const std::chrono::duration< int64_t, DurationT > &time_delay) const
 Check if the state is deprecated given a certain time delay.
 
 operator bool () const noexcept
 Boolean operator for the truthiness of a state.
 

Static Public Member Functions

static DigitalIOState Zero (const std::string &name, unsigned int nb_ios)
 Constructor for a zero digital IO state.
 
static DigitalIOState Zero (const std::string &name, const std::vector< std::string > &names)
 Constructor for a zero digital IO state.
 
static DigitalIOState Random (const std::string &name, unsigned int nb_ios)
 Constructor for a digital IO state with random data.
 
static DigitalIOState Random (const std::string &name, const std::vector< std::string > &names)
 Constructor for a digital IO state with random data.
 

Protected Member Functions

std::string to_string () const override
 Convert the state to its string representation.
 
- Protected Member Functions inherited from state_representation::IOState< bool >
 IOState ()=default
 Empty constructor for an IO state.
 
 IOState (const std::string &name, unsigned int nb_ios)
 Constructor with name and number of IOs provided.
 
 IOState (const std::string &name, const std::vector< std::string > &io_names)
 Constructor with name and list of IO names provided.
 
- Protected Member Functions inherited from state_representation::State
void set_type (const StateType &type)
 Setter of the state type attribute.
 
void set_empty (bool empty=true)
 Setter of the empty attribute.
 
void assert_not_empty () const
 Throw an exception if the state is empty.
 

Friends

std::ostream & operator<< (std::ostream &os, const DigitalIOState &state)
 Overload the ostream operator for printing.
 
void swap (DigitalIOState &state1, DigitalIOState &state2)
 Swap the values of the IO states.
 

Additional Inherited Members

- Static Protected Member Functions inherited from state_representation::IOState< bool >
static void assert_index_in_range (unsigned int io_index, unsigned int size)
 
- Protected Attributes inherited from state_representation::IOState< bool >
std::vector< std::string > names_
 names of the IOs
 
Eigen::Vector< bool, Eigen::Dynamic > data_
 IO values.
 

Detailed Description

Definition at line 7 of file DigitalIOState.hpp.

Constructor & Destructor Documentation

◆ DigitalIOState() [1/4]

state_representation::DigitalIOState::DigitalIOState ( )

Empty constructor for a digital IO state.

Definition at line 9 of file DigitalIOState.cpp.

◆ DigitalIOState() [2/4]

state_representation::DigitalIOState::DigitalIOState ( const std::string &  name,
unsigned int  nb_ios = 0 
)
explicit

Constructor with name and number of digital IOs provided.

Parameters
nameThe name of the associated IO state
nb_iosThe number of IOs for initialization

Definition at line 13 of file DigitalIOState.cpp.

◆ DigitalIOState() [3/4]

state_representation::DigitalIOState::DigitalIOState ( const std::string &  name,
const std::vector< std::string > &  io_names 
)

Constructor with name and list of digital IO names provided.

Parameters
nameThe name of the associated digital IO state
io_nameList of IO names

Definition at line 18 of file DigitalIOState.cpp.

◆ DigitalIOState() [4/4]

state_representation::DigitalIOState::DigitalIOState ( const DigitalIOState state)

Copy constructor of a digital IO state.

Parameters
stateThe digital IO state to copy from

Definition at line 23 of file DigitalIOState.cpp.

Member Function Documentation

◆ copy()

DigitalIOState state_representation::DigitalIOState::copy ( ) const

Return a copy of the digital IO state.

Definition at line 97 of file DigitalIOState.cpp.

◆ is_false() [1/2]

bool state_representation::DigitalIOState::is_false ( const std::string &  name) const

Check if a digital IO is false by its name, if it exists.

Parameters
nameThe name of the IO
Exceptions
IONotFoundExceptionif the desired IO doesn't exist
Returns
The value of the IO, if it exists

Definition at line 73 of file DigitalIOState.cpp.

◆ is_false() [2/2]

bool state_representation::DigitalIOState::is_false ( unsigned int  io_index) const

Check if a digital IO is false by its index, if it exists.

Parameters
io_indexThe index of the IO
Exceptions
IONotFoundExceptionif the desired IO doesn't exist
Returns
The value of the IO, if it exists

Definition at line 77 of file DigitalIOState.cpp.

◆ is_true() [1/2]

bool state_representation::DigitalIOState::is_true ( const std::string &  name) const

Check if a digital IO is true by its name, if it exists.

Parameters
nameThe name of the IO
Exceptions
IONotFoundExceptionif the desired IO doesn't exist
Returns
The value of the IO, if it exists

Definition at line 63 of file DigitalIOState.cpp.

◆ is_true() [2/2]

bool state_representation::DigitalIOState::is_true ( unsigned int  io_index) const

Check if a digital IO is true by its index, if it exists.

Parameters
io_indexThe index of the IO
Exceptions
IONotFoundExceptionif the desired IO doesn't exist
Returns
The value of the IO, if it exists

Definition at line 67 of file DigitalIOState.cpp.

◆ operator=()

DigitalIOState & state_representation::DigitalIOState::operator= ( const DigitalIOState state)

Copy assignment operator that has to be defined to the custom assignment operator.

Parameters
stateThe state with value to assign
Returns
Reference to the current state with new values

Definition at line 57 of file DigitalIOState.cpp.

◆ Random() [1/2]

DigitalIOState state_representation::DigitalIOState::Random ( const std::string &  name,
const std::vector< std::string > &  names 
)
static

Constructor for a digital IO state with random data.

Parameters
nameThe name of the associated digital IO state
namesList of IO names
Returns
Digital IO state with random data

Definition at line 50 of file DigitalIOState.cpp.

◆ Random() [2/2]

DigitalIOState state_representation::DigitalIOState::Random ( const std::string &  name,
unsigned int  nb_ios 
)
static

Constructor for a digital IO state with random data.

Parameters
nameThe name of the associated digital IO state
nb_iosThe number of digital IOs for initialization
Returns
Digital IO state with random data

Definition at line 43 of file DigitalIOState.cpp.

◆ reset()

void state_representation::DigitalIOState::reset ( )
overridevirtual

Reset the object to a post-construction state.

Reimplemented from state_representation::State.

Definition at line 102 of file DigitalIOState.cpp.

◆ set_false() [1/3]

void state_representation::DigitalIOState::set_false ( )

Set all digital IOs false.

Definition at line 107 of file DigitalIOState.cpp.

◆ set_false() [2/3]

void state_representation::DigitalIOState::set_false ( const std::string &  name)

Set the a digital IO to false by its name.

Parameters
nameThe name of the IO
Exceptions
IONotFoundExceptionif the desired IO doesn't exist

Definition at line 89 of file DigitalIOState.cpp.

◆ set_false() [3/3]

void state_representation::DigitalIOState::set_false ( unsigned int  io_index)

Set the a digital IO to false by its index.

Parameters
io_indexThe index of the IO
Exceptions
IONotFoundExceptionif the desired IO doesn't exist

Definition at line 93 of file DigitalIOState.cpp.

◆ set_true() [1/2]

void state_representation::DigitalIOState::set_true ( const std::string &  name)

Set the a digital IO to true by its name.

Parameters
nameThe name of the IO
Exceptions
IONotFoundExceptionif the desired IO doesn't exist

Definition at line 81 of file DigitalIOState.cpp.

◆ set_true() [2/2]

void state_representation::DigitalIOState::set_true ( unsigned int  io_index)

Set the a digital IO to true by its index.

Parameters
io_indexThe index of the IO
Exceptions
IONotFoundExceptionif the desired IO doesn't exist

Definition at line 85 of file DigitalIOState.cpp.

◆ to_string()

std::string state_representation::DigitalIOState::to_string ( ) const
overrideprotectedvirtual

Convert the state to its string representation.

Reimplemented from state_representation::State.

Definition at line 114 of file DigitalIOState.cpp.

◆ Zero() [1/2]

DigitalIOState state_representation::DigitalIOState::Zero ( const std::string &  name,
const std::vector< std::string > &  names 
)
static

Constructor for a zero digital IO state.

Parameters
nameThe name of the associated digital IO state
namesList of IO names
Returns
Digital IO state with zero data

Definition at line 36 of file DigitalIOState.cpp.

◆ Zero() [2/2]

DigitalIOState state_representation::DigitalIOState::Zero ( const std::string &  name,
unsigned int  nb_ios 
)
static

Constructor for a zero digital IO state.

Parameters
nameThe name of the associated digital IO state
nb_iosThe number of digital IOs for initialization
Returns
Digital IO state with zero data

Definition at line 29 of file DigitalIOState.cpp.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const DigitalIOState state 
)
friend

Overload the ostream operator for printing.

Parameters
osThe ostream to append the string representing the state to
stateThe spatial state to print
Returns
The appended ostream

Definition at line 129 of file DigitalIOState.cpp.

◆ swap

void swap ( DigitalIOState state1,
DigitalIOState state2 
)
friend

Swap the values of the IO states.

Parameters
state1IO state to be swapped with 2
state2IO state to be swapped with 1

Definition at line 170 of file DigitalIOState.hpp.


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