[openrtm-commit:00673] r2314 - trunk/OpenRTM-aist/src/ext/ec/logical_time/example
openrtm @ openrtm.org
openrtm @ openrtm.org
2012年 2月 8日 (水) 03:37:37 JST
Author: n-ando
Date: 2012-02-08 03:37:35 +0900 (Wed, 08 Feb 2012)
New Revision: 2314
Modified:
trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.cpp
trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.h
trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSampleComp.cpp
Log:
[compat,impl/header,func] LTTSample component has been updated. It is modified in order to activate when RTC is started.
Modified: trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.cpp
===================================================================
--- trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.cpp 2012-02-07 03:02:45 UTC (rev 2313)
+++ trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.cpp 2012-02-07 18:37:35 UTC (rev 2314)
@@ -9,7 +9,7 @@
#include "LTTSample.h"
#include <iostream>
-
+#include <iomanip>
// Module specification
// <rtc-template block="module_spec">
static const char* consolein_spec[] =
@@ -30,8 +30,8 @@
LTTSample::LTTSample(RTC::Manager* manager)
: RTC::DataFlowComponentBase(manager),
+ m_clock(coil::ClockManager::instance().getClock("logical"))
// <rtc-template block="initializer">
- m_outOut("out", m_out)
// </rtc-template>
{
}
@@ -48,7 +48,6 @@
// Set InPort buffers
// Set OutPort buffer
- addOutPort("out", m_outOut);
// Set service provider to Ports
@@ -63,11 +62,9 @@
RTC::ReturnCode_t LTTSample::onExecute(RTC::UniqueId ec_id)
{
- std::cout << "Please input number: ";
- std::cin >> m_out.data;
- std::cout << "Sending to subscriber: " << m_out.data << std::endl;
- m_outOut.write();
-
+ std::cout.setf(std::ios_base::fixed,std::ios_base::floatfield);
+ std::cout << std::setprecision(6);
+ std::cout << "Current time (in onExecute()): " << std::setw(10) << m_clock.gettime() << std::endl;
return RTC::RTC_OK;
}
Modified: trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.h
===================================================================
--- trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.h 2012-02-07 03:02:45 UTC (rev 2313)
+++ trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.h 2012-02-07 18:37:35 UTC (rev 2314)
@@ -7,9 +7,12 @@
* $Id: LTTSample.h 1402 2009-06-24 05:46:53Z hakuta $
*/
-#ifndef CONSOLEIN_H
-#define CONSOLEIN_H
+#ifndef LTTSAMPLE_H
+#define LTTSAMPLE_H
+#include <coil/ClockManager.h>
+#include <coil/TimeValue.h>
+
#include <rtm/idl/BasicDataTypeSkel.h>
#include <rtm/Manager.h>
#include <rtm/DataFlowComponentBase.h>
@@ -94,9 +97,7 @@
// DataOutPort declaration
// <rtc-template block="outport_declare">
- TimedLong m_out;
- OutPort<TimedLong> m_outOut;
-
+
// </rtc-template>
// CORBA Port declaration
@@ -115,7 +116,7 @@
// </rtc-template>
private:
-
+ coil::IClock& m_clock;
};
@@ -124,4 +125,4 @@
DLL_EXPORT void LTTSampleInit(RTC::Manager* manager);
};
-#endif // CONSOLEIN_H
+#endif // LTTSAMPLE_H
Modified: trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSampleComp.cpp
===================================================================
--- trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSampleComp.cpp 2012-02-07 03:02:45 UTC (rev 2313)
+++ trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSampleComp.cpp 2012-02-07 18:37:35 UTC (rev 2314)
@@ -24,7 +24,9 @@
std::cout << "Creating a component: \"LTTSample\"....";
comp = manager->createComponent("LTTSample");
std::cout << "succeed." << std::endl;
-
+ RTC::ExecutionContextList_var eclist = comp->get_owned_contexts();
+ eclist[0]->start();
+ eclist[0]->activate_component(RTC::RTObject::_duplicate(comp->getObjRef()));
RTC::ComponentProfile_var prof;
prof = comp->get_component_profile();
std::cout << "=================================================" << std::endl;
@@ -48,37 +50,56 @@
PortService_ptr port;
port = (*portlist)[i];
std::cout << "================================================="
- << std::endl;
+ << std::endl;
std::cout << "Port" << i << " (name): ";
std::cout << port->get_port_profile()->name << std::endl;
std::cout << "-------------------------------------------------"
- << std::endl;
+ << std::endl;
RTC::PortInterfaceProfileList iflist;
iflist = port->get_port_profile()->interfaces;
-
for (CORBA::ULong i(0), n(iflist.length()); i < n; ++i)
- {
- std::cout << "I/F name: ";
- std::cout << iflist[i].instance_name << std::endl;
- std::cout << "I/F type: ";
- std::cout << iflist[i].type_name << std::endl;
- const char* pol;
- pol = iflist[i].polarity == 0 ? "PROVIDED" : "REQUIRED";
- std::cout << "Polarity: " << pol << std::endl;
- }
+ {
+ std::cout << "I/F name: ";
+ std::cout << iflist[i].instance_name << std::endl;
+ std::cout << "I/F type: ";
+ std::cout << iflist[i].type_name << std::endl;
+ const char* pol;
+ pol = iflist[i].polarity == 0 ? "PROVIDED" : "REQUIRED";
+ std::cout << "Polarity: " << pol << std::endl;
+ }
std::cout << "- properties -" << std::endl;
NVUtil::dump(port->get_port_profile()->properties);
- std::cout << "-------------------------------------------------" << std::endl;
+ std::cout << "-------------------------------------------------"
+ << std::endl;
}
return;
}
-
int main (int argc, char** argv)
{
+ std::cout << "Usage:" << std::endl;
+ std::cout << argv[0] << " [--standalone]" << std::endl;
+ std::cout << std::endl;
+ std::cout << " --standalone: send tick to the EC internally" << std::endl;
+
+ bool standalone(false);
+ for (int i(0); i < argc; ++i)
+ {
+ if (std::string("--standalone") == argv[i])
+ {
+ standalone = true;
+ }
+ }
RTC::Manager* manager;
- manager = RTC::Manager::init(argc, argv);
+ if (standalone)
+ {
+ manager = RTC::Manager::init(0, 0);
+ }
+ else
+ {
+ manager = RTC::Manager::init(argc, argv);
+ }
// Set module initialization proceduer
// This procedure will be invoked in activateManager() function.
@@ -89,7 +110,7 @@
// run the manager in blocking mode
// runManager(false) is the default.
- manager->runManager(true);
+ manager->runManager(standalone);
// If you want to run the manager in non-blocking mode, do like this
// manager->runManager(true);
@@ -118,10 +139,15 @@
}
for (size_t i(0); i < 100; ++i)
{
+ std::cout << "sending a tick (time: " << i;
+ std::cout << " [s], " << i * 1000 << " [usec])" << std::endl;
ttlec->tick(i, i * 1000);
CORBA::ULong sec, usec;
ttlec->get_time(sec, usec);
- std::cout << "time: " << sec << " [s] " << usec << " [usec]" << std::endl;
+ std::cout << "getting time (time: " << sec;
+ std::cout << " [s], " << usec << " [usec])" << std::endl;
+ std::cout << std::endl;
+ coil::usleep(500000);
}
manager->shutdown();
return 0;
openrtm-commit メーリングリストの案内