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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
// -*- C++ -*-
//
// $Id$
// **** Code generated by the The ACE ORB (TAO) IDL Compiler ****
// TAO and the TAO IDL Compiler have been developed by:
// Center for Distributed Object Computing
// Washington University
// St. Louis, MO
// USA
// http://www.cs.wustl.edu/~schmidt/doc-center.html
// and
// Distributed Object Computing Laboratory
// University of California at Irvine
// Irvine, CA
// USA
// http://doc.ece.uci.edu/
// and
// Institute for Software Integrated Systems
// Vanderbilt University
// Nashville, TN
// USA
// http://www.isis.vanderbilt.edu/
//
// Information about TAO is available at:
// http://www.cs.wustl.edu/~schmidt/TAO.html
// TAO_IDL - Generated from
// be/be_codegen.cpp:1063
#include "Executor_i.h"
#include "orbsvcs/CosNamingC.h"
#include <tao/RTCORBA/RTCORBA.h>
#include <iostream>
// Implementation skeleton constructor
Executor_ExecCmd_i::Executor_ExecCmd_i ()
{
}
Executor_ExecCmd_i::Executor_ExecCmd_i (int argc, char* argv[], CORBA::ORB_var orb)
{
try{
// 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;
// NameService
CORBA::Object_var namingObject = orb->resolve_initial_references("NameService");
CosNaming::NamingContext_var namingContext = CosNaming::NamingContext::_narrow(namingObject.in());
CosNaming::Name name(1);
name.length(1);
// Connect to Receiver
name[0].id = CORBA::string_dup("Receiver");
// receive Object
CORBA::Object_var benchObj = namingContext->resolve(name);
put = Receiver::Put::_narrow(benchObj.in());
std::cout<<"TransferObjekt ok"<<std::endl;
name.length(2);
name[0].id = CORBA::string_dup("manut.Controller");
name[1].id = CORBA::string_dup("Disp");
benchObj = namingContext->resolve(name);
display = Controller::Display::_narrow(benchObj.in());
std::cout<<"DisplayObjekt ok"<<std::endl;
// auf Interface schreiben
// ...
put->connect();
put->allPorts(0, 0, 0);
sleep(1);
put->allPorts(255, 255, 255);
sleep(1);
put->allPorts(0, 0, 0);
display->show("ready!!!");
}catch(CORBA::Exception &e){
std::cout<<e<<std::endl;
}
}
// Implementation skeleton destructor
Executor_ExecCmd_i::~Executor_ExecCmd_i (void)
{
}
::CORBA::Boolean Executor_ExecCmd_i::changeMode (
::CORBA::Short mode
)
ACE_THROW_SPEC ((
::CORBA::SystemException
))
{
// Add your implementation here
std::cout<<"changeMode called\n";
switch(mode){
case 1:
display->show("moving...");
for(int i = 0; i<255; i++){
put->allPorts(i,i,i);
}
break;
case 2:
display->show("blinking...");
std::cout<<"blink"<<std::endl;
for(int i = 0; i<255; i++){
if(i%2) put->allPorts(255,255,255);
else put->allPorts(0,0,0);
}
break;
case 3:
display->show("flashing...");
std::cout<<"flash"<<std::endl;
for(int i = 0; i<255; i++){
if(i%3)put->allPorts(255,255,255);
else put->allPorts(0,0,0);
}
break;
default:
std::cout<<"Mode not implemented"<<std::endl;
}
return true;
}
::CORBA::Boolean Executor_ExecCmd_i::setPorts (
::CORBA::Short one,
::CORBA::Short two,
::CORBA::Short three
)
ACE_THROW_SPEC ((
::CORBA::SystemException
))
{
// Add your implementation here
put->allPorts(one, two, three);
return true;
}
|