20 #include <coil/Properties.h> 21 #include <coil/Time.h> 22 #include <coil/stringutil.h> 27 #include <rtm/idl/DataPortSkel.h> 41 : rtclog(
"PublisherPeriodic"),
42 m_consumer(0), m_buffer(0), m_task(0), m_listeners(0),
43 m_retcode(PORT_OK), m_pushPolicy(NEW),
44 m_skipn(0), m_active(false), m_readback(false), m_leftskip(0)
115 RTC_ERROR((
"setConsumer(consumer = 0): invalid argument."));
135 RTC_ERROR((
"setBuffer(buffer == 0): invalid argument"));
157 RTC_ERROR((
"setListeners(listeners == 0): invalid argument"));
185 RTC_DEBUG((
"write(): connection lost."));
191 RTC_DEBUG((
"write(): InPort buffer is full."));
342 int loopcnt(preskip/(
m_skipn +1));
344 for (
int i(0); i < loopcnt; ++i)
347 readable -= postskip;
411 std::string push_policy = prop.
getProperty(
"publisher.push_policy",
"new");
412 RTC_DEBUG((
"push_policy: %s", push_policy.c_str()));
421 RTC_ERROR((
"invalid push_policy value: %s", push_policy.c_str()));
426 std::string skip_count = prop.
getProperty(
"publisher.skip_count",
"0");
427 RTC_DEBUG((
"skip_count: %s", skip_count.c_str()));
431 RTC_ERROR((
"invalid skip_count value: %s", skip_count.c_str()));
460 prop.
getProperty(
"thread_type",
"default").c_str()));
471 RTC_ERROR((
"publisher.push_rate/push_rate were not found."));
477 RTC_ERROR((
"invalid period: %f [s]", hz));
484 "enable",
"disable",
true));
487 if (
coil::stringTo(ecount, prop[
"measurement.exec_count"].c_str()))
493 "enable",
"disable",
true));
495 if (
coil::stringTo(pcount, prop[
"measurement.period_count"].c_str()))
517 const cdrMemoryStream&
data)
565 const cdrMemoryStream&
data)
DATAPORTSTATUS_ENUM PublisherPeriodic(void)
Constructor.
ConnectorListeners class.
InPortConsumer abstract class.
#define RTC_ERROR(fmt)
Error log output macro.
std::string normalize(std::string &str)
Erase the head/tail blank and replace upper case to lower case.
void onBufferWriteTimeout(const cdrMemoryStream &data)
Notify an ON_BUFFER_WRITE_TIMEOUT event to listeners.
virtual int resume(void)=0
Resuming the suspended task.
bool stringTo(To &val, const char *str)
Convert the given std::string to object.
RT component logger class.
AbstractClass * Creator()
Creator template.
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
virtual ~PublisherPeriodic(void)
Destructor.
static const char * toString(Enum status)
Convert BufferStatus into the string.
virtual int suspend(void)=0
Suspending the task.
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.
virtual ReturnCode activate()
activation
ReturnCode pushAll()
push "all" policy
void onBufferWrite(const cdrMemoryStream &data)
Notify an ON_BUFFER_WRITE event to listeners.
virtual bool setTask(TaskFuncBase *func, bool delete_in_dtor=true)=0
Setting task execution function.
static GlobalFactory< AbstractClass, Identifier, Compare, Creator, Destructor > & instance()
Create instance.
GlobalFactory template class.
Enum
DataPortStatus return codes.
virtual ReturnCode init(coil::Properties &prop)
Initialization.
void onBufferRead(const cdrMemoryStream &data)
Notify an ON_BUFFER_READ event to listeners.
#define RTC_DEBUG_STR(str)
coil::PeriodicTaskBase * m_task
#define RTC_PARANOID(fmt)
Paranoid level log output macro.
std::vector< Identifier > getIdentifiers()
Get factory ID list.
virtual ReturnCode get(DataType &value)=0
Read data from the buffer.
virtual ReturnCode setConsumer(InPortConsumer *consumer)
Store InPort consumer.
void setPushPolicy(const coil::Properties &prop)
Setting PushPolicy.
std::vector< std::string > vstring
virtual ReturnCode deactivate()
deactivation
void onReceiverFull(const cdrMemoryStream &data)
Notify an ON_RECEIVER_FULL event to listeners.
virtual void executionMeasureCount(int n)=0
Task execute time measurement period.
ReturnCode invokeListener(DataPortStatus::Enum status, const cdrMemoryStream &data)
Call listeners according to the DataPortStatus.
virtual void activate()=0
Starting the task.
#define RTC_DEBUG(fmt)
Debug level log output macro.
PeiodicTaskFactory class.
virtual void periodicMeasure(bool value)=0
Validate a Task period time measurement.
std::string flatten(vstring sv)
Create CSV file from the given string list.
virtual void finalize()=0
Finalizing the task.
virtual ReturnCode setBuffer(CdrBufferBase *buffer)
Setting buffer pointer.
virtual bool isActive()
If publisher is active state.
ReturnCode pushFifo()
push "fifo" policy
virtual int svc(void)
Thread execution function.
AbstractClass * createObject(const Identifier &id)
Create factory object.
ReturnCode pushNew()
push "new" policy
ConnectorListeners * m_listeners
::RTC::BufferStatus::Enum ReturnCode
prop
Organization::get_organization_property ();.
void onReceived(const cdrMemoryStream &data)
Notify an ON_RECEIVED event to listeners.
InPortConsumer * m_consumer
void onBufferFull(const cdrMemoryStream &data)
Notify an ON_BUFFER_FULL event to listeners.
void Destructor(AbstractClass *&obj)
Destructor template.
Class represents a set of properties.
bool toBool(std::string str, std::string yes, std::string no, bool default_value)
Convert given string into bool value.
virtual void setPeriod(double period)=0
Setting task execution period.
virtual void executionMeasure(bool value)=0
Validate a Task execute time measurement.
virtual ReturnCode advanceRptr(long int n=1)=0
Forward n reading pointers.
virtual void periodicMeasureCount(int n)=0
Task period time measurement count.
ReturnCode convertReturn(BufferStatus::Enum status, const cdrMemoryStream &data)
Convertion from BufferStatus to DataPortStatus.
bool createTask(const coil::Properties &prop)
Setting Task.
ReturnCode pushSkip()
push "skip" policy
virtual size_t readable() const =0
Write data into the buffer.
virtual ReturnCode write(const DataType &value, long int sec=-1, long int nsec=-1)=0
Write data into the buffer.
virtual ReturnCode setListener(ConnectorInfo &info, ConnectorListeners *listeners)
Set the listener.
virtual ReturnCode put(const cdrMemoryStream &data)=0
Send data to the destination port.
virtual ReturnCode write(const cdrMemoryStream &data, unsigned long sec, unsigned long usec)
Write data.
BufferBase abstract class.
void PublisherPeriodicInit()
Enum
DataPortStatus return codes.
static const char * toString(DataPortStatus::Enum status)
Convert DataPortStatus into the string.
const std::string & getProperty(const std::string &key) const
Search for the property with the specified key in this property.
void onSend(const cdrMemoryStream &data)
Notify an ON_SEND event to listners.