MAK RTIspy API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
31 {
32 public:
33 
35 // Default Constructor
38 
40 // Constructor
43 
45 // Destructor
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
75 
77 // Publish and subscribe the object class attributes.
78 // Register an object instance of the class.
81 
83 // Publish and Subscribe to an interaction class
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}
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
170 
171  // Map between strings and parameter handles
173 
174  static const unsigned int myNumAttributes;
175  static const unsigned long myNumExtents;
176 
177  // Array of attributeHandles.
179 
180  RTI::AttributeHandleSet* myAttrHandlesSet;
181 
182  RTI::AttributeHandleValuePairSet *myAttrValues;
183 
184  // Data shared between federate and federate ambassador
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}
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
216 
217  // the Handle for the hourlyInteraction, (to be retrieved from RTI).
219 
220  // the Handle for the quarterlyInteraction, (to be retrieved from RTI).
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.
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).
239 
240  //The object instance handle ( to be retrieved from the rti).
242 
243  // The interaction class handle (to be retrieved from RTI).
245 
246  // The Seconds dimension handle (to be retrieved from the RTI).
248 
249  // The UTC dimension handle (to be retrieved from the RTI).
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 
268 {
269  myEnableScopeAdvisories = yesNo;
271 }
272 
274 {
275  if (!isPublisher())
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 
291 {
292  return strdup(myFederationFile.c_str());
293 }
294 
295 
296 
297 #endif
Handle ObjectHandle
Definition: RTItypes13.h:116
std::string myFederationName
Definition: simpleDDMSimple13.h:189
bool enableScopeAdvisories
Definition: simpleDDMFedAmb13.h:35
static const unsigned int myNumAttributes
Definition: simpleDDMSimple13.h:174
int position()
Definition: simpleDDMSimple13.h:273
std::map< std::string, RTI::AttributeHandle > DtAttrNameHandleMap
Definition: simpleDDMSimple13.h:25
void sendUpdate(int currentPosition)
std::string myInterClassName
Definition: simpleDDMSimple13.h:200
Basic federate ambassador service callback implementation.
Definition: rtiSimpleFedAmb13.h:35
std::string myClassName
Definition: simpleDDMSimple13.h:203
static const unsigned long myNumExtents
Definition: simpleDDMSimple13.h:175
void sendInteraction_hourly()
ULong InteractionClassHandle
Definition: RTItypes13.h:106
Handle ParameterHandle
Definition: RTItypes13.h:114
int position
Definition: simpleDDMFedAmb13.h:30
MyFederateAmbassador * myFedAmb
Definition: simpleDDMSimple13.h:215
RTI::InteractionClassHandle myInterClassHandle
Definition: simpleDDMSimple13.h:244
std::string DtToString(const std::wstring &in_val)
Definition: rtiSimpleStringUtil.h:22
void setPosition(int data)
void setIsPublisher(bool yesNo)
Definition: simpleDDMSimple13.h:261
RTI::AttributeHandle * myAttrHandlesArray
Definition: simpleDDMSimple13.h:178
RTI::AttributeHandleValuePairSet * myAttrValues
Definition: simpleDDMSimple13.h:182
Handle DimensionHandle
Definition: RTItypes13.h:118
std::string myQuarterlyInteraction
Definition: simpleDDMSimple13.h:197
Definition: simpleDDMSimple13.h:30
RTI::ParameterHandleValuePairSet * myParamValues
Definition: simpleDDMSimple13.h:226
Definition: simpleDDMFederate.h:25
RTI::ObjectHandle myObjectHandle
Definition: simpleDDMSimple13.h:241
RTI::Region * myListenRegion
Definition: simpleDDMSimple13.h:253
std::string mySecondsDimensionName
Definition: simpleDDMSimple13.h:229
void setFedFileName(const char *newFedName)
Definition: simpleDDMSimple13.h:280
RTI::Region * mySendRegion
Definition: simpleDDMSimple13.h:256
RTI::AttributeHandleSet * myAttrHandlesSet
Definition: simpleDDMSimple13.h:180
bool tick(double atMost=0.0f)
void sendInteraction_quarterly()
RTI::ObjectClassHandle myClassHandle
Definition: simpleDDMSimple13.h:238
bool publishAndSubscribeInteraction()
Definition: rtiSimpleFedAmb13dlc.h:15
RTI::ParameterHandle myHourlyHandle
Definition: simpleDDMSimple13.h:218
RTI::DimensionHandle mySecondsDimHandle
Definition: simpleDDMSimple13.h:247
std::string myFederateType
Definition: simpleDDMSimple13.h:191
unsigned int myNumberOfDimensions
Definition: simpleDDMSimple13.h:209
bool isPublisher
Definition: simpleDDMFedAmb13.h:36
DtTalkAmbData myAmbData
Definition: simpleDDMSimple13.h:185
std::string myHourlyInteraction
Definition: simpleDDMSimple13.h:194
RTI::RTIambassador * myRTIamb
Definition: simpleDDMSimple13.h:212
std::string myFederationFile
Definition: simpleDDMSimple13.h:190
bool createAndInitializeRegions()
std::string myAttrName
Definition: simpleDDMSimple13.h:206
void changeBounds(int lower, int upper, int UTCZone)
std::map< std::string, RTI::ParameterHandle > DtParamNameHandleMap
Definition: simpleDDMSimple13.h:27
ULong ObjectClassHandle
Definition: RTItypes13.h:104
bool isPublisher() const
Definition: simpleDDMFederate.h:328
void setEnableScopeAdvisories(bool yesNo)
Definition: simpleDDMSimple13.h:267
DtAttrNameHandleMap myAttrNameHandleMap
Definition: simpleDDMSimple13.h:169
bool publishSubscribeAndRegisterObject()
DtParamNameHandleMap myParamNameHandleMap
Definition: simpleDDMSimple13.h:172
std::string mySpaceName
Definition: simpleDDMSimple13.h:235
std::string myUTCDimensionName
Definition: simpleDDMSimple13.h:232
Handle AttributeHandle
Definition: RTItypes13.h:112
RTI::ParameterHandle myQuarterlyHandle
Definition: simpleDDMSimple13.h:221
int myCurrentposition
Definition: simpleDDMFederate.h:267
char * getFedFileName() const
Definition: simpleDDMSimple13.h:290
bool myIsPublisher
Definition: simpleDDMFederate.h:251
RTI::DimensionHandle myUTCDimHandle
Definition: simpleDDMSimple13.h:250
bool myEnableScopeAdvisories
Definition: simpleDDMFederate.h:281

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)