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
|
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>nevrax.org : docs</TITLE>
<LINK REL=stylesheet TYPE="text/css" HREF="/inc/css/nevrax.css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
<!-- uplinks -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF='/'><b>Home</B></FONT></A> </TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=><b>nevrax.com</B></FONT></A> </TD>
</TR>
</TABLE>
<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
<TR><TD BGCOLOR="#000000" BACKGROUND="/inc/img/black_banner.jpg"><A HREF=""><IMG SRC="/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
</TABLE>
<!-- main table -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!------ Begin Box ------>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
<FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
<TABLE cellspacing=0 cellpadding=1 border=0>
<tr><td ALIGN=middle><a class='linkbox' href="/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
</TABLE>
</TD></TR></TABLE></TD></TR></TABLE>
<!------ End Box ------>
</TD>
<TD WIDTH=15><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD ALIGN=left valign=top><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!-- title -->
<TABLE background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG SRC="/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
<!-- block -->
<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="/inc/img/reddots.gif"></TD>
<TD><B>Documentation</B></TD>
<TD ALIGN=RIGHT> </td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> </center>
<hr><h1>logic_state.cpp</h1><a href="logic__state_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
00007 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025
00026
00027 <font class="preprocessor">#include "<a class="code" href="logic__state_8h.html">nel/logic/logic_state.h</a>"</font>
00028 <font class="preprocessor">#include "<a class="code" href="logic__state__machine_8h.html">nel/logic/logic_state_machine.h</a>"</font>
00029
00030
00031 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00032 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00033 <font class="keyword">using</font> <font class="keyword">namespace </font>NLNET;
00034
00035 <font class="keyword">namespace </font>NLLOGIC
00036 {
00037
00038 <font class="comment">//---------------------------------------------------</font>
00039 <font class="comment">// CLogicState</font>
00040 <font class="comment">//</font>
00041 <font class="comment">//---------------------------------------------------</font>
<a name="l00042"></a><a class="code" href="classNLLOGIC_1_1CLogicState.html#a0">00042</a> CLogicState::CLogicState()
00043 {
00044 <a class="code" href="classNLLOGIC_1_1CLogicState.html#m0">_StateName</a> = <font class="stringliteral">"no_state"</font>;
00045 <a class="code" href="classNLLOGIC_1_1CLogicState.html#m4">_LogicStateMachine</a> = 0;
00046
00047 } <font class="comment">// CLogicState //</font>
00048
00049
00050 <font class="comment">//---------------------------------------------------</font>
00051 <font class="comment">// setLogicStateMachine</font>
00052 <font class="comment">//</font>
00053 <font class="comment">//---------------------------------------------------</font>
<a name="l00054"></a><a class="code" href="classNLLOGIC_1_1CLogicState.html#a1">00054</a> <font class="keywordtype">void</font> CLogicState::setLogicStateMachine( CLogicStateMachine * logicStateMachine )
00055 {
00056 <font class="keywordflow">if</font>( logicStateMachine == 0 )
00057 {
00058 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"(LOGIC)<CLogicCondition::setLogicStateMachine> The state machine is null"</font>);
00059 }
00060 <font class="keywordflow">else</font>
00061 {
00062 <font class="comment">// init the logic state machine for this state</font>
00063 <a class="code" href="classNLLOGIC_1_1CLogicState.html#m4">_LogicStateMachine</a> = logicStateMachine;
00064
00065 <font class="comment">// init the logic state machine in each event</font>
00066 vector<CLogicEvent>::iterator itEvent;
00067 <font class="keywordflow">for</font>( itEvent = <a class="code" href="classNLLOGIC_1_1CLogicState.html#m3">_Events</a>.begin(); itEvent != <a class="code" href="classNLLOGIC_1_1CLogicState.html#m3">_Events</a>.end(); ++itEvent )
00068 {
00069 (*itEvent).setLogicStateMachine( logicStateMachine );
00070 }
00071 }
00072
00073 } <font class="comment">// setLogicStateMachine //</font>
00074
00075
00076
00077 <font class="comment">//---------------------------------------------------</font>
00078 <font class="comment">// addEvent :</font>
00079 <font class="comment">// </font>
00080 <font class="comment">//---------------------------------------------------</font>
<a name="l00081"></a><a class="code" href="classNLLOGIC_1_1CLogicState.html#a4">00081</a> <font class="keywordtype">void</font> CLogicState::addEvent( CLogicEvent event )
00082 {
00083 event.setLogicStateMachine( <a class="code" href="classNLLOGIC_1_1CLogicState.html#m4">_LogicStateMachine</a> );
00084 <a class="code" href="classNLLOGIC_1_1CLogicState.html#m3">_Events</a>.push_back( event );
00085
00086 } <font class="comment">// addEvent //</font>
00087
00088
00089
00090 <font class="comment">//---------------------------------------------------</font>
00091 <font class="comment">// addSIdMap :</font>
00092 <font class="comment">//</font>
00093 <font class="comment">// looks in all the messages of the state if the </font>
00094 <font class="comment">// destination names can be associated with a sid.</font>
00095 <font class="comment">//---------------------------------------------------</font>
<a name="l00096"></a><a class="code" href="classNLLOGIC_1_1CLogicState.html#a5">00096</a> <font class="keywordtype">void</font> CLogicState::addSIdMap( <font class="keyword">const</font> <a class="code" href="namespaceNLLOGIC.html#a0">TSIdMap</a>& sIdMap )
00097 {
00098 vector<CLogicEventMessage>::iterator itMsg;
00099
00101 <font class="keywordflow">for</font>( itMsg = <a class="code" href="classNLLOGIC_1_1CLogicState.html#m1">_EntryMessages</a>.begin(); itMsg != <a class="code" href="classNLLOGIC_1_1CLogicState.html#m1">_EntryMessages</a>.end(); ++itMsg )
00102 {
00103 TSIdMap::const_iterator itId = sIdMap.find( (*itMsg).Destination );
00104 <font class="comment">// if message destination exists in the map we associate the sid with the message</font>
00105 <font class="keywordflow">if</font>( itId != sIdMap.end() )
00106 {
00107 (*itMsg).DestinationId = (*itId).second;
00108 }
00109 }
00111 <a class="code" href="classNLLOGIC_1_1CLogicState.html#a10">trySendEntryMessages</a>();
00112
00113
00114 <font class="comment">// event messages</font>
00115 vector<CLogicEvent>::iterator itEvt;
00116 <font class="keywordflow">for</font>( itEvt = <a class="code" href="classNLLOGIC_1_1CLogicState.html#m3">_Events</a>.begin(); itEvt != <a class="code" href="classNLLOGIC_1_1CLogicState.html#m3">_Events</a>.end(); ++itEvt )
00117 {
00118 string dest = (*itEvt).EventAction.EventMessage.Destination;
00119 TSIdMap::const_iterator itId = sIdMap.find( dest );
00120 <font class="comment">// if message destination exists in the map we associate the sid with the message</font>
00121 <font class="keywordflow">if</font>( itId != sIdMap.end() )
00122 {
00123 (*itEvt).EventAction.EventMessage.DestinationId = (*itId).second;
00124 }
00125 }
00127 <a class="code" href="classNLLOGIC_1_1CLogicState.html#a11">trySendEventMessages</a>();
00128
00129
00131 <font class="keywordflow">for</font>( itMsg = <a class="code" href="classNLLOGIC_1_1CLogicState.html#m2">_ExitMessages</a>.begin(); itMsg != <a class="code" href="classNLLOGIC_1_1CLogicState.html#m2">_ExitMessages</a>.end(); ++itMsg )
00132 {
00133 TSIdMap::const_iterator itId = sIdMap.find( (*itMsg).Destination );
00134 <font class="comment">// if message destination exists in the map we associate the sid with the message</font>
00135 <font class="keywordflow">if</font>( itId != sIdMap.end() )
00136 {
00137 (*itMsg).DestinationId = (*itId).second;
00138 }
00139 }
00140
00141 } <font class="comment">// addSIdMap //</font>
00142
00143
00144 <font class="comment">//---------------------------------------------------</font>
00145 <font class="comment">// processLogic :</font>
00146 <font class="comment">// </font>
00147 <font class="comment">//---------------------------------------------------</font>
<a name="l00148"></a><a class="code" href="classNLLOGIC_1_1CLogicState.html#a6">00148</a> <font class="keywordtype">void</font> CLogicState::processLogic()
00149 {
00150 <font class="comment">// test all conditions managed by this state</font>
00151 vector<CLogicEvent>::iterator itEvent;
00152 <font class="keywordflow">for</font>( itEvent = <a class="code" href="classNLLOGIC_1_1CLogicState.html#m3">_Events</a>.begin(); itEvent != <a class="code" href="classNLLOGIC_1_1CLogicState.html#m3">_Events</a>.end(); ++itEvent )
00153 {
00154 <font class="keywordflow">if</font>( (*itEvent).testCondition() )
00155 {
00156 <font class="comment">//nlinfo("The condition %s is valid",(*itEvent).ConditionName.c_str());</font>
00157 <font class="keywordflow">if</font>( (*itEvent).EventAction.IsStateChange )
00158 {
00159 <a class="code" href="classNLLOGIC_1_1CLogicState.html#m4">_LogicStateMachine</a>->setCurrentState( (*itEvent).EventAction.StateChange );
00160 }
00161 <font class="keywordflow">else</font>
00162 {
00163 <font class="comment">// this message will be sent as soon as the dest id will be given</font>
00164 (*itEvent).EventAction.enableSendMessage();
00165
00167 <a class="code" href="classNLLOGIC_1_1CLogicState.html#a11">trySendEventMessages</a>();
00168 }
00169 }
00170 <font class="keywordflow">else</font>
00171 {
00172 <font class="comment">// reset message send status here to be able to send messages several times in the logic state</font>
00173 <font class="comment">// --> this has to be done if we want messages to be sent every time the condition becomes verified</font>
00174 }
00175 }
00176
00177 } <font class="comment">// processLogic //</font>
00178
00179
00180 <font class="comment">//---------------------------------------------------</font>
00181 <font class="comment">// enterState :</font>
00182 <font class="comment">// </font>
00183 <font class="comment">//---------------------------------------------------</font>
<a name="l00184"></a><a class="code" href="classNLLOGIC_1_1CLogicState.html#a8">00184</a> <font class="keywordtype">void</font> CLogicState::enterState()
00185 {
00187 <a class="code" href="classNLLOGIC_1_1CLogicState.html#a10">trySendEntryMessages</a>();
00188
00189 } <font class="comment">// enterState //</font>
00190
00191
00192 <font class="comment">//---------------------------------------------------</font>
00193 <font class="comment">// exitState :</font>
00194 <font class="comment">// </font>
00195 <font class="comment">//---------------------------------------------------</font>
<a name="l00196"></a><a class="code" href="classNLLOGIC_1_1CLogicState.html#a9">00196</a> <font class="keywordtype">void</font> CLogicState::exitState()
00197 {
00198 vector<CLogicEventMessage>::iterator itMsg;
00199 <font class="keywordflow">for</font>( itMsg = <a class="code" href="classNLLOGIC_1_1CLogicState.html#m2">_ExitMessages</a>.begin(); itMsg != <a class="code" href="classNLLOGIC_1_1CLogicState.html#m2">_ExitMessages</a>.end(); ++itMsg )
00200 {
00201 <font class="keywordflow">if</font>( (*itMsg).DestinationId != CEntityId() )
00202 {
00203 CMessage msgOut( (*itMsg).MessageId );
00204 msgOut.serial( (*itMsg).Arguments );
00205
00206 <a class="code" href="classNLLOGIC_1_1CLogicState.html#m5">_MessagesToSend</a>.insert( make_pair((*itMsg).DestinationId,msgOut) );
00207 }
00208 }
00209
00210 <font class="comment">// reset the entry messages send status</font>
00211 <font class="keywordflow">for</font>( itMsg = <a class="code" href="classNLLOGIC_1_1CLogicState.html#m1">_EntryMessages</a>.begin(); itMsg != <a class="code" href="classNLLOGIC_1_1CLogicState.html#m1">_EntryMessages</a>.end(); ++itMsg )
00212 {
00213 (*itMsg).ToSend = <font class="keyword">false</font>;
00214 (*itMsg).Sent = <font class="keyword">false</font>;
00215 }
00216
00217 <font class="comment">// reset all events</font>
00218 vector<CLogicEvent>::iterator itEvent;
00219 <font class="keywordflow">for</font>( itEvent = <a class="code" href="classNLLOGIC_1_1CLogicState.html#m3">_Events</a>.begin(); itEvent != <a class="code" href="classNLLOGIC_1_1CLogicState.html#m3">_Events</a>.end(); ++itEvent )
00220 {
00221 (*itEvent).reset();
00222 }
00223
00224 <font class="comment">// reset the exit messages send status</font>
00225 <font class="keywordflow">for</font>( itMsg = <a class="code" href="classNLLOGIC_1_1CLogicState.html#m2">_ExitMessages</a>.begin(); itMsg != <a class="code" href="classNLLOGIC_1_1CLogicState.html#m2">_ExitMessages</a>.end(); ++itMsg )
00226 {
00227 (*itMsg).ToSend = <font class="keyword">false</font>;
00228 (*itMsg).Sent = <font class="keyword">false</font>;
00229 }
00230
00231 } <font class="comment">// exitState //</font>
00232
00233
00234
00235 <font class="comment">//---------------------------------------------------</font>
00236 <font class="comment">// trySendEntryMessages :</font>
00237 <font class="comment">// </font>
00238 <font class="comment">//---------------------------------------------------</font>
<a name="l00239"></a><a class="code" href="classNLLOGIC_1_1CLogicState.html#a10">00239</a> <font class="keywordtype">void</font> CLogicState::trySendEntryMessages()
00240 {
00242 vector<CLogicEventMessage>::iterator itMsg;
00243 <font class="keywordflow">for</font>( itMsg = <a class="code" href="classNLLOGIC_1_1CLogicState.html#m1">_EntryMessages</a>.begin(); itMsg != <a class="code" href="classNLLOGIC_1_1CLogicState.html#m1">_EntryMessages</a>.end(); ++itMsg )
00244 {
00245 <font class="keywordflow">if</font>( !(*itMsg).Sent && (*itMsg).DestinationId.getType() != 0xfe )
00246 {
00247 CMessage msgOut( (*itMsg).MessageId );
00248 msgOut.serial( (*itMsg).Arguments );
00249
00250 <a class="code" href="classNLLOGIC_1_1CLogicState.html#m5">_MessagesToSend</a>.insert( make_pair((*itMsg).DestinationId,msgOut) );
00251
00252 (*itMsg).ToSend = <font class="keyword">false</font>;
00253 (*itMsg).Sent = <font class="keyword">true</font>;
00254 }
00255 }
00256
00257 } <font class="comment">// trySendEntryMessages //</font>
00258
00259
00260
00261 <font class="comment">//---------------------------------------------------</font>
00262 <font class="comment">// trySendEventMessages :</font>
00263 <font class="comment">// </font>
00264 <font class="comment">//---------------------------------------------------</font>
<a name="l00265"></a><a class="code" href="classNLLOGIC_1_1CLogicState.html#a11">00265</a> <font class="keywordtype">void</font> CLogicState::trySendEventMessages()
00266 {
00267 <font class="comment">// test all conditions managed by this state</font>
00268 vector<CLogicEvent>::iterator itEvent;
00269 <font class="keywordflow">for</font>( itEvent = <a class="code" href="classNLLOGIC_1_1CLogicState.html#m3">_Events</a>.begin(); itEvent != <a class="code" href="classNLLOGIC_1_1CLogicState.html#m3">_Events</a>.end(); ++itEvent )
00270 {
00271 <font class="keywordflow">if</font>( (*itEvent).EventAction.EventMessage.ToSend == <font class="keyword">true</font> )
00272 {
00273 <font class="keywordflow">if</font>( (*itEvent).EventAction.EventMessage.Sent == <font class="keyword">false</font> )
00274 {
00275 <font class="keywordflow">if</font>( (*itEvent).EventAction.EventMessage.DestinationId.getType() != 0xfe )
00276 {
00277 CMessage msgOut( (*itEvent).EventAction.EventMessage.MessageId );
00278 msgOut.serial( (*itEvent).EventAction.EventMessage.Arguments );
00279
00280 <a class="code" href="classNLLOGIC_1_1CLogicState.html#m5">_MessagesToSend</a>.insert( make_pair((*itEvent).EventAction.EventMessage.DestinationId,msgOut) );
00281
00282 (*itEvent).EventAction.EventMessage.ToSend = <font class="keyword">false</font>;
00283 (*itEvent).EventAction.EventMessage.Sent = <font class="keyword">true</font>;
00284 }
00285 }
00286 }
00287 }
00288
00289 } <font class="comment">// trySendEventMessages //</font>
00290
00291
00292 <font class="comment">//---------------------------------------------------</font>
00293 <font class="comment">// getMessagesToSend :</font>
00294 <font class="comment">// </font>
00295 <font class="comment">//---------------------------------------------------</font>
00296 <font class="keywordtype">void</font> CLogicState::getMessagesToSend( multimap<CEntityId,CMessage>& msgs )
00297 {
00298 multimap<CEntityId,CMessage>::iterator itMsg;
00299 <font class="keywordflow">for</font>( itMsg = <a class="code" href="classNLLOGIC_1_1CLogicState.html#m5">_MessagesToSend</a>.begin(); itMsg != <a class="code" href="classNLLOGIC_1_1CLogicState.html#m5">_MessagesToSend</a>.end(); ++itMsg )
00300 {
00301 msgs.insert( *itMsg );
00302 }
00303
00304 <font class="comment">// erase all the messages</font>
00305 <a class="code" href="classNLLOGIC_1_1CLogicState.html#m5">_MessagesToSend</a>.clear();
00306
00307 } <font class="comment">// getMessagesToSend //</font>
00308
00309
00310
00311 <font class="comment">//---------------------------------------------------</font>
00312 <font class="comment">// fillVarMap :</font>
00313 <font class="comment">// </font>
00314 <font class="comment">//---------------------------------------------------</font>
00315 <font class="keywordtype">void</font> CLogicState::fillVarMap( multimap<CEntityId,string >& stateMachineVariables )
00316 {
00317 <font class="comment">// events</font>
00318 vector<CLogicEvent>::iterator itEvt;
00319 <font class="keywordflow">for</font>( itEvt = <a class="code" href="classNLLOGIC_1_1CLogicState.html#m3">_Events</a>.begin(); itEvt != <a class="code" href="classNLLOGIC_1_1CLogicState.html#m3">_Events</a>.end(); ++itEvt )
00320 {
00321 <font class="comment">// get the condition used in the event</font>
00322 CLogicCondition <a class="code" href="driver__opengl__extension__def_8h.html#a254">condition</a>;
00323 <font class="keywordflow">if</font>( <a class="code" href="classNLLOGIC_1_1CLogicState.html#m4">_LogicStateMachine</a>->getCondition((*itEvt).ConditionName,<a class="code" href="driver__opengl__extension__def_8h.html#a254">condition</a>) )
00324 {
00325 <font class="comment">// get vars used in the conditions</font>
00326 set<string> condVars;
00327 <a class="code" href="driver__opengl__extension__def_8h.html#a254">condition</a>.fillVarSet( condVars );
00328
00329 <font class="comment">// add var with related service</font>
00330 set<string>::iterator itCV;
00331 <font class="keywordflow">for</font>( itCV = condVars.begin(); itCV != condVars.end(); ++itCV )
00332 {
00333 stateMachineVariables.insert( make_pair((*itEvt).EventAction.EventMessage.DestinationId,*itCV) );
00334 }
00335 }
00336 }
00337
00338 } <font class="comment">// fillVarMap //</font>
00339
00340
00341
00342 <font class="comment">//---------------------------------------------------</font>
00343 <font class="comment">// serial :</font>
00344 <font class="comment">// </font>
00345 <font class="comment">//---------------------------------------------------</font>
00346 <font class="comment">/*void CLogicState::serial( IStream &f )</font>
00347 <font class="comment">{</font>
00348 <font class="comment"> f.xmlPush( "STATE");</font>
00349 <font class="comment"></font>
00350 <font class="comment"> f.serial( _StateName );</font>
00351 <font class="comment"> f.serialCont( _EntryMessages );</font>
00352 <font class="comment"> f.serialCont( _ExitMessages );</font>
00353 <font class="comment"> f.serialCont( _Events );</font>
00354 <font class="comment"></font>
00355 <font class="comment"> f.xmlPop();</font>
00356 <font class="comment"></font>
00357 <font class="comment">} // serial //*/</font>
00358
<a name="l00359"></a><a class="code" href="classNLLOGIC_1_1CLogicState.html#a13">00359</a> <font class="keywordtype">void</font> CLogicState::write (xmlNodePtr node)<font class="keyword"> const</font>
00360 <font class="keyword"></font>{
00361 xmlNodePtr elmPtr = xmlNewChild ( node, NULL, (<font class="keyword">const</font> xmlChar*)<font class="stringliteral">"STATE"</font>, NULL);
00362 xmlSetProp (elmPtr, (<font class="keyword">const</font> xmlChar*)<font class="stringliteral">"Name"</font>, (<font class="keyword">const</font> xmlChar*)<a class="code" href="classNLLOGIC_1_1CLogicState.html#m0">_StateName</a>.c_str());
00363
00364 <a class="code" href="types__nl_8h.html#a14">uint</a> i;
00365 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNLLOGIC_1_1CLogicState.html#m1">_EntryMessages</a>.size(); i++)
00366 {
00367 <a class="code" href="classNLLOGIC_1_1CLogicState.html#m1">_EntryMessages</a>[i].write(elmPtr, <font class="stringliteral">"ENTRY_"</font>);
00368 }
00369 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNLLOGIC_1_1CLogicState.html#m2">_ExitMessages</a>.size(); i++)
00370 {
00371 <a class="code" href="classNLLOGIC_1_1CLogicState.html#m2">_ExitMessages</a>[i].write(elmPtr, <font class="stringliteral">"EXIT_"</font>);
00372 }
00373 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNLLOGIC_1_1CLogicState.html#m3">_Events</a>.size(); i++)
00374 {
00375 <a class="code" href="classNLLOGIC_1_1CLogicState.html#m3">_Events</a>[i].write(elmPtr);
00376 }
00377 }
00378
<a name="l00379"></a><a class="code" href="classNLLOGIC_1_1CLogicState.html#a14">00379</a> <font class="keywordtype">void</font> CLogicState::read (xmlNodePtr node)
00380 {
00381 <a class="code" href="namespaceNLLOGIC.html#a1">xmlCheckNodeName</a> (node, <font class="stringliteral">"STATE"</font>);
00382
00383 <a class="code" href="classNLLOGIC_1_1CLogicState.html#m0">_StateName</a> = <a class="code" href="namespaceNLLOGIC.html#a2">getXMLProp</a> (node, <font class="stringliteral">"Name"</font>);
00384
00385 {
00386 <font class="comment">// Count the parent</font>
00387 <a class="code" href="types__nl_8h.html#a14">uint</a> nb = CIXml::countChildren (node, <font class="stringliteral">"ENTRY_EVENT_MESSAGE"</font>);
00388 <a class="code" href="types__nl_8h.html#a14">uint</a> i = 0;
00389 xmlNodePtr parent = CIXml::getFirstChildNode (node, <font class="stringliteral">"ENTRY_EVENT_MESSAGE"</font>);
00390 <font class="keywordflow">while</font> (i<nb)
00391 {
00392 CLogicEventMessage <a class="code" href="driver__opengl__extension__def_8h.html#a246">v</a>;
00393 <a class="code" href="driver__opengl__extension__def_8h.html#a246">v</a>.read(parent);
00394 <a class="code" href="classNLLOGIC_1_1CLogicState.html#m1">_EntryMessages</a>.push_back(<a class="code" href="driver__opengl__extension__def_8h.html#a246">v</a>);
00395
00396 <font class="comment">// Next parent</font>
00397 parent = CIXml::getNextChildNode (parent, <font class="stringliteral">"ENTRY_EVENT_MESSAGE"</font>);
00398 i++;
00399 }
00400 }
00401
00402 {
00403 <font class="comment">// Count the parent</font>
00404 <a class="code" href="types__nl_8h.html#a14">uint</a> nb = CIXml::countChildren (node, <font class="stringliteral">"EXIT_EVENT_MESSAGE"</font>);
00405 <a class="code" href="types__nl_8h.html#a14">uint</a> i = 0;
00406 xmlNodePtr parent = CIXml::getFirstChildNode (node, <font class="stringliteral">"EXIT_EVENT_MESSAGE"</font>);
00407 <font class="keywordflow">while</font> (i<nb)
00408 {
00409 CLogicEventMessage <a class="code" href="driver__opengl__extension__def_8h.html#a246">v</a>;
00410 <a class="code" href="driver__opengl__extension__def_8h.html#a246">v</a>.read(parent);
00411 <a class="code" href="classNLLOGIC_1_1CLogicState.html#m2">_ExitMessages</a>.push_back(<a class="code" href="driver__opengl__extension__def_8h.html#a246">v</a>);
00412
00413 <font class="comment">// Next parent</font>
00414 parent = CIXml::getNextChildNode (parent, <font class="stringliteral">"EXIT_EVENT_MESSAGE"</font>);
00415 i++;
00416 }
00417 }
00418
00419 {
00420 <font class="comment">// Count the parent</font>
00421 <a class="code" href="types__nl_8h.html#a14">uint</a> nb = CIXml::countChildren (node, <font class="stringliteral">"EVENT"</font>);
00422 <a class="code" href="types__nl_8h.html#a14">uint</a> i = 0;
00423 xmlNodePtr parent = CIXml::getFirstChildNode (node, <font class="stringliteral">"EVENT"</font>);
00424 <font class="keywordflow">while</font> (i<nb)
00425 {
00426 CLogicEvent <a class="code" href="driver__opengl__extension__def_8h.html#a246">v</a>;
00427 <a class="code" href="driver__opengl__extension__def_8h.html#a246">v</a>.read(parent);
00428 <a class="code" href="classNLLOGIC_1_1CLogicState.html#m3">_Events</a>.push_back(<a class="code" href="driver__opengl__extension__def_8h.html#a246">v</a>);
00429
00430 <font class="comment">// Next parent</font>
00431 parent = CIXml::getNextChildNode (parent, <font class="stringliteral">"EVENT"</font>);
00432 i++;
00433 }
00434 }
00435
00436 }
00437
00438
00439 } <font class="comment">// NLLOGIC</font>
00440
</pre></div>
<!-- footer -->
<BR><FONT Size=+5> </FONT>
</TD>
<TD WIDTH=15><IMG SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>
|