PublisherPeriodic.h
Go to the documentation of this file.
1 // -*- C++ -*-
20 #ifndef RTC_PUBLISHERPERIODIC_H
21 #define RTC_PUBLISHERPERIODIC_H
22 
23 #include <coil/Task.h>
24 #include <coil/Mutex.h>
25 #include <coil/Condition.h>
26 #include <coil/PeriodicTask.h>
27 
28 #include <rtm/RTC.h>
29 #include <rtm/PublisherBase.h>
30 #include <rtm/CdrBufferBase.h>
31 #include <rtm/SystemLogger.h>
32 #include <rtm/ConnectorBase.h>
33 #include <rtm/ConnectorListener.h>
34 
35 namespace coil
36 {
37  class Properties;
38 };
39 
40 namespace RTC
41 {
42  class InPortConsumer;
65  : public PublisherBase
66  {
67  public:
68  typedef coil::Mutex Mutex;
72 
82  PublisherPeriodic(void);
83 
97  virtual ~PublisherPeriodic(void);
98 
160  virtual ReturnCode init(coil::Properties& prop);
161 
187  virtual ReturnCode setConsumer(InPortConsumer* consumer);
188 
214  virtual ReturnCode setBuffer(CdrBufferBase* buffer);
215 
249  virtual ReturnCode setListener(ConnectorInfo& info,
250  ConnectorListeners* listeners);
326  virtual ReturnCode write(const cdrMemoryStream& data,
327  unsigned long sec,
328  unsigned long usec);
356  virtual bool isActive();
357 
383  virtual ReturnCode activate();
384 
410  virtual ReturnCode deactivate();
411 
425  virtual int svc(void);
426 
427  protected:
428  enum Policy
429  {
433  NEW
434  };
435 
443  void setPushPolicy(const coil::Properties& prop);
444 
452  bool createTask(const coil::Properties& prop);
453 
457  ReturnCode pushAll();
458 
462  ReturnCode pushFifo();
463 
467  ReturnCode pushSkip();
468 
472  ReturnCode pushNew();
473 
529  ReturnCode convertReturn(BufferStatus::Enum status,
530  const cdrMemoryStream& data);
531 
532 
550  ReturnCode invokeListener(DataPortStatus::Enum status,
551  const cdrMemoryStream& data);
552 
562  inline void onBufferWrite(const cdrMemoryStream& data)
563  {
564  m_listeners->
565  connectorData_[ON_BUFFER_WRITE].notify(m_profile, data);
566  }
567 
577  inline void onBufferFull(const cdrMemoryStream& data)
578  {
579  m_listeners->
580  connectorData_[ON_BUFFER_FULL].notify(m_profile, data);
581  }
582 
592  inline void onBufferWriteTimeout(const cdrMemoryStream& data)
593  {
594  m_listeners->
595  connectorData_[ON_BUFFER_WRITE_TIMEOUT].notify(m_profile, data);
596  }
597 
607  inline void onBufferRead(const cdrMemoryStream& data)
608  {
609  m_listeners->
610  connectorData_[ON_BUFFER_READ].notify(m_profile, data);
611  }
612 
622  inline void onSend(const cdrMemoryStream& data)
623  {
624  m_listeners->
625  connectorData_[ON_SEND].notify(m_profile, data);
626  }
627 
637  inline void onReceived(const cdrMemoryStream& data)
638  {
639  m_listeners->
640  connectorData_[ON_RECEIVED].notify(m_profile, data);
641  }
642 
652  inline void onReceiverFull(const cdrMemoryStream& data)
653  {
654  m_listeners->
655  connectorData_[ON_RECEIVER_FULL].notify(m_profile, data);
656  }
657 
667  inline void onReceiverTimeout(const cdrMemoryStream& data)
668  {
669  m_listeners->
670  connectorData_[ON_RECEIVER_TIMEOUT].notify(m_profile, data);
671  }
672 
682  inline void onReceiverError(const cdrMemoryStream& data)
683  {
684  m_listeners->
685  connectorData_[ON_RECEIVER_ERROR].notify(m_profile, data);
686  }
687 
695  inline void onBufferEmpty()
696  {
697  m_listeners->
698  connector_[ON_BUFFER_EMPTY].notify(m_profile);
699  }
700 
708  inline void onSenderEmpty()
709  {
710  m_listeners->
711  connector_[ON_SENDER_EMPTY].notify(m_profile);
712  }
713 
721  inline void onSenderError()
722  {
723  m_listeners->
724  connector_[ON_SENDER_ERROR].notify(m_profile);
725  }
726 
727 
728  private:
730  {
731  if (m_buffer->empty() && !m_readback)
732  {
733  RTC_DEBUG(("buffer empty"));
734  onBufferEmpty();
735  onSenderEmpty();
736  return true;
737  }
738  return false;
739  }
740 
748  Mutex m_retmutex;
750  int m_skipn;
751  bool m_active;
754  };
755 }; // namespace RTC
756 
757 extern "C"
758 {
760 };
761 
762 #endif // RTC_PUBLISHERPERIODIC_H
763 
ConnectorListeners class.
InPortConsumer abstract class.
void onBufferWriteTimeout(const cdrMemoryStream &data)
Notify an ON_BUFFER_WRITE_TIMEOUT event to listeners.
#define DATAPORTSTATUS_ENUM
Importing RTC::DataPortStatus macro.
RT-Component.
Mutex class.
RT component logger class.
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 onSenderError()
Notify an ON_SENDER_ERROR event to listeners.
void onBufferWrite(const cdrMemoryStream &data)
Notify an ON_BUFFER_WRITE event to listeners.
Enum
DataPortStatus return codes.
Definition: BufferStatus.h:84
void onBufferRead(const cdrMemoryStream &data)
Notify an ON_BUFFER_READ event to listeners.
coil::PeriodicTaskBase * m_task
void onReceiverFull(const cdrMemoryStream &data)
Notify an ON_RECEIVER_FULL event to listeners.
Connector base class.
#define RTC_DEBUG(fmt)
Debug level log output macro.
Definition: SystemLogger.h:488
void onSenderEmpty()
Notify an ON_SENDER_EMPTY event to listeners.
#define DLL_EXPORT
Definition: PluginC.cpp:8
Condition template class.
coil::Guard< coil::Mutex > Guard
ConnectorListeners * m_listeners
PeriodicTaskBase class.
prop
Organization::get_organization_property ();.
void onReceived(const cdrMemoryStream &data)
Notify an ON_RECEIVED event to listeners.
InPortConsumer * m_consumer
Publisher base class.
void onBufferFull(const cdrMemoryStream &data)
Notify an ON_BUFFER_FULL event to listeners.
Class represents a set of properties.
Definition: Properties.h:101
void DLL_EXPORT PublisherPeriodicInit()
Base class of Publisher.
Definition: PublisherBase.h:63
RTComponent header.
void onBufferEmpty()
Notify an ON_BUFFER_EMPTY event to listeners.
BufferBase abstract class.
Definition: BufferBase.h:104
connector listener class
Enum
DataPortStatus return codes.
coil::Condition< Mutex > Condition
void onSend(const cdrMemoryStream &data)
Notify an ON_SEND event to listners.
Common Object Interface Layer.


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:07:54