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. | |
TwirreLink & | operator= (const TwirreLink &other) |
Copy assignment operator. | |
TwirreLink & | operator= (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... | |
Sensor & | getSensor (const std::string &sensorName) |
Get a sensor by name. More... | |
Actuator & | getActuator (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 |
Registry for sensors and actuators.
|
explicit |
Create a TwirreLink, immediately adding a DeviceProvider.
prov | the provider to add |
twirre::TwirreLink::TwirreLink | ( | const std::vector< DeviceProvider * > & | provs | ) |
Create a Twirrelink, immediately adding all DeviceProviders.
provs | a vector of pointers to DeviceProviders. May contain nullptrs, which are ignored. |
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.
prov | the device provider to register |
Actuator & twirre::TwirreLink::getActuator | ( | const std::string & | actuatorName | ) |
Get an actuator by name.
actuatorName | the name of the requested actuator |
a | runtime_error if no actuator with that name is found |
const std::map< string, Actuator * > & twirre::TwirreLink::getActuators | ( | ) |
Get all registered actuators.
Sensor & twirre::TwirreLink::getSensor | ( | const std::string & | sensorName | ) |
Get a sensor by name.
sensorName | the name of the requested sensor |
a | runtime_error if no sensor with that name is found |
const std::map< string, Sensor * > & twirre::TwirreLink::getSensors | ( | ) |
Get all registered sensors.
bool twirre::TwirreLink::haveActuator | ( | const std::string & | actuatorName | ) | const |
Check if a certain actuator exists.
actuatorName | the name of the actuator to check |
bool twirre::TwirreLink::haveSensor | ( | const std::string & | sensorName | ) | const |
Check if a certain sensor exists.
sensorName | the name of the sensor to check |
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.
prov | The 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.
max | The 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.
loggingPath | path where the logfile should be created |
bool twirre::TwirreLink::stopLogging | ( | void | ) |
Stop logging and close the logfile.
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)
sensorName | The name of the sensor to emulate |
values | A vector containing pairs of valuenames with their corresponding values to write |