PublisherPeriodic.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00020 #ifndef PublisherPeriodic_h
00021 #define PublisherPeriodic_h
00022 
00023 #include <coil/Task.h>
00024 #include <coil/Mutex.h>
00025 #include <coil/Condition.h>
00026 #include <coil/PeriodicTask.h>
00027 
00028 #include <rtm/RTC.h>
00029 #include <rtm/PublisherBase.h>
00030 #include <rtm/CdrBufferBase.h>
00031 #include <rtm/SystemLogger.h>
00032 
00033 namespace coil
00034 {
00035   class Properties;
00036 };
00037 
00038 namespace RTC
00039 {
00040   class InPortConsumer;
00058   class PublisherPeriodic
00059     : public PublisherBase
00060   {
00061   public: 
00062     typedef coil::Mutex Mutex;
00063     typedef coil::Condition<Mutex> Condition;
00064     typedef coil::Guard<coil::Mutex> Guard;
00065     DATAPORTSTATUS_ENUM
00066 
00096     PublisherPeriodic();
00097     
00111     virtual ~PublisherPeriodic(void);
00112     
00120     virtual ReturnCode init(coil::Properties& prop);
00121     virtual ReturnCode setConsumer(InPortConsumer* consumer);
00122     virtual ReturnCode setBuffer(CdrBufferBase* buffer);
00123     virtual ReturnCode write(const cdrMemoryStream& data,
00124                              unsigned long sec,
00125                              unsigned long usec);
00126     virtual bool isActive();
00127     virtual ReturnCode activate();
00128     virtual ReturnCode deactivate();
00129     
00143     virtual int svc(void);
00144     
00145   protected:
00146     enum Policy
00147       {
00148         ALL,
00149         FIFO,
00150         SKIP,
00151         NEW
00152       };
00153 
00157     ReturnCode pushAll();
00161     ReturnCode pushFifo();
00165     ReturnCode pushSkip();
00169     ReturnCode pushNew();
00170 
00171     ReturnCode convertReturn(BufferStatus::Enum status);
00172     
00173   private:
00174     Logger rtclog;
00175     InPortConsumer* m_consumer;
00176     CdrBufferBase* m_buffer;
00177     coil::PeriodicTaskBase* m_task;
00178     ReturnCode m_retcode;
00179     Mutex m_retmutex;
00180     Policy m_pushPolicy;
00181     int m_skipn;
00182     bool m_active;
00183     bool m_readback;
00184   };
00185 };     // namespace RTC
00186 
00187 extern "C"
00188 {
00189   void DLL_EXPORT PublisherPeriodicInit();
00190 };
00191 
00192 #endif // PublisherPeriodic_h
00193 

Generated on Sun May 24 14:08:45 2009 for OpenRTM by  doxygen 1.5.3