MAK RTIspy API Documentation for HLA 1516
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  void tick(double atMost=0.0f);
117 
119 // Perform the tick or evokeCallback method.
121  void 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 
181 
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
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
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
254 
255  // The publish region
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

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)