Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
SensorGroup Class Reference

The SensorGroup class builds the syntactic template for its specific command that results from the sensor group definition and parses incoming sensor group data. More...

#include <sensorgroup.h>

Public Member Functions

void createSensorGroupCommand (Command &cmd, std::string &command) const
 Get the generated sensor group command, that can be used to register this sensor group on the serial device. More...
 
template<typename T >
const bool getChannelValue (const std::string &name, T &value) const
 Get a received value from a certain channel. More...
 
const bool getChannelValueConverted (const std::string &name, double &value) const
 Get a received converted value from a certain channel. More...
 
const std::string & getName () const
 Get the name of this sensor group. More...
 
void processResponse (const std::string &response)
 Parses an incoming sensor group message, extracts contained values and calls the registered sensor group callback. More...
 
void registerErrorCallback (valueErrorCallbackPtr valueError)
 Register a value error function pointer to handle value errors during communication. More...
 
 SensorGroup ()
 SensorGroup default constructor. More...
 
 SensorGroup (const SensorGroupParameter &sensorParams, std::shared_ptr< Syntax > syntax)
 SensorGroup constructor. More...
 
void setResponseCallback (responseCallback callbackFunction)
 Register a sensor group callback. More...
 
const bool verifyResponseOnComand (Command &cmd, const std::string &response) const
 Verfy the response on a constructed set sensor group command. More...
 

Static Public Attributes

static const std::string ENCODING_ASCII = "ASCII"
 
static const std::string ENCODING_B64 = "B64"
 
static const std::string ENCODING_HEX = "HEX"
 

Private Member Functions

void parseResponse (const std::string &response)
 Parse a received sensor channel message and extract channel values, i.e. convert encoded data to "proper" data types. More...
 

Private Attributes

responseCallback callbackFunction
 
bool callbackRegistered
 
std::vector< std::shared_ptr< Channel > > channelList
 
std::unordered_map< std::string, std::shared_ptr< Channel > > channelMap
 
Parameter::ParameterMap channelValues
 
Parameter::ParameterMap cmdInputParams
 
std::string grpName
 
unsigned char grpNumber
 
std::vector< std::string > optionsList
 
Parameter::ParameterMap optionValues
 
std::vector< std::string > optionVariableList
 
std::string responseEncoding
 
std::shared_ptr< Syntaxsyntax
 
valueErrorCallbackPtr valueError
 
bool valueErrorCBSet
 

Detailed Description

The SensorGroup class builds the syntactic template for its specific command that results from the sensor group definition and parses incoming sensor group data.

A SensorGroup object builds its command message given the required channels and channel options. It can also parse incoming sensor group data and call a registered function which decides what to do with the received data.

Definition at line 82 of file sensorgroup.h.

Constructor & Destructor Documentation

SensorGroup::SensorGroup ( )

SensorGroup default constructor.

Definition at line 13 of file sensorgroup.cpp.

SensorGroup::SensorGroup ( const SensorGroupParameter sensorParams,
std::shared_ptr< Syntax syntax 
)

SensorGroup constructor.

Parameters
[in]sensorParamsserves as a data struct to configure SensorGroup a object.
[in]syntaxSyntax object used to detect escape sequences and other important symbols.

Definition at line 15 of file sensorgroup.cpp.

Member Function Documentation

void SensorGroup::createSensorGroupCommand ( Command cmd,
std::string &  command 
) const

Get the generated sensor group command, that can be used to register this sensor group on the serial device.

Parameters
[in]cmdCommand object containing a set sensor group command
[out]commandconstructed set sensor group command

Definition at line 208 of file sensorgroup.cpp.

template<typename T >
const bool SensorGroup::getChannelValue ( const std::string &  name,
T &  value 
) const
inline

Get a received value from a certain channel.

Parameters
[in]namesensor channel name
[out]returned(unconverted) value
Exceptions
std::exception
Returns
true if channel is in sensor group, else false

Definition at line 143 of file sensorgroup.h.

const bool SensorGroup::getChannelValueConverted ( const std::string &  name,
double &  value 
) const

Get a received converted value from a certain channel.

Parameters
[in]namesensor channel name
[out]returnedconverted value
Exceptions
std::exception
Returns
true if channel is in sensor group, else false

Definition at line 223 of file sensorgroup.cpp.

const std::string & SensorGroup::getName ( ) const

Get the name of this sensor group.

Returns
name of this sensor group

Definition at line 206 of file sensorgroup.cpp.

void SensorGroup::parseResponse ( const std::string &  response)
private

Parse a received sensor channel message and extract channel values, i.e. convert encoded data to "proper" data types.

Parameters
[in]responseposted sensor group message
Exceptions
std::exception

Definition at line 116 of file sensorgroup.cpp.

void SensorGroup::processResponse ( const std::string &  response)

Parses an incoming sensor group message, extracts contained values and calls the registered sensor group callback.

Parameters
[in]responseinput sensor group message

Definition at line 109 of file sensorgroup.cpp.

void SensorGroup::registerErrorCallback ( valueErrorCallbackPtr  valueError)

Register a value error function pointer to handle value errors during communication.

Parameters
[in]valueErrorthis function decides what to do with the contents of a value error message

Definition at line 200 of file sensorgroup.cpp.

void SensorGroup::setResponseCallback ( responseCallback  callbackFunction)

Register a sensor group callback.

Exceptions
std::exception
Parameters
[in]callbackFunctionpointer to the function that gets call whenever this sensor group object receives a message.

Definition at line 194 of file sensorgroup.cpp.

const bool SensorGroup::verifyResponseOnComand ( Command cmd,
const std::string &  response 
) const

Verfy the response on a constructed set sensor group command.

Parameters
[in]cmdCommand object containing a set sensor group command
[in]responseresponse from the serial device
Exceptions
std::exception
Returns
true if response is valid, else false

Definition at line 215 of file sensorgroup.cpp.

Member Data Documentation

responseCallback SensorGroup::callbackFunction
private

Sensor group message callback pointer

Definition at line 173 of file sensorgroup.h.

bool SensorGroup::callbackRegistered
private

Has a group callback been registered?

Definition at line 174 of file sensorgroup.h.

std::vector<std::shared_ptr<Channel> > SensorGroup::channelList
private

List of all channels in a sensor group.

Definition at line 168 of file sensorgroup.h.

std::unordered_map<std::string, std::shared_ptr<Channel> > SensorGroup::channelMap
private

Map of Channel objects in this group (first: name, second Channel)

Definition at line 169 of file sensorgroup.h.

Parameter::ParameterMap SensorGroup::channelValues
private

Parameter map of received channel values

Definition at line 170 of file sensorgroup.h.

Parameter::ParameterMap SensorGroup::cmdInputParams
private

Set group command input parameter map

Definition at line 175 of file sensorgroup.h.

const std::string SensorGroup::ENCODING_ASCII = "ASCII"
static

Constant Ascii encoding indicator

Definition at line 160 of file sensorgroup.h.

const std::string SensorGroup::ENCODING_B64 = "B64"
static

Constant b64 encoding indicator

Definition at line 161 of file sensorgroup.h.

const std::string SensorGroup::ENCODING_HEX = "HEX"
static

Constant hex encoding indicator

Definition at line 162 of file sensorgroup.h.

std::string SensorGroup::grpName
private

Optional semanitc descriptor of a group

Definition at line 166 of file sensorgroup.h.

unsigned char SensorGroup::grpNumber
private

The unique identifier of a group

Definition at line 165 of file sensorgroup.h.

std::vector<std::string> SensorGroup::optionsList
private

List of enabled options for a group

Definition at line 176 of file sensorgroup.h.

Parameter::ParameterMap SensorGroup::optionValues
private

Parameter map of given option values

Definition at line 172 of file sensorgroup.h.

std::vector<std::string> SensorGroup::optionVariableList
private

List of parameter names for given options

Definition at line 171 of file sensorgroup.h.

std::string SensorGroup::responseEncoding
private

Encoding standard of a sensor group message

Definition at line 167 of file sensorgroup.h.

std::shared_ptr<Syntax> SensorGroup::syntax
private

Pointer to a Syntax object

Definition at line 177 of file sensorgroup.h.

valueErrorCallbackPtr SensorGroup::valueError
private

Pointer to the value error handling function

Definition at line 178 of file sensorgroup.h.

bool SensorGroup::valueErrorCBSet
private

Has a value error callback been registered?

Definition at line 179 of file sensorgroup.h.


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


pses_ucbridge
Author(s): Sebastian Ehmes
autogenerated on Sat Oct 28 2017 19:16:13