33 #include <transports/corba/ServiceC.h> 49 pint1(
"pint1",
"", 3), pdouble1(new
Property<double>(
"pdouble1",
"", -3.0)),
50 aint1(3), adouble1(-3.0)
53 BOOST_REQUIRE( caller->ready() );
62 tc->ports()->addEventPort(*mi1);
63 tc->ports()->addPort(*mo1);
68 t2->ports()->addPort(*mo2);
74 tc->provides()->addProperty(pint1);
75 storeProperty(*tc->provides()->properties(),
"s1.s2", pdouble1 );
77 tc->addAttribute(
"aint1", aint1);
78 tc->addAttribute(
"adouble1", adouble1);
116 void testPortDataConnection();
117 void testPortBufferConnection();
118 void testPortDisconnected();
123 signalled_port = port;
127 #define ASSERT_PORT_SIGNALLING(code, read_port) do { \ 128 signalled_port = 0; \ 131 while (read_port != signalled_port && wait++ != 5) \ 133 BOOST_CHECK( read_port == signalled_port ); \ 136 #define wait_for( cond, times ) do { \ 137 bool wait_for_helper; \ 139 while( (wait_for_helper = !(cond)) && wait++ != times ) \ 141 if (wait_for_helper) BOOST_CHECK( cond ); \ 144 #define wait_for_equal( a, b, times ) do { \ 145 bool wait_for_helper; \ 147 while( (wait_for_helper = ((a) != (b))) && wait++ != times ) \ 149 if (wait_for_helper) BOOST_CHECK_EQUAL( a, b ); \ 156 BOOST_CHECK( mo1->connected() );
157 BOOST_CHECK( mi2->connected() );
162 BOOST_CHECK_EQUAL( mi2->read(value),
NoData );
166 BOOST_CHECK( mi2->read(value) );
167 BOOST_CHECK_EQUAL( 1.0, value );
169 BOOST_CHECK( mi2->read(value) );
170 BOOST_CHECK_EQUAL( 2.0, value );
177 BOOST_CHECK( mo1->connected() );
178 BOOST_CHECK( mi2->connected() );
183 BOOST_CHECK_EQUAL( mi2->read(value),
NoData );
189 BOOST_CHECK( mi2->read(value) );
190 BOOST_CHECK_EQUAL( 1.0, value );
191 BOOST_CHECK( mi2->read(value) );
192 BOOST_CHECK_EQUAL( 2.0, value );
193 BOOST_CHECK( mi2->read(value) );
194 BOOST_CHECK_EQUAL( 3.0, value );
195 BOOST_CHECK_EQUAL( mi2->read(value),
OldData );
200 BOOST_CHECK( !mo1->connected() );
201 BOOST_CHECK( !mi2->connected() );
204 template <
typename T>
209 BOOST_TEST_CHECKPOINT(
"Testing CORBA conversion for type " <<
typeid(T).name());
212 BOOST_CHECK_EQUAL( copy, value );
215 template <
typename T>
220 BOOST_TEST_CHECKPOINT(
"Testing CORBA conversion for a vector with elements of type " <<
typeid(T).name());
221 std::vector<T> vec(size, value);
232 testCorbaType<double>(1.0);
233 testCorbaTypeSequence<double>(3, 1.0);
234 testCorbaType<float>(2.0);
235 testCorbaTypeSequence<float>(3, 2.0);
236 testCorbaType<int>(-3);
237 testCorbaTypeSequence<int>(3, -3);
238 testCorbaType<unsigned int>(4);
239 testCorbaTypeSequence<unsigned int>(3, 4);
240 testCorbaType<long long>(-9223372036854775807ll);
241 testCorbaTypeSequence<long long>(3, 9223372036854775807ll);
242 testCorbaType<unsigned long long>(18446744073709551615ull);
243 testCorbaTypeSequence<unsigned long long>(3, 18446744073709551615ull);
244 testCorbaType<bool>(
true);
245 testCorbaType<char>(
'c');
246 testCorbaTypeSequence<char>(3,
'c');
247 testCorbaType<std::string>(
"foo");
248 testCorbaTypeSequence<std::string>(3,
"foo");
249 testCorbaType<RTT::ConnPolicy>();
251 testCorbaType<rt_string>(
"bar");
260 ts = corba::TaskContextServer::Create( tc,
false );
262 tp = corba::TaskContextProxy::Create( ts->server(), true );
265 BOOST_CHECK( tp->provides()->hasAttribute(
"aint1") );
267 BOOST_REQUIRE( proxy_int.ready() );
270 BOOST_CHECK_EQUAL( proxy_int.get(), 3);
273 BOOST_CHECK_EQUAL( proxy_int.set(), 4);
276 BOOST_CHECK_EQUAL( aint1, 5);
278 BOOST_CHECK( tp->provides()->hasAttribute(
"adouble1") );
280 BOOST_REQUIRE( proxy_double.ready() );
283 BOOST_CHECK_EQUAL( proxy_double.set(), -3.0 );
285 proxy_double.
set( 5.0 );
286 BOOST_CHECK_EQUAL( adouble1, 5.0 );
287 BOOST_CHECK_EQUAL( proxy_double.get(), 5.0);
290 BOOST_CHECK_EQUAL( proxy_double.get(), 6.0);
295 ts = corba::TaskContextServer::Create( tc,
false );
297 tp = corba::TaskContextProxy::Create( ts->server(), true );
300 BOOST_CHECK(
findProperty( *tp->provides()->properties(),
"pint1") );
302 BOOST_REQUIRE( proxy_int.
ready() );
304 BOOST_CHECK_EQUAL( proxy_int.
get(), 3);
307 BOOST_CHECK_EQUAL( proxy_int.
set(), 4);
310 BOOST_CHECK_EQUAL( pint1, 5);
312 BOOST_CHECK(
findProperty( *tp->provides()->properties(),
"s1.s2.pdouble1") );
314 BOOST_REQUIRE( proxy_d.
ready() );
316 BOOST_CHECK_EQUAL( proxy_d.
set(), -3.0 );
319 BOOST_CHECK_EQUAL( pdouble1->get(), 5.0 );
320 BOOST_CHECK_EQUAL( proxy_d.
get(), 5.0);
321 pdouble1->set( 6.0 );
323 BOOST_CHECK_EQUAL( proxy_d.
get(), 6.0);
329 ts = corba::TaskContextServer::Create( tc,
false );
331 tp = corba::TaskContextProxy::Create( ts->server(), true );
337 mc = tp->provides(
"methods")->create(
"vm0", tc->engine() );
338 BOOST_CHECK( mc.
call() );
339 BOOST_CHECK( r == 0.0 );
341 mc = tp->provides(
"methods")->create(
"m0", tc->engine() ).ret( r );
342 BOOST_CHECK( mc.
call() );
343 BOOST_CHECK( r == -1.0 );
345 mc = tp->provides(
"methods")->create(
"m2", tc->engine() ).argC(1).
argC(2.0).
ret( r );
346 BOOST_CHECK( mc.
call() );
347 BOOST_CHECK( r == -3.0 );
349 mc = tp->provides(
"methods")->create(
"m3", tc->engine() ).ret( r ).
argC(1).
argC(2.0).
argC(
true);
350 BOOST_CHECK( mc.
call() );
351 BOOST_CHECK( r == -4.0 );
353 mc = tp->provides(
"methods")->create(
"m0except", tc->engine() );
354 BOOST_CHECK_THROW( mc.
call(), std::runtime_error );
355 BOOST_REQUIRE( tc->inException() );
361 ts = corba::TaskContextServer::Create( tc,
false );
363 tp = corba::TaskContextProxy::Create( ts->server(), true );
370 mc = tp->provides(
"methods")->create(
"m0", caller->engine()).ret( r );
371 BOOST_CHECK_NO_THROW( mc.
check() );
374 BOOST_CHECK( shc.ready() );
375 BOOST_CHECK_NO_THROW( shc.check() );
378 BOOST_CHECK_EQUAL( r, 0.0 );
379 BOOST_CHECK_EQUAL( cr, -1.0 );
381 mc = tp->provides(
"methods")->create(
"m2", caller->engine()).argC(1).
argC(2.0).
ret( r );
382 BOOST_CHECK_NO_THROW( mc.
check() );
385 BOOST_CHECK( shc.ready() );
386 BOOST_CHECK_NO_THROW( shc.check() );
389 BOOST_CHECK_EQUAL( r, 0.0 );
390 BOOST_CHECK_EQUAL( cr, -3.0 );
392 mc = tp->provides(
"methods")->create(
"m3", caller->engine()).ret( r ).
argC(1).
argC(2.0).
argC(
true);
393 BOOST_CHECK_NO_THROW( mc.
check() );
396 BOOST_CHECK( shc.ready() );
397 BOOST_CHECK_NO_THROW( shc.check() );
400 BOOST_CHECK_EQUAL( r, 0.0 );
401 BOOST_CHECK_EQUAL( cr, -4.0 );
403 mc = tp->provides(
"methods")->create(
"m4", caller->engine()).ret( r ).
argC(1).
argC(2.0).
argC(
true).
argC(
string(
"hello"));
404 BOOST_CHECK_NO_THROW( mc.
check() );
407 BOOST_CHECK( shc.ready() );
408 BOOST_CHECK_NO_THROW( shc.check() );
411 BOOST_CHECK_EQUAL( r, 0.0 );
412 BOOST_CHECK_EQUAL( cr, -5.0 );
414 #ifndef RTT_CORBA_SEND_ONEWAY_OPERATIONS 415 mc = tp->provides(
"methods")->create(
"m0except", caller->engine());
416 BOOST_CHECK_NO_THROW( mc.
check() );
418 BOOST_CHECK( shc.ready() );
419 BOOST_CHECK_NO_THROW( shc.check() );
421 BOOST_CHECK_THROW( shc.collect(), std::runtime_error);
422 BOOST_REQUIRE( tc->inException() );
429 ts = corba::TaskContextServer::Create( tc,
false );
430 tp = corba::TaskContextProxy::Create( ts->server(), true );
441 BOOST_CHECK_EQUAL( -1.0, m0() );
442 BOOST_CHECK_EQUAL( -2.0, m1(1) );
443 BOOST_CHECK_EQUAL( -3.0, m2(1, 2.0) );
444 BOOST_CHECK_EQUAL( -4.0, m3(1, 2.0,
true) );
445 BOOST_CHECK_EQUAL( -5.0, m4(1, 2.0,
true,
"hello") );
446 BOOST_CHECK_THROW( m0e(), std::runtime_error );
447 BOOST_REQUIRE( tc->inException() );
454 ts = corba::TaskContextServer::Create( tc,
false );
455 tp = corba::TaskContextProxy::Create( ts->server() ,
true);
458 corba::CService_var co = ts->server()->getProvider(
"methods");
459 BOOST_CHECK( co.in() );
461 corba::CAnyArguments_var any_args =
new corba::CAnyArguments(0);
462 CORBA::Any_var vm0 = co->callOperation(
"vm0", any_args.inout() );
465 CORBA::Any_var m0 = co->callOperation(
"m0", any_args.inout());
466 BOOST_CHECK( m0 >>= d );
467 BOOST_CHECK_EQUAL(d, -1.0 );
469 any_args =
new corba::CAnyArguments(1);
471 unsigned int index = 0;
472 any_args[index] <<= (CORBA::Long) 1;
474 BOOST_CHECK_NO_THROW( m1 = co->callOperation(
"m1", any_args.inout()));
475 BOOST_CHECK( m1 >>= d );
476 BOOST_CHECK_EQUAL(d, -2.0 );
478 any_args =
new corba::CAnyArguments(2);
481 any_args[index] <<= (CORBA::Long) 1;
483 any_args[index] <<= (CORBA::Double) 2.0;
485 BOOST_CHECK_NO_THROW( m2 = co->callOperation(
"m2", any_args.inout()));
486 BOOST_CHECK( m2 >>= d );
487 BOOST_CHECK_EQUAL(d, -3.0 );
489 any_args =
new corba::CAnyArguments(3);
492 any_args[index] <<= (CORBA::Long) 1;
494 any_args[index] <<= (CORBA::Double) 2.0;
496 any_args[index] <<= CORBA::Any::from_boolean(
true );
498 BOOST_CHECK_NO_THROW( m3= co->callOperation(
"m3", any_args.inout()) );
499 BOOST_CHECK( m3 >>= d );
500 BOOST_CHECK_EQUAL(d, -4.0 );
502 any_args =
new corba::CAnyArguments(4);
505 any_args[index] <<= (CORBA::Long) 1;
507 any_args[index] <<= (CORBA::Double) 2.0;
509 any_args[index] <<= CORBA::Any::from_boolean(
true );
511 any_args[index] <<=
"hello";
513 BOOST_CHECK_NO_THROW ( m4 = co->callOperation(
"m4", any_args.inout()) );
514 BOOST_CHECK( m4 >>= d );
515 BOOST_CHECK_EQUAL(d, -5.0 );
517 any_args =
new corba::CAnyArguments(0);
518 BOOST_CHECK_THROW(co->callOperation(
"m0except", any_args.inout() ), ::RTT::corba::CCallError);
519 BOOST_REQUIRE( tc->inException() );
524 ts = corba::TaskContextServer::Create( tc,
false );
526 corba::CDataFlowInterface_var ports = ts->server()->ports();
528 corba::CDataFlowInterface::CPortNames_var names =
531 BOOST_CHECK_EQUAL(CORBA::ULong(2), names->length());
532 BOOST_CHECK_EQUAL(
string(
"mi"),
string(names[CORBA::ULong(0)]));
533 BOOST_CHECK_EQUAL(
string(
"mo"),
string(names[CORBA::ULong(1)]));
536 BOOST_CHECK_EQUAL(RTT::corba::COutput,
537 ports->getPortType(
"mo"));
538 BOOST_CHECK_EQUAL(RTT::corba::CInput,
539 ports->getPortType(
"mi"));
542 CORBA::String_var cstr = ports->getDataType(
"mo");
543 BOOST_CHECK_EQUAL(
string(
"double"),
550 ts = corba::TaskContextServer::Create( tc,
false );
551 ts2 = corba::TaskContextServer::Create( t2,
false );
558 corba::CDataFlowInterface_var ports = ts->server()->ports();
559 corba::CDataFlowInterface_var ports2 = ts2->server()->ports();
562 BOOST_CHECK_THROW( ports->createConnection(
"mo", ports2,
"does_not_exist", policy), CNoSuchPortException );
563 BOOST_CHECK_THROW( ports->createConnection(
"does_not_exist", ports2,
"mi", policy), CNoSuchPortException );
564 BOOST_CHECK_THROW( ports->createConnection(
"does_not_exist", ports2,
"does_not_exist", policy), CNoSuchPortException );
565 BOOST_CHECK_THROW( ports->createConnection(
"mo", ports2,
"mo", policy), CNoSuchPortException );
566 BOOST_CHECK_THROW( ports->createConnection(
"mi", ports2,
"mi", policy), CNoSuchPortException );
567 BOOST_CHECK_THROW( ports->createConnection(
"mi", ports2,
"mo", policy), CNoSuchPortException );
570 BOOST_CHECK( t2->start() );
575 policy.type = RTT::corba::CData;
577 BOOST_CHECK( ports->createConnection(
"mo", ports2,
"mi", policy) );
578 testPortDataConnection();
579 ports->disconnectPort(
"mo");
580 testPortDisconnected();
582 policy.type = RTT::corba::CData;
584 BOOST_CHECK( ports->createConnection(
"mo", ports2,
"mi", policy) );
585 #ifndef RTT_CORBA_PORTS_DISABLE_SIGNAL 586 testPortDataConnection();
587 #endif // RTT_CORBA_PORTS_DISABLE_SIGNAL 588 ports2->disconnectPort(
"mi");
589 testPortDisconnected();
591 policy.type = RTT::corba::CBuffer;
594 BOOST_CHECK( ports->createConnection(
"mo", ports2,
"mi", policy) );
595 testPortBufferConnection();
596 ports->disconnectPort(
"mo");
597 testPortDisconnected();
599 policy.type = RTT::corba::CBuffer;
601 BOOST_CHECK( ports->createConnection(
"mo", ports2,
"mi", policy) );
602 #ifndef RTT_CORBA_PORTS_DISABLE_SIGNAL 603 testPortBufferConnection();
604 #endif // RTT_CORBA_PORTS_DISABLE_SIGNAL 607 mo1->createConnection(*mi1);
609 ports->removeConnection(
"mo", ports2,
"mi");
611 BOOST_CHECK(mo1->connected());
612 BOOST_CHECK(mi1->connected());
613 BOOST_CHECK(!mi2->connected());
631 #if __cplusplus > 199711L 632 unique_ptr<RTT::InputPort<double> >
634 auto_ptr<RTT::InputPort<double> >
637 t2->addPort(
"mi3", *mi3);
640 ts = corba::TaskContextServer::Create( tc,
false );
641 ts2 = corba::TaskContextServer::Create( t2,
false );
644 BOOST_CHECK( t2->start() );
651 corba::CDataFlowInterface_var ports = ts->server()->ports();
652 corba::CDataFlowInterface_var ports2 = ts2->server()->ports();
656 policy.buffer_policy = RTT::corba::CShared;
658 BOOST_CHECK( ports->createConnection(
"mo", ports2,
"mi", policy) );
659 BOOST_CHECK( ports->createConnection(
"mo", ports2,
"mi3", policy) );
660 BOOST_CHECK( ports2->createConnection(
"mo", ports2,
"mi", policy) );
661 BOOST_CHECK( mi3->connected() );
662 BOOST_CHECK( mo2->connected() );
663 BOOST_REQUIRE( mi2->getManager()->getSharedConnection() );
664 BOOST_REQUIRE( mi3->getManager()->getSharedConnection() );
665 BOOST_CHECK_EQUAL( mi2->getManager()->getSharedConnection()->getName(), mi3->getManager()->getSharedConnection()->getName() );
666 BOOST_CHECK_EQUAL( mi3->read(value),
NoData );
667 testPortDataConnection();
668 BOOST_CHECK_EQUAL( mi3->read(value),
OldData );
669 BOOST_CHECK_EQUAL( value, 2.0 );
672 BOOST_CHECK_EQUAL( mi3->read(value),
NewData );
673 BOOST_CHECK_EQUAL( value, 3.0 );
675 BOOST_CHECK_EQUAL( mi2->read(value),
OldData );
676 BOOST_CHECK_EQUAL( value, 3.0 );
678 ports->disconnectPort(
"mo");
679 ports2->disconnectPort(
"mo");
680 BOOST_CHECK( !mo1->connected() );
681 BOOST_CHECK( !mo2->connected() );
682 BOOST_CHECK( !mi2->connected() );
683 BOOST_CHECK( !mi3->connected() );
686 policy.buffer_policy = RTT::corba::CShared;
688 BOOST_CHECK( ports->createConnection(
"mo", ports2,
"mi", policy) );
689 BOOST_CHECK( ports->createConnection(
"mo", ports2,
"mi3", policy) );
690 BOOST_CHECK( ports2->createConnection(
"mo", ports2,
"mi", policy) );
691 BOOST_CHECK( mi3->connected() );
692 BOOST_CHECK( mo2->connected() );
693 BOOST_REQUIRE( mi2->getManager()->getSharedConnection() );
694 BOOST_REQUIRE( mi3->getManager()->getSharedConnection() );
695 BOOST_CHECK_EQUAL( mi2->getManager()->getSharedConnection()->getName(), mi3->getManager()->getSharedConnection()->getName() );
696 BOOST_CHECK_EQUAL( mi3->read(value),
NoData );
697 #ifndef RTT_CORBA_PORTS_DISABLE_SIGNAL 698 testPortDataConnection();
699 BOOST_CHECK_EQUAL( mi3->read(value),
OldData );
700 BOOST_CHECK_EQUAL( value, 2.0 );
701 #endif // RTT_CORBA_PORTS_DISABLE_SIGNAL 704 BOOST_CHECK_EQUAL( mi3->read(value),
NewData );
705 BOOST_CHECK_EQUAL( value, 3.0 );
707 BOOST_CHECK_EQUAL( mi2->read(value),
OldData );
708 BOOST_CHECK_EQUAL( value, 3.0 );
710 ports->disconnectPort(
"mo");
711 ports2->disconnectPort(
"mo");
712 BOOST_CHECK( !mo1->connected() );
713 BOOST_CHECK( !mo2->connected() );
714 BOOST_CHECK( !mi2->connected() );
715 BOOST_CHECK( !mi3->connected() );
718 policy.buffer_policy = RTT::corba::CPerOutputPort;
720 BOOST_CHECK( ports->createConnection(
"mo", ports2,
"mi", policy) );
721 BOOST_CHECK( ports->createConnection(
"mo", ports2,
"mi3", policy) );
722 BOOST_CHECK( ports2->createConnection(
"mo", ports2,
"mi", policy) );
723 BOOST_CHECK( mi3->connected() );
724 BOOST_CHECK( mo2->connected() );
725 BOOST_CHECK( mo1->getSharedBuffer() );
726 BOOST_CHECK( mo2->getSharedBuffer() );
727 BOOST_CHECK_EQUAL( mi3->read(value),
NoData );
728 #ifndef RTT_CORBA_PORTS_DISABLE_SIGNAL 729 testPortDataConnection();
730 BOOST_CHECK_EQUAL( mi3->read(value),
OldData );
731 BOOST_CHECK_EQUAL( value, 2.0 );
732 #endif // RTT_CORBA_PORTS_DISABLE_SIGNAL 736 BOOST_CHECK_EQUAL( mi3->read(value),
NewData );
737 BOOST_CHECK_EQUAL( value, 3.0 );
739 BOOST_CHECK_EQUAL( mi2->read(value),
NewData );
740 BOOST_CHECK_EQUAL( value, 4.0 );
742 BOOST_CHECK_EQUAL( mi3->read(value),
OldData );
743 BOOST_CHECK_EQUAL( value, 3.0 );
745 BOOST_CHECK_EQUAL( mi2->read(value),
OldData );
746 BOOST_CHECK_EQUAL( value, 4.0 );
748 ports2->disconnectPort(
"mi");
749 ports2->disconnectPort(
"mi3");
750 BOOST_CHECK( !mo1->connected() );
751 BOOST_CHECK( !mo2->connected() );
752 BOOST_CHECK( !mi2->connected() );
753 BOOST_CHECK( !mi3->connected() );
758 ts = corba::TaskContextServer::Create( tc,
false );
759 tp = corba::TaskContextProxy::Create( ts->server(), true );
760 ts2 = corba::TaskContextServer::Create( t2,
false );
761 tp2 = corba::TaskContextProxy::Create( ts2->server(), true );
765 untyped_port = tp->ports()->getPort(
"mi");
766 BOOST_CHECK(untyped_port);
768 BOOST_CHECK(read_port);
770 untyped_port = tp->ports()->getPort(
"mi");
771 BOOST_CHECK(untyped_port);
773 BOOST_CHECK(write_port);
777 BOOST_CHECK(dynamic_cast<corba::RemoteInputPort*>(read_port));
778 BOOST_CHECK(dynamic_cast<corba::RemoteOutputPort*>(write_port));
781 BOOST_CHECK(read_port->
getTypeInfo() == mi1->getTypeInfo());
783 BOOST_CHECK(write_port->
getTypeInfo() == mo2->getTypeInfo());
785 mo2->createConnection(*read_port);
792 mo2->createConnection(*read_port);
800 #if __cplusplus > 199711L 801 unique_ptr<base::InputPortInterface>
803 auto_ptr<base::InputPortInterface>
805 read_clone(dynamic_cast<base::InputPortInterface*>(read_port->
clone()));
806 BOOST_CHECK(mo2->createConnection(*read_clone));
807 BOOST_CHECK(read_clone->connected());
814 ts = corba::TaskContextServer::Create( tc,
false );
815 tp = corba::TaskContextProxy::Create( ts->server(), true );
816 ts2 = corba::TaskContextServer::Create( t2,
false );
817 tp2 = corba::TaskContextProxy::Create( ts2->server(), true );
827 untyped_port = tp->ports()->getPort(
"mi");
828 BOOST_CHECK(untyped_port);
830 BOOST_CHECK(read_port1);
833 untyped_port = tp2->ports()->getPort(
"mi");
834 BOOST_CHECK(untyped_port);
836 BOOST_CHECK(read_port2);
839 untyped_port = tp2->ports()->getPort(
"mo");
840 BOOST_CHECK(untyped_port);
842 BOOST_CHECK(write_port2);
845 untyped_port = tp->ports()->getPort(
"mo");
846 BOOST_CHECK(untyped_port);
848 BOOST_CHECK(write_port1);
852 BOOST_CHECK(dynamic_cast<corba::RemoteInputPort*>(read_port1));
853 BOOST_CHECK(dynamic_cast<corba::RemoteInputPort*>(read_port2));
854 BOOST_CHECK(dynamic_cast<corba::RemoteOutputPort*>(write_port1));
855 BOOST_CHECK(dynamic_cast<corba::RemoteOutputPort*>(write_port2));
858 write_port2->
connectTo(read_port1, policy);
863 write_port1->
connectTo(read_port1, policy);
876 write_port2->
connectTo(read_port1, policy);
879 BOOST_CHECK(read_port1->
disconnect(write_port2));
886 BOOST_CHECK(mi1->connected());
892 mo2->connectTo(read_port1, policy);
894 BOOST_CHECK(mo2->connected());
896 BOOST_CHECK(!mo2->connected());
905 ts = corba::TaskContextServer::Create( tc,
false );
912 corba::CDataFlowInterface_var ports = ts->server()->ports();
913 BOOST_REQUIRE( ports.in() );
917 CChannelElement_var cce = ports->buildChannelInput(
"mo", policy);
918 CORBA::Any_var sample =
new CORBA::Any();
919 BOOST_REQUIRE( cce.in() );
921 BOOST_CHECK_EQUAL( cce->read( sample.out(), true ), CNoData );
924 BOOST_CHECK_EQUAL( cce->read( sample.out(), true ), CNewData );
926 BOOST_CHECK_EQUAL( result, 3.33);
930 BOOST_CHECK_EQUAL( cce->read( sample.out(), true ), COldData );
932 BOOST_CHECK_EQUAL( result, 3.33);
937 cce = ports->buildChannelOutput(
"mi", policy);
938 cce->channelReady(policy);
939 sample =
new CORBA::Any();
940 BOOST_REQUIRE( cce.in() );
945 cce->write( sample.in() );
946 BOOST_CHECK_EQUAL( mi1->read( result ),
NewData );
947 BOOST_CHECK_EQUAL( result, 4.44 );
951 BOOST_CHECK_EQUAL( mi1->read( result ),
OldData );
952 BOOST_CHECK_EQUAL( result, 4.44);
959 ts = corba::TaskContextServer::Create( tc,
false );
966 corba::CDataFlowInterface_var ports = ts->server()->ports();
967 BOOST_REQUIRE( ports.in() );
971 CChannelElement_var cce = ports->buildChannelInput(
"mo", policy);
972 CORBA::Any_var sample =
new CORBA::Any();
973 BOOST_REQUIRE( cce.in() );
975 BOOST_CHECK_EQUAL( cce->read( sample.out(), true ), CNoData );
979 BOOST_CHECK_EQUAL( cce->read( sample.out(), true ), CNewData );
981 BOOST_CHECK_EQUAL( result, 6.33);
982 BOOST_CHECK_EQUAL( cce->read( sample.out(), true ), CNewData );
984 BOOST_CHECK_EQUAL( result, 3.33);
988 BOOST_CHECK_EQUAL( cce->read( sample.out(), true ), COldData );
990 BOOST_CHECK_EQUAL( result, 3.33);
995 cce = ports->buildChannelOutput(
"mi", policy);
996 cce->channelReady(policy);
997 sample =
new CORBA::Any();
998 BOOST_REQUIRE( cce.in() );
1003 cce->write( sample.in() );
1005 cce->write( sample.in() );
1006 BOOST_CHECK_EQUAL( mi1->read( result ),
NewData );
1007 BOOST_CHECK_EQUAL( result, 6.44 );
1008 BOOST_CHECK_EQUAL( mi1->read( result ),
NewData );
1009 BOOST_CHECK_EQUAL( result, 4.44 );
1013 BOOST_CHECK_EQUAL( mi1->read( result ),
OldData );
1014 BOOST_CHECK_EQUAL( result, 4.44);
virtual PortInterface * clone() const =0
InputPort< double > * mi2
static ConnPolicy data(int lock_policy=LOCK_FREE, bool init_connection=true, bool pull=false)
#define BOOST_FIXTURE_TEST_SUITE(suite_name, F)
DataSourceType get() const
void new_data_listener(base::PortInterface *port)
virtual const types::TypeInfo * getTypeInfo() const =0
OutputPort< double > * mo1
OutputPort< double > * mo2
void testPortDisconnected()
#define BOOST_AUTO_TEST_SUITE_END()
#define ASSERT_PORT_SIGNALLING(code, read_port)
BOOST_AUTO_TEST_CASE(testCorbaTypes)
static void testCorbaTypeSequence(std::size_t size=3, const T &value=T())
PropertyBase * findProperty(const PropertyBag &bag, const std::string &nameSequence, const std::string &separator)
SendHandleC & arg(base::DataSourceBase::shared_ptr a)
static void testCorbaType(const T &value=T())
A property represents a named value of any type with a description.
virtual bool connectTo(PortInterface *other, ConnPolicy const &policy)
static ConnPolicy buffer(int size, int lock_policy=LOCK_FREE, bool init_connection=false, bool pull=false)
static bool operator==(const ConnPolicy &, const ConnPolicy &)
virtual bool connected() const
void testPortBufferConnection()
OperationCallerC & ret(base::AttributeBase *r)
RTT::corba::CConnPolicy toCORBA(RTT::ConnPolicy const &policy)
bool storeProperty(PropertyBag &bag, const std::string &path, base::PropertyBase *item, const std::string &separator)
#define ORO_CORBA_PROTOCOL_ID
virtual void disconnect()
OperationCallerC & argC(const ArgT a)
void testPortDataConnection()
InputPort< double > * mi1
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Property< double > * pdouble1
static bool update(TaskContext *tc)