#include <MTDevice.hpp>
Public Types | |
| typedef boost::function< void(MTMsgPtr)> | FunctorType |
| typedef std::map< int, FunctorType > | HandlerMap |
Public Member Functions | |
| MTDevice (const std::string &portName, uint32_t baud) | |
| void | registerHandlers (const HandlerMap &map) |
| void | send (MTMsgPtr message) |
| ~MTDevice () | |
Private Types | |
| enum | { Sync, Header, Data } |
| enum | { ringBufferSize = 7 } |
Private Member Functions | |
| void | onData (const boost::system::error_code &error, std::size_t bytes_transferred) |
| void | onHeader (StreamPtr data, const boost::system::error_code &error, std::size_t bytes_transferred) |
| void | onSync (const boost::system::error_code &error, std::size_t bytes_transferred) |
| void | start_receive (uint8_t state) |
Private Attributes | |
| HandlerMap | handlers |
| boost::asio::streambuf | input |
| boost::archive::binary_iarchive | inputSer |
| boost::asio::io_service | io |
| boost::asio::serial_port | port |
| std::vector< uint8_t > | ringBuffer |
| boost::thread | service |
| typedef boost::function<void (MTMsgPtr)> labust::tritech::MTDevice::FunctorType |
The functor typedef.
Definition at line 66 of file MTDevice.hpp.
| typedef std::map<int,FunctorType> labust::tritech::MTDevice::HandlerMap |
The handler typedef.
Definition at line 70 of file MTDevice.hpp.
anonymous enum [private] |
Definition at line 60 of file MTDevice.hpp.
anonymous enum [private] |
Definition at line 61 of file MTDevice.hpp.
| MTDevice::MTDevice | ( | const std::string & | portName, |
| uint32_t | baud | ||
| ) |
Default constructor with specified portname and baud rate.
Definition at line 46 of file MTDevice.cpp.
Generic destructor.
Definition at line 75 of file MTDevice.cpp.
| void labust::tritech::MTDevice::onData | ( | const boost::system::error_code & | error, |
| std::size_t | bytes_transferred | ||
| ) | [private] |
Handle data message.
| void MTDevice::onHeader | ( | StreamPtr | data, |
| const boost::system::error_code & | error, | ||
| std::size_t | bytes_transferred | ||
| ) | [private] |
Handle next incoming header.
Definition at line 143 of file MTDevice.cpp.
| void MTDevice::onSync | ( | const boost::system::error_code & | error, |
| std::size_t | bytes_transferred | ||
| ) | [private] |
Handles synchronization.
Definition at line 100 of file MTDevice.cpp.
| void labust::tritech::MTDevice::registerHandlers | ( | const HandlerMap & | map | ) | [inline] |
The method registers the handler.
Definition at line 87 of file MTDevice.hpp.
| void MTDevice::send | ( | MTMsgPtr | message | ) |
The method sends the buffer content to the device.
Definition at line 186 of file MTDevice.cpp.
| void MTDevice::start_receive | ( | uint8_t | state | ) | [private] |
Start async_reads based on current state.
Definition at line 83 of file MTDevice.cpp.
The handler map.
Definition at line 138 of file MTDevice.hpp.
boost::asio::streambuf labust::tritech::MTDevice::input [private] |
The input buffer.
Definition at line 122 of file MTDevice.hpp.
boost::archive::binary_iarchive labust::tritech::MTDevice::inputSer [private] |
Structure serializator.
Definition at line 130 of file MTDevice.hpp.
boost::asio::io_service labust::tritech::MTDevice::io [private] |
IO service
Definition at line 114 of file MTDevice.hpp.
boost::asio::serial_port labust::tritech::MTDevice::port [private] |
Serial port.
Definition at line 118 of file MTDevice.hpp.
The header ring buffer.
Definition at line 126 of file MTDevice.hpp.
boost::thread labust::tritech::MTDevice::service [private] |
The runner thread.
Definition at line 134 of file MTDevice.hpp.