MAK RTIspy API Documentation for HLA 1.3
Home
Modules
Namespaces
Classes
Files
Examples
Libraries
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
examples
simpleDDM
simpleDDMFederate.h
Go to the documentation of this file.
1
/******************************************************************************
2
** Copyright (c) 2006 MaK Technologies, Inc.
3
** All rights reserved.
4
******************************************************************************/
5
/******************************************************************************
6
** $RCSfile: simpleDDMFederate.h,v $ $Revision: 1.17 $ $State: Exp $
7
******************************************************************************/
8
9
#ifndef REGIONEXAMPLE_H_
10
#define REGIONEXAMPLE_H_
11
12
// Base class for wrappers around the RTI Ambassador calls.
13
14
#include <sstream>
15
#include <string>
16
#include <iostream>
17
#include <iomanip>
18
#include <vector>
19
20
21
#include "
simpleDDMStringUtil.h
"
22
23
24
25
class
simpleDDMFederate
26
{
27
public
:
29
// Default Constructor
31
simpleDDMFederate
();
32
34
// Constructor
36
simpleDDMFederate
(
simpleDDMFederate
& data);
37
39
// Destructor
41
virtual
~simpleDDMFederate
();
42
43
// RTI Wrappers
44
46
// Initialize the RTI
48
virtual
void
initializeRTI
() = 0;
49
51
// Create a federation execution
53
virtual
bool
createFedEx
() = 0;
54
56
// Join a federation execution
58
virtual
bool
joinFedEx
() = 0;
59
61
// Resign from the federation execution and destroy it
63
virtual
void
resignAndDestroy
() = 0;
64
66
// Create the Region and initialize its bounds
68
virtual
bool
createAndInitializeRegions
() = 0;
69
71
// Publish and subscribe the object class attributes.
72
// Register an object instance of the class.
74
virtual
bool
publishSubscribeAndRegisterObject
() = 0;
75
77
// Publish and Subscribe to an interaction class
79
virtual
bool
publishAndSubscribeInteraction
() = 0;
80
82
// Send the default update with Region. A less simple federate would have to
83
// specify which attributes need be updated. This on merely passes in the
84
// position which is sent with Region as the object update.
86
virtual
void
sendUpdate
(
int
currentPosition ) = 0;
87
89
// Send Interactions with Region. The following two interactions are meant to
90
// emulate a cuckoo clock with both an hourly chime, and a quarterly chime.
92
94
// Send the hourly interaction with Region. This is an interaction that in this
95
// example occurs for each hour that is passed on the clock that is not
96
// {12,3,6,9}.
98
virtual
void
sendInteraction_hourly
() = 0;
99
101
// Send the quarterly interaction with Region. This is an interaction that in
102
// this example occurs for each hour that is passed on the clock that is in the
103
// following set {12,3,6,9}
105
virtual
void
sendInteraction_quarterly
() = 0;
106
108
// changeBounds sets the subscription of publication bounds of this federate.
110
virtual
void
changeBounds
(
int
lower,
int
upper,
int
UTCZone) = 0;
111
113
// Set the RTI's enable advisory switch
115
virtual
void
setEnableScopeAdvisories
(
bool
yesNo) = 0;
116
118
// Get scope advisory setting
120
bool
enableScopeAdvisories
()
const
;
121
123
// Perform the tick or evokeCallback method.
125
virtual
bool
tick
(
double
atMost=0.0f) = 0;
126
128
// Perform the tick or evokeCallback method.
130
virtual
bool
tick
(
double
atLeast,
double
atMost) = 0;
131
132
// Simulation Methods
133
135
// Set federate as publisher (true) or subscriber (false)
137
virtual
void
setIsPublisher
(
bool
yesNo) = 0;
138
140
// Return true if this federate is publishing
142
bool
isPublisher
()
const
;
143
145
// Set the position (number of seconds)
147
virtual
void
setPosition
(
int
data) = 0;
148
150
// Get the position (number of seconds)
152
virtual
int
position
() = 0;
153
155
// Set the number of seconds to increment each cycle
157
void
setSizeToInc
(
int
data);
158
160
// Get the number of seconds to increment each cycle
162
int
sizeToInc
()
const
;
163
165
// Get the zone used to send or listen
167
int
zone
()
const
;
168
169
// Region Range Bound Methods
170
172
// Set the update range (number of seconds ahead of current position)
173
// This value should be at least large enough to have the next update fall
174
// within the range.
176
void
setSendRangeSize
(
int
data);
177
179
// Get the update range (number of seconds ahead of current position)
181
int
sendRangeSize
()
const
;
182
184
// Get this listen upper bound
186
int
listenUpperBound
()
const
;
187
189
// Get this listen lower bound
191
int
listenLowerBound
()
const
;
192
194
// Get the send upper bound
196
int
sendUpperBound
()
const
;
197
199
// Get the send lower bound
201
int
sendLowerBound
()
const
;
202
203
205
// Set the Fed File Name
207
virtual
void
setFedFileName
(
const
wchar_t
* newFedName) = 0;
208
210
// Set the Fed File Name with a std::string.
212
virtual
void
setFedFileName
(
const
char
* newFedName) = 0;
213
215
// Get the Fed File Name
217
virtual
char
*
getFedFileName
()
const
= 0;
218
219
// Constants used in calculations
220
static
const
unsigned
int
NUMSECONDSPERMINUTE
;
221
static
const
unsigned
int
NUMMINUTESPERHOUR
;
222
static
const
unsigned
int
NUMSECONDSPERHOUR
;
223
224
// 0 seconds is the minimum.
225
static
const
unsigned
int
LOWESTSecondsInRegion
;
226
//60 seconds * 60 minutes * 360 degrees.
227
static
const
unsigned
int
GREATESTSecondsInRegion
;
228
// 0 is the default UTC
229
static
const
unsigned
int
LOWESTUTCInRegion
;
230
// For this example, the World has only 24 distinct Time Zones. (GREATESTUTCInRegion = 23)
231
static
const
unsigned
int
GREATESTUTCInRegion
;
232
233
enum
simpleAttributeHandleIndex
234
{
235
simplePositionIndex
= 0,
236
simpleMaxIndex
237
};
238
239
protected
:
240
241
// Our upper bound is the number of seconds in a circle.
242
// This is our default upper bound of interest extent in our region.
243
int
myListenUpperBound
;
244
245
// This is our default lower bound of interest extent in our region.
246
int
myListenLowerBound
;
247
248
// Is this instance the publisher. The Simple DDM example has one federate
249
// publishing and the other federate publishing no information,
250
// simply subscribing.
251
bool
myIsPublisher
;
252
253
//******************************************//
254
// The following are publisher specific data
255
//******************************************//
256
// This is our default upper area of interest extent in our region.
257
int
mySendUpperBound
;
258
// This is our default lower area of interest extent in our region.
259
int
mySendLowerBound
;
260
// This is the default time increment between ticks (seconds)
261
int
mySizeToInc
;
262
// This is the calculated range of the sender
263
float
mySendRangeSize
;
264
// This represents the current position of the executing federate.
265
// The valid range for this int is between
266
// [positionLowerBound, positionUpperBound)
267
int
myCurrentposition
;
268
269
// The number of updates sent
270
int
myUpdateCount
;
271
272
int
myUTCZone
;
273
274
//******************************************//
275
// The following is subscriber specific data
276
//******************************************//
277
// This boolean enables the scope Advisory callback from the rti1516.
278
// The scoping callback is issued when an object that is subscribed with
279
// region changes visibility to the federate. i.e. When the subscribed and
280
// published region start to instersect and cease to intersect.
281
bool
myEnableScopeAdvisories
;
282
283
//initialized represents whether or not the QT process has Initialized,
284
// After main launches a QT thread,
285
// main waits for QT to set initialized before proceeding
286
bool
myInitialized
;
287
// closed is a global representing whether the main loop has exited for any
288
// reason including the user closing the dialog.
289
// The main loop sets it prior to exiting and the QT thread
290
// exits when it detects the main loop has closed.
291
bool
myClosed
;
292
293
bool
myRegionValid
;
294
bool
myMapsInitialized
;
295
296
private
:
297
// Assignment Operator not implemented: Copy not allowed
298
simpleDDMFederate
&
operator=
(
const
simpleDDMFederate
&);
299
};
300
301
302
inline
void
simpleDDMFederate::setSizeToInc
(
int
data)
303
{
304
mySizeToInc
= data;
305
}
306
inline
void
simpleDDMFederate::setSendRangeSize
(
int
data)
307
{
308
if
( data < (
int
)(
GREATESTSecondsInRegion
-
LOWESTSecondsInRegion
) )
309
{
310
mySendRangeSize
= (float)data;
311
}
312
else
313
{
314
mySendRangeSize
= (float)(
GREATESTSecondsInRegion
-
LOWESTSecondsInRegion
);
315
}
316
}
317
318
inline
int
simpleDDMFederate::listenUpperBound
()
const
319
{
320
return
myListenUpperBound
;
321
}
322
323
inline
int
simpleDDMFederate::listenLowerBound
()
const
324
{
325
return
myListenLowerBound
;
326
}
327
328
inline
bool
simpleDDMFederate::isPublisher
()
const
329
{
330
return
myIsPublisher
;
331
}
332
333
inline
int
simpleDDMFederate::sendUpperBound
()
const
334
{
335
return
mySendUpperBound
;
336
}
337
338
inline
int
simpleDDMFederate::sendLowerBound
()
const
339
{
340
return
mySendLowerBound
;
341
}
342
343
inline
int
simpleDDMFederate::sizeToInc
()
const
344
{
345
return
mySizeToInc
;
346
}
347
348
inline
int
simpleDDMFederate::sendRangeSize
()
const
349
{
350
return
(
int
)
mySendRangeSize
;
351
}
352
353
inline
bool
simpleDDMFederate::enableScopeAdvisories
()
const
354
{
355
return
myEnableScopeAdvisories
;
356
}
357
358
inline
int
simpleDDMFederate::zone
()
const
359
{
360
return
myUTCZone
;
361
}
362
363
#endif
Document ID: Generated on Fri Sep 27 00:57:56 EDT 2019 from SVN revision 201708
Copyright © 2005-2018 VT MÄK Inc. All Rights Reserved (
www.mak.com
)