1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
#include <iostream>
#include "benchC.h"
#include "orbsvcs/CosNamingC.h"
#include <tao/RTCORBA/RTCORBA.h>
#include <unistd.h>
#include "cpx.h"
//benchmark::Put_var put;
benchmark::PutHigh_var highPut;
CPX cpx;
void sigproc(int signo)
{ signal(SIGRTMIN+29, sigproc);
// int i1 = cpx.get(1);
// int i2 /*= cpx.get(2)*/;
// int i3 /*= cpx.get(3)*/;
// put->allPorts(i1, i2, i3);
highPut->onePort(1, cpx.get(1));
// put->allPorts(cpx.get(1), -1, -1);
// put->onePort(3, cpx.get(3));
}
int main(int argc, char* argv[]){
struct sched_param schedparam;
schedparam.sched_priority = 99;
if (sched_setscheduler(0, SCHED_FIFO, &schedparam) != 0) {
fprintf(stderr, "%s: PID %d: sched_setscheduler() failed errno = %d\n", __FUNCTION__, getpid(), errno);
}
try{
// initialize ORB
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "Client2ORB");
std::cout<<"ORB ok"<<std::endl;
// get RTORB
CORBA::Object_var rtorb = orb->resolve_initial_references("RTORB");
RTCORBA::RTORB_var rtORB = RTCORBA::RTORB::_narrow(rtorb.in());
std::cout<<"RTORB ok"<<std::endl;
// Network Settings
CORBA::Long sendBufferSize = 0;
CORBA::Long recvBufferSize = 0;
CORBA::Boolean keepAlive = 1;
CORBA::Boolean dontRoute = 1;
CORBA::Boolean noDelay = 1;
RTCORBA::TCPProtocolProperties_var tcpProperties = rtORB->create_tcp_protocol_properties(
sendBufferSize, recvBufferSize, keepAlive, dontRoute, noDelay, RTCORBA::maxPriority /*network priority*/);
tcpProperties->enable_network_priority(1);
RTCORBA::ProtocolList protocols;
protocols.length(1);
protocols[0].protocol_type = 0; //TAO_TAG_IIOP_PROFILE;
protocols[0].transport_protocol_properties = RTCORBA::ProtocolProperties::_duplicate(tcpProperties.in());
// NamingService
CORBA::Object_var namingObject = orb->resolve_initial_references("NameService");
CosNaming::NamingContext_var namingContext = CosNaming::NamingContext::_narrow(namingObject.in());
std::cout<<"NamingService ok"<<std::endl;
// receive Objects
CosNaming::Name name(1);
name.length(1);
// name[0].id = CORBA::string_dup("Receiver");
// CORBA::Object_var benchObj = namingContext->resolve(name);
// put = benchmark::Put::_narrow(benchObj.in());
name[0].id = CORBA::string_dup("HighReceiver");
CORBA::Object_var lowBenchObj = namingContext->resolve(name);
highPut = benchmark::PutHigh::_narrow(lowBenchObj.in());
std::cout<<"TransferOjekt ok"<<std::endl;
// Private Connection Policy
CORBA::PolicyList pcPolicy(2);
pcPolicy.length(2);
pcPolicy[0] = rtORB->create_private_connection_policy();
pcPolicy[1] = rtORB->create_client_protocol_policy(protocols);
CORBA::Object_var newTran = highPut->_set_policy_overrides(pcPolicy, CORBA::SET_OVERRIDE);
highPut = benchmark::PutHigh::_narrow(newTran.in());
highPut = benchmark::PutHigh::_narrow(newTran.in());
std::cout<<"PrivateConnection, RTProtocol ok"<<std::endl;
// rtCurrent set priority
//CORBA::Object_var rtCurrentObj = orb->resolve_initial_references("RTCurrent");
//RTCORBA::Current_var rtCurrent = RTCORBA::Current::_narrow(rtCurrentObj.in());
//rtCurrent->the_priority(RTCORBA::maxPriority);
//std::cout<<"PriorityChange ok"<<std::endl;
// explicitly bind connection to server
//CORBA::PolicyList_var inconsistentPolicies;
//CORBA::Boolean status = transfer->_validate_connection(inconsistentPolicies.out());
//std::cout<<"explicit bind ok"<<std::endl;
// Input auf Interface schreiben
// ...
highPut->connect();
//lowPut->connect();
highPut->allPorts(0, 0, 0);
sleep(1);
highPut->onePort(1, 255);
sleep(1);
highPut->allPorts(0, 0, 0);
// signal handling
signal(SIGRTMIN+29, sigproc);
while(true){
pause();
}
// destroy ORB
orb->destroy();
}catch(CORBA::Exception &any){
std::cout<<"Exception occured: "<<any<<std::endl;
}
return 0;
}
|