PublisherNew class. More...
#include <PublisherNew.h>
Public Types | |
typedef coil::Condition< Mutex > | Condition |
typedef coil::Guard< coil::Mutex > | Guard |
typedef coil::Mutex | Mutex |
Public Member Functions | |
virtual ReturnCode | activate () |
activation | |
virtual ReturnCode | deactivate () |
deactivation | |
virtual ReturnCode | init (coil::Properties &prop) |
Initialization. | |
virtual bool | isActive () |
If publisher is active state. | |
DATAPORTSTATUS_ENUM | PublisherNew () |
Constructor. | |
virtual ReturnCode | setBuffer (CdrBufferBase *buffer) |
Setting buffer pointer. | |
virtual ReturnCode | setConsumer (InPortConsumer *consumer) |
Store InPort consumer. | |
virtual ReturnCode | setListener (ConnectorInfo &info, ConnectorListeners *listeners) |
Set the listener. | |
virtual int | svc (void) |
Thread execution function. | |
virtual ReturnCode | write (const cdrMemoryStream &data, unsigned long sec, unsigned long usec) |
Write data. | |
virtual | ~PublisherNew (void) |
Destructor. | |
Protected Types | |
enum | Policy { ALL, FIFO, SKIP, NEW } |
Protected Member Functions | |
ReturnCode | convertReturn (BufferStatus::Enum status, const cdrMemoryStream &data) |
Convertion from BufferStatus to DataPortStatus. | |
bool | createTask (const coil::Properties &prop) |
Setting Task. | |
ReturnCode | invokeListener (DataPortStatus::Enum status, const cdrMemoryStream &data) |
Call listeners according to the DataPortStatus. | |
void | onBufferFull (const cdrMemoryStream &data) |
Notify an ON_BUFFER_FULL event to listeners. | |
void | onBufferRead (const cdrMemoryStream &data) |
Notify an ON_BUFFER_READ event to listeners. | |
void | onBufferWrite (const cdrMemoryStream &data) |
Notify an ON_BUFFER_WRITE event to listeners. | |
void | onBufferWriteOverwrite (const cdrMemoryStream &data) |
Notify an ON_BUFFER_OVERWRITE event to listeners. | |
void | onBufferWriteTimeout (const cdrMemoryStream &data) |
Notify an ON_BUFFER_WRITE_TIMEOUT event to listeners. | |
void | onReceived (const cdrMemoryStream &data) |
Notify an ON_RECEIVED event to listeners. | |
void | onReceiverError (const cdrMemoryStream &data) |
Notify an ON_RECEIVER_ERROR 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 | onSend (const cdrMemoryStream &data) |
Notify an ON_SEND event to listners. | |
void | onSenderError () |
Notify an ON_SENDER_ERROR event to listeners. | |
ReturnCode | pushAll () |
push "all" policy | |
ReturnCode | pushFifo () |
push "fifo" policy | |
ReturnCode | pushNew () |
push "new" policy | |
ReturnCode | pushSkip () |
push "skip" policy | |
void | setPushPolicy (const coil::Properties &prop) |
Setting PushPolicy. | |
Private Attributes | |
bool | m_active |
CdrBufferBase * | m_buffer |
InPortConsumer * | m_consumer |
int | m_leftskip |
ConnectorListeners * | m_listeners |
ConnectorInfo | m_profile |
Policy | m_pushPolicy |
ReturnCode | m_retcode |
Mutex | m_retmutex |
int | m_skipn |
coil::PeriodicTaskBase * | m_task |
Logger | rtclog |
PublisherNew class.
Send new data at timing of when it is stored into the buffer. This class is used when operating Consumer that waits for the data send timing in different thread from one of the send side. Publisher's driven is blocked until the data send timing reaches, if the send timing notification is received, the Consumer's send processing will be invoked immediately.
Definition at line 69 of file PublisherNew.h.
Definition at line 74 of file PublisherNew.h.
Definition at line 75 of file PublisherNew.h.
typedef coil::Mutex RTC::PublisherNew::Mutex |
Definition at line 73 of file PublisherNew.h.
enum RTC::PublisherNew::Policy [protected] |
Definition at line 429 of file PublisherNew.h.
RTC::PublisherNew::~PublisherNew | ( | void | ) | [virtual] |
PublisherBase::ReturnCode RTC::PublisherNew::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.
Definition at line 219 of file PublisherNew.cpp.
PublisherBase::ReturnCode RTC::PublisherNew::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 |
Definition at line 493 of file PublisherNew.cpp.
bool RTC::PublisherNew::createTask | ( | const coil::Properties & | prop | ) | [protected] |
Setting Task.
Definition at line 317 of file PublisherNew.cpp.
PublisherBase::ReturnCode RTC::PublisherNew::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.
Definition at line 232 of file PublisherNew.cpp.
PublisherBase::ReturnCode RTC::PublisherNew::init | ( | coil::Properties & | prop | ) | [virtual] |
Initialization.
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. all, fifo, skip, new can be given as a data push policy in a value of the key "publisher.push_policy."
The following options are available.
property | Property objects that includes the control information of this Publisher |
Implements RTC::PublisherBase.
Definition at line 82 of file PublisherNew.cpp.
PublisherNew::ReturnCode RTC::PublisherNew::invokeListener | ( | DataPortStatus::Enum | status, |
const cdrMemoryStream & | data | ||
) | [protected] |
Call listeners according to the DataPortStatus.
status | DataPortStatus |
data | cdrMemoryStream |
Definition at line 541 of file PublisherNew.cpp.
bool RTC::PublisherNew::isActive | ( | void | ) | [virtual] |
If publisher is active state.
Confirm to activate.
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.
Definition at line 207 of file PublisherNew.cpp.
void RTC::PublisherNew::onBufferFull | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_BUFFER_FULL event to listeners.
data | cdrMemoryStream |
Definition at line 577 of file PublisherNew.h.
void RTC::PublisherNew::onBufferRead | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_BUFFER_READ event to listeners.
data | cdrMemoryStream |
Definition at line 622 of file PublisherNew.h.
void RTC::PublisherNew::onBufferWrite | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_BUFFER_WRITE event to listeners.
data | cdrMemoryStream |
Definition at line 562 of file PublisherNew.h.
void RTC::PublisherNew::onBufferWriteOverwrite | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_BUFFER_OVERWRITE event to listeners.
data | cdrMemoryStream |
Definition at line 607 of file PublisherNew.h.
void RTC::PublisherNew::onBufferWriteTimeout | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_BUFFER_WRITE_TIMEOUT event to listeners.
data | cdrMemoryStream |
Definition at line 592 of file PublisherNew.h.
void RTC::PublisherNew::onReceived | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_RECEIVED event to listeners.
data | cdrMemoryStream |
Definition at line 652 of file PublisherNew.h.
void RTC::PublisherNew::onReceiverError | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_RECEIVER_ERROR event to listeners.
data | cdrMemoryStream |
Definition at line 697 of file PublisherNew.h.
void RTC::PublisherNew::onReceiverFull | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_RECEIVER_FULL event to listeners.
data | cdrMemoryStream |
Definition at line 667 of file PublisherNew.h.
void RTC::PublisherNew::onReceiverTimeout | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_RECEIVER_TIMEOUT event to listeners.
data | cdrMemoryStream |
Definition at line 682 of file PublisherNew.h.
void RTC::PublisherNew::onSend | ( | const cdrMemoryStream & | data | ) | [inline, protected] |
Notify an ON_SEND event to listners.
data | cdrMemoryStream |
Definition at line 637 of file PublisherNew.h.
void RTC::PublisherNew::onSenderError | ( | ) | [inline, protected] |
Notify an ON_SENDER_ERROR event to listeners.
data | cdrMemoryStream |
Definition at line 712 of file PublisherNew.h.
PublisherNew::ReturnCode RTC::PublisherNew::pushAll | ( | ) | [protected] |
PublisherNew::ReturnCode RTC::PublisherNew::pushFifo | ( | ) | [protected] |
push "fifo" policy
Definition at line 390 of file PublisherNew.cpp.
PublisherNew::ReturnCode RTC::PublisherNew::pushNew | ( | ) | [protected] |
push "new" policy
Definition at line 462 of file PublisherNew.cpp.
PublisherNew::ReturnCode RTC::PublisherNew::pushSkip | ( | ) | [protected] |
push "skip" policy
Definition at line 414 of file PublisherNew.cpp.
PublisherBase::ReturnCode RTC::PublisherNew::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. |
Definition at line 122 of file PublisherNew.cpp.
PublisherBase::ReturnCode RTC::PublisherNew::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.
Definition at line 102 of file PublisherNew.cpp.
PublisherBase::ReturnCode RTC::PublisherNew::setListener | ( | ConnectorInfo & | info, |
ConnectorListeners * | listeners | ||
) | [virtual] |
Set the listener.
Setting buffer pointer.
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.
Definition at line 143 of file PublisherNew.cpp.
void RTC::PublisherNew::setPushPolicy | ( | const coil::Properties & | prop | ) | [protected] |
Setting PushPolicy.
Definition at line 277 of file PublisherNew.cpp.
int RTC::PublisherNew::svc | ( | void | ) | [virtual] |
Thread execution function.
A task execution function to be executed by coil::PeriodicTask.
Definition at line 245 of file PublisherNew.cpp.
PublisherBase::ReturnCode RTC::PublisherNew::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.
Definition at line 165 of file PublisherNew.cpp.
bool RTC::PublisherNew::m_active [private] |
Definition at line 730 of file PublisherNew.h.
CdrBufferBase* RTC::PublisherNew::m_buffer [private] |
Definition at line 722 of file PublisherNew.h.
InPortConsumer* RTC::PublisherNew::m_consumer [private] |
Definition at line 721 of file PublisherNew.h.
int RTC::PublisherNew::m_leftskip [private] |
Definition at line 731 of file PublisherNew.h.
ConnectorListeners* RTC::PublisherNew::m_listeners [private] |
Definition at line 725 of file PublisherNew.h.
ConnectorInfo RTC::PublisherNew::m_profile [private] |
Definition at line 723 of file PublisherNew.h.
Policy RTC::PublisherNew::m_pushPolicy [private] |
Definition at line 728 of file PublisherNew.h.
ReturnCode RTC::PublisherNew::m_retcode [private] |
Definition at line 726 of file PublisherNew.h.
Mutex RTC::PublisherNew::m_retmutex [private] |
Definition at line 727 of file PublisherNew.h.
int RTC::PublisherNew::m_skipn [private] |
Definition at line 729 of file PublisherNew.h.
coil::PeriodicTaskBase* RTC::PublisherNew::m_task [private] |
Definition at line 724 of file PublisherNew.h.
Logger RTC::PublisherNew::rtclog [private] |
Definition at line 720 of file PublisherNew.h.