communication.h
Go to the documentation of this file.
1 
7 #ifndef COMMUNICATION_H
8 #define COMMUNICATION_H
9 
10 #include <string>
15 #include <ros/ros.h>
18 
37 {
38 public:
44  Communication(const std::string& configPath);
53  void connect();
58  void startCommunication();
63  void stopCommunication();
68  void disconnect();
77  void sendRawMessage(const std::string& msg);
106  bool sendCommand(const std::string& command,
107  const Parameter::ParameterMap& inputParams,
108  Parameter::ParameterMap& outputParams,
109  unsigned int timeout = 100000);
127  bool sendCommand(const std::string& command,
128  const std::vector<std::string>& options,
129  const Parameter::ParameterMap& inputParams,
130  Parameter::ParameterMap& outputParams,
131  unsigned int timeout = 100000);
160  bool registerSensorGroups(const std::string& cmdName,
161  unsigned int timeout = 100000);
172  void registerSensorGroupCallback(const unsigned char& grpNumber,
173  responseCallback cbPtr);
174 
175 private:
177  std::shared_ptr<SerialInterfaceParams> serialParams;
178  std::shared_ptr<Syntax> syntax;
179  std::unordered_map<std::string, std::shared_ptr<Command>> commands;
180  std::unordered_map<unsigned char, std::shared_ptr<SensorGroup>> sensorGroups;
185  mutable std::mutex mtx;
186  std::condition_variable cv;
192  void configSerialInterface();
193 };
194 
195 #endif // COMMUNICATION_H
Header file for the CommunicationConfig class.
std::unordered_map< std::string, std::shared_ptr< Command > > commands
void startCommunication()
Start reading the serial input buffer and start parsing threads.
bool registerSensorGroups(const std::string &cmdName, unsigned int timeout=100000)
Register all predefined sensor groups on the serial device.
boost::function< void(SensorGroup *)> responseCallback
Definition: sensorgroup.h:63
Header file for the Command class.
Header file for the ReadingThread class.
void enableRawCommunication()
Enables the transmission of raw messages to the serial device.
void sendRawMessage(const std::string &msg)
Method to send a string directly to the serial device.
The ThreadDispatcher class coordinates other communication threads and handles start up and shut down...
void stopCommunication()
Stop reading the serial input buffer and shutdown parsing threads.
void connect()
Tries to setup a connection to a serial devive with a certain device-tag and specified baudrate...
std::condition_variable cv
SensorGroupThread * sensorGroupThread
The ReadingThread class implements threadded polling of the serial input buffer.
Definition: readingthread.h:31
The Parameter::ParameterMap class provides a map functionality for Parameter::Parameter objects conta...
Definition: parameter.h:163
bool sendCommand(const std::string &command, const Parameter::ParameterMap &inputParams, Parameter::ParameterMap &outputParams, unsigned int timeout=100000)
Send a command to the servial device.
void registerErrorCallback(debugCallbackPtr error)
Register a callback to handle transmission/communication errors.
Header file for the ThreadDispatcher class.
void disconnect()
Terminates a connection to a serial devive with a certain device-tag.
void configSerialInterface()
Configures the serial connection setup with the provided parameters.
void enableDebugMessages(debugCallbackPtr debug)
Enable pass through of every line in the input buffer.
ReadingThread * rxPolling
void registerTextCallback(debugCallbackPtr text)
Register a callback to handle plain text messages from the serial device.
void registerSensorGroupCallback(const unsigned char &grpNumber, responseCallback cbPtr)
Register a callback to handle sensor group messages from the serial device.
The Communication class provides access to microcontroller communication.
Definition: communication.h:36
Header file for the SerialInterface class.
~Communication()
Communication default destructor.
boost::function< void(const std::string &)> debugCallbackPtr
CommunicationConfig comCfg
The CommunicationConfig class parses config files and provides configuration parameters to a Communca...
ThreadDispatcher * dispatcher
std::shared_ptr< SerialInterfaceParams > serialParams
std::shared_ptr< Syntax > syntax
std::unordered_map< unsigned char, std::shared_ptr< SensorGroup > > sensorGroups
Header file for the Parameter::Parameter, Parameter::GenericParameter and Parameter::ParameterMap cla...
The SensorGroupThread class implements functionality to extract the group identifier of an incoming s...
std::mutex mtx
Communication(const std::string &configPath)
Communication constructor.
bool rawCommunicationEnabled


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