30 #ifndef PublisherPeriodic_cpp 31 #define PublisherPeriodic_cpp 33 #include <cppunit/ui/text/TestRunner.h> 34 #include <cppunit/TextOutputter.h> 35 #include <cppunit/extensions/TestFactoryRegistry.h> 36 #include <cppunit/extensions/HelperMacros.h> 37 #include <cppunit/TestAssert.h> 40 #include <coil/Properties.h> 41 #include <coil/Time.h> 46 #include <rtm/idl/ManagerSkel.h> 48 #include <rtm/idl/BasicDataTypeSkel.h> 72 const RTC::TimedLong&
data)
74 std::cout <<
"------------------------------" << std::endl;
75 std::cout <<
"Listener: " <<
m_name << std::endl;
76 std::cout <<
" Data: " << data.data << std::endl;
77 std::cout <<
"------------------------------" << std::endl;
132 if (m_buffer->full())
163 else if(m_OnCheck == 1) {
166 else if(m_OnCheck == 2) {
169 else if(m_OnCheck == 3) {
172 else if(m_OnCheck == 4) {
175 else if(m_OnCheck == 5) {
178 else if(m_OnCheck == 6) {
182 else if(m_test_mode == 1)
184 std::string str(
"test");
209 ic = (int)m_buffer->readable();
243 if (! isLastTimeCleared())
246 (now.tv_sec - _lastTime.tv_sec) * 1000000
247 + (now.tv_usec - _lastTime.tv_usec);
249 _intervalTicks.push_back(interval);
258 copy(_intervalTicks.begin(), _intervalTicks.end(), clone->
_intervalTicks.begin());
276 return _intervalTicks;
281 return static_cast<int>(_intervalTicks.size());
303 _lastTime.tv_sec = 0;
304 _lastTime.tv_usec = 0;
309 return (_lastTime.tv_sec == 0) && (_lastTime.tv_usec == 0);
318 :
RTC::InPortConsumer(), _count(0), _component(component) {}
326 if (_component != NULL)
372 :
public CppUnit::TestFixture
377 CPPUNIT_TEST(test_setConsumer);
378 CPPUNIT_TEST(test_setBuffer);
380 CPPUNIT_TEST(test_pushAll);
381 CPPUNIT_TEST(test_pushAll_2);
382 CPPUNIT_TEST(test_pushFifo);
383 CPPUNIT_TEST(test_pushFifo_2);
384 CPPUNIT_TEST(test_pushSkip);
385 CPPUNIT_TEST(test_pushSkip_2);
386 CPPUNIT_TEST(test_pushNew);
387 CPPUNIT_TEST(test_write);
389 CPPUNIT_TEST_SUITE_END();
435 retcode = publisher.
init(prop);
441 prop.
setProperty(
"measurement.exec_time",
"default");
446 retcode = publisher.
init(prop);
454 prop.
setProperty(
"measurement.exec_time",
"enable");
456 prop.
setProperty(
"measurement.period_time",
"enable");
459 retcode = publisher.
init(prop);
466 prop.
setProperty(
"measurement.exec_time",
"disable");
468 prop.
setProperty(
"measurement.period_time",
"disable");
471 retcode = publisher.
init(prop);
483 retcode = publisher.
init(prop);
490 prop.
setProperty(
"measurement.exec_time",
"enable");
492 prop.
setProperty(
"measurement.period_time",
"enable");
493 prop.
setProperty(
"measurement.period_count",
"foo");
495 retcode = publisher.
init(prop);
502 prop.
setProperty(
"measurement.exec_time",
"enable");
504 prop.
setProperty(
"measurement.period_time",
"enable");
507 retcode = publisher.
init(prop);
514 prop.
setProperty(
"measurement.exec_time",
"enable");
516 prop.
setProperty(
"measurement.period_time",
"enable");
519 retcode = publisher.
init(prop);
526 prop.
setProperty(
"measurement.exec_time",
"enable");
528 prop.
setProperty(
"measurement.period_time",
"enable");
531 retcode = publisher.
init(prop);
611 prop.setProperty(
"publisher.push_policy",
"all");
612 prop.setProperty(
"publisher.skip_count",
"0");
613 prop.setProperty(
"thread_type",
"default");
614 prop.setProperty(
"measurement.exec_time",
"enable");
615 prop.setProperty(
"measurement.exec_count",
"0");
616 prop.setProperty(
"measurement.period_time",
"enable");
617 prop.setProperty(
"measurement.period_count",
"0");
618 prop.setProperty(
"publisher.push_rate",
"20");
619 publisher.
init(prop);
633 CPPUNIT_ASSERT_EQUAL(
false,
639 CPPUNIT_ASSERT_EQUAL(
true,
648 CPPUNIT_ASSERT_EQUAL(
true,
654 CPPUNIT_ASSERT_EQUAL(
false,
663 CPPUNIT_ASSERT_EQUAL(
false,
685 prop.
setProperty(
"measurement.exec_time",
"enable");
687 prop.
setProperty(
"measurement.period_time",
"enable");
690 publisher.
init(prop);
729 for(
int icc(0);icc<8;++icc)
737 publisher.
write(cdr,0,0));
749 publisher.
write(cdr,0,0));
758 publisher.
write(cdr,0,0));
764 for(
int icc(0);icc<4;++icc)
766 cdrMemoryStream
data;
768 CORBA::ULong inlen = data.bufSize();
769 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
773 CPPUNIT_ASSERT_EQUAL((
long)icc, (
long)rtd.data);
784 publisher.
write(cdr,0,0));
793 publisher.
write(cdr,0,0));
798 for(
int icc(0);icc<8;++icc)
800 cdrMemoryStream
data;
802 CORBA::ULong inlen = data.bufSize();
803 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
807 CPPUNIT_ASSERT_EQUAL((
long)icc+4, (
long)rtd.data);
831 prop.
setProperty(
"measurement.exec_time",
"enable");
833 prop.
setProperty(
"measurement.period_time",
"enable");
836 publisher.
init(prop);
875 for(
int icc(0);icc<16;++icc)
883 ret = publisher.
write(cdr,0,0);
906 publisher.
write(cdr,0,0));
911 for(
int icc(0);icc<8;++icc)
913 cdrMemoryStream
data;
915 CORBA::ULong inlen = data.bufSize();
916 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
920 CPPUNIT_ASSERT_EQUAL((
long)icc, (
long)rtd.data);
925 for(
int icc(0);icc<8;++icc)
927 cdrMemoryStream
data;
929 CORBA::ULong inlen = data.bufSize();
930 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
934 CPPUNIT_ASSERT_EQUAL((
long)icc+8, (
long)rtd.data);
942 publisher.
write(cdr,0,0));
947 cdrMemoryStream
data;
949 CORBA::ULong inlen = data.bufSize();
950 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
954 CPPUNIT_ASSERT_EQUAL((
long)17, (
long)rtd.data);
979 prop.
setProperty(
"measurement.exec_time",
"enable");
981 prop.
setProperty(
"measurement.period_time",
"enable");
984 publisher.
init(prop);
1023 for(
int icc(0);icc<8;++icc)
1025 cdrMemoryStream cdr;
1031 publisher.
write(cdr,0,0));
1038 cdrMemoryStream cdr;
1043 publisher.
write(cdr,0,0));
1047 cdrMemoryStream cdr;
1052 publisher.
write(cdr,0,0));
1058 for(
int icc(0);icc<4;++icc)
1060 cdrMemoryStream
data;
1062 CORBA::ULong inlen = data.bufSize();
1063 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1067 CPPUNIT_ASSERT_EQUAL((
long)icc, (
long)rtd.data);
1073 cdrMemoryStream cdr;
1078 publisher.
write(cdr,0,0));
1082 cdrMemoryStream cdr;
1087 publisher.
write(cdr,0,0));
1091 cdrMemoryStream cdr;
1096 publisher.
write(cdr,0,0));
1100 cdrMemoryStream cdr;
1105 publisher.
write(cdr,0,0));
1110 for(
int icc(0);icc<8;++icc)
1112 cdrMemoryStream
data;
1114 CORBA::ULong inlen = data.bufSize();
1115 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1119 CPPUNIT_ASSERT_EQUAL((
long)icc+4, (
long)rtd.data);
1122 for(
int icc(0);icc<2;++icc)
1124 cdrMemoryStream
data;
1126 CORBA::ULong inlen = data.bufSize();
1127 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1131 CPPUNIT_ASSERT_EQUAL((
long)icc+12, (
long)rtd.data);
1157 prop.
setProperty(
"measurement.exec_time",
"enable");
1159 prop.
setProperty(
"measurement.period_time",
"enable");
1162 publisher.
init(prop);
1202 for(
int icc(0);icc<16;++icc)
1204 cdrMemoryStream cdr;
1210 ret = publisher.
write(cdr,0,0);
1228 cdrMemoryStream cdr;
1233 publisher.
write(cdr,0,0));
1238 for(
int icc(0);icc<8;++icc)
1240 cdrMemoryStream
data;
1242 CORBA::ULong inlen = data.bufSize();
1243 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1247 CPPUNIT_ASSERT_EQUAL((
long)icc, (
long)rtd.data);
1252 for(
int icc(0);icc<8;++icc)
1254 cdrMemoryStream cdr;
1259 ret = publisher.
write(cdr,0,0);
1274 for(
int icc(0);icc<8;++icc)
1276 cdrMemoryStream
data;
1278 CORBA::ULong inlen = data.bufSize();
1279 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1283 CPPUNIT_ASSERT_EQUAL((
long)icc+8, (
long)rtd.data);
1287 cdrMemoryStream cdr;
1297 for(
int icc(0);icc<8;++icc)
1299 cdrMemoryStream
data;
1301 CORBA::ULong inlen = data.bufSize();
1302 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1306 CPPUNIT_ASSERT_EQUAL((
long)icc+17, (
long)rtd.data);
1332 prop.
setProperty(
"measurement.exec_time",
"enable");
1334 prop.
setProperty(
"measurement.period_time",
"enable");
1337 publisher.
init(prop);
1376 for(
int icc(0);icc<16;++icc)
1378 cdrMemoryStream cdr;
1384 publisher.
write(cdr,0,0));
1391 cdrMemoryStream cdr;
1396 publisher.
write(cdr,0,0));
1400 cdrMemoryStream cdr;
1405 publisher.
write(cdr,0,0));
1411 for(
int icc(0);icc<4;++icc)
1413 cdrMemoryStream
data;
1415 CORBA::ULong inlen = data.bufSize();
1416 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1420 CPPUNIT_ASSERT_EQUAL((
long)icc*2+1, (
long)rtd.data);
1426 cdrMemoryStream cdr;
1431 publisher.
write(cdr,0,0));
1435 cdrMemoryStream cdr;
1440 publisher.
write(cdr,0,0));
1445 CPPUNIT_ASSERT_EQUAL(6,
1447 for(
int icc(0);icc<6;++icc)
1449 cdrMemoryStream
data;
1451 CORBA::ULong inlen = data.bufSize();
1452 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1456 CPPUNIT_ASSERT_EQUAL((
long)icc*2+9, (
long)rtd.data);
1480 prop.
setProperty(
"measurement.exec_time",
"enable");
1482 prop.
setProperty(
"measurement.period_time",
"enable");
1485 publisher.
init(prop);
1525 for(
int icc(0);icc<25;++icc)
1527 cdrMemoryStream cdr;
1533 ret = publisher.
write(cdr,0,0);
1551 cdrMemoryStream cdr;
1556 publisher.
write(cdr,0,0));
1561 for(
int icc(0);icc<8;++icc)
1563 cdrMemoryStream
data;
1565 CORBA::ULong inlen = data.bufSize();
1566 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1570 CPPUNIT_ASSERT_EQUAL((
long)icc*2+1, (
long)rtd.data);
1576 CPPUNIT_ASSERT_EQUAL(4,len);
1577 for(
int icc(0);icc<len;++icc)
1579 cdrMemoryStream
data;
1581 CORBA::ULong inlen = data.bufSize();
1582 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1586 CPPUNIT_ASSERT_EQUAL((
long)icc*2+17, (
long)rtd.data);
1590 cdrMemoryStream cdr;
1595 publisher.
write(cdr,0,0));
1599 cdrMemoryStream cdr;
1604 publisher.
write(cdr,0,0));
1610 cdrMemoryStream
data;
1612 CORBA::ULong inlen = data.bufSize();
1613 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1617 CPPUNIT_ASSERT_EQUAL((
long)26, (
long)rtd.data);
1642 prop.
setProperty(
"measurement.exec_time",
"enable");
1644 prop.
setProperty(
"measurement.period_time",
"enable");
1647 publisher.
init(prop);
1688 for(
int icc(0);icc<8;++icc)
1690 cdrMemoryStream cdr;
1696 publisher.
write(cdr,0,0));
1705 for(
int icc(0);icc<len;++icc)
1707 cdrMemoryStream
data;
1709 CORBA::ULong inlen = data.bufSize();
1710 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1715 cdrMemoryStream
data;
1717 CORBA::ULong inlen = data.bufSize();
1718 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1722 CPPUNIT_ASSERT_EQUAL((
long)7, (
long)rtd.data);
1746 prop.
setProperty(
"measurement.exec_time",
"enable");
1748 prop.
setProperty(
"measurement.period_time",
"enable");
1751 publisher.
init(prop);
1788 cdrMemoryStream cdr;
1793 publisher.
write(cdr,0,0));
1800 cdrMemoryStream cdr;
1805 publisher.
write(cdr,0,0));
1812 cdrMemoryStream cdr;
1817 publisher.
write(cdr,0,0));
1822 cdrMemoryStream cdr;
1830 publisher.
write(cdr,0,0);
1833 publisher.
write(cdr,0,0);
1836 publisher.
write(cdr,0,0);
1839 publisher.
write(cdr,0,0);
1842 publisher.
write(cdr,0,0);
1958 int main(
int argc,
char* argv[])
1971 std::string arg(argv[i]);
1972 std::string next_arg;
1973 if (i + 1 < argc) next_arg = argv[i + 1];
1976 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
1989 ofs.open(fname.c_str());
1991 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
1992 if ( arg ==
"--cerr" ) { target = 1;
break; }
1993 if ( arg ==
"--xsl" )
1995 if (next_arg ==
"") xsl =
"default.xsl";
1996 else xsl = next_arg;
1998 if ( arg ==
"--namespace" )
2002 std::cerr <<
"no namespace specified" << std::endl;
2012 CppUnit::TextUi::TestRunner runner;
2014 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
2016 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
2017 CppUnit::Outputter* outputter = 0;
2018 std::ostream* stream = target ? &std::cerr : &std::cout;
2022 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
2025 std::cout <<
"XML_OUT" << std::endl;
2026 outputter =
new CppUnit::XmlOutputter(&runner.result(),
2028 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
2031 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
2034 runner.setOutputter(outputter);
2039 #endif // PublisherPeriodic_cpp CPPUNIT_TEST_SUITE_REGISTRATION(PublisherPeriodic::PublisherPeriodicTests)
void test_pushAll(void)
write(), pushAll() メソッドのテスト
ConnectorListeners class.
InPortConsumer abstract class.
virtual InPortConsumer::ReturnCode put(const cdrMemoryStream &data)
Send data to the destination port.
int main(int argc, char **argv)
virtual void publishInterfaceProfile(SDOPackage::NVList &properties)
Publish InterfaceProfile information.
InPortCorbaCdrConsumer class.
PublisherPeriodicMock(void)
virtual void init(coil::Properties &prop)
Initializing configuration.
~PublisherPeriodicTests()
Destructor.
void test_pushAll_2(void)
write(), pushAll() メソッドのテスト
virtual int getCount() const
virtual void operator()(const RTC::ConnectorInfo &info, const RTC::TimedLong &data)
Virtual Callback method.
void addListener(ConnectorDataListener *listener, bool autoclean)
Add the listener.
std::vector< std::pair< std::string, std::string > > NVList
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
void test_pushSkip_2(void)
write(), pushSkip() メソッドのテスト
int get_m_put_data_len(void)
void test_pushNew(void)
pushNew()メソッドのテスト
std::vector< long > _intervalTicks
void test_setConsumer(void)
setConsumer()メソッドのテスト
virtual ReturnCode activate()
activation
void set_m_mode(int mode)
void test_pushSkip(void)
pushSklip()メソッドのテスト
RingBuffer< cdrMemoryStream > CdrRingBuffer
CounterConsumer(CounterConsumer *component=NULL)
Enum
DataPortStatus return codes.
virtual ReturnCode init(coil::Properties &prop)
Initialization.
void test_pushFifo_2(void)
write(), pushFifo() メソッドのテスト
void test_pushFifo(void)
pushFifo()メソッドのテスト
virtual ReturnCode setConsumer(InPortConsumer *consumer)
Store InPort consumer.
std::vector< std::string > vstring
virtual ReturnCode deactivate()
deactivation
int gettimeofday(struct timeval *tv, struct timezone *tz)
Get the time and timezone.
virtual bool subscribeInterface(const SDOPackage::NVList &)
Subscribe the data send notification.
ConnectorDataListenerHolder connectorData_[CONNECTOR_DATA_LISTENER_NUM]
ConnectorDataListenerType listener array The ConnectorDataListenerType listener is stored...
virtual void unsubscribeInterface(const SDOPackage::NVList &)
Unsubscribe the data send notification.
ConnectorDataListenerT class.
virtual ReturnCode setBuffer(CdrBufferBase *buffer)
Setting buffer pointer.
virtual bool isActive()
If publisher is active state.
virtual void unsubscribeInterface(const SDOPackage::NVList &)
Unsubscribe the data send notification.
RTC::ConnectorListeners m_listeners
std::string setProperty(const std::string &key, const std::string &value)
Set a value associated with key in the property list.
PublisherPeriodicTests()
Constructor.
virtual void publishInterfaceProfile(SDOPackage::NVList &properties)
Publish InterfaceProfile information.
void test_activate_deactivate_isActive(void)
activate(),deactivate(),isActiveメソッドのテスト
RTC::CdrBufferBase * m_buffer
virtual int getCount() const
virtual ~CounterConsumer()
virtual void setUp()
Test initialization.
::RTC::BufferStatus::Enum ReturnCode
void test_setBuffer(void)
setBuffer()メソッドのテスト
virtual ReturnCode put(const cdrMemoryStream &data)
Send data to the destination port.
prop
Organization::get_organization_property ();.
cdrMemoryStream get_m_put_data(void)
Class represents a set of properties.
virtual bool subscribeInterface(const SDOPackage::NVList &)
Subscribe the data send notification.
void test_write(void)
write()メソッドのテスト
InPortCorbaCdrConsumerMock(void)
InPortCorbaCdrConsumer class.
virtual RTC::InPortConsumer * clone() const
virtual InPortConsumer::ReturnCode put(const cdrMemoryStream &data)
Send data to the destination port.
void test_init(void)
init()メソッドのテスト
virtual const std::vector< long > & getIntervalTicks() const
virtual ~InPortCorbaCdrConsumerMock()
DataListener(const char *name)
virtual ReturnCode setListener(ConnectorInfo &info, ConnectorListeners *listeners)
Set the listener.
virtual void tearDown()
Test finalization.
virtual ReturnCode write(const cdrMemoryStream &data, unsigned long sec, unsigned long usec)
Write data.
BufferBase abstract class.
CounterConsumer * _component
virtual RTC::InPortConsumer * clone() const
virtual void init(coil::Properties &prop)
Initializing configuration.
int usleep(useconds_t usec)
Stop a processing at specified micro second time.
virtual ~PublisherPeriodicMock(void)
::OpenRTM::CdrData m_put_data