PublisherPeriodic class. More...
#include <PublisherPeriodic.h>
Public Types | |
typedef coil::Mutex | Mutex |
typedef coil::Condition< Mutex > | Condition |
typedef coil::Guard< coil::Mutex > | Guard |
Public Member Functions | |
DATAPORTSTATUS_ENUM | PublisherPeriodic (void) |
Constructor. | |
virtual | ~PublisherPeriodic (void) |
Destructor. | |
virtual ReturnCode | init (coil::Properties &prop) |
Initialization. | |
virtual ReturnCode | setConsumer (InPortConsumer *consumer) |
Store InPort consumer. | |
virtual ReturnCode | setBuffer (CdrBufferBase *buffer) |
Setting buffer pointer. | |
virtual ReturnCode | setListener (ConnectorInfo &info, ConnectorListeners *listeners) |
Set the listener. | |
virtual ReturnCode | write (const cdrMemoryStream &data, unsigned long sec, unsigned long usec) |
Write data. | |
virtual bool | isActive () |
If publisher is active state. | |
virtual ReturnCode | activate () |
activation | |
virtual ReturnCode | deactivate () |
deactivation | |
virtual int | svc (void) |
Thread execution function. | |
Protected Types | |
enum | Policy { ALL, FIFO, SKIP, NEW } |
Protected Member Functions | |
void | setPushPolicy (const coil::Properties &prop) |
Setting PushPolicy. | |
bool | createTask (const coil::Properties &prop) |
Setting Task. | |
ReturnCode | pushAll () |
push "all" policy | |
ReturnCode | pushFifo () |
push "fifo" policy | |
ReturnCode | pushSkip () |
push "skip" policy | |
ReturnCode | pushNew () |
push "new" policy | |
ReturnCode | convertReturn (BufferStatus::Enum status, const cdrMemoryStream &data) |
Convertion from BufferStatus to DataPortStatus. | |
ReturnCode | invokeListener (DataPortStatus::Enum status, const cdrMemoryStream &data) |
Call listeners according to the DataPortStatus. | |
void | onBufferWrite (const cdrMemoryStream &data) |
Notify an ON_BUFFER_WRITE event to listeners. | |
void | onBufferFull (const cdrMemoryStream &data) |
Notify an ON_BUFFER_FULL event to listeners. | |
void | onBufferWriteTimeout (const cdrMemoryStream &data) |
Notify an ON_BUFFER_WRITE_TIMEOUT event to listeners. | |
void | onBufferRead (const cdrMemoryStream &data) |
Notify an ON_BUFFER_READ event to listeners. | |
void | onSend (const cdrMemoryStream &data) |
Notify an ON_SEND event to listners. | |
void | onReceived (const cdrMemoryStream &data) |
Notify an ON_RECEIVED event to listeners. | |
void | onReceiverFull (const cdrMemoryStream &data) |
Notify an ON_RECEIVER_FULL event to listeners. | |
void | onReceiverTimeout (const cdrMemoryStream &data) |
Notify an ON_RECEIVER_TIMEOUT event to listeners. | |
void | onReceiverError (const cdrMemoryStream &data) |
Notify an ON_RECEIVER_ERROR event to listeners. | |
void | onBufferEmpty () |
Notify an ON_BUFFER_EMPTY event to listeners. | |
void | onSenderEmpty () |
Notify an ON_SENDER_EMPTY event to listeners. | |
void | onSenderError () |
Notify an ON_SENDER_ERROR event to listeners. |
PublisherPeriodic class.
Publisher for periodic data transmitting. Usually this class object exists in a Connector object, and it is associated with a buffer and a consumer. This publisher periodically gets data from the buffer and publish it into the consumer.
typedef coil::Condition<Mutex> RTC::PublisherPeriodic::Condition |
typedef coil::Guard<coil::Mutex> RTC::PublisherPeriodic::Guard |
typedef coil::Mutex RTC::PublisherPeriodic::Mutex |
enum RTC::PublisherPeriodic::Policy [protected] |
DATAPORTSTATUS_ENUM RTC::PublisherPeriodic::PublisherPeriodic | ( | void | ) |
Constructor.
virtual RTC::PublisherPeriodic::~PublisherPeriodic | ( | void | ) | [virtual] |
Destructor.
Destructor
virtual ReturnCode RTC::PublisherPeriodic::activate | ( | ) | [virtual] |
activation
This function activates the publisher. By calling this function, this publisher starts the thread that pushes data to InPort. If precondition such as initialization process and so on is not met, the error code PRECONDITION_NOT_MET is returned.
Implements RTC::PublisherBase.
ReturnCode RTC::PublisherPeriodic::convertReturn | ( | BufferStatus::Enum | status, | |
const cdrMemoryStream & | data | |||
) | [protected] |
Convertion from BufferStatus to DataPortStatus.
This function converts return value from the buffer to DataPortStatus::Enum typed return value. The conversion rule is as follows. Callback functions are also shown, if it exists.
status | BufferStatus | |
data | cdrMemoryStream |
bool RTC::PublisherPeriodic::createTask | ( | const coil::Properties & | prop | ) | [protected] |
Setting Task.
virtual ReturnCode RTC::PublisherPeriodic::deactivate | ( | ) | [virtual] |
deactivation
This function deactivates the publisher. By calling this function, this publisher stops the thread that pushes data to InPort. If precondition such as initialization process and so on is not met, the error code PRECONDITION_NOT_MET is returned.
Implements RTC::PublisherBase.
virtual ReturnCode RTC::PublisherPeriodic::init | ( | coil::Properties & | prop | ) | [virtual] |
Initialization.
This function have to be called before using this class object. Properties object that includes certain configuration information should be given as an argument. At least, a numerical value of unit of Hz with the key of "dataport.publisher.push_rate" has to be set to the Properties object of argument. The value is the invocation cycle of data sending process. In case of 5 ms period or 200 Hz, the value should be set as 200.0. False will be returned, if there is no value with the key of "dataport.publisher.push_rate".
The following options are available.
property | Property objects that includes the control information of this Publisher |
Implements RTC::PublisherBase.
ReturnCode RTC::PublisherPeriodic::invokeListener | ( | DataPortStatus::Enum | status, | |
const cdrMemoryStream & | data | |||
) | [protected] |
Call listeners according to the DataPortStatus.
status | DataPortStatus | |
data | cdrMemoryStream |
virtual bool RTC::PublisherPeriodic::isActive | ( | ) | [virtual] |
If publisher is active state.
A Publisher can be activated/deactivated synchronized with the data port. The active state and the non-active state are made transition by the "activate()" and the "deactivate()" functions respectively. This function confirms if the publisher is in active state.
Implements RTC::PublisherBase.
void RTC::PublisherPeriodic::onBufferEmpty | ( | ) | [inline, protected] |
Notify an ON_BUFFER_EMPTY event to listeners.
References RTC::ON_BUFFER_EMPTY.
void RTC::PublisherPeriodic::onBufferFull | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_BUFFER_FULL event to listeners.
data | cdrMemoryStream |
References RTC::ON_BUFFER_FULL.
void RTC::PublisherPeriodic::onBufferRead | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_BUFFER_READ event to listeners.
data | cdrMemoryStream |
References RTC::ON_BUFFER_READ.
void RTC::PublisherPeriodic::onBufferWrite | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_BUFFER_WRITE event to listeners.
data | cdrMemoryStream |
References RTC::ON_BUFFER_WRITE.
void RTC::PublisherPeriodic::onBufferWriteTimeout | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_BUFFER_WRITE_TIMEOUT event to listeners.
data | cdrMemoryStream |
References RTC::ON_BUFFER_WRITE_TIMEOUT.
void RTC::PublisherPeriodic::onReceived | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_RECEIVED event to listeners.
data | cdrMemoryStream |
References RTC::ON_RECEIVED.
void RTC::PublisherPeriodic::onReceiverError | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_RECEIVER_ERROR event to listeners.
data | cdrMemoryStream |
References RTC::ON_RECEIVER_ERROR.
void RTC::PublisherPeriodic::onReceiverFull | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_RECEIVER_FULL event to listeners.
data | cdrMemoryStream |
References RTC::ON_RECEIVER_FULL.
void RTC::PublisherPeriodic::onReceiverTimeout | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_RECEIVER_TIMEOUT event to listeners.
data | cdrMemoryStream |
References RTC::ON_RECEIVER_TIMEOUT.
void RTC::PublisherPeriodic::onSend | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
void RTC::PublisherPeriodic::onSenderEmpty | ( | ) | [inline, protected] |
Notify an ON_SENDER_EMPTY event to listeners.
References RTC::ON_SENDER_EMPTY.
void RTC::PublisherPeriodic::onSenderError | ( | ) | [inline, protected] |
Notify an ON_SENDER_ERROR event to listeners.
References RTC::ON_SENDER_ERROR.
ReturnCode RTC::PublisherPeriodic::pushAll | ( | ) | [protected] |
push "all" policy
ReturnCode RTC::PublisherPeriodic::pushFifo | ( | ) | [protected] |
push "fifo" policy
ReturnCode RTC::PublisherPeriodic::pushNew | ( | ) | [protected] |
push "new" policy
ReturnCode RTC::PublisherPeriodic::pushSkip | ( | ) | [protected] |
push "skip" policy
virtual ReturnCode RTC::PublisherPeriodic::setBuffer | ( | CdrBufferBase * | buffer | ) | [virtual] |
Setting buffer pointer.
This operation sets a buffer that is associated with this object. If the buffer object is NULL, INVALID_ARGS will be returned.
buffer | A pointer to a CDR buffer object. |
virtual ReturnCode RTC::PublisherPeriodic::setConsumer | ( | InPortConsumer * | consumer | ) | [virtual] |
Store InPort consumer.
This operation sets a consumer that is associated with this object. If the consumer object is NULL, INVALID_ARGS will be returned.
consumer | A pointer to a consumer object. |
Implements RTC::PublisherBase.
virtual ReturnCode RTC::PublisherPeriodic::setListener | ( | ConnectorInfo & | info, | |
ConnectorListeners * | listeners | |||
) | [virtual] |
Set the listener.
This function sets ConnectorListeners listener object to the Publisher. By setting ConnectorListeners containing various listeners objects, these listeners are called at the time of reading and writing of a buffer, and transmission of data etc. Since the ownership of the ConnectorListeners object is owned by Port or RTObject, the Publisher never deletes the ConnectorListeners object. If the given ConnectorListeners' pointer is NULL, this function returns INVALID_ARGS.
info | ConnectorInfo that is localized object of ConnectorProfile | |
listeners | ConnectorListeners that holds various listeners |
Implements RTC::PublisherBase.
void RTC::PublisherPeriodic::setPushPolicy | ( | const coil::Properties & | prop | ) | [protected] |
Setting PushPolicy.
virtual int RTC::PublisherPeriodic::svc | ( | void | ) | [virtual] |
Thread execution function.
A task execution function to be executed by coil::PeriodicTask.
virtual ReturnCode RTC::PublisherPeriodic::write | ( | const cdrMemoryStream & | data, | |
unsigned long | sec, | |||
unsigned long | usec | |||
) | [virtual] |
Write data.
This function writes data into the buffer associated with this Publisher. If a Publisher object calls this function, without initializing correctly such as a consumer, a buffer, listeners, etc., error code PRECONDITION_NOT_MET will be returned and no operation of the writing to a buffer etc. will be performed.
Since writing into the buffer and sending data to InPort are performed asynchronously, occasionally this function returns return-codes such as CONNECTION_LOST and BUFFER_FULL that indicate the result of sending data to InPort. In this case, writing data into buffer will not be performed.
When publisher writes data to the buffer, if the buffer is filled, returns error, is returned with timeout and returns precondition error, error codes BUFFER_FULL, BUFFER_ERROR, BUFFER_TIMEOUT and PRECONDITION_NOT_MET will be returned respectively.
In other cases, PROT_ERROR will be returned.
data | Data to be wrote to the buffer | |
sec | Timeout time in unit seconds | |
nsec | Timeout time in unit nano-seconds |
Implements RTC::PublisherBase.