Public Types | Public Member Functions | Protected Types | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
RTC::PublisherPeriodic Class Reference

PublisherPeriodic class. More...

#include <PublisherPeriodic.h>

Inheritance diagram for RTC::PublisherPeriodic:
Inheritance graph
[legend]

Public Types

typedef coil::Condition< MutexCondition
 
typedef coil::Guard< coil::MutexGuard
 
typedef coil::Mutex Mutex
 
- Public Types inherited from RTC::DataPortStatus
enum  Enum {
  PORT_OK = 0, PORT_ERROR, BUFFER_ERROR, BUFFER_FULL,
  BUFFER_EMPTY, BUFFER_TIMEOUT, SEND_FULL, SEND_TIMEOUT,
  RECV_EMPTY, RECV_TIMEOUT, INVALID_ARGS, PRECONDITION_NOT_MET,
  CONNECTION_LOST, UNKNOWN_ERROR
}
 DataPortStatus return codes. More...
 

Public Member Functions

virtual ReturnCode activate ()
 activation More...
 
virtual ReturnCode deactivate ()
 deactivation More...
 
virtual ReturnCode init (coil::Properties &prop)
 Initialization. More...
 
virtual bool isActive ()
 If publisher is active state. More...
 
DATAPORTSTATUS_ENUM PublisherPeriodic (void)
 Constructor. More...
 
virtual ReturnCode setBuffer (CdrBufferBase *buffer)
 Setting buffer pointer. More...
 
virtual ReturnCode setConsumer (InPortConsumer *consumer)
 Store InPort consumer. More...
 
virtual ReturnCode setListener (ConnectorInfo &info, ConnectorListeners *listeners)
 Set the listener. More...
 
virtual int svc (void)
 Thread execution function. More...
 
virtual ReturnCode write (const cdrMemoryStream &data, unsigned long sec, unsigned long usec)
 Write data. More...
 
virtual ~PublisherPeriodic (void)
 Destructor. More...
 
- Public Member Functions inherited from RTC::PublisherBase
virtual void release ()
 Release the Publisher. More...
 
virtual DATAPORTSTATUS_ENUM ~PublisherBase (void)
 Destructor. More...
 

Protected Types

enum  Policy { ALL, FIFO, SKIP, NEW }
 

Protected Member Functions

ReturnCode convertReturn (BufferStatus::Enum status, const cdrMemoryStream &data)
 Convertion from BufferStatus to DataPortStatus. More...
 
bool createTask (const coil::Properties &prop)
 Setting Task. More...
 
ReturnCode invokeListener (DataPortStatus::Enum status, const cdrMemoryStream &data)
 Call listeners according to the DataPortStatus. More...
 
void onBufferEmpty ()
 Notify an ON_BUFFER_EMPTY event to listeners. More...
 
void onBufferFull (const cdrMemoryStream &data)
 Notify an ON_BUFFER_FULL event to listeners. More...
 
void onBufferRead (const cdrMemoryStream &data)
 Notify an ON_BUFFER_READ event to listeners. More...
 
void onBufferWrite (const cdrMemoryStream &data)
 Notify an ON_BUFFER_WRITE event to listeners. More...
 
void onBufferWriteTimeout (const cdrMemoryStream &data)
 Notify an ON_BUFFER_WRITE_TIMEOUT event to listeners. More...
 
void onReceived (const cdrMemoryStream &data)
 Notify an ON_RECEIVED event to listeners. More...
 
void onReceiverError (const cdrMemoryStream &data)
 Notify an ON_RECEIVER_ERROR event to listeners. More...
 
void onReceiverFull (const cdrMemoryStream &data)
 Notify an ON_RECEIVER_FULL event to listeners. More...
 
void onReceiverTimeout (const cdrMemoryStream &data)
 Notify an ON_RECEIVER_TIMEOUT event to listeners. More...
 
void onSend (const cdrMemoryStream &data)
 Notify an ON_SEND event to listners. More...
 
void onSenderEmpty ()
 Notify an ON_SENDER_EMPTY event to listeners. More...
 
void onSenderError ()
 Notify an ON_SENDER_ERROR event to listeners. More...
 
ReturnCode pushAll ()
 push "all" policy More...
 
ReturnCode pushFifo ()
 push "fifo" policy More...
 
ReturnCode pushNew ()
 push "new" policy More...
 
ReturnCode pushSkip ()
 push "skip" policy More...
 
void setPushPolicy (const coil::Properties &prop)
 Setting PushPolicy. More...
 

Private Member Functions

bool bufferIsEmpty ()
 

Private Attributes

bool m_active
 
CdrBufferBasem_buffer
 
InPortConsumerm_consumer
 
int m_leftskip
 
ConnectorListenersm_listeners
 
ConnectorInfo m_profile
 
Policy m_pushPolicy
 
bool m_readback
 
ReturnCode m_retcode
 
Mutex m_retmutex
 
int m_skipn
 
coil::PeriodicTaskBasem_task
 
Logger rtclog
 

Additional Inherited Members

- Static Public Member Functions inherited from RTC::DataPortStatus
static const char * toString (DataPortStatus::Enum status)
 Convert DataPortStatus into the string. More...
 

Detailed Description

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.

Definition at line 64 of file PublisherPeriodic.h.

Member Typedef Documentation

Definition at line 69 of file PublisherPeriodic.h.

Definition at line 70 of file PublisherPeriodic.h.

Definition at line 68 of file PublisherPeriodic.h.

Member Enumeration Documentation

Enumerator
ALL 
FIFO 
SKIP 
NEW 

Definition at line 428 of file PublisherPeriodic.h.

Constructor & Destructor Documentation

RTC::PublisherPeriodic::PublisherPeriodic ( void  )

Constructor.

Definition at line 40 of file PublisherPeriodic.cpp.

RTC::PublisherPeriodic::~PublisherPeriodic ( void  )
virtual

Destructor.

Destructor

Definition at line 56 of file PublisherPeriodic.cpp.

Member Function Documentation

PublisherBase::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.

Returns
PORT_OK normal return PRECONDITION_NOT_MET precondition is not met

Implements RTC::PublisherBase.

Definition at line 222 of file PublisherPeriodic.cpp.

bool RTC::PublisherPeriodic::bufferIsEmpty ( )
inlineprivate

Definition at line 729 of file PublisherPeriodic.h.

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.

  • BUFFER_OK: PORT_OK
    • None
  • BUFFER_ERROR: BUFFER_ERROR
    • None
  • BUFFER_FULL: BUFFER_FULL
  • NOT_SUPPORTED: PORT_ERROR
    • None
  • TIMEOUT: BUFFER_TIMEOUT
  • PRECONDITION_NOT_MET: PRECONDITION_NOT_MET
    • None
  • other: PORT_ERROR
    • None
Parameters
statusBufferStatus
datacdrMemoryStream
Returns
DataPortStatus typed return code

Definition at line 516 of file PublisherPeriodic.cpp.

bool RTC::PublisherPeriodic::createTask ( const coil::Properties prop)
protected

Setting Task.

Definition at line 448 of file PublisherPeriodic.cpp.

PublisherBase::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.

Returns
PORT_OK normal return PRECONDITION_NOT_MET precondition is not met

Implements RTC::PublisherBase.

Definition at line 238 of file PublisherPeriodic.cpp.

PublisherBase::ReturnCode RTC::PublisherPeriodic::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. 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.

  • publisher.thread_type: Thread type (string, default: default)
  • publisher.push_rate: Publisher sending period (numberical)
  • publisher.push_policy: Push policy (all, fifo, skip, new)
  • publisher.skip_count: The number of skip count in the "skip" policy
  • measurement.exec_time: Task execution time measurement (enable/disable)
  • measurement.exec_count: Task execution time measurement count (numerical, number of times)
  • measurement.period_time: Task period time measurement (enable/disable)
  • measurement.period_count: Task period time measurement count (number, count)
Parameters
propertyProperty objects that includes the control information of this Publisher
Returns
ReturnCode PORT_OK normal return INVALID_ARGS Properties with invalid values.

Implements RTC::PublisherBase.

Definition at line 82 of file PublisherPeriodic.cpp.

PublisherPeriodic::ReturnCode RTC::PublisherPeriodic::invokeListener ( DataPortStatus::Enum  status,
const cdrMemoryStream &  data 
)
protected

Call listeners according to the DataPortStatus.

Parameters
statusDataPortStatus
datacdrMemoryStream
Returns
Return code

Definition at line 564 of file PublisherPeriodic.cpp.

bool RTC::PublisherPeriodic::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.

Returns
Result of state confirmation (Active state:true, Inactive state:false)

Implements RTC::PublisherBase.

Definition at line 210 of file PublisherPeriodic.cpp.

void RTC::PublisherPeriodic::onBufferEmpty ( )
inlineprotected

Notify an ON_BUFFER_EMPTY event to listeners.

Definition at line 695 of file PublisherPeriodic.h.

void RTC::PublisherPeriodic::onBufferFull ( const cdrMemoryStream &  data)
inlineprotected

Notify an ON_BUFFER_FULL event to listeners.

Parameters
datacdrMemoryStream

Definition at line 577 of file PublisherPeriodic.h.

void RTC::PublisherPeriodic::onBufferRead ( const cdrMemoryStream &  data)
inlineprotected

Notify an ON_BUFFER_READ event to listeners.

Parameters
datacdrMemoryStream

Definition at line 607 of file PublisherPeriodic.h.

void RTC::PublisherPeriodic::onBufferWrite ( const cdrMemoryStream &  data)
inlineprotected

Notify an ON_BUFFER_WRITE event to listeners.

Parameters
datacdrMemoryStream

Definition at line 562 of file PublisherPeriodic.h.

void RTC::PublisherPeriodic::onBufferWriteTimeout ( const cdrMemoryStream &  data)
inlineprotected

Notify an ON_BUFFER_WRITE_TIMEOUT event to listeners.

Parameters
datacdrMemoryStream

Definition at line 592 of file PublisherPeriodic.h.

void RTC::PublisherPeriodic::onReceived ( const cdrMemoryStream &  data)
inlineprotected

Notify an ON_RECEIVED event to listeners.

Parameters
datacdrMemoryStream

Definition at line 637 of file PublisherPeriodic.h.

void RTC::PublisherPeriodic::onReceiverError ( const cdrMemoryStream &  data)
inlineprotected

Notify an ON_RECEIVER_ERROR event to listeners.

Parameters
datacdrMemoryStream

Definition at line 682 of file PublisherPeriodic.h.

void RTC::PublisherPeriodic::onReceiverFull ( const cdrMemoryStream &  data)
inlineprotected

Notify an ON_RECEIVER_FULL event to listeners.

Parameters
datacdrMemoryStream

Definition at line 652 of file PublisherPeriodic.h.

void RTC::PublisherPeriodic::onReceiverTimeout ( const cdrMemoryStream &  data)
inlineprotected

Notify an ON_RECEIVER_TIMEOUT event to listeners.

Parameters
datacdrMemoryStream

Definition at line 667 of file PublisherPeriodic.h.

void RTC::PublisherPeriodic::onSend ( const cdrMemoryStream &  data)
inlineprotected

Notify an ON_SEND event to listners.

Parameters
datacdrMemoryStream

Definition at line 622 of file PublisherPeriodic.h.

void RTC::PublisherPeriodic::onSenderEmpty ( )
inlineprotected

Notify an ON_SENDER_EMPTY event to listeners.

Definition at line 708 of file PublisherPeriodic.h.

void RTC::PublisherPeriodic::onSenderError ( )
inlineprotected

Notify an ON_SENDER_ERROR event to listeners.

Definition at line 721 of file PublisherPeriodic.h.

PublisherBase::ReturnCode RTC::PublisherPeriodic::pushAll ( )
protected

push "all" policy

push all policy

Definition at line 280 of file PublisherPeriodic.cpp.

PublisherBase::ReturnCode RTC::PublisherPeriodic::pushFifo ( )
protected

push "fifo" policy

Definition at line 308 of file PublisherPeriodic.cpp.

PublisherBase::ReturnCode RTC::PublisherPeriodic::pushNew ( )
protected

push "new" policy

Definition at line 373 of file PublisherPeriodic.cpp.

PublisherBase::ReturnCode RTC::PublisherPeriodic::pushSkip ( )
protected

push "skip" policy

Definition at line 334 of file PublisherPeriodic.cpp.

PublisherBase::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.

Parameters
bufferA pointer to a CDR buffer object.
Returns
ReturnCode PORT_OK normal return INVALID_ARGS given argument has invalid value

Implements RTC::PublisherBase.

Definition at line 129 of file PublisherPeriodic.cpp.

PublisherBase::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.

Parameters
consumerA pointer to a consumer object.
Returns
ReturnCode PORT_OK normal return INVALID_ARGS given argument has invalid value

Implements RTC::PublisherBase.

Definition at line 109 of file PublisherPeriodic.cpp.

PublisherBase::ReturnCode RTC::PublisherPeriodic::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.

Parameters
infoConnectorInfo that is localized object of ConnectorProfile
listenersConnectorListeners that holds various listeners
Returns
PORT_OK Normal return INVALID_ARGS Invalid arguments

Implements RTC::PublisherBase.

Definition at line 150 of file PublisherPeriodic.cpp.

void RTC::PublisherPeriodic::setPushPolicy ( const coil::Properties prop)
protected

Setting PushPolicy.

Definition at line 408 of file PublisherPeriodic.cpp.

int RTC::PublisherPeriodic::svc ( void  )
virtual

Thread execution function.

A task execution function to be executed by coil::PeriodicTask.

Definition at line 253 of file PublisherPeriodic.cpp.

PublisherBase::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.

Parameters
dataData to be wrote to the buffer
secTimeout time in unit seconds
nsecTimeout time in unit nano-seconds
Returns
PORT_OK Normal return PRECONDITION_NO_MET Precondition does not met. A consumer, a buffer, listenes are not set properly. CONNECTION_LOST detected that the connection has been lost BUFFER_FULL The buffer is full status. BUFFER_ERROR Some kind of error occurred in the buffer. NOT_SUPPORTED Some kind of operation that is not supported has been performed. TIMEOUT Timeout occurred when writing to the buffer.

Implements RTC::PublisherBase.

Definition at line 173 of file PublisherPeriodic.cpp.

Member Data Documentation

bool RTC::PublisherPeriodic::m_active
private

Definition at line 751 of file PublisherPeriodic.h.

CdrBufferBase* RTC::PublisherPeriodic::m_buffer
private

Definition at line 743 of file PublisherPeriodic.h.

InPortConsumer* RTC::PublisherPeriodic::m_consumer
private

Definition at line 742 of file PublisherPeriodic.h.

int RTC::PublisherPeriodic::m_leftskip
private

Definition at line 753 of file PublisherPeriodic.h.

ConnectorListeners* RTC::PublisherPeriodic::m_listeners
private

Definition at line 746 of file PublisherPeriodic.h.

ConnectorInfo RTC::PublisherPeriodic::m_profile
private

Definition at line 744 of file PublisherPeriodic.h.

Policy RTC::PublisherPeriodic::m_pushPolicy
private

Definition at line 749 of file PublisherPeriodic.h.

bool RTC::PublisherPeriodic::m_readback
private

Definition at line 752 of file PublisherPeriodic.h.

ReturnCode RTC::PublisherPeriodic::m_retcode
private

Definition at line 747 of file PublisherPeriodic.h.

Mutex RTC::PublisherPeriodic::m_retmutex
private

Definition at line 748 of file PublisherPeriodic.h.

int RTC::PublisherPeriodic::m_skipn
private

Definition at line 750 of file PublisherPeriodic.h.

coil::PeriodicTaskBase* RTC::PublisherPeriodic::m_task
private

Definition at line 745 of file PublisherPeriodic.h.

Logger RTC::PublisherPeriodic::rtclog
private

Definition at line 741 of file PublisherPeriodic.h.


The documentation for this class was generated from the following files:


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:26:04