MAK RTIspy API Documentation for HLA 1.3
Home
Modules
Namespaces
Classes
Files
Examples
Libraries
File List
File Members
examples
simpleDDM
simpleDDMSimple1516.h
Go to the documentation of this file.
1
/******************************************************************************
2
** Copyright (c) 2006 MaK Technologies, Inc.
3
** All rights reserved.
4
******************************************************************************/
5
/******************************************************************************
6
** $RCSfile: simpleDDMSimple1516.h,v $ $Revision: 1.2 $ $State: Exp $
7
******************************************************************************/
8
9
#ifndef REGIONEXAMPLE1516_H_
10
#define REGIONEXAMPLE1516_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 <wchar.h>
20
#include "
simpleDDMFederate.h
"
21
#include <string.h>
22
23
#include <RTI/RTI1516.h>
24
#include <RTI/RTIambassadorFactory.h>
25
#include "
simpleDDMFedAmb1516.h
"
26
27
// Map between strings and attribute handles
28
typedef
std::map<std::wstring, rti1516::AttributeHandle>
DtAttrNameHandleMap
;
29
// Map between strings and parameter handles
30
typedef
std::map<std::wstring, rti1516::ParameterHandle>
DtParamNameHandleMap
;
31
32
33
class
simpleDDMFederate1516
:
public
simpleDDMFederate
34
{
35
public
:
36
38
// Default Constructor
40
simpleDDMFederate1516
();
41
43
// Constructor
45
simpleDDMFederate1516
(
simpleDDMFederate1516
& data);
46
48
// Destructor
50
virtual
~simpleDDMFederate1516
();
51
52
// RTI Wrappers
53
55
// Initialize the RTI
57
void
initializeRTI
();
58
60
// Create a federation execution
62
bool
createFedEx
();
63
65
// Join a federation execution
67
bool
joinFedEx
();
68
70
// Resign from the federation execution and destroy it
72
void
resignAndDestroy
();
73
75
// Create the Region and initialize its bounds
77
bool
createAndInitializeRegions
();
78
80
// Publish and subscribe the object class attributes.
81
// Register an object instance of the class.
83
bool
publishSubscribeAndRegisterObject
();
84
86
// Publish and Subscribe to an interaction class
88
bool
publishAndSubscribeInteraction
();
89
91
// Send the default update with Region. A less simple federate would have to
92
// specify which attributes need be updated. This on merely passes in the
93
// position which is sent with Region as the object update.
95
void
sendUpdate
(
int
currentPosition);
96
98
// Send Interactions with Region. The following two interactions are meant to
99
// emulate a cuckoo clock with both an hourly chime, and a quarterly chime.
101
103
// Send the hourly interaction with Region. This is an interaction that in this
104
// example occurs for each hour that is passed on the clock that is not
105
// {12,3,6,9}.
107
void
sendInteraction_hourly
();
108
110
// Send the quarterly interaction with Region. This is an interaction that in
111
// this example occurs for each hour that is passed on the clock that is in the
112
// following set {12,3,6,9}
114
void
sendInteraction_quarterly
();
115
117
// Perform the tick or evokeCallback method.
119
void
tick
(
double
atMost=0.0f);
120
122
// Perform the tick or evokeCallback method.
124
void
tick
(
double
atLeast,
double
atMost);
125
127
// changeBounds sets the subscription of publication bounds of this federate.
129
void
changeBounds
(
int
lower,
int
upper,
int
UTCZone) ;
130
132
// Set the RTI's enable advisory switch
134
void
setEnableScopeAdvisories
(
bool
yesNo);
135
136
// Simulation Methods
137
139
// Set federate as publisher (true) or subscriber (false)
141
void
setIsPublisher
(
bool
yesNo);
142
144
// Get the position (number of seconds)
146
int
position
();
147
149
// Set the position (number of seconds)
151
void
setPosition
(
int
data);
152
153
155
// Set the Fed File Name
157
void
setFedFileName
(
const
wchar_t
* newFedName);
158
160
// Set the Fed File Name with a std::string.
162
void
setFedFileName
(
const
char
* newFedName);
163
164
166
// Get the Fed File Name
168
char
*
getFedFileName
()
const
;
169
170
171
protected
:
172
174
// Map between strings and attribute handles
176
DtAttrNameHandleMap
myAttrNameHandleMap
;
177
179
// Map between strings and parameter handles
181
DtParamNameHandleMap
myParamNameHandleMap
;
182
184
// Construct an attribute handle value pair set with the
185
// values containing the attribute names
187
rti1516::AttributeHandleValueMap
myAttrValues
;
188
190
// Data shared between federate and federate ambassador
192
DtTalkAmbData
theAmbData
;
193
194
private
:
195
// Federate and Federation info
196
std::wstring
myFederationName
;
197
std::wstring
myFederationFile
;
198
std::wstring
myFederateType
;
199
200
// An interaction published at {1, 2, 4, 5, 7, 8, 10 , 11}
201
std::wstring
myHourlyInteraction
;
202
203
// An interaction published at {3,6,9,12}
204
std::wstring
myQuarterlyInteraction
;
205
206
// The interaction class name
207
std::wstring
myInterClassName
;
208
209
// The object class name
210
std::wstring
myClassName
;
211
212
// The attribute name
213
std::wstring
myAttrName
;
214
215
// The RTI Ambassador
216
rti1516::RTIambassador
*
myRTIamb
;
217
218
// The Federate Ambassador
219
MyFederateAmbassador
*
myFedAmb
;
220
221
// the Handle for the hourlyInteraction, (to be retrieved from rti1516).
222
rti1516::ParameterHandle
myHourlyHandle
;
223
224
// the Handle for the quarterlyInteraction, (to be retrieved from rti1516).
225
rti1516::ParameterHandle
myQuarterlyHandle
;
226
227
// The dimension handle Set.
228
rti1516::DimensionHandleSet
myDimHandleSet
;
229
230
// Construct a parameter handle value pair set with the
231
// values containing the parameter names
232
rti1516::ParameterHandleValueMap
myParamValues
;
233
234
// The name of the seconds dimension as specified in your FED file.
235
std::wstring
mySecondsDimensionName
;
236
// seconds dimension handle
237
rti1516::DimensionHandle
mySecondsDim
;
238
239
// The name of the UTC dimension as specified in your FED file.
240
std::wstring
myUTCDimensionName
;
241
// UTC dimension handle
242
rti1516::DimensionHandle
myUTCDim
;
243
244
// The object class handle (to be retrieved from rti1516).
245
rti1516::ObjectClassHandle
myClassHandle
;
246
247
//The object instance handle ( to be retrieved from the rti).
248
rti1516::ObjectInstanceHandle
myObjectInstanceHandle
;
249
250
// The interaction class handle (to be retrieved from rti1516).
251
rti1516::InteractionClassHandle
myInterClassHandle
;
252
253
rti1516::AttributeHandleSetRegionHandleSetPairVector
myRegionHandleSet
;
254
255
// Array of attributeHandles.
256
rti1516::AttributeHandleSet
myAttrHandles
;
257
258
// Region handle list
259
rti1516::RegionHandleSet
myRegions
;
260
261
// The listen region
262
rti1516::RegionHandle
myListenRegion
;
263
264
// The send region
265
rti1516::RegionHandle
mySendRegion
;
266
};
267
268
269
inline
void
simpleDDMFederate1516::setIsPublisher
(
bool
yesNo)
270
{
271
myIsPublisher
= yesNo;
272
theAmbData
.
isPublisher
= yesNo;
273
}
274
275
inline
void
simpleDDMFederate1516::setEnableScopeAdvisories
(
bool
yesNo)
276
{
277
myEnableScopeAdvisories
= yesNo;
278
theAmbData
.
enableScopeAdvisories
= yesNo;
279
}
280
281
inline
int
simpleDDMFederate1516::position
()
282
{
283
if
(!
isPublisher
())
284
myCurrentposition
=
theAmbData
.
position
;
285
return
myCurrentposition
;
286
}
287
288
inline
void
simpleDDMFederate1516::setFedFileName
(
const
wchar_t
* newFedName)
289
{
290
myFederationFile
= std::wstring(newFedName);
291
}
292
293
inline
void
simpleDDMFederate1516::setFedFileName
(
const
char
* newFedName)
294
{
295
myFederationFile
=
DtToWString
(newFedName);
296
}
297
298
inline
char
*
simpleDDMFederate1516::getFedFileName
()
const
299
{
300
return
strdup(
DtToString
(
myFederationFile
).c_str());
301
}
302
303
#endif
Document ID: Generated on Tue May 7 16:26:47 EDT 2013 from SVN revision 126903
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (
www.mak.com
)