MAK RTIspy API Documentation for HLA 1.3
simpleDDMSimple1516e.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 REGIONEXAMPLE1516E_H_
10 #define REGIONEXAMPLE1515E_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 #ifdef DtHLA1516E
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 "simpleDDMFedAmb1516e.h"
26 
27 // Map between strings and attribute handles
28 typedef std::map<std::wstring, rti1516e::AttributeHandle> DtAttrNameHandleMap;
29 // Map between strings and parameter handles
30 typedef std::map<std::wstring, rti1516e::ParameterHandle> DtParamNameHandleMap;
31 
32 
33 class simpleDDMFederate1516e : public simpleDDMFederate
34 {
35 public:
36 
38  // Default Constructor
40  simpleDDMFederate1516e();
41 
43  // Constructor
45  simpleDDMFederate1516e(simpleDDMFederate1516e& data);
46 
48  // Destructor
50  virtual ~simpleDDMFederate1516e();
51 
52  // RTI Wrappers
53 
55  // Initialize the RTI
57  void initializeRTI();
58 
60  // Connect
62  void connect(RTIambassador & rtiAmb, MyFederateAmbassador & fedAmb);
63 
65  // Create a federation execution
67  bool createFedEx();
68 
70  // Join a federation execution
72  bool joinFedEx();
73 
75  // Resign from the federation execution and destroy it
77  void resignAndDestroy();
78 
80  // Create the Region and initialize its bounds
83 
85  // Publish and subscribe the object class attributes.
86  // Register an object instance of the class.
89 
91  // Publish and Subscribe to an interaction class
94 
96  // Send the default update with Region. A less simple federate would have to
97  // specify which attributes need be updated. This on merely passes in the
98  // position which is sent with Region as the object update.
100  void sendUpdate(int currentPosition);
101 
103  // Send Interactions with Region. The following two interactions are meant to
104  // emulate a cuckoo clock with both an hourly chime, and a quarterly chime.
106 
108  // Send the hourly interaction with Region. This is an interaction that in this
109  // example occurs for each hour that is passed on the clock that is not
110  // {12,3,6,9}.
112  void sendInteraction_hourly();
113 
115  // Send the quarterly interaction with Region. This is an interaction that in
116  // this example occurs for each hour that is passed on the clock that is in the
117  // following set {12,3,6,9}
120 
122  // Perform the tick or evokeCallback method.
124  void tick(double atMost=0.0f);
125 
127  // Perform the tick or evokeCallback method.
129  void tick(double atLeast, double atMost);
130 
132  // changeBounds sets the subscription of publication bounds of this federate.
134  void changeBounds(int lower, int upper, int UTCZone) ;
135 
137  // Set the RTI's enable advisory switch
139  void setEnableScopeAdvisories(bool yesNo);
140 
141  // Simulation Methods
142 
144  // Set federate as publisher (true) or subscriber (false)
146  void setIsPublisher(bool yesNo);
147 
149  // Get the position (number of seconds)
151  int position();
152 
154  // Set the position (number of seconds)
156  void setPosition(int data);
157 
158 
160  // Set the Fed File Name
162  void setFedFileName(const wchar_t* newFedName);
163 
165  // Set the Fed File Name with a std::string.
167  void setFedFileName(const char* newFedName);
168 
169 
171  // Get the Fed File Name
173  char* getFedFileName() const;
174 
175 
176 protected:
177 
179  // Map between strings and attribute handles
181  DtAttrNameHandleMap myAttrNameHandleMap;
182 
184  // Map between strings and parameter handles
186  DtParamNameHandleMap myParamNameHandleMap;
187 
189  // Construct an attribute handle value pair set with the
190  // values containing the attribute names
193 
195  // Data shared between federate and federate ambassador
198 
199 private:
200  // Federate and Federation info
201  std::wstring myFederationName;
202  std::wstring myFederationFile;
203  std::wstring myFederateType;
204 
205  // An interaction published at {1, 2, 4, 5, 7, 8, 10 , 11}
206  std::wstring myHourlyInteraction;
207 
208  // An interaction published at {3,6,9,12}
209  std::wstring myQuarterlyInteraction;
210 
211  // The interaction class name
212  std::wstring myInterClassName;
213 
214  // The object class name
215  std::wstring myClassName;
216 
217  // The attribute name
218  std::wstring myAttrName;
219 
220  // The RTI Ambassador
221  rti1516e::RTIambassador* myRTIamb;
222 
223  // The Federate Ambassador
224  MyFederateAmbassador* myFedAmb;
225 
226  // the Handle for the hourlyInteraction, (to be retrieved from rti1516).
227  rti1516e::ParameterHandle myHourlyHandle;
228 
229  // the Handle for the quarterlyInteraction, (to be retrieved from rti1516).
230  rti1516e::ParameterHandle myQuarterlyHandle;
231 
232  // The dimension handle Set.
233  rti1516e::DimensionHandleSet myDimHandleSet;
234 
235  // Construct a parameter handle value pair set with the
236  // values containing the parameter names
237  rti1516e::ParameterHandleValueMap myParamValues;
238 
239  // The name of the seconds dimension as specified in your FED file.
240  std::wstring mySecondsDimensionName;
241  // seconds dimension handle
242  rti1516e::DimensionHandle mySecondsDim;
243 
244  // The name of the UTC dimension as specified in your FED file.
245  std::wstring myUTCDimensionName;
246  // UTC dimension handle
247  rti1516e::DimensionHandle myUTCDim;
248 
249  // The object class handle (to be retrieved from rti1516).
250  rti1516e::ObjectClassHandle myClassHandle;
251 
252  //The object instance handle ( to be retrieved from the rti).
253  rti1516e::ObjectInstanceHandle myObjectInstanceHandle;
254 
255  // The interaction class handle (to be retrieved from rti1516).
256  rti1516e::InteractionClassHandle myInterClassHandle;
257 
259 
260  // Array of attributeHandles.
261  rti1516e::AttributeHandleSet myAttrHandles;
262 
263  // Region handle list
264  rti1516e::RegionHandleSet myRegions;
265 
266  // The listen region
267  rti1516e::RegionHandle myListenRegion;
268 
269  // The send region
270  rti1516e::RegionHandle mySendRegion;
271 };
272 
273 
274 inline void simpleDDMFederate1516e::setIsPublisher(bool yesNo)
275 {
276  myIsPublisher = yesNo;
277  theAmbData.isPublisher = yesNo;
278 }
279 
281 {
282  myEnableScopeAdvisories = yesNo;
284 }
285 
287 {
288  if (!isPublisher())
289  myCurrentposition = theAmbData.position;
290  return myCurrentposition;
291 }
292 
293 inline void simpleDDMFederate1516e::setFedFileName(const wchar_t* newFedName)
294 {
295  myFederationFile = std::wstring(newFedName);
296 }
297 
298 inline void simpleDDMFederate1516e::setFedFileName(const char* newFedName)
299 {
300  myFederationFile = DtToWString(newFedName);
301 }
302 
303 inline char* simpleDDMFederate1516e::getFedFileName() const
304 {
305  return strdup(DtToString(myFederationFile).c_str());
306 }
307 
308 #endif
309 #endif
310 
311 

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)