OpenRTM-aist 2.0.2
Loading...
Searching...
No Matches
RTC::PublisherNew Class Reference

PublisherNew class. More...

#include <PublisherNew.h>

Inheritance diagram for RTC::PublisherNew:
Collaboration diagram for RTC::PublisherNew:

Public Member Functions

 PublisherNew ()
 Constructor.
 
 ~PublisherNew () override
 Destructor.
 
DataPortStatus init (coil::Properties &prop) override
 Initialization.
 
DataPortStatus setConsumer (InPortConsumer *consumer) override
 Store InPort consumer.
 
DataPortStatus setBuffer (CdrBufferBase *buffer) override
 Setting buffer pointer.
 
DataPortStatus setListener (ConnectorInfo &info, ConnectorListenersBase *listeners) override
 Set the listener.
 
DataPortStatus write (ByteDataStreamBase *data, std::chrono::nanoseconds timeout) override
 Write data.
 
bool isActive () override
 If publisher is active state.
 
DataPortStatus activate () override
 activation
 
DataPortStatus deactivate () override
 deactivation
 
virtual int svc ()
 Thread execution function.
 
- Public Member Functions inherited from RTC::PublisherBase
virtual ~PublisherBase ()=default
 Destructor.
 
virtual DataPortStatus setBuffer (BufferBase< ByteData > *buffer)=0
 Setting buffer pointer.
 
virtual void release ()
 Release the Publisher.
 

Protected Types

enum  Policy { PUBLISHER_POLICY_ALL , PUBLISHER_POLICY_FIFO , PUBLISHER_POLICY_SKIP , PUBLISHER_POLICY_NEW }
 

Protected Member Functions

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

Detailed Description

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.

Member Enumeration Documentation

◆ Policy

enum RTC::PublisherNew::Policy
protected
Enumerator
PUBLISHER_POLICY_ALL 
PUBLISHER_POLICY_FIFO 
PUBLISHER_POLICY_SKIP 
PUBLISHER_POLICY_NEW 

Constructor & Destructor Documentation

◆ PublisherNew()

RTC::PublisherNew::PublisherNew ( )

Constructor.

Constructor

◆ ~PublisherNew()

RTC::PublisherNew::~PublisherNew ( )
override

Destructor.

Destructor

Member Function Documentation

◆ activate()

DataPortStatus RTC::PublisherNew::activate ( )
overridevirtual

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.

◆ convertReturn()

DataPortStatus RTC::PublisherNew::convertReturn ( BufferStatus status,
ByteData & data )
protected

Convertion from BufferStatus to DataPortStatus.

This function converts return value from the buffer to DataPortStatus 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

◆ createTask()

bool RTC::PublisherNew::createTask ( const coil::Properties & prop)
protected

Setting Task .

◆ deactivate()

DataPortStatus RTC::PublisherNew::deactivate ( )
overridevirtual

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.

◆ init()

DataPortStatus RTC::PublisherNew::init ( coil::Properties & prop)
overridevirtual

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.

  • thread_type: Thread type (string, default: default)
  • 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
DataPortStatus PORT_OK normal return INVALID_ARGS Properties with invalid values.

Implements RTC::PublisherBase.

◆ invokeListener()

DataPortStatus RTC::PublisherNew::invokeListener ( DataPortStatus status,
ByteData & data )
protected

Call listeners according to the DataPortStatus.

Parameters
statusDataPortStatus
datacdrMemoryStream
Returns
Return code

◆ isActive()

bool RTC::PublisherNew::isActive ( )
overridevirtual

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.

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

Implements RTC::PublisherBase.

◆ onBufferFull()

void RTC::PublisherNew::onBufferFull ( ByteData & data)
inlineprotected

Notify an ON_BUFFER_FULL event to listeners.

Parameters
datacdrMemoryStream

References RTC::ConnectorListenersBase::notifyOut(), and RTC::ON_BUFFER_FULL.

◆ onBufferRead()

void RTC::PublisherNew::onBufferRead ( ByteData & data)
inlineprotected

Notify an ON_BUFFER_READ event to listeners.

Parameters
datacdrMemoryStream

References RTC::ConnectorListenersBase::notifyOut(), and RTC::ON_BUFFER_READ.

◆ onBufferWrite()

void RTC::PublisherNew::onBufferWrite ( ByteData & data)
inlineprotected

Notify an ON_BUFFER_WRITE event to listeners.

Parameters
datacdrMemoryStream

References RTC::ConnectorListenersBase::notifyOut(), and RTC::ON_BUFFER_WRITE.

◆ onBufferWriteOverwrite()

void RTC::PublisherNew::onBufferWriteOverwrite ( ByteData & data)
inlineprotected

Notify an ON_BUFFER_OVERWRITE event to listeners.

Parameters
datacdrMemoryStream

References RTC::ConnectorListenersBase::notifyOut(), and RTC::ON_BUFFER_OVERWRITE.

◆ onBufferWriteTimeout()

void RTC::PublisherNew::onBufferWriteTimeout ( ByteData & data)
inlineprotected

Notify an ON_BUFFER_WRITE_TIMEOUT event to listeners.

Parameters
datacdrMemoryStream

References RTC::ConnectorListenersBase::notifyOut(), and RTC::ON_BUFFER_WRITE_TIMEOUT.

◆ onReceived()

void RTC::PublisherNew::onReceived ( ByteData & data)
inlineprotected

Notify an ON_RECEIVED event to listeners.

Parameters
datacdrMemoryStream

References RTC::ConnectorListenersBase::notifyOut(), and RTC::ON_RECEIVED.

◆ onReceiverError()

void RTC::PublisherNew::onReceiverError ( ByteData & data)
inlineprotected

Notify an ON_RECEIVER_ERROR event to listeners.

Parameters
datacdrMemoryStream

References RTC::ConnectorListenersBase::notifyOut(), and RTC::ON_RECEIVER_ERROR.

◆ onReceiverFull()

void RTC::PublisherNew::onReceiverFull ( ByteData & data)
inlineprotected

Notify an ON_RECEIVER_FULL event to listeners.

Parameters
datacdrMemoryStream

References RTC::ConnectorListenersBase::notifyOut(), and RTC::ON_RECEIVER_FULL.

◆ onReceiverTimeout()

void RTC::PublisherNew::onReceiverTimeout ( ByteData & data)
inlineprotected

Notify an ON_RECEIVER_TIMEOUT event to listeners.

Parameters
datacdrMemoryStream

References RTC::ConnectorListenersBase::notifyOut(), and RTC::ON_RECEIVER_TIMEOUT.

◆ onSend()

void RTC::PublisherNew::onSend ( ByteData & data)
inlineprotected

Notify an ON_SEND event to listners.

Parameters
datacdrMemoryStream

References RTC::ConnectorListenersBase::notifyOut(), and RTC::ON_SEND.

◆ onSenderError()

void RTC::PublisherNew::onSenderError ( )
inlineprotected

Notify an ON_SENDER_ERROR event to listeners.

Parameters
datacdrMemoryStream

References RTC::ConnectorListenersBase::notify(), and RTC::ON_SENDER_ERROR.

◆ pushAll()

DataPortStatus RTC::PublisherNew::pushAll ( )
protected

push "all" policy

◆ pushFifo()

DataPortStatus RTC::PublisherNew::pushFifo ( )
protected

push "fifo" policy

◆ pushNew()

DataPortStatus RTC::PublisherNew::pushNew ( )
protected

push "new" policy

◆ pushSkip()

DataPortStatus RTC::PublisherNew::pushSkip ( )
protected

push "skip" policy

◆ setBuffer()

DataPortStatus RTC::PublisherNew::setBuffer ( CdrBufferBase * buffer)
override

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
DataPortStatus PORT_OK normal return INVALID_ARGS given argument has invalid value

◆ setConsumer()

DataPortStatus RTC::PublisherNew::setConsumer ( InPortConsumer * consumer)
overridevirtual

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
DataPortStatus PORT_OK normal return INVALID_ARGS given argument has invalid value

Implements RTC::PublisherBase.

◆ setListener()

DataPortStatus RTC::PublisherNew::setListener ( ConnectorInfo & info,
ConnectorListenersBase * listeners )
overridevirtual

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.

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.

◆ setPushPolicy()

void RTC::PublisherNew::setPushPolicy ( const coil::Properties & prop)
protected

Setting PushPolicy .

◆ svc()

virtual int RTC::PublisherNew::svc ( )
virtual

Thread execution function.

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

◆ write()

DataPortStatus RTC::PublisherNew::write ( ByteDataStreamBase * data,
std::chrono::nanoseconds timeout )
overridevirtual

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
timeoutTimeout 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.


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