23 #include <coil/Properties.h> 24 #include <coil/stringutil.h> 30 #include <rtm/idl/DataPortSkel.h> 43 : rtclog(
"PublisherNew"),
44 m_consumer(0), m_buffer(0), m_task(0), m_listeners(0),
45 m_retcode(PORT_OK), m_pushPolicy(NEW),
46 m_skipn(0), m_active(false), m_leftskip(0)
108 RTC_ERROR((
"setConsumer(consumer = 0): invalid argument."));
128 RTC_ERROR((
"setBuffer(buffer == 0): invalid argument"));
150 RTC_ERROR((
"setListeners(listeners == 0): invalid argument"));
177 RTC_DEBUG((
"write(): connection lost."));
183 RTC_DEBUG((
"write(): InPort buffer is full."));
280 std::string push_policy = prop.
getProperty(
"publisher.push_policy",
"new");
281 RTC_DEBUG((
"push_policy: %s", push_policy.c_str()));
290 RTC_ERROR((
"invalid push_policy value: %s", push_policy.c_str()));
295 std::string skip_count = prop.
getProperty(
"publisher.skip_count",
"0");
296 RTC_DEBUG((
"skip_count: %s", skip_count.c_str()));
300 RTC_ERROR((
"invalid skip_count value: %s", skip_count.c_str()));
327 prop.
getProperty(
"thread_type",
"default").c_str()));
336 "enable",
"disable",
true));
339 if (
coil::stringTo(ecount, prop[
"measurement.exec_count"].c_str()))
345 "enable",
"disable",
true));
347 if (
coil::stringTo(pcount, prop[
"measurement.period_count"].c_str()))
420 int loopcnt(preskip/(
m_skipn +1));
422 for (
int i(0); i < loopcnt; ++i)
494 const cdrMemoryStream&
data)
542 const cdrMemoryStream&
data)
ConnectorListeners class.
InPortConsumer abstract class.
virtual ReturnCode setListener(ConnectorInfo &info, ConnectorListeners *listeners)
Set the listener.
#define RTC_ERROR(fmt)
Error log output macro.
virtual ~PublisherNew(void)
Destructor.
std::string normalize(std::string &str)
Erase the head/tail blank and replace upper case to lower case.
ReturnCode pushFifo()
push "fifo" policy
ReturnCode pushSkip()
push "skip" policy
ConnectorListeners * m_listeners
virtual int resume(void)=0
Resuming the suspended task.
virtual ReturnCode write(const cdrMemoryStream &data, unsigned long sec, unsigned long usec)
Write data.
bool stringTo(To &val, const char *str)
Convert the given std::string to object.
virtual ReturnCode deactivate()
deactivation
AbstractClass * Creator()
Creator template.
DATAPORTSTATUS_ENUM PublisherNew()
Constructor.
virtual ReturnCode setBuffer(CdrBufferBase *buffer)
Setting buffer pointer.
void onBufferWrite(const cdrMemoryStream &data)
Notify an ON_BUFFER_WRITE event to listeners.
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
static const char * toString(Enum status)
Convert BufferStatus into the string.
virtual int suspend(void)=0
Suspending the task.
virtual ReturnCode init(coil::Properties &prop)
Initialization.
virtual bool isActive()
If publisher is active state.
void onBufferFull(const cdrMemoryStream &data)
Notify an ON_BUFFER_FULL 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.
#define RTC_DEBUG_STR(str)
virtual ReturnCode activate()
activation
#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.
std::vector< std::string > vstring
void onBufferWriteTimeout(const cdrMemoryStream &data)
Notify an ON_BUFFER_WRITE_TIMEOUT event to listeners.
virtual void executionMeasureCount(int n)=0
Task execute time measurement period.
void setPushPolicy(const coil::Properties &prop)
Setting PushPolicy.
virtual void signal()=0
Executing the suspended task one tick.
virtual void activate()=0
Starting the task.
#define RTC_DEBUG(fmt)
Debug level log output macro.
PeiodicTaskFactory class.
void onBufferRead(const cdrMemoryStream &data)
Notify an ON_BUFFER_READ event to listeners.
void onReceiverError(const cdrMemoryStream &data)
Notify an ON_RECEIVER_ERROR event to listeners.
const std::string & getProperty(const std::string &key) const
Search for the property with the specified key in this property.
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 ReturnCode setConsumer(InPortConsumer *consumer)
Store InPort consumer.
virtual void finalize()=0
Finalizing the task.
bool createTask(const coil::Properties &prop)
Setting Task.
void onReceiverTimeout(const cdrMemoryStream &data)
Notify an ON_RECEIVER_TIMEOUT event to listeners.
AbstractClass * createObject(const Identifier &id)
Create factory object.
::RTC::BufferStatus::Enum ReturnCode
prop
Organization::get_organization_property ();.
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.
coil::PeriodicTaskBase * m_task
virtual ReturnCode advanceRptr(long int n=1)=0
Forward n reading pointers.
ReturnCode convertReturn(BufferStatus::Enum status, const cdrMemoryStream &data)
Convertion from BufferStatus to DataPortStatus.
virtual void periodicMeasureCount(int n)=0
Task period time measurement count.
virtual size_t readable() const =0
Write data into the buffer.
void onReceiverFull(const cdrMemoryStream &data)
Notify an ON_RECEIVER_FULL event to listeners.
virtual ReturnCode write(const DataType &value, long int sec=-1, long int nsec=-1)=0
Write data into the buffer.
virtual ReturnCode put(const cdrMemoryStream &data)=0
Send data to the destination port.
ReturnCode pushAll()
push "all" policy
BufferBase abstract class.
void onReceived(const cdrMemoryStream &data)
Notify an ON_RECEIVED event to listeners.
virtual int svc(void)
Thread execution function.
ReturnCode pushNew()
push "new" policy
void onSend(const cdrMemoryStream &data)
Notify an ON_SEND event to listners.
Enum
DataPortStatus return codes.
static const char * toString(DataPortStatus::Enum status)
Convert DataPortStatus into the string.
ReturnCode invokeListener(DataPortStatus::Enum status, const cdrMemoryStream &data)
Call listeners according to the DataPortStatus.
InPortConsumer * m_consumer