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
simpleDDMSimple13.h
Go to the documentation of this file.
1
/******************************************************************************
2
** Copyright (c) 2006 MaK Technologies, Inc.
3
** All rights reserved.
4
******************************************************************************/
5
/******************************************************************************
6
** $RCSfile: simpleDDMSimple13.h,v $ $Revision: 1.2 $ $State: Exp $
7
******************************************************************************/
8
9
#ifndef REGIONEXAMPLE13_H_
10
#define REGIONEXAMPLE13_H_
11
12
// A wrapper around the RTI Ambassador calls that incorporates
13
// Data Distribution Management (DDM).
14
// The typical calls are supported such as create/destroy, join/resign,
15
// publish/subscribe, register/delete object, update object, and send interaction.
16
// The DDM calls to create and maintain regions are also supported and regions
17
// are used with the other services where appropriate.
18
19
#include "
simpleDDMFederate.h
"
20
#include <string.h>
21
#include "RTI.hh"
22
#include "
simpleDDMFedAmb13.h
"
23
24
// Map between strings and attribute handles
25
typedef
std::map<std::string, RTI::AttributeHandle>
DtAttrNameHandleMap
;
26
// Map between strings and parameter handles
27
typedef
std::map<std::string, RTI::ParameterHandle>
DtParamNameHandleMap
;
28
29
30
class
simpleDDMFederate13
:
public
simpleDDMFederate
31
{
32
public
:
33
35
// Default Constructor
37
simpleDDMFederate13
();
38
40
// Constructor
42
simpleDDMFederate13
(
simpleDDMFederate13
& data);
43
45
// Destructor
47
~simpleDDMFederate13
();
48
49
// RTI Wrappers
50
52
// Initialize the RTI
54
void
initializeRTI
();
55
57
// Create a federation execution
59
bool
createFedEx
();
60
62
// Join a federation execution
64
bool
joinFedEx
();
65
67
// Resign from the federation execution and destroy it
69
void
resignAndDestroy
();
70
72
// Create the Region and initialize its bounds
74
bool
createAndInitializeRegions
();
75
77
// Publish and subscribe the object class attributes.
78
// Register an object instance of the class.
80
bool
publishSubscribeAndRegisterObject
();
81
83
// Publish and Subscribe to an interaction class
85
bool
publishAndSubscribeInteraction
();
86
88
// Send the default update with Region. A less simple federate would have to
89
// specify which attributes need be updated. This on merely passes in the
90
// position which is sent with Region as the object update.
92
void
sendUpdate
(
int
currentPosition );
93
95
// Send Interactions with Region. The following two interactions are meant to
96
// emulate a cuckoo clock with both an hourly chime, and a quarterly chime.
98
100
// Send the hourly interaction with Region. This is an interaction that in this
101
// example occurs for each hour that is passed on the clock that is not
102
// {12,3,6,9}.
104
void
sendInteraction_hourly
();
105
107
// Send the quarterly interaction with Region. This is an interaction that in
108
// this example occurs for each hour that is passed on the clock that is in the
109
// following set {12,3,6,9}
111
void
sendInteraction_quarterly
();
112
114
// Perform the tick or evokeCallback method.
116
bool
tick
(
double
atMost=0.0f);
117
119
// Perform the tick or evokeCallback method.
121
bool
tick
(
double
atLeast,
double
atMost);
122
124
// changeBounds sets the subscription of publication bounds of this federate.
126
void
changeBounds
(
int
lower,
int
upper,
int
UTCZone) ;
127
129
// Set the RTI's enable advisory switch
131
void
setEnableScopeAdvisories
(
bool
yesNo);
132
133
// Simulation Methods
134
136
// Set federate as publisher (true) or subscriber (false)
138
void
setIsPublisher
(
bool
yesNo);
139
141
// Get the position (number of seconds)
143
int
position
();
144
146
// Set the position (number of seconds)
148
void
setPosition
(
int
data);
149
151
// Set the Fed File Name
153
void
setFedFileName
(
const
char
* newFedName);
154
156
// Set the Fed File Name
158
void
setFedFileName
(
const
wchar_t
* newFedName);
159
161
// Get the Fed File Name
163
char
*
getFedFileName
()
const
;
164
165
166
protected
:
167
168
// Map between strings and attribute handles
169
DtAttrNameHandleMap
myAttrNameHandleMap
;
170
171
// Map between strings and parameter handles
172
DtParamNameHandleMap
myParamNameHandleMap
;
173
174
static
const
unsigned
int
myNumAttributes
;
175
static
const
unsigned
long
myNumExtents
;
176
177
// Array of attributeHandles.
178
RTI::AttributeHandle
*
myAttrHandlesArray
;
179
180
RTI::AttributeHandleSet*
myAttrHandlesSet
;
181
182
RTI::AttributeHandleValuePairSet *
myAttrValues
;
183
184
// Data shared between federate and federate ambassador
185
DtTalkAmbData
myAmbData
;
186
187
private
:
188
// Federate and Federation info
189
std::string
myFederationName
;
190
std::string
myFederationFile
;
191
std::string
myFederateType
;
192
193
// An interaction published at {1, 2, 4, 5, 7, 8, 10 , 11}
194
std::string
myHourlyInteraction
;
195
196
// An interaction published at {3,6,9,12}
197
std::string
myQuarterlyInteraction
;
198
199
// The interaction class name
200
std::string
myInterClassName
;
201
202
// The object class name
203
std::string
myClassName
;
204
205
// The attribute name
206
std::string
myAttrName
;
207
208
// The number of dimensions
209
unsigned
int
myNumberOfDimensions
;
210
211
// The RTI Ambassador
212
RTI::RTIambassador
*
myRTIamb
;
213
214
// The Federate Ambassador
215
MyFederateAmbassador
*
myFedAmb
;
216
217
// the Handle for the hourlyInteraction, (to be retrieved from RTI).
218
RTI::ParameterHandle
myHourlyHandle
;
219
220
// the Handle for the quarterlyInteraction, (to be retrieved from RTI).
221
RTI::ParameterHandle
myQuarterlyHandle
;
222
223
224
// Construct a parameter handle value pair set with the
225
// values containing the parameter names
226
RTI::ParameterHandleValuePairSet*
myParamValues
;
227
228
// The name of the dimension is specified in your FED file.
229
std::string
mySecondsDimensionName
;
230
231
// The time zone dimension name
232
std::string
myUTCDimensionName
;
233
234
// The routing space name
235
std::string
mySpaceName
;
236
237
// The object class handle (to be retrieved from RTI).
238
RTI::ObjectClassHandle
myClassHandle
;
239
240
//The object instance handle ( to be retrieved from the rti).
241
RTI::ObjectHandle
myObjectHandle
;
242
243
// The interaction class handle (to be retrieved from RTI).
244
RTI::InteractionClassHandle
myInterClassHandle
;
245
246
// The Seconds dimension handle (to be retrieved from the RTI).
247
RTI::DimensionHandle
mySecondsDimHandle
;
248
249
// The UTC dimension handle (to be retrieved from the RTI).
250
RTI::DimensionHandle
myUTCDimHandle
;
251
252
// The listen region
253
RTI::Region*
myListenRegion
;
254
255
// The publish region
256
RTI::Region*
mySendRegion
;
257
258
259
};
260
261
inline
void
simpleDDMFederate13::setIsPublisher
(
bool
yesNo)
262
{
263
myIsPublisher
= yesNo;
264
myAmbData
.
isPublisher
= yesNo;
265
}
266
267
inline
void
simpleDDMFederate13::setEnableScopeAdvisories
(
bool
yesNo)
268
{
269
myEnableScopeAdvisories
= yesNo;
270
myAmbData
.
enableScopeAdvisories
= yesNo;
271
}
272
273
inline
int
simpleDDMFederate13::position
()
274
{
275
if
(!
isPublisher
())
276
myCurrentposition
=
myAmbData
.
position
;
277
return
myCurrentposition
;
278
}
279
280
inline
void
simpleDDMFederate13::setFedFileName
(
const
char
* newFedName)
281
{
282
myFederationFile
= std::string(newFedName);
283
}
284
285
inline
void
simpleDDMFederate13::setFedFileName
(
const
wchar_t
* newFedName)
286
{
287
myFederationFile
=
DtToString
(std::wstring(newFedName));
288
}
289
290
inline
char
*
simpleDDMFederate13::getFedFileName
()
const
291
{
292
return
strdup(
myFederationFile
.c_str());
293
}
294
295
296
297
#endif
Document ID: Generated on Mon Mar 21 09:41:37 EDT 2016 from SVN revision 163228
Copyright © 2005-2015 VT MÄK Inc. All Rights Reserved (
www.mak.com
)