Orocos Real-Time Toolkit
2.8.3
|
Implements the sending/receiving of mqueue messages. More...
#include <rtt/transports/mqueue/MQSendRecv.hpp>
Public Member Functions | |
MQSendRecv (types::TypeMarshaller const &transport) | |
Create a channel element for remote data exchange. More... | |
void | setupStream (base::DataSourceBase::shared_ptr ds, base::PortInterface *port, ConnPolicy const &policy, bool is_sender) |
~MQSendRecv () | |
void | cleanupStream () |
virtual void | mqNewSample (base::DataSourceBase::shared_ptr ds) |
Adapts the mq send/receive buffer size according to the data in mqdata_source, or the value set in mdata_size;. More... | |
virtual bool | mqReady (base::DataSourceBase::shared_ptr ds, base::ChannelElementBase *chan) |
Works only in receive mode, waits for a new sample and adapts the receive buffer to match it's size. More... | |
bool | mqRead (base::DataSourceBase::shared_ptr ds) |
Read from the message queue. More... | |
bool | mqWrite (base::DataSourceBase::shared_ptr ds) |
Write to the message queue. More... | |
Protected Attributes | |
types::TypeMarshaller const & | mtransport |
Transport marshaller used for size calculations and data updates. More... | |
void * | marshaller_cookie |
A private blob that is returned by mtransport.getCookie(). More... | |
mqd_t | mqdes |
MQueue file descriptor. More... | |
char * | buf |
Send/Receive buffer. More... | |
bool | mis_sender |
True if this object is a sender. More... | |
bool | minit_done |
True if setupStream() was called, false after cleanupStream(). More... | |
int | max_size |
The size of buf. More... | |
std::string | mqname |
The name of the queue, as specified in the ConnPolicy when creating the stream, or self-calculated when that name was empty. More... | |
int | mdata_size |
The size of the data, as specified in the ConnPolicy when creating the stream, or calculated using the transport when that size was zero. More... | |
Implements the sending/receiving of mqueue messages.
It can only be OR sender OR receiver (logical XOR).
Definition at line 54 of file MQSendRecv.hpp.
MQSendRecv::MQSendRecv | ( | types::TypeMarshaller const & | transport | ) |
Create a channel element for remote data exchange.
transport | The type specific object that will be used to marshal the data. |
Definition at line 64 of file MQSendRecv.cpp.
MQSendRecv::~MQSendRecv | ( | ) |
Definition at line 153 of file MQSendRecv.cpp.
References mqdes.
void MQSendRecv::cleanupStream | ( | ) |
Definition at line 159 of file MQSendRecv.cpp.
References buf, RTT::types::TypeMarshaller::deleteCookie(), RTT::mqueue::Dispatcher::Instance(), marshaller_cookie, minit_done, mis_sender, mqdes, mqname, and mtransport.
Referenced by RTT::mqueue::MQChannelElement< T >::~MQChannelElement().
|
virtual |
Adapts the mq send/receive buffer size according to the data in mqdata_source, or the value set in mdata_size;.
sample |
Definition at line 188 of file MQSendRecv.cpp.
References buf, RTT::types::TypeMarshaller::getSampleSize(), max_size, mdata_size, and mtransport.
Referenced by RTT::mqueue::MQChannelElement< T >::data_sample().
bool MQSendRecv::mqRead | ( | base::DataSourceBase::shared_ptr | ds | ) |
Read from the message queue.
sample | stores the resulting data sample. |
Definition at line 246 of file MQSendRecv.cpp.
References buf, marshaller_cookie, max_size, mqdes, mtransport, and RTT::types::TypeMarshaller::updateFromBlob().
Referenced by RTT::mqueue::MQChannelElement< T >::signal().
|
virtual |
Works only in receive mode, waits for a new sample and adapts the receive buffer to match it's size.
Definition at line 198 of file MQSendRecv.cpp.
References buf, CLOCK_REALTIME, RTT::Error, RTT::mqueue::Dispatcher::Instance(), marshaller_cookie, max_size, minit_done, mis_sender, mqdes, mtransport, RTT::Seconds_to_nsecs(), and RTT::types::TypeMarshaller::updateFromBlob().
Referenced by RTT::mqueue::MQChannelElement< T >::inputReady().
bool MQSendRecv::mqWrite | ( | base::DataSourceBase::shared_ptr | ds | ) |
Write to the message queue.
ds | the data sample to write |
is_data_sample | true if the sample is used for initialization, false if it is a proper write |
Definition at line 261 of file MQSendRecv.cpp.
References buf, RTT::Error, RTT::types::TypeMarshaller::fillBlob(), marshaller_cookie, max_size, mqdes, and mtransport.
Referenced by RTT::mqueue::MQChannelElement< T >::data_sample(), and RTT::mqueue::MQChannelElement< T >::write().
void MQSendRecv::setupStream | ( | base::DataSourceBase::shared_ptr | ds, |
base::PortInterface * | port, | ||
ConnPolicy const & | policy, | ||
bool | is_sender | ||
) |
Definition at line 69 of file MQSendRecv.cpp.
References buf, RTT::types::TypeMarshaller::createCookie(), RTT::ConnPolicy::data_size, RTT::Debug, RTT::Error, RTT::base::PortInterface::getInterface(), RTT::base::PortInterface::getName(), RTT::TaskContext::getName(), RTT::DataFlowInterface::getOwner(), RTT::types::TypeMarshaller::getSampleSize(), marshaller_cookie, max_size, mdata_size, mis_sender, mqdes, mqname, mtransport, RTT::ConnPolicy::name_id, and RTT::ConnPolicy::size.
Referenced by RTT::mqueue::MQChannelElement< T >::MQChannelElement().
|
protected |
Send/Receive buffer.
It is initialized to the size of the value provided by the ConnPolicy or, if the policy has a zero data size, the sample given to setupStream
Its size is saved in max_size
Definition at line 79 of file MQSendRecv.hpp.
Referenced by cleanupStream(), mqNewSample(), mqRead(), mqReady(), mqWrite(), and setupStream().
|
protected |
A private blob that is returned by mtransport.getCookie().
It is used by the marshallers if they need private internal data to do the marshalling
Definition at line 67 of file MQSendRecv.hpp.
Referenced by cleanupStream(), mqRead(), mqReady(), mqWrite(), and setupStream().
|
protected |
The size of buf.
Definition at line 91 of file MQSendRecv.hpp.
Referenced by mqNewSample(), mqRead(), mqReady(), mqWrite(), and setupStream().
|
protected |
The size of the data, as specified in the ConnPolicy when creating the stream, or calculated using the transport when that size was zero.
Definition at line 102 of file MQSendRecv.hpp.
Referenced by mqNewSample(), and setupStream().
|
protected |
True if setupStream() was called, false after cleanupStream().
Definition at line 87 of file MQSendRecv.hpp.
Referenced by cleanupStream(), and mqReady().
|
protected |
True if this object is a sender.
Definition at line 83 of file MQSendRecv.hpp.
Referenced by cleanupStream(), RTT::mqueue::MQChannelElement< T >::data_sample(), mqReady(), setupStream(), and RTT::mqueue::MQChannelElement< T >::signal().
|
protected |
MQueue file descriptor.
Definition at line 71 of file MQSendRecv.hpp.
Referenced by cleanupStream(), mqRead(), mqReady(), mqWrite(), setupStream(), and ~MQSendRecv().
|
protected |
The name of the queue, as specified in the ConnPolicy when creating the stream, or self-calculated when that name was empty.
Definition at line 96 of file MQSendRecv.hpp.
Referenced by cleanupStream(), RTT::mqueue::MQChannelElement< T >::getLocalURI(), RTT::mqueue::MQChannelElement< T >::getRemoteURI(), and setupStream().
|
protected |
Transport marshaller used for size calculations and data updates.
Definition at line 61 of file MQSendRecv.hpp.
Referenced by cleanupStream(), mqNewSample(), mqRead(), mqReady(), mqWrite(), and setupStream().