TwirreLink
 All Classes Functions Pages
Public Member Functions | Friends | List of all members
twirre::TwirreLink Class Reference

Registry for sensors and actuators. More...

#include <TwirreLink.h>

Public Member Functions

 TwirreLink ()
 Create an empty TwirreLink.
 
 TwirreLink (DeviceProvider &prov)
 Create a TwirreLink, immediately adding a DeviceProvider. More...
 
 TwirreLink (const std::vector< DeviceProvider * > &provs)
 Create a Twirrelink, immediately adding all DeviceProviders. More...
 
 TwirreLink (const TwirreLink &other)
 Copy constructor.
 
 TwirreLink (TwirreLink &&other)
 Move constructor.
 
TwirreLinkoperator= (const TwirreLink &other)
 Copy assignment operator.
 
TwirreLinkoperator= (TwirreLink &&other)
 Move assignment operator.
 
void addProvider (DeviceProvider &prov, bool update=true)
 Register all sensors and actuators of the given provider. More...
 
void removeProvider (DeviceProvider &prov)
 Remove a provider, making all its devices unavailable for use within this TwirreLink instance. More...
 
const std::map< std::string,
Actuator * > & 
getActuators ()
 Get all registered actuators. More...
 
const std::map< std::string,
Sensor * > & 
getSensors ()
 Get all registered sensors. More...
 
bool haveSensor (const std::string &sensorName) const
 Check if a certain sensor exists. More...
 
bool haveActuator (const std::string &actuatorName) const
 Check if a certain actuator exists. More...
 
SensorgetSensor (const std::string &sensorName)
 Get a sensor by name. More...
 
ActuatorgetActuator (const std::string &actuatorName)
 Get an actuator by name. More...
 
void startLogging (const std::string &loggingPath)
 Start logging all actions to logfile at loggingPath. More...
 
bool stopLogging (void)
 Stop logging and close the logfile. More...
 
void writeToLog (std::string sensorName, const std::vector< std::pair< std::string, std::string >> &values)
 Manually write some values into the logfile, similar to a 'sense' event (except that it will be called a 'manual' event instead) More...
 
void setLoggingMaxArraySize (size_t max)
 Set a size limit for logging array values. More...
 

Friends

class DeviceProvider
 

Detailed Description

Registry for sensors and actuators.

Constructor & Destructor Documentation

twirre::TwirreLink::TwirreLink ( DeviceProvider prov)
explicit

Create a TwirreLink, immediately adding a DeviceProvider.

Parameters
provthe provider to add
twirre::TwirreLink::TwirreLink ( const std::vector< DeviceProvider * > &  provs)

Create a Twirrelink, immediately adding all DeviceProviders.

Parameters
provsa vector of pointers to DeviceProviders. May contain nullptrs, which are ignored.

Member Function Documentation

void twirre::TwirreLink::addProvider ( DeviceProvider prov,
bool  update = true 
)

Register all sensors and actuators of the given provider.

The sensor- and actuator-map of the provider will be inserted into the corresponding maps of this TwirreLink.

If there is a name collision between devices in different providers, some of those devices will no longer be visible.

Parameters
provthe device provider to register
Actuator & twirre::TwirreLink::getActuator ( const std::string &  actuatorName)

Get an actuator by name.

Parameters
actuatorNamethe name of the requested actuator
Returns
a reference to the requested actuator
Exceptions
aruntime_error if no actuator with that name is found
const std::map< string, Actuator * > & twirre::TwirreLink::getActuators ( )

Get all registered actuators.

Returns
a map, which maps the actuators to their names
Sensor & twirre::TwirreLink::getSensor ( const std::string &  sensorName)

Get a sensor by name.

Parameters
sensorNamethe name of the requested sensor
Returns
a reference to the requested sensor
Exceptions
aruntime_error if no sensor with that name is found
const std::map< string, Sensor * > & twirre::TwirreLink::getSensors ( )

Get all registered sensors.

Returns
All sensors are returned inside of a map, which maps them to their names
bool twirre::TwirreLink::haveActuator ( const std::string &  actuatorName) const

Check if a certain actuator exists.

Parameters
actuatorNamethe name of the actuator to check
Returns
true if the actuator is registered, false otherwise
bool twirre::TwirreLink::haveSensor ( const std::string &  sensorName) const

Check if a certain sensor exists.

Parameters
sensorNamethe name of the sensor to check
Returns
true if the sensor is registered, false otherwise
void twirre::TwirreLink::removeProvider ( DeviceProvider prov)

Remove a provider, making all its devices unavailable for use within this TwirreLink instance.

If the given provider is not present in this TwirreLink instance, the call has no effect.

Parameters
provThe provider which should be detached from this TwirreLink
void twirre::TwirreLink::setLoggingMaxArraySize ( size_t  max)

Set a size limit for logging array values.

Has no effect when logging hasn't been started.

Parameters
maxThe maximum size of arrays to fully log. Arrays with bigger size are not written to the binfile.
void twirre::TwirreLink::startLogging ( const std::string &  loggingPath)

Start logging all actions to logfile at loggingPath.

Parameters
loggingPathpath where the logfile should be created
bool twirre::TwirreLink::stopLogging ( void  )

Stop logging and close the logfile.

Returns
returns true if a logger was active and has been stopped, returns false if no logger was active.
void twirre::TwirreLink::writeToLog ( std::string  sensorName,
const std::vector< std::pair< std::string, std::string >> &  values 
)

Manually write some values into the logfile, similar to a 'sense' event (except that it will be called a 'manual' event instead)

Parameters
sensorNameThe name of the sensor to emulate
valuesA vector containing pairs of valuenames with their corresponding values to write

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