26 #ifndef DataInOutPort_cpp 27 #define DataInOutPort_cpp 31 #include <cppunit/ui/text/TestRunner.h> 32 #include <cppunit/TextOutputter.h> 33 #include <cppunit/extensions/TestFactoryRegistry.h> 34 #include <cppunit/extensions/HelperMacros.h> 35 #include <cppunit/TestAssert.h> 37 #include <rtm/idl/BasicDataTypeSkel.h> 38 #include <rtm/idl/RTCSkel.h> 43 #include <coil/Properties.h> 51 template <
class DataType>
57 d.data = value.data * value.data;
63 :
public CppUnit::TestFixture
66 CPPUNIT_TEST(test_connect);
67 CPPUNIT_TEST_SUITE_END();
87 : m_outport(
"fout", m_ofloat),
88 m_inport(
"fin", m_ifloat)
94 m_pORB = CORBA::ORB_init(argc, argv);
95 m_pPOA = PortableServer::POA::_narrow(
96 m_pORB->resolve_initial_references(
"RootPOA"));
97 m_pPOA->the_POAManager()->activate();
100 m_inport.
init(dummy);
101 m_outport.
init(dummy);
132 RTC::ConnectorProfile prof;
133 prof.connector_id =
"";
134 prof.name = CORBA::string_dup(
"connector0");
135 prof.ports.length(2);
136 prof.ports[0] = m_oportref;
137 prof.ports[1] = m_iportref;
159 std::cout <<
"Returned connector ID" 160 << prof.connector_id << std::endl;
161 std::cout <<
"InPort's connector ID" 162 << (*iprof)[0].connector_id << std::endl;
163 std::cout <<
"OutPort's connector ID" 164 << (*oprof)[0].connector_id << std::endl;
166 std::string c_id, i_id, o_id;
167 c_id = prof.connector_id;
168 i_id = (*iprof)[0].connector_id;
169 o_id = (*oprof)[0].connector_id;
171 CPPUNIT_ASSERT(c_id == o_id);
172 CPPUNIT_ASSERT(c_id == i_id);
173 CPPUNIT_ASSERT(o_id == i_id);
175 for (
int i = 0; i < 100; ++i)
177 m_ofloat.data = 1.234567 * i;
183 std::cout << m_ofloat.data <<
" <=> " << m_ifloat.data << std::endl;
185 CPPUNIT_ASSERT(m_ofloat.data == m_ifloat.data);
188 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(&m_inport));
189 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(&m_outport));
201 int main(
int argc,
char* argv[])
214 std::string arg(argv[i]);
215 std::string next_arg;
216 if (i + 1 < argc) next_arg = argv[i + 1];
219 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
232 ofs.open(fname.c_str());
234 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
235 if ( arg ==
"--cerr" ) { target = 1;
break; }
236 if ( arg ==
"--xsl" )
238 if (next_arg ==
"") xsl =
"default.xsl";
241 if ( arg ==
"--namespace" )
245 std::cerr <<
"no namespace specified" << std::endl;
255 CppUnit::TextUi::TestRunner runner;
257 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
259 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
260 CppUnit::Outputter* outputter = 0;
261 std::ostream* stream = target ? &std::cerr : &std::cout;
265 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
268 std::cout <<
"XML_OUT" << std::endl;
269 outputter =
new CppUnit::XmlOutputter(&runner.result(),
271 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
274 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
277 runner.setOutputter(outputter);
282 #endif // DataInOutPort_cpp SDOPackage::NameValue newNV(const char *name, Value value)
Create NameValue.
virtual void tearDown()
Test finalization.
int main(int argc, char **argv)
virtual ConnectorProfileList * get_connector_profiles()
[CORBA interface] Get the ConnectorProfileList of the Port
HogeCovnert< RTC::TimedFloat > * m_conv
virtual ReturnCode_t connect(ConnectorProfile &connector_profile)
[CORBA interface] Connect the Port
unsigned int sleep(unsigned int seconds)
Stop a processing at specified second time.
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
RTC::PortService_var m_iportref
RTC::InPort< RTC::TimedFloat > m_inport
Data convert callback abstract class on read()
std::vector< ConnectorProfile * > ConnectorProfileList
CPPUNIT_TEST_SUITE_REGISTRATION(DataInOutPort::DataInOutPortTests)
DataType operator()(const DataType &value)
Callback method.
~DataInOutPortTests()
Destructor.
RTC::PortService_var m_oportref
void init(coil::Properties &prop)
Initializing properties.
virtual PortProfile * get_port_profile()
[CORBA interface] Get the PortProfile of the Port
Class represents a set of properties.
RTC::OutPort< RTC::TimedFloat > m_outport
PortableServer::POA_ptr m_pPOA
virtual bool write(DataType &value)
Write data.
virtual void setUp()
Test initialization.
void push_back(CorbaSequence &seq, SequenceElement elem)
Push the new element back to the CORBA sequence.
void init(coil::Properties &prop)
Initializing properties.
bool read()
Readout the value from DataPort.
DataInOutPortTests()
Constructor.