forked from RedhawkSDR/Documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainch16.html
575 lines (548 loc) · 28.7 KB
/
mainch16.html
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
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html >
<head><title>16 Events</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="mainch17.html" >next</a>] [<a
href="mainch15.html" >prev</a>] [<a
href="mainch15.html#tailmainch15.html" >prev-tail</a>] [<a
href="#tailmainch16.html">tail</a>] [<a
href="main.html#mainch16.html" >up</a>] </p></div>
<h2 class="chapterHead"><span class="titlemark">Chapter 16</span><br /><a
id="x18-21700016"></a>Events</h2>
<h3 class="sectionHead"><span class="titlemark">16.1 </span> <a
id="x18-21800016.1"></a>Introduction</h3>
<!--l. 6--><p class="noindent" >Events are heavily leveraged by REDHAWK to provide system awareness and exchange both
synchronous and asynchronous data. This chapter describes the mechanics of creating and
consuming Events as well as standard Event types defined in REDHAWK and how
they are used. The methodology used to exchange synchronous and asynchronous data,
although reliant on Events as the communications mechanism, is discussed in <a
href="mainch17.html#x19-23100017">Chapter
17</a>.
<!--l. 11--><p class="noindent" >
<h3 class="sectionHead"><span class="titlemark">16.2 </span> <a
id="x18-21900016.2"></a>Event Definition</h3>
<!--l. 13--><p class="noindent" ><a
href="mainap3.html#corba">CORBA</a> defines an interface for the transport of Events as well as an interface for the creation of
<a
href="mainli2.html#glo:eventchannel">Event Channels</a> that can support a publish/subscribe pattern; within REDHAWK, publishers are
often described as producers, and subscribers are often described as consumers.
<!--l. 15--><p class="noindent" >In REDHAWK, an Event is defined as the payload sent on a single call to the <span
class="cmtt-12">push() </span>function in
the <span
class="cmtt-12">PushConsumer </span>interface of the <span
class="cmtt-12">CosEventComm </span><a
href="mainap3.html#idl">IDL</a> module.
<!--l. 17--><p class="noindent" >The <span
class="cmtt-12">PushConsumer </span>interface is as follows:
<script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
interface PushConsumer {
void push (in any data) raises(Disconnected);
void disconnect_push_consumer();
};
]]></script>
<!--l. 26--><p class="noindent" >The description of the <a
href="mainli2.html#glo:eventchannel">Event Channel</a> interface and its use is complicated but luckily unnecessary
for the use of Events in REDHAWK. The main thing to be aware of regarding channels is that
they provide a logical association between a plain text string (channel name) and an object
that implements the interfaces necessary to interconnect producers and consumers,
<span
class="cmtt-12">CosEventChannelAdmin::EventChannel</span>. The <span
class="cmtt-12">EventChannel </span>interface allows a producer or
consumer to register itself with the <a
href="mainli2.html#glo:eventchannel">Event Channel</a>. This registration process gives the producer a
reference to a virtual consumer where Events can be pushed (recall that at the end of the day,
<a
href="mainap3.html#corba">CORBA</a> is just an <a
href="mainap3.html#rpc">RPC</a> mechanism). The registration process allows the consumer to give a
reference to itself to a virtual producer, so that when an Event becomes available, the correct
function is invoked in the consumer. It is the job of the implementer of the <a
href="mainli2.html#glo:eventchannel">Event Channel</a>
interface, also known as an <a
href="mainli2.html#glo:eventservice">Event Service</a>, to maintain the registration interface as well as the
different virtual producers and consumers necessary to re-direct all Events to their appropriate
destinations. The program <span
class="cmtt-12">omniEvents </span>implements the <a
href="mainli2.html#glo:eventchannel">Event Channel</a> interface and enables the
publish/subscribe pattern as described above; REDHAWK uses omniEvents as its <a
href="mainli2.html#glo:eventservice">Event
Service</a>.
<!--l. 34--><p class="noindent" >An interesting aspect of the <span
class="cmtt-12">EventChannel </span>interface is that there is no reason why
that interface is implemented on a single central Event broker. It is possible to create a
consumer that implements both a consumer interface and the <a
href="mainli2.html#glo:eventchannel">Event Channel</a> interface. This
allows that consumer to consume Events either directly from a producer or indirectly
through an <a
href="mainli2.html#glo:eventservice">Event Service</a>. While a central Event broker like omniEvents allows for the
fluid addition of producers and consumers into the <a
href="mainli2.html#glo:domain">Domain</a>, the inherent latency to
the distribution of the Event can be significant (a single call for the publishing of the
Event, an intermediate process queuing that Event, and then one or more pushes for the
distribution of the Event to one or more consumers). On the other hand, a point-to-point
connection between a producer and a consumer removes the intermediary broker and
enables low-latency messaging between <a
href="mainli2.html#glo:component">Components</a>. In REDHAWK 1.8, low-latency
point-to-point Events are used only on <a
href="mainli2.html#glo:message">Messages</a>, which are described in <a
href="mainch17.html#x19-23100017">Chapter 17</a>. In
REDHAWK 1.9, low-latency point-to-point Event consumers of other types will be
supported.
<!--l. 72--><p class="noindent" >
<h3 class="sectionHead"><span class="titlemark">16.3 </span> <a
id="x18-22000016.3"></a>Standard REDHAWK Events</h3>
<!--l. 74--><p class="noindent" >REDHAWK has defined several standard Event types that can be used to monitor the overall state
of a <a
href="mainli2.html#glo:domain">Domain</a> or individual <a
href="mainli2.html#glo:component">Components</a>. The system management Events are sent over the
<a
href="mainli2.html#glo:domain">Domain</a> management channels. Individual <a
href="mainli2.html#glo:component">Component</a> Events are associated with <a
href="mainli2.html#glo:property">Property</a>
changes.
<!--l. 78--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">16.3.1 </span> <a
id="x18-22100016.3.1"></a>Domain Management</h4>
<!--l. 80--><p class="noindent" >REDHAWK defines an Outgoing Domain Management (<a
href="mainap3.html#odm">ODM</a>) channel as well as an Incoming
Domain Management (<a
href="mainap3.html#idm">IDM</a>) channel. The <a
href="mainap3.html#odm">ODM</a> channel contains Events that are generated by the
<a
href="mainli2.html#glo:domainmanager">Domain Manager</a> which indicate the addition or removal of entities to and from the <a
href="mainli2.html#glo:domain">Domain</a>. The
<a
href="mainap3.html#idm">IDM</a> channel contains Events that are generated by <a
href="mainli2.html#glo:device">Devices</a> which indicate changes in the state of
a <a
href="mainli2.html#glo:device">Device</a>.
<!--l. 84--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x18-22200016.3.1"></a>ODM Channel</h5>
<!--l. 86--><p class="noindent" >The <a
href="mainap3.html#odm">ODM</a> channel contains either one of the following Event types:
<script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
struct DomainManagementObjectAddedEventType {
string producerId;
string sourceId;
string sourceName;
StandardEvent::SourceCategoryType sourceCategory;
Object sourceIOR;
};
]]></script>
<script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
struct DomainManagementObjectRemovedEventType {
string producerId;
string sourceId;
string sourceName;
StandardEvent::SourceCategoryType sourceCategory;
};
]]></script>
<!--l. 107--><p class="noindent" >Either Event contains information as to who had something added/removed to/from it, the <a
href="mainap3.html#id">ID</a> of
the entity that was added/removed, the name of the entity that was added/removed, and the
category of item that was added/removed. In the case of an added object, the <a
href="mainap3.html#ior">IOR</a> (stringified
pointer to the object) is included in the Event.
<!--l. 110--><p class="noindent" >The category of item that was added or removed is of type <span
class="cmtt-12">SourceCategoryType</span>, which is defined
as:
<script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
enum SourceCategoryType {
DEVICE_MANAGER,
DEVICE,
APPLICATION_FACTORY,
APPLICATION,
SERVICE
};
]]></script>
<!--l. 122--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x18-22300016.3.1"></a>IDM Channel</h5>
<!--l. 124--><p class="noindent" >The <a
href="mainap3.html#idm">IDM</a> channel can only contain a <span
class="cmtt-12">StateChangeEventType </span>Event, which is defined
as:
<script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
struct StateChangeEventType {
string producerId;
string sourceId;
StandardEvent::StateChangeCategoryType stateChangeCategory;
StandardEvent::StateChangeType stateChangeFrom;
StandardEvent::StateChangeType stateChangeTo;
};
]]></script>
<!--l. 136--><p class="noindent" >The <span
class="cmtt-12">producerId </span>and <span
class="cmtt-12">sourceId </span>of the Event type are redundant; they are both the <a
href="mainap3.html#id"><span
class="cmtt-12">ID</span></a> of the
<a
href="mainli2.html#glo:device">Device</a> that is issuing the Event.
<!--l. 138--><p class="noindent" >The <span
class="cmtt-12">StateChangeCategoryType </span>and <span
class="cmtt-12">StateChangeType </span>are: <script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
enum StateChangeCategoryType {
ADMINISTRATIVE_STATE_EVENT,
OPERATIONAL_STATE_EVENT,
USAGE_STATE_EVENT
};
enum StateChangeType {
LOCKED,
UNLOCKED,
SHUTTING_DOWN,
ENABLED,
DISABLED,
IDLE,
ACTIVE,
BUSY
};
]]></script>
<!--l. 157--><p class="noindent" >The two enumerated types are closely linked; an <span
class="cmtt-12">ADMINISTRATIVE</span><span
class="cmtt-12">_STATE</span><span
class="cmtt-12">_EVENT </span>can only contain
states <span
class="cmtt-12">LOCKED</span>, <span
class="cmtt-12">UNLOCKED</span>, and <span
class="cmtt-12">SHUTTING</span><span
class="cmtt-12">_DOWN</span>, while an <span
class="cmtt-12">OPERATIONAL</span><span
class="cmtt-12">_STATE</span><span
class="cmtt-12">_EVENT </span>can only
contain states <span
class="cmtt-12">ENABLED </span>and <span
class="cmtt-12">DISABLED</span>, and a <span
class="cmtt-12">USAGE</span><span
class="cmtt-12">_STATE</span><span
class="cmtt-12">_EVENT </span>can only contain states <span
class="cmtt-12">IDLE</span>,
<span
class="cmtt-12">ACTIVE</span>, or <span
class="cmtt-12">BUSY</span>.
<!--l. 159--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">16.3.2 </span> <a
id="x18-22400016.3.2"></a>Component Events</h4>
<!--l. 161--><p class="noindent" >The only Event type that is defined for <a
href="mainli2.html#glo:component">Components</a> as a fixed type is the Event that can be issued
when a <a
href="mainli2.html#glo:property">Property</a> value changes in a <a
href="mainli2.html#glo:component">Component</a>.
<!--l. 163--><p class="noindent" >This is defined as:
<script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
struct PropertySetChangeEventType {
string sourceId;
string sourceName;
CF::Properties properties;
};
]]></script>
<!--l. 173--><p class="noindent" >There is no standard channel for the distribution of <span
class="cmtt-12">PropertySetChangeEventType </span>Events from
<a
href="mainli2.html#glo:component">Components</a>. When a <a
href="mainli2.html#glo:component">Component</a> contains the ability to issue these Events, a <a
href="mainli2.html#glo:port">Port</a> called
<span
class="cmtt-12">propEvent </span>is automatically added to the <a
href="mainli2.html#glo:component">Component</a> by the code generators to support the
issuing of such Events. It is up to the <a
href="mainli2.html#glo:application">Application</a> developer to determine what <a
href="mainli2.html#glo:eventchannel">Event
Channel</a> that <a
href="mainli2.html#glo:port">Port</a> is to be connected with when a <a
href="mainli2.html#glo:component">Component</a> with a <span
class="cmtt-12">propEvent </span><a
href="mainli2.html#glo:port">Port</a> is
deployed.
<!--l. 177--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x18-22500016.3.2"></a>Setting up a monitored property</h5>
<!--l. 179--><p class="noindent" >When adding a <a
href="mainli2.html#glo:property">Property</a> to your <a
href="mainli2.html#glo:component">Component</a>, simply check the <span
class="cmbx-12">event </span>type to mark it as an Event
type <a
href="mainli2.html#glo:property">Property</a>. When you save the <span
class="cmtt-12">.prf </span>file inside the <a
href="mainap3.html#prf">PRF</a> editor a uses <a
href="mainli2.html#glo:port">Port</a> will automatically
be generated for the named <span
class="cmtt-12">propEvent</span>. When a property changes through external action (i.e.,
someone calls <span
class="cmtt-12">configure() </span>on the <a
href="mainli2.html#glo:component">Component</a>) and the <a
href="mainli2.html#glo:property">Property</a> value changes, then an Event is
automatically triggered. However, given that a <a
href="mainli2.html#glo:property">Property</a> can be used internally to maintain state,
issuing an Event every time the property changes can easily flood a system. Instead, a
developer is provided the ability to internally trigger Events when a <a
href="mainli2.html#glo:property">Property</a> is considered
in a state where an Event should be issued. Manually triggering Events takes slightly
different syntax in C++, Java, or Python. The syntax for each language is described
below.
<!--l. 187--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x18-22600016.3.2"></a>C++</h5>
<!--l. 189--><p class="noindent" >Below is an example of how to generate a <a
href="mainli2.html#glo:message">Message</a>.
<!--l. 191--><p class="noindent" >This method call is added to the <span
class="cmtt-12">serviceFunction() </span>method of the C++ <a
href="mainli2.html#glo:component">Component</a>:
<script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
propEvent->sendPropertyEvent(propid);
]]></script>
<!--l. 197--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x18-22700016.3.2"></a>Java</h5>
<!--l. 199--><p class="noindent" >Below is an example of how to generate a <a
href="mainli2.html#glo:message">Message</a>.
<!--l. 201--><p class="noindent" >This method call is added to the <span
class="cmtt-12">run() </span>method of the Java <a
href="mainli2.html#glo:component">Component</a>:
<script type="syntaxhighlighter" class="brush: java"><![CDATA[
port_propEvent.sendPropertyEvent(propid);
]]></script>
<!--l. 207--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x18-22800016.3.2"></a>Python</h5>
<!--l. 209--><p class="noindent" >Python provides the ability to send a single Event containing multiple <a
href="mainli2.html#glo:property">Properties</a> whenever an
Event needs to be generated,
<!--l. 211--><p class="noindent" >Below is an example of how to send an Event with a single <a
href="mainli2.html#glo:property">Property</a>.
<!--l. 213--><p class="noindent" >This method call is added to the <span
class="cmtt-12">process() </span>method of the Python <a
href="mainli2.html#glo:component">Component</a>:
<script type="syntaxhighlighter" class="brush: python"><![CDATA[
self.port_propEvent.sendPropertyEvent(propid)
]]></script>
<!--l. 219--><p class="noindent" >Below is an example of how to send an Event with multiple <a
href="mainli2.html#glo:property">Properties</a>.
<!--l. 221--><p class="noindent" >This method call is added to the <span
class="cmtt-12">process() </span>method of the Python <a
href="mainli2.html#glo:component">Component</a>:
<script type="syntaxhighlighter" class="brush: python"><![CDATA[
self.port_propEvent.sendPropertiesEvent(propids)
#or with no arguments to produce an Event with all Event
#properties
]]></script>
<!--l. 229--><p class="noindent" >
<h3 class="sectionHead"><span class="titlemark">16.4 </span> <a
id="x18-22900016.4"></a>Consuming Events</h3>
<!--l. 231--><p class="noindent" >Event consumption is meant as a system-level monitoring process. Therefore, version 1.8 of
REDHAWK does not include <a
href="mainli2.html#glo:component">Component</a> <a
href="mainli2.html#glo:port">Ports</a> that allow the consumption of these
Events; these <a
href="mainli2.html#glo:port">Ports</a> will be added in version 1.9 of REDHAWK. To monitor Events
over a given channel, a simple <a
href="mainap3.html#api">API</a> is available. The <a
href="mainli2.html#glo:domainmanager">Domain Manager</a> contains the
function <span
class="cmtt-12">registerWithEventChannel() </span>to register a consumer to a given channel and
<span
class="cmtt-12">unregisterFromEventChannel() </span>to unregister a consumer from an <a
href="mainli2.html#glo:eventchannel">Event Channel</a>.
<!--l. 235--><p class="noindent" >A command-line tool is available that registers with <a
href="mainli2.html#glo:eventchannel">Event Channels</a> and displays the contents of
the channel, <span
class="cmtt-12">eventviewer</span>. The arguments to <span
class="cmtt-12">eventviewer </span>are the name of the <a
href="mainli2.html#glo:domain">Domain</a> and the
name of the channel.
<!--l. 238--><p class="noindent" >An example of the use of <span
class="cmtt-12">eventviewer </span>is described below:
<!--l. 240--><p class="noindent" >
<ol class="enumerate1" >
<li
class="enumerate" id="x18-229002x1">Start a <a
href="mainli2.html#glo:domainmanager">Domain Manager</a>: <script type="syntaxhighlighter" class="brush: bash"><![CDATA[
$ nodeBooter -D
]]></script>
</li>
<li
class="enumerate" id="x18-229004x2">In a new terminal, attach the eventviewer to the <a
href="mainli2.html#glo:domain">Domain</a>’s <a
href="mainap3.html#odm">ODM</a> channel: <script type="syntaxhighlighter" class="brush: bash"><![CDATA[
$ eventviewer REDHAWK_DEV ODM_Channel
Receiving events. Press 'enter' key to exit
]]></script>
</li>
<li
class="enumerate" id="x18-229006x3">In a new terminal, start a <a
href="mainli2.html#glo:devicemanager">Device Manager</a>: <script type="syntaxhighlighter" class="brush: bash"><![CDATA[
$ nodeBooter -d $SDRROOT/dev/nodes/DevMgr_localhost-loca
ldomain/DeviceManager.dcd.xml
]]></script>
</li>
<li
class="enumerate" id="x18-229008x4">On the Eventviewer terminal, the DeviceManager and <a
href="mainli2.html#glo:device">Device</a> registration should be shown: <script type="syntaxhighlighter" class="brush: bash"><![CDATA[
$ eventviewer REDHAWK_DEV ODM_Channel
Receiving events. Press 'enter' key to exit
{'sourceId': 'DCE:83f3c741-19bf-4794-877f-0322cd62290a',
'sourceName': 'DevMgr_localhost-localdomain', 'sourceIOR
': <ossie.cf.CF._objref_DeviceManager instance at 0x2516
0e0>, 'sourceCategory': DEVICE_MANAGER, 'producerId': 'D
CE:516aa867-e262-4c70-8355-db415f4b0fc6'}
{'sourceId': 'DCE:f5781785-9dd7-4873-8f30-99d7e2ca1a8f',
'sourceName': 'GPP_localhost_localdomain', 'sourceIOR':
<ossie.cf.CF._objref_AggregateExecutableDevice instance
at 0x2d46638>, 'sourceCategory': DEVICE, 'producerId': '
DCE:516aa867-e262-4c70-8355-db415f4b0fc6'}
]]></script>
</li>
<li
class="enumerate" id="x18-229010x5">Shutdown the <a
href="mainli2.html#glo:devicemanager">Device Manager</a> (ctrl-c on the <a
href="mainli2.html#glo:devicemanager">Device Manager</a> terminal)
</li>
<li
class="enumerate" id="x18-229012x6">On the eventviewer terminal, the <a
href="mainli2.html#glo:device">Device</a> and DeviceManager unregistration should be shown: <script type="syntaxhighlighter" class="brush: bash"><![CDATA[
$ eventviewer REDHAWK_DEV ODM_Channel
Receiving events. Press 'enter' key to exit
{'sourceId': 'DCE:83f3c741-19bf-4794-877f-0322cd62290a',
'sourceName': 'DevMgr_localhost-localdomain', 'sourceIOR
': <ossie.cf.CF._objref_DeviceManager instance at 0x2516
0e0>, 'sourceCategory': DEVICE_MANAGER, 'producerId': 'D
CE:516aa867-e262-4c70-8355-db415f4b0fc6'}
{'sourceId': 'DCE:f5781785-9dd7-4873-8f30-99d7e2ca1a8f',
'sourceName': 'GPP_localhost_localdomain', 'sourceIOR':
<ossie.cf.CF._objref_AggregateExecutableDevice instance
at 0x2d46638>, 'sourceCategory': DEVICE, 'producerId': '
DCE:516aa867-e262-4c70-8355-db415f4b0fc6'}
{'sourceId': 'DCE:f5781785-9dd7-4873-8f30-99d7e2ca1a8f',
'sourceName': 'GPP_localhost_localdomain', 'sourceCatego
ry': DEVICE, 'producerId': 'DCE:516aa867-e262-4c70-8355-
db415f4b0fc6'}
{'sourceId': 'DCE:83f3c741-19bf-4794-877f-0322cd62290a',
'sourceName': 'DevMgr_localhost-localdomain', 'sourceCat
egory': DEVICE_MANAGER, 'producerId': 'DCE:516aa867-e262
-4c70-8355-db415f4b0fc6'}
]]></script>
</li></ol>
<!--l. 296--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">16.4.1 </span> <a
id="x18-23000016.4.1"></a>Writing Your Own Event Consumer</h4>
<!--l. 298--><p class="noindent" >In <a
href="mainap3.html#corba">CORBA</a>’s Event <a
href="mainap3.html#api">API</a>, <a
href="mainli2.html#glo:message">Messages</a> are passed as an <span
class="cmtt-12">CORBA::Any </span>type, so when the Event is
consumed from an <a
href="mainli2.html#glo:eventchannel">Event Channel</a>, it arrives as a <span
class="cmtt-12">CORBA::Any </span>type. The <a
href="mainli2.html#glo:application">Application</a> <span
class="cmtt-12">eventviewer</span>
contains an example of how to create an Event consumer.
<!--l. 301--><p class="noindent" >The consumer object is an object that implements the <span
class="cmtt-12">PushConsumer </span>interface.
<!--l. 303--><p class="noindent" >In Python, the definition of such a class is: <script type="syntaxhighlighter" class="brush: python"><![CDATA[
class Consumer_i(CosEventComm__POA.PushConsumer):
def __init__(self):
pass
def push(self, data):
event = any.from_any(data)
print event
def disconnect_push_consumer (self):
pass
]]></script>
<!--l. 317--><p class="noindent" >In the above example, the call to <span
class="cmtt-12">any.from</span><span
class="cmtt-12">_any </span>converts from a <span
class="cmtt-12">CORBA::Any </span>type to a Python
dictionary.
<!--l. 319--><p class="noindent" >An object of the class <span
class="cmtt-12">Consumer </span>needs to be instantiated and given to the <a
href="mainli2.html#glo:domainmanager">Domain Manager</a>. In Python,
the easiest way to access a running <a
href="mainli2.html#glo:domain">Domain</a> is to use the REDHAWK runtime package (a thorough
description of the REDHAWK runtime package is available in <a
href="mainch13.html#x15-19500013">Chapter 13</a>); in the case of a <a
href="mainli2.html#glo:domain">Domain</a>
called <span
class="cmtt-12">REDHAWK</span><span
class="cmtt-12">_DEV</span>, the process needed to associate this consumer with the <a
href="mainli2.html#glo:eventchannel">Event Channel</a> is: <script type="syntaxhighlighter" class="brush: python"><![CDATA[
from ossie.utils import redhawk
_consumer = Consumer_i()
channel_name = 'ODM_Channel'
registration_id = 'some random string'
dom = redhawk.attach('REDHAWK_DEV')
dom.registerWithEventChannel(_consumer._this(), registration_id,
channel_name)
]]></script>
<!--l. 334--><p class="noindent" >In the example shown above, the consumer is attached to the <span
class="cmtt-12">ODM</span><span
class="cmtt-12">_Channel </span>on the <a
href="mainli2.html#glo:domain">Domain</a>
<span
class="cmtt-12">REDHAWK</span><span
class="cmtt-12">_DEV</span>. The registration <a
href="mainap3.html#id"><span
class="cmtt-12">ID</span></a> is some string that can be used to uniquely identify this
registration.
<!--l. 336--><p class="noindent" >Using this <a
href="mainap3.html#id"><span
class="cmtt-12">ID</span></a>, to unregister the code the following method is invoked:
<script type="syntaxhighlighter" class="brush: python"><![CDATA[
dom.unregisterFromEventChannel(registration_id, channel_name)
]]></script>
<!--l. 1--><div class="crosslinks"><p class="noindent">[<a
href="mainch17.html" >next</a>] [<a
href="mainch15.html" >prev</a>] [<a
href="mainch15.html#tailmainch15.html" >prev-tail</a>] [<a
href="mainch16.html" >front</a>] [<a
href="main.html#mainch16.html" >up</a>] </p></div>
<!--l. 1--><p class="noindent" ><a
id="tailmainch16.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>