MAK RTIspy API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
simpleDDMSimple13dlc.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2009 MaK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 /******************************************************************************
6 ** $RCSfile: simpleDDMSimple13dlc.h,v $ $Revision: 1.1 $ $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 "RTI13.h"
22 #include "simpleDDMFedAmb13dlc.h"
23 
24 // Map between strings and attribute handles
25 typedef std::map<std::string, AttributeHandle> DtAttrNameHandleMap;
26 // Map between strings and parameter handles
27 typedef std::map<std::string, ParameterHandle> DtParamNameHandleMap;
28 
29 using namespace rti13;
30 
32 {
33 public:
34 
36 // Default Constructor
39 
41 // Constructor
44 
46 // Destructor
49 
50 // RTI Wrappers
51 
53 // Initialize the RTI
55  void initializeRTI();
56 
58 // Create a federation execution
60  bool createFedEx();
61 
63 // Join a federation execution
65  bool joinFedEx();
66 
68 // Resign from the federation execution and destroy it
70  void resignAndDestroy();
71 
73 // Create the Region and initialize its bounds
75  bool createAndInitializeRegions();
76 
78 // Publish and subscribe the object class attributes.
79 // Register an object instance of the class.
81  bool publishSubscribeAndRegisterObject();
82 
84 // Publish and Subscribe to an interaction class
86  bool publishAndSubscribeInteraction();
87 
89 // Send the default update with Region. A less simple federate would have to
90 // specify which attributes need be updated. This on merely passes in the
91 // position which is sent with Region as the object update.
93  void sendUpdate(int currentPosition );
94 
96 // Send Interactions with Region. The following two interactions are meant to
97 // emulate a cuckoo clock with both an hourly chime, and a quarterly chime.
99 
101 // Send the hourly interaction with Region. This is an interaction that in this
102 // example occurs for each hour that is passed on the clock that is not
103 // {12,3,6,9}.
105  void sendInteraction_hourly();
106 
108 // Send the quarterly interaction with Region. This is an interaction that in
109 // this example occurs for each hour that is passed on the clock that is in the
110 // following set {12,3,6,9}
112  void sendInteraction_quarterly();
113 
115 // Perform the tick or evokeCallback method.
117  void tick(double atMost=0.0f);
118 
120 // Perform the tick or evokeCallback method.
122  void tick(double atLeast, double atMost);
123 
125 // changeBounds sets the subscription of publication bounds of this federate.
127  void changeBounds(int lower, int upper, int UTCZone) ;
128 
130 // Set the RTI's enable advisory switch
132  void setEnableScopeAdvisories(bool yesNo);
133 
134  // Simulation Methods
135 
137 // Set federate as publisher (true) or subscriber (false)
139  void setIsPublisher(bool yesNo);
140 
142 // Get the position (number of seconds)
144  int position();
145 
147 // Set the position (number of seconds)
149  void setPosition(int data);
150 
152 // Set the Fed File Name
154  void setFedFileName(const char* newFedName);
155 
157 // Set the Fed File Name
159 void setFedFileName(const wchar_t* newFedName);
160 
162 // Get the Fed File Name
164 char* getFedFileName() const;
165 
166 
167 protected:
168 
169  // Map between strings and attribute handles
170  DtAttrNameHandleMap myAttrNameHandleMap;
171 
172  // Map between strings and parameter handles
173  DtParamNameHandleMap myParamNameHandleMap;
174 
175  static const unsigned int myNumAttributes;
176  static const unsigned long myNumExtents;
177 
178  // Array of attributeHandles.
180 
182 
184 
185  // Data shared between federate and federate ambassador
186  DtTalkAmbData myAmbData;
187 
188 private:
189  // Federate and Federation info
190  std::string myFederationName;
191  std::string myFederationFile;
192  std::string myFederateType;
193 
194  // An interaction published at {1, 2, 4, 5, 7, 8, 10 , 11}
195  std::string myHourlyInteraction;
196 
197  // An interaction published at {3,6,9,12}
198  std::string myQuarterlyInteraction;
199 
200  // The interaction class name
201  std::string myInterClassName;
202 
203  // The object class name
204  std::string myClassName;
205 
206  // The attribute name
207  std::string myAttrName;
208 
209  // The number of dimensions
210  unsigned int myNumberOfDimensions;
211 
212  // The RTI Ambassador
214 
215  // The Federate Ambassador
216  MyFederateAmbassador* myFedAmb;
217 
218  // the Handle for the hourlyInteraction, (to be retrieved from RTI).
220 
221  // the Handle for the quarterlyInteraction, (to be retrieved from RTI).
223 
224 
225  // Construct a parameter handle value pair set with the
226  // values containing the parameter names
228 
229  // The name of the dimension is specified in your FED file.
230  std::string mySecondsDimensionName;
231 
232  // The time zone dimension name
233  std::string myUTCDimensionName;
234 
235  // The routing space name
236  std::string mySpaceName;
237 
238  // The object class handle (to be retrieved from RTI).
240 
241  //The object instance handle ( to be retrieved from the rti).
243 
244  // The interaction class handle (to be retrieved from RTI).
246 
247  // The Seconds dimension handle (to be retrieved from the RTI).
249 
250  // The UTC dimension handle (to be retrieved from the RTI).
252 
253  // The listen region
255 
256  // The publish region
258 
259 
260 };
261 
262 inline void simpleDDMFederate13::setIsPublisher(bool yesNo)
263 {
264  myIsPublisher = yesNo;
265  myAmbData.isPublisher = yesNo;
266 }
267 
268 inline void simpleDDMFederate13::setEnableScopeAdvisories(bool yesNo)
269 {
270  myEnableScopeAdvisories = yesNo;
271  myAmbData.enableScopeAdvisories = yesNo;
272 }
273 
275 {
276  if (!isPublisher())
277  myCurrentposition = myAmbData.position;
278  return myCurrentposition;
279 }
280 
281 inline void simpleDDMFederate13::setFedFileName(const char* newFedName)
282 {
283  myFederationFile = std::string(newFedName);
284 }
285 
286 inline void simpleDDMFederate13::setFedFileName(const wchar_t* newFedName)
287 {
288  myFederationFile = DtToString(std::wstring(newFedName));
289 }
290 
291 inline char* simpleDDMFederate13::getFedFileName() const
292 {
293  return strdup(myFederationFile.c_str());
294 }
295 
296 
297 
298 #endif
virtual Boolean tick(TickTime minimum, TickTime maximum)
Handle ObjectHandle
Definition: RTItypes13.h:116
int position()
Definition: simpleDDMSimple13.h:273
Definition: RTItypes13.h:236
InteractionClassHandle myInterClassHandle
Definition: simpleDDMSimple13dlc.h:245
std::map< std::string, RTI::AttributeHandle > DtAttrNameHandleMap
Definition: simpleDDMSimple13.h:25
ParameterHandleValuePairSet * myParamValues
Definition: simpleDDMSimple13dlc.h:227
Basic federate ambassador service callback implementation.
Definition: rtiSimpleFedAmb13.h:35
ParameterHandle myQuarterlyHandle
Definition: simpleDDMSimple13dlc.h:222
ULong InteractionClassHandle
Definition: RTItypes13.h:106
Handle ParameterHandle
Definition: RTItypes13.h:114
ObjectClassHandle myClassHandle
Definition: simpleDDMSimple13dlc.h:239
std::string DtToString(const std::wstring &in_val)
Definition: rtiSimpleStringUtil.h:22
Definition: RTItypes13.h:138
DimensionHandle mySecondsDimHandle
Definition: simpleDDMSimple13dlc.h:248
void setIsPublisher(bool yesNo)
Definition: simpleDDMSimple13.h:261
AttributeHandleValuePairSet * myAttrValues
Definition: simpleDDMSimple13dlc.h:183
ObjectHandle myObjectHandle
Definition: simpleDDMSimple13dlc.h:242
AttributeHandleSet * myAttrHandlesSet
Definition: simpleDDMSimple13dlc.h:181
AttributeHandle * myAttrHandlesArray
Definition: simpleDDMSimple13dlc.h:179
Handle DimensionHandle
Definition: RTItypes13.h:118
Region * myListenRegion
Definition: simpleDDMSimple13dlc.h:254
Definition: simpleDDMSimple13.h:30
RTIambassador * myRTIamb
Definition: simpleDDMSimple13dlc.h:213
Definition: simpleDDMFederate.h:25
void setFedFileName(const char *newFedName)
Definition: simpleDDMSimple13.h:280
Region * mySendRegion
Definition: simpleDDMSimple13dlc.h:257
Definition: rtiSimpleFedAmb13dlc.h:15
std::map< std::string, RTI::ParameterHandle > DtParamNameHandleMap
Definition: simpleDDMSimple13.h:27
ULong ObjectClassHandle
Definition: RTItypes13.h:104
void setEnableScopeAdvisories(bool yesNo)
Definition: simpleDDMSimple13.h:267
Definition: RTI13.h:87
Definition: RTItypes13.h:304
Definition: RTItypes13.h:393
Handle AttributeHandle
Definition: RTItypes13.h:112
ParameterHandle myHourlyHandle
Definition: simpleDDMSimple13dlc.h:219
char * getFedFileName() const
Definition: simpleDDMSimple13.h:290
DimensionHandle myUTCDimHandle
Definition: simpleDDMSimple13dlc.h:251

Document ID: Generated on Wed Jul 8 16:20:32 EDT 2026 from SVN revision 291616
Copyright © 2005-2025 MAK Technologies Inc. All Rights Reserved (www.mak.com)