19 #ifndef ExtTrigExecutionContext_cpp 20 #define ExtTrigExecutionContext_cpp 22 #include <cppunit/ui/text/TestRunner.h> 23 #include <cppunit/TextOutputter.h> 24 #include <cppunit/extensions/TestFactoryRegistry.h> 25 #include <cppunit/extensions/HelperMacros.h> 26 #include <cppunit/TestAssert.h> 28 #include <rtm/idl/RTCSkel.h> 40 :
public virtual POA_RTC::LightweightRTObject,
41 public virtual PortableServer::RefCountServantBase
44 typedef std::map<RTC::UniqueId, RTC::ExecutionContext_ptr>
ExecContexts;
53 : m_alive(true), m_error(false)
60 m_log.push_back(
"attach_executioncontext");
61 m_execContexts.insert(
62 std::pair<RTC::UniqueId, RTC::ExecutionContext_ptr>(m_nextUniqueId++, exec_context));
67 m_log.push_back(
"detach_executioncontext");
68 m_execContexts.erase(ec_id);
73 m_log.push_back(
"on_initialize");
78 m_log.push_back(
"on_finalize");
83 m_log.push_back(
"on_startup");
88 m_log.push_back(
"on_shutdown");
93 m_log.push_back(
"on_activated");
98 m_log.push_back(
"on_deactivated");
103 m_log.push_back(
"on_aborting");
108 m_log.push_back(
"on_error");
113 m_log.push_back(
"on_reset");
120 m_log.push_back(
"initialize");
125 m_log.push_back(
"finalize");
130 m_log.push_back(
"exit");
133 virtual CORBA::Boolean
is_alive(RTC::ExecutionContext_ptr exec_context)
135 m_log.push_back(
"is_alive");
136 return CORBA::Boolean(m_alive);
140 m_log.push_back(
"get_contexts");
145 m_log.push_back(
"get_context");
161 for (
int i = 0; i < (int) m_log.size(); ++i)
163 if (m_log[i] == line) ++count;
187 :
public virtual POA_OpenRTM::DataFlowComponent,
195 m_log.push_back(
"get_owned_organizations");
201 m_log.push_back(
"get_sdo_id");
207 m_log.push_back(
"get_sdo_type");
213 m_log.push_back(
"get_device_profile");
219 m_log.push_back(
"get_service_profiles");
223 throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable, SDOPackage::InternalError)
225 m_log.push_back(
"get_service_profile");
229 throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable, SDOPackage::InternalError)
231 m_log.push_back(
"get_sdo_service");
232 return SDOPackage::SDOService::_nil();
237 m_log.push_back(
"get_configuration");
238 return SDOPackage::Configuration::_nil();
243 m_log.push_back(
"get_monitoring");
244 return SDOPackage::Monitoring::_nil();
249 m_log.push_back(
"get_organizations");
255 m_log.push_back(
"get_status_list");
259 throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable, SDOPackage::InternalError)
261 m_log.push_back(
"get_status");
268 m_log.push_back(
"get_component_profile");
270 RTC::ComponentProfile_var prof(
new RTC::ComponentProfile());
275 m_log.push_back(
"get_ports");
279 return ports._retn();
294 m_log.push_back(
"on_execute");
299 m_log.push_back(
"on_state_update");
304 m_log.push_back(
"on_rate_changed");
310 :
public CppUnit::TestFixture
313 CPPUNIT_TEST(test_tick);
314 CPPUNIT_TEST_SUITE_END();
328 m_pORB = CORBA::ORB_init(argc, argv);
329 m_pPOA = PortableServer::POA::_narrow(
330 m_pORB->resolve_initial_references(
"RootPOA"));
331 m_pPOA->the_POAManager()->activate();
358 POA_RTC::LightweightRTObject* rto
373 for (
int tickCalledCount = 0; tickCalledCount < 10; tickCalledCount++)
376 CPPUNIT_ASSERT_EQUAL(tickCalledCount, mock->
countLog(
"on_execute"));
382 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(ec));
384 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(rto));
397 int main(
int argc,
char* argv[])
410 std::string arg(argv[i]);
411 std::string next_arg;
412 if (i + 1 < argc) next_arg = argv[i + 1];
415 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
428 ofs.open(fname.c_str());
430 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
431 if ( arg ==
"--cerr" ) { target = 1;
break; }
432 if ( arg ==
"--xsl" )
434 if (next_arg ==
"") xsl =
"default.xsl";
437 if ( arg ==
"--namespace" )
441 std::cerr <<
"no namespace specified" << std::endl;
451 CppUnit::TextUi::TestRunner runner;
453 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
455 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
456 CppUnit::Outputter* outputter = 0;
457 std::ostream* stream = target ? &std::cerr : &std::cout;
461 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
464 std::cout <<
"XML_OUT" << std::endl;
465 outputter =
new CppUnit::XmlOutputter(&runner.result(),
467 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
470 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
473 runner.setOutputter(outputter);
478 #endif // ExtTrigExecutionContext_cpp virtual RTC::ReturnCode_t on_rate_changed(RTC::UniqueId ec_id)
virtual RTC::ReturnCode_t on_finalize()
virtual RTC::ExecutionContextList * get_owned_contexts()
#define RTC_ERROR(fmt)
Error log output macro.
int main(int argc, char **argv)
virtual RTC::ReturnCode_t on_initialize()
EXECUTION_HANDLE_TYPE_NATIVE ExecutionContextHandle_t
CPPUNIT_TEST_SUITE_REGISTRATION(ExtTrigExecutionContext::ExtTrigExecutionContextTests)
RTC::ReturnCode_t returnCode(RTC::ReturnCode_t rc)
virtual RTC::ExecutionContextHandle_t get_context_handle(RTC::_objref_ExecutionContext *)
std::vector< std::pair< std::string, std::string > > NVList
virtual RTC::ReturnCode_t exit()
std::map< RTC::UniqueId, RTC::ExecutionContext_ptr > ExecContexts
virtual void tearDown()
Test finalization.
virtual SDOPackage::ServiceProfile * get_service_profile(const char *id)
virtual SDOPackage::ServiceProfileList * get_service_profiles()
virtual ReturnCode_t add_component(LightweightRTObject_ptr comp)
Add an RT-component.
virtual RTC::ReturnCode_t on_state_update(RTC::UniqueId ec_id)
virtual RTC::ReturnCode_t on_activated(RTC::UniqueId ec_id)
ExtTrigExecutionContextTests()
Constructor.
CORBA::Long m_nextUniqueId
virtual SDOPackage::Configuration_ptr get_configuration()
virtual RTC::UniqueId attach_context(RTC::ExecutionContext_ptr exec_context)
LightweightRTObjectMock()
virtual RTC::ReturnCode_t on_aborting(RTC::UniqueId ec_id)
virtual char * get_sdo_id()
virtual RTC::ReturnCode_t on_execute(RTC::UniqueId ec_id)
virtual RTC::ReturnCode_t initialize()
virtual RTC::_objref_ExecutionContext * get_context(RTC::ExecutionContextHandle_t)
std::vector< ExecutionContext * > ExecutionContextList
ExecutionContextHandle_t UniqueId
ExecContexts m_execContexts
virtual SDOPackage::DeviceProfile * get_device_profile()
virtual ReturnCode_t start(void)
Start the ExecutionContext.
virtual ~ExtTrigExecutionContextTests()
Destructor.
ExtTrigExecutionContext class.
virtual ReturnCode_t activate_component(LightweightRTObject_ptr comp)
Activate an RT-component.
CORBA sequence utility template functions.
void setAlive(bool alive)
virtual RTC::ReturnCode_t on_shutdown(RTC::UniqueId ec_id)
virtual RTC::ReturnCode_t finalize()
std::vector< std::string > m_log
virtual SDOPackage::NVList * get_status_list()
PortableServer::POA_ptr m_pPOA
virtual RTC::ComponentProfile * get_component_profile()
void setError(bool error)
virtual RTC::PortServiceList * get_ports()
virtual ReturnCode_t stop(void)
Stop the ExecutionContext.
virtual RTC::ReturnCode_t on_startup(RTC::UniqueId ec_id)
virtual RTC::ReturnCode_t on_reset(RTC::UniqueId ec_id)
virtual RTC::ReturnCode_t detach_context(RTC::UniqueId ec_id)
virtual SDOPackage::Monitoring_ptr get_monitoring()
std::vector< IPortService * > PortServiceList
int countLog(std::string line)
virtual RTC::ReturnCode_t on_deactivated(RTC::UniqueId ec_id)
virtual SDOPackage::OrganizationList * get_owned_organizations()
virtual void tick()
Move forward one step of ExecutionContext.
virtual RTC::ExecutionContextList * get_participating_contexts()
virtual RTC::ReturnCode_t on_error(RTC::UniqueId ec_id)
virtual void setUp()
Test initialization.
virtual CORBA::Boolean is_alive(RTC::ExecutionContext_ptr exec_context)
int usleep(useconds_t usec)
Stop a processing at specified micro second time.
virtual CORBA::Any * get_status(const char *name)
virtual char * get_sdo_type()
ExecutionContext class that enables one step execution.
virtual SDOPackage::OrganizationList * get_organizations()
virtual SDOPackage::SDOService_ptr get_sdo_service(const char *id)