forked from RedhawkSDR/Documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainch12.html
More file actions
463 lines (435 loc) · 18.8 KB
/
mainch12.html
File metadata and controls
463 lines (435 loc) · 18.8 KB
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html >
<head><title>12 Component Control</title>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8"">
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
<!-- html,2,next,javascript,charset="utf-8" -->
<meta name="src" content="main.tex">
<meta name="date" content="2013-03-12 19:46:00">
<link rel="stylesheet" type="text/css" href="main.css">
<script type="text/javascript" src="scripts/shCore.js"></script>
<script type="text/javascript" src="scripts/shBrushCpp.js"></script>
<script type="text/javascript" src="scripts/shBrushJava.js"></script>
<script type="text/javascript" src="scripts/shBrushPython.js"></script>
<script type="text/javascript" src="scripts/shBrushBash.js"></script>
<script type="text/javascript" src="scripts/shBrushXml.js"></script>
<link href="styles/shCore.css" rel="stylesheet" type="text/css" />
<link href="styles/shThemeDefault.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
SyntaxHighlighter.all()
</script>
</head><body
>
<script>
function f() {
document.getElementById('main_content_wrap').focus();
}
if (window.addEventListener) {
window.addEventListener("load", f, false);
} else if (window.attachEvent) {
window.attachEvent("onload", f);
}
</script>
<div class="header">
<ul class="navbar">
<li><a class="logo-small" href="index.html"><img src="images/RedHawk_Logo_ALT_B_121px.png"/></a></li> <li><a href="index.html">Home</a></li>
<li><a href="gettingstarted/main.html">Getting Started</a></li>
<li><a class="active" href="main.html">Documentation</a></li>
<li><a href="download.html">Download</a></li>
<li><a href="support.html">Support</a></li>
</ul>
<div class="pattern right"></div>
<a id="forkme_banner" href="https://github.com/redhawksdr">View on GitHub</a>
</div>
<!-- Custom MAIN CONTENT -->
<div id="main_content_wrap" tabindex="0" class="outer">
<section id="main_content" class="inner">
<!--l. 1--><div class="crosslinks"><p class="noindent">[<a
href="mainch13.html" >next</a>] [<a
href="mainch11.html" >prev</a>] [<a
href="mainch11.html#tailmainch11.html" >prev-tail</a>] [<a
href="#tailmainch12.html">tail</a>] [<a
href="main.html#mainch12.html" >up</a>] </p></div>
<h2 class="chapterHead"><span class="titlemark">Chapter 12</span><br /><a
id="x14-17700012"></a>Component Control</h2>
<h3 class="sectionHead"><span class="titlemark">12.1 </span> <a
id="x14-17800012.1"></a>Introduction</h3>
<!--l. 6--><p class="noindent" >In the execution of <a
href="mainli2.html#glo:component">Components</a> it becomes critical to give the user custom access to certain
aspects of its control and configuration. This allows for the ability to make runtime changes on
pieces of software that are deployed.
<!--l. 9--><p class="noindent" >Control of <a
href="mainli2.html#glo:component">Components</a> is handled by inheriting from the <span
class="cmtt-12">CF::Resource </span>interface, which in
turn inherits from <span
class="cmtt-12">CF::LifeCycle</span>, <span
class="cmtt-12">CF::PortSupplier</span>, <span
class="cmtt-12">CF::PropertySet</span>, and
<span
class="cmtt-12">CF::TestableObject</span>. <span
class="cmtt-12">CF::Resource </span>thus implements a wide range of methods including
<span
class="cmtt-12">initialize()</span>, <span
class="cmtt-12">releaseObject()</span>, <span
class="cmtt-12">getPort()</span>, <span
class="cmtt-12">configure()</span>, <span
class="cmtt-12">query()</span>, <span
class="cmtt-12">runTest()</span>,
<span
class="cmtt-12">start() </span>and <span
class="cmtt-12">stop()</span>. These methods allow the user to manipulate and customize their
<a
href="mainli2.html#glo:component">Components</a> to achieve the exact behavior they desire in all phases of the <a
href="mainli2.html#glo:component">Component</a>’s life
cycle.
<!--l. 13--><p class="noindent" >
<h3 class="sectionHead"><span class="titlemark">12.2 </span> <a
id="x14-17900012.2"></a>Overview of Functionality</h3>
<!--l. 15--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">12.2.1 </span> <a
id="x14-18000012.2.1"></a>Life Cycle</h4>
<!--l. 17--><p class="noindent" >The set up and tear down of resources are handled through the Life Cycle interface. The method
<span
class="cmtt-12">initialize() </span>is used to get a <a
href="mainli2.html#glo:component">Component</a> into its known initial state, by allocating data or setting
structures to their proper initial values. <span
class="cmtt-12">releaseObject() </span>is used to tear down a <a
href="mainli2.html#glo:component">Component</a> by
freeing up any resources used by the <a
href="mainli2.html#glo:component">Component</a>. <span
class="cmtt-12">initialize() </span>can be thought of as a
framework-level constructor, while <span
class="cmtt-12">releaseObject() </span>can be thought of as a framework level
destructor. As such, they are generally called at the beginning and end of the <a
href="mainli2.html#glo:component">Component</a>’s
respective life cycle.
<!--l. 23--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">12.2.2 </span> <a
id="x14-18100012.2.2"></a>Port Supplier</h4>
<!--l. 25--><p class="noindent" >Access to <a
href="mainli2.html#glo:port">Ports</a> are controlled through the <a
href="mainli2.html#glo:port">Port</a> Supplier interface where <span
class="cmtt-12">getPort() </span>is used to
obtain a specific uses (output) or provides (input) <a
href="mainli2.html#glo:port">Port</a>. The method is passed a string containing
the name of the desired <a
href="mainli2.html#glo:port">Port</a>, and then an object reference to that <a
href="mainli2.html#glo:port">Port</a> is returned. If no <a
href="mainli2.html#glo:port">Ports</a> are
found, an <span
class="cmtt-12">UnknownPort </span>exception is thrown. This allows the user to obtain an object that provides
the ability to receive data in and push data out of the <a
href="mainli2.html#glo:component">Component</a>. Each <a
href="mainli2.html#glo:component">Component</a> can
have zero to many input and output <a
href="mainli2.html#glo:port">Ports</a> which are specified in the <a
href="mainli2.html#glo:component">Component</a>’s <a
href="mainap3.html#scd">SCD</a>
file.
<!--l. 31--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">12.2.3 </span> <a
id="x14-18200012.2.3"></a>Property Set</h4>
<!--l. 34--><p class="noindent" ><a
href="mainli2.html#glo:property">Property</a> control is handled through the <span
class="cmtt-12">configure() </span>and <span
class="cmtt-12">query() </span>methods. The <span
class="cmtt-12">configure()</span>
method takes in a list of <a
href="mainap3.html#id">ID</a> and value pairs and attempts to set them. An Invalid Configuration
error is thrown if no <a
href="mainli2.html#glo:property">Properties</a> in the list are able to be set. A Partial Configuration error is
thrown if at least one, but not all <a
href="mainli2.html#glo:property">Properties</a> are set. The <span
class="cmtt-12">query() </span>method serves as the getter for
the <a
href="mainli2.html#glo:component">Component</a>’s <a
href="mainli2.html#glo:property">Properties</a>. If the <span
class="cmtt-12">query() </span>method is passed an empty list, it returns all of the
<a
href="mainli2.html#glo:component">Component</a>’s <a
href="mainli2.html#glo:property">Properties</a>. Otherwise, it will return any valid <a
href="mainli2.html#glo:property">Properties</a> based on the <a
href="mainap3.html#id">ID</a> and value
pair passed in as a parameter.
<!--l. 41--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">12.2.4 </span> <a
id="x14-18300012.2.4"></a>Testable Object</h4>
<!--l. 43--><p class="noindent" >In the Testable Object interface, <span
class="cmtt-12">runTest() </span>is defined to provide a means to perform stand-alone
testing of a <a
href="mainli2.html#glo:component">Component</a>. Test <a
href="mainap3.html#id">ID</a>s and a set of test values are passed in as parameters, with the test
results returned in the test values parameter. This method gives the <a
href="mainli2.html#glo:component">Component</a> the ability to
be “black box” tested where an input is provided in an attempt to match the actual
output with the desired output without any knowledge of the <a
href="mainli2.html#glo:component">Component</a>’s internal
structure.
<h3 class="sectionHead"><span class="titlemark">12.3 </span> <a
id="x14-18400012.3"></a>Examples</h3>
<!--l. 47--><p class="noindent" >This section provides code examples of the methods described above for each of the supported
programming languages.
<!--l. 49--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">12.3.1 </span> <a
id="x14-18500012.3.1"></a><span
class="cmtt-12">CF::LifeCycle</span></h4>
<!--l. 51--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x14-18600012.3.1"></a><span
class="cmtt-12">initialize()</span></h5>
<!--l. 53--><p class="noindent" ><span
class="cmbx-12">C++</span>
<script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
try {
this->initialize();
} catch (CF::LifeCycle::InitializeError e){
// error reporting
}
]]></script>
<!--l. 64--><p class="noindent" ><span
class="cmbx-12">Python</span>
<script type="syntaxhighlighter" class="brush: python"><![CDATA[
try:
self.initialize()
except:
# error reporting
]]></script>
<!--l. 73--><p class="noindent" ><span
class="cmbx-12">Java</span>
<script type="syntaxhighlighter" class="brush: java"><![CDATA[
try {
this.initialize();
} catch (InitializeError e) {
// error reporting
}
]]></script>
<!--l. 83--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x14-18700012.3.1"></a><span
class="cmtt-12">releaseObject()</span></h5>
<!--l. 85--><p class="noindent" ><span
class="cmbx-12">C++</span>
<script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
try {
this->releaseObject();
} catch (CF::LifeCycle::ReleaseError e){
// error reporting
}
]]></script>
<!--l. 95--><p class="noindent" ><span
class="cmbx-12">Python</span>
<script type="syntaxhighlighter" class="brush: python"><![CDATA[
try:
self.releaseObject()
except:
# error reporting
]]></script>
<!--l. 104--><p class="noindent" ><span
class="cmbx-12">Java</span>
<script type="syntaxhighlighter" class="brush: java"><![CDATA[
try {
this.releaseObject();
} catch (ReleaseError e) {
// error reporting
}
]]></script>
<!--l. 114--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">12.3.2 </span> <a
id="x14-18800012.3.2"></a><span
class="cmtt-12">CF::PortSupplier</span></h4>
<!--l. 116--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x14-18900012.3.2"></a><span
class="cmtt-12">getPort()</span></h5>
<!--l. 118--><p class="noindent" ><span
class="cmbx-12">C++</span>
<script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
try {
CORBA::Object_var port = this->getPort("my_port");
} catch (CF::PortSupplier::UnknownPort e){
// error reporting
}
]]></script>
<!--l. 128--><p class="noindent" ><span
class="cmbx-12">Python</span>
<script type="syntaxhighlighter" class="brush: python"><![CDATA[
try:
port = self.getPort("my_port")
except:
# error reporting
]]></script>
<!--l. 137--><p class="noindent" ><span
class="cmbx-12">Java</span>
<script type="syntaxhighlighter" class="brush: java"><![CDATA[
try {
org.omg.CORBA.Object port = this.getPort("my_port");
} catch (UnknownPort e) {
// error reporting
}
]]></script>
<!--l. 147--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">12.3.3 </span> <a
id="x14-19000012.3.3"></a><span
class="cmtt-12">CF::PropertySet</span></h4>
<!--l. 151--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x14-19100012.3.3"></a><span
class="cmtt-12">configure()</span></h5>
<!--l. 153--><p class="noindent" ><span
class="cmbx-12">C++</span>
<script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
CF::Properties props;
props.length(2);
CF::DataType string_var;
string_var.id = "string_prop";
string_var.value <<= "my string prop";
props[0] = string_var;
CF::DataType long_var;
long_var.id = "long_prop";
long_var.value <<= 1234;
props[1] = long_var;
try {
this->configure(props);
} catch (CF::PropertySet::InvalidConfiguration e) {
// error reporting
} catch (CF::PropertySet::PartialConfiguration e) {
// error reporting
}
]]></script>
<!--l. 178--><p class="noindent" ><span
class="cmbx-12">Python</span>
<script type="syntaxhighlighter" class="brush: python"><![CDATA[
prop = CF.DataType(id="prop", value=CORBA.Any(CORBA.TC_long, 1))
try:
self.configure([prop])
except:
# error reporting
]]></script>
<!--l. 188--><p class="noindent" ><span
class="cmbx-12">Java</span>
<script type="syntaxhighlighter" class="brush: java"><![CDATA[
DataType[] props = new DataType[2];
props[0] = new DataType("prop",
AnyUtils.toAny("my prop", TCKind.tk_string));
props[1] = new DataType("prop2",
AnyUtils.toAny(
AnyUtils.convertString("123", "long"), TCKind.tk_long));
try {
this.configure(props);
} catch (InvalidConfiguration e) {
// error reporting
} catch (PartialConfiguration e) {
// error reporting
}
]]></script>
<!--l. 206--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x14-19200012.3.3"></a><span
class="cmtt-12">query()</span></h5>
<!--l. 208--><p class="noindent" ><span
class="cmbx-12">C++</span>
<script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
CF::Properties props;
try {
// queries all properties
this->query(props);
for (unsigned int i = 0; i < props.length(); i++){
// iterates through returned properties and prints ids
std::cout << props[i].id << std::endl;
}
} catch (CF::UnknownProperties e) {
// error reporting
}
]]></script>
<!--l. 224--><p class="noindent" ><span
class="cmbx-12">Python</span>
<script type="syntaxhighlighter" class="brush: python"><![CDATA[
try:
# queries all properties
props = self.query([])
for prop in props:
# iterates through returned properties and prints ids
print prop.id
except:
# error reporting
]]></script>
<!--l. 237--><p class="noindent" ><span
class="cmbx-12">Java</span>
<script type="syntaxhighlighter" class="brush: java"><![CDATA[
PropertiesHolder props =
new PropertiesHolder(new CF.DataType[0]);
try {
// queries all properties
this.query(props);
for (int i = 0; i < props.value.length; i ++){
// iterates through returned properties and prints ids
System.out.println(props.value[i].id);
}
} catch (UnknownProperties e1) {
// error reporting
}
]]></script>
<!--l. 254--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">12.3.4 </span> <a
id="x14-19300012.3.4"></a><span
class="cmtt-12">CF::TestableObject</span></h4>
<!--l. 256--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x14-19400012.3.4"></a><span
class="cmtt-12">runTest()</span></h5>
<!--l. 258--><p class="noindent" ><span
class="cmbx-12">C++</span>
<script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
CF::Properties props;
props.length(1);
CF::DataType test_var;
test_var.id = "prop";
test_var.value <<= 1234;
props[0] = test_var;
try {
this->runTest(0, props);
} catch (CF::TestableObject::UnknownTest e) {
// error reporting
} catch (CF::UnknownProperties e){
// error reporting
}
]]></script>
<!--l. 278--><p class="noindent" ><span
class="cmbx-12">Python</span>
<script type="syntaxhighlighter" class="brush: python"><![CDATA[
prop = CF.DataType(id="prop", value=CORBA.Any(CORBA.TC_long, 1))
try:
self.runTest(0, [prop])
except:
# error reporting
]]></script>
<!--l. 288--><p class="noindent" ><span
class="cmbx-12">Java</span>
<script type="syntaxhighlighter" class="brush: java"><![CDATA[
DataType[] props = new DataType[1];
props[0] = new DataType("prop",
AnyUtils.toAny("my prop", TCKind.tk_string));
PropertiesHolder holders = new PropertiesHolder(props);
try {
this.runTest(0, holders);
} catch (UnknownTest e) {
// error reporting
} catch (UnknownProperties e) {
// error reporting
}
]]></script>
<!--l. 1--><div class="crosslinks"><p class="noindent">[<a
href="mainch13.html" >next</a>] [<a
href="mainch11.html" >prev</a>] [<a
href="mainch11.html#tailmainch11.html" >prev-tail</a>] [<a
href="mainch12.html" >front</a>] [<a
href="main.html#mainch12.html" >up</a>] </p></div>
<!--l. 1--><p class="noindent" ><a
id="tailmainch12.html"></a>
<div class=license>
<hr>
<a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/80x15.png" /></a><br /><span xmlns:dct="http:// purl.org/dc/terms/" property="dct:title">REDHAWK Documentation</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.
</div>
</body></html>