#include #include #include "benchC.h" #include "orbsvcs/CosNamingC.h" #include #include #include "Custom_Network_Priority_Mapping.h" #include "cpx.h" CPX cpx; benchmark::msg_var message = new benchmark::msg; benchmark::msgAndPort1_var msgAndPort1; benchmark::msgAndPort2_var msgAndPort2; benchmark::msgOnly_var msgOnly; benchmark::setPortsOnly_var portOnly; RTCORBA::Current_var current; int mode; std::string strData; void sigproc(int signo) { signal(SIGRTMIN+29, sigproc); switch(mode){ case 1: current->the_priority( RTCORBA::maxPriority /* Priority Definition */ ); msgAndPort1->setPorts(cpx.get(1), cpx.get(2), cpx.get(3)); current->the_priority( RTCORBA::minPriority /* Priority Definition */ ); msgAndPort1->sendMsg(message); break; case 2: current->the_priority( RTCORBA::maxPriority /* Priority Definition */ ); msgAndPort2->setPortsSendMsg(cpx.get(1), cpx.get(2), cpx.get(3), message); break; case 3: current->the_priority( RTCORBA::minPriority /* Priority Definition */ ); std::cout<<"msgOnly mode and DI signal? ..strange"<the_priority( RTCORBA::maxPriority /* Priority Definition */ ); portOnly->setPorts(cpx.get(1), cpx.get(2), cpx.get(3)); current->the_priority( RTCORBA::minPriority /* Priority Definition */ ); msgOnly->sendMsg(message); break; default: std::cout<<"this is impossible :-)"<>mode; if ( (mode < 1) || (mode > 4) ) { std::cout<<"Fehlerhafte Eingabe\nBenutze 4)"<sender = CORBA::string_alloc(sizeof(argv[1])); message->sender = CORBA::string_dup((const char*)argv[1]); message->message = CORBA::string_alloc(sizeof(strData)); message->message = CORBA::string_dup((const char*)strData.c_str()); try{ // initialize ORB CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "ClientORB"); std::cout<<"ORB ok"<resolve_initial_references("RTORB"); RTCORBA::RTORB_var rtORB = RTCORBA::RTORB::_narrow(rtorb.in()); std::cout<<"RTORB ok"<create_tcp_protocol_properties (ACE_DEFAULT_MAX_SOCKET_BUFSIZ, ACE_DEFAULT_MAX_SOCKET_BUFSIZ, 1, 0, 1, 1 /*enable netw. priority*/); RTCORBA::ProtocolList protocols; protocols.length (1); protocols[0].protocol_type = 0; protocols[0].transport_protocol_properties = RTCORBA::ProtocolProperties::_duplicate (tcp_properties.in ()); protocols[0].orb_protocol_properties = RTCORBA::ProtocolProperties::_nil (); // NamingService CORBA::Object_var namingObject = orb->resolve_initial_references("NameService"); CosNaming::NamingContext_var namingContext = CosNaming::NamingContext::_narrow(namingObject.in()); std::cout<<"NamingService ok"<create_private_connection_policy(); pcPolicy[1] = rtORB->create_client_protocol_policy(protocols); CORBA::Policy_var policy; RTCORBA::PriorityModelPolicy_var rtpolicy; RTCORBA::PriorityModel priomod; CORBA::Object_var curobj; CORBA::Object_var newTran; CORBA::Object_var benchObj; curobj = orb->resolve_initial_references("RTCurrent"); current = RTCORBA::Current::_narrow (curobj.in()); // Retrive apropriate objects switch(mode) { case 1: name[0].id = CORBA::string_dup("msgAndPort1"); benchObj = namingContext->resolve(name); msgAndPort1 = benchmark::msgAndPort1::_narrow(benchObj.in()); newTran = msgAndPort1->_set_policy_overrides(pcPolicy, CORBA::SET_OVERRIDE); msgAndPort1 = benchmark::msgAndPort1::_narrow(newTran.in()); current->the_priority( 99 /* Priority Definition */ ); // network priority benchObj = msgAndPort1->_set_policy_overrides (pcPolicy, CORBA::SET_OVERRIDE); msgAndPort1 = benchmark::msgAndPort1::_narrow( benchObj.in() ); msgAndPort1->connect(); msgAndPort1->setPorts(0,0,0); sleep(1); msgAndPort1->setPorts(255,255,255); sleep(1); msgAndPort1->setPorts(0,0,0); break; case 2: name[0].id = CORBA::string_dup("msgAndPort2"); benchObj = namingContext->resolve(name); msgAndPort2 = benchmark::msgAndPort2::_narrow(benchObj.in()); newTran = msgAndPort2->_set_policy_overrides(pcPolicy, CORBA::SET_OVERRIDE); msgAndPort2 = benchmark::msgAndPort2::_narrow(newTran.in()); current->the_priority( 99 /* Priority Definition */ ); benchObj = msgAndPort2->_set_policy_overrides (pcPolicy, CORBA::SET_OVERRIDE); msgAndPort2 = benchmark::msgAndPort2::_narrow( benchObj.in() ); msgAndPort2->connect(); msgAndPort2->setPortsSendMsg(0,0,0, message); sleep(1); msgAndPort2->setPortsSendMsg(255,255,255, message); sleep(1); msgAndPort2->setPortsSendMsg(0,0,0, message); break; case 3: name[0].id = CORBA::string_dup("msgOnly"); benchObj = namingContext->resolve(name); msgOnly = benchmark::msgOnly::_narrow(benchObj.in()); newTran = msgOnly->_set_policy_overrides(pcPolicy, CORBA::SET_OVERRIDE); msgOnly = benchmark::msgOnly::_narrow(newTran.in()); current->the_priority( RTCORBA::minPriority /* Priority Definition */ ); benchObj = msgOnly->_set_policy_overrides (pcPolicy, CORBA::SET_OVERRIDE); msgOnly = benchmark::msgOnly::_narrow( benchObj.in() ); while(true){ if(!msgOnly->sendMsg(message)){ std::cout<<"error occured -> exit"<resolve(name); portOnly = benchmark::setPortsOnly::_narrow(benchObj.in()); newTran = portOnly->_set_policy_overrides(pcPolicy, CORBA::SET_OVERRIDE); portOnly = benchmark::setPortsOnly::_narrow(newTran.in()); benchObj = portOnly->_set_policy_overrides (pcPolicy, CORBA::SET_OVERRIDE); portOnly = benchmark::setPortsOnly::_narrow( benchObj.in() ); name[0].id = CORBA::string_dup("msgOnly"); benchObj = namingContext->resolve(name); msgOnly = benchmark::msgOnly::_narrow(benchObj.in()); newTran = msgOnly->_set_policy_overrides(pcPolicy, CORBA::SET_OVERRIDE); msgOnly = benchmark::msgOnly::_narrow(newTran.in()); current->the_priority( 99 /* Priority Definition */ ); benchObj = msgOnly->_set_policy_overrides (pcPolicy, CORBA::SET_OVERRIDE); msgOnly = benchmark::msgOnly::_narrow( benchObj.in() ); portOnly->connect(); portOnly->setPorts(0,0,0); sleep(1); portOnly->setPorts(255,255,255); sleep(1); portOnly->setPorts(0,0,0); break; default: std::cout<<"this never happens ;-)"<destroy(); }catch(CORBA::Exception &any){ std::cout<<"Exception occured: "<