MAK RTIspy API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
34 {
35 public:
36 
38 // Default Constructor
41 
43 // Constructor
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
78 
80 // Publish and subscribe the object class attributes.
81 // Register an object instance of the class.
84 
86 // Publish and Subscribe to an interaction class
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}
115 
117 // Perform the tick or evokeCallback method.
119  bool tick(double atMost=0.0f);
120 
122 // Perform the tick or evokeCallback method.
124  bool 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
177 
179 // Map between strings and parameter handles
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
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}
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
220 
221  // the Handle for the hourlyInteraction, (to be retrieved from rti1516).
223 
224  // the Handle for the quarterlyInteraction, (to be retrieved from rti1516).
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.
236  // seconds dimension handle
238 
239  // The name of the UTC dimension as specified in your FED file.
240  std::wstring myUTCDimensionName;
241  // UTC dimension handle
243 
244  // The object class handle (to be retrieved from rti1516).
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).
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 
270 {
271  myIsPublisher = yesNo;
272  theAmbData.isPublisher = yesNo;
273 }
274 
276 {
277  myEnableScopeAdvisories = yesNo;
279 }
280 
282 {
283  if (!isPublisher())
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 
299 {
300  return strdup(DtToString(myFederationFile).c_str());
301 }
302 
303 #endif
bool enableScopeAdvisories
Definition: simpleDDMFedAmb13.h:35
DtParamNameHandleMap myParamNameHandleMap
Definition: simpleDDMSimple1516.h:181
std::wstring myHourlyInteraction
Definition: simpleDDMSimple1516.h:201
std::map< std::string, RTI::AttributeHandle > DtAttrNameHandleMap
Definition: simpleDDMSimple13.h:25
DtAttrNameHandleMap myAttrNameHandleMap
Definition: simpleDDMSimple1516.h:176
void setIsPublisher(bool yesNo)
Definition: simpleDDMSimple1516.h:269
rti1516::DimensionHandle myUTCDim
Definition: simpleDDMSimple1516.h:242
rti1516::AttributeHandleSetRegionHandleSetPairVector myRegionHandleSet
Definition: simpleDDMSimple1516.h:253
rti1516::InteractionClassHandle myInterClassHandle
Definition: simpleDDMSimple1516.h:251
rti1516::ParameterHandle myHourlyHandle
Definition: simpleDDMSimple1516.h:222
Basic federate ambassador service callback implementation.
Definition: rtiSimpleFedAmb13.h:35
std::wstring myFederationName
Definition: simpleDDMSimple1516.h:196
DtTalkAmbData theAmbData
Definition: simpleDDMSimple1516.h:192
bool tick(double atMost=0.0f)
bool publishSubscribeAndRegisterObject()
void sendInteraction_quarterly()
rti1516::AttributeHandleValueMap myAttrValues
Definition: simpleDDMSimple1516.h:187
std::wstring myFederateType
Definition: simpleDDMSimple1516.h:198
Definition: simpleDDMSimple1516.h:33
ULong InteractionClassHandle
Definition: RTItypes13.h:106
Handle ParameterHandle
Definition: RTItypes13.h:114
std::wstring myAttrName
Definition: simpleDDMSimple1516.h:213
rti1516::ParameterHandle myQuarterlyHandle
Definition: simpleDDMSimple1516.h:225
int position
Definition: simpleDDMFedAmb13.h:30
std::wstring myFederationFile
Definition: simpleDDMSimple1516.h:197
rti1516::DimensionHandleSet myDimHandleSet
Definition: simpleDDMSimple1516.h:228
std::string DtToString(const std::wstring &in_val)
Definition: rtiSimpleStringUtil.h:22
rti1516::ObjectInstanceHandle myObjectInstanceHandle
Definition: simpleDDMSimple1516.h:248
std::wstring mySecondsDimensionName
Definition: simpleDDMSimple1516.h:235
int position()
Definition: simpleDDMSimple1516.h:281
rti1516::RegionHandle myListenRegion
Definition: simpleDDMSimple1516.h:262
rti1516::ObjectClassHandle myClassHandle
Definition: simpleDDMSimple1516.h:245
rti1516::RegionHandle mySendRegion
Definition: simpleDDMSimple1516.h:265
Handle DimensionHandle
Definition: RTItypes13.h:118
bool createAndInitializeRegions()
rti1516::RegionHandleSet myRegions
Definition: simpleDDMSimple1516.h:259
Definition: simpleDDMFederate.h:25
rti1516::DimensionHandle mySecondsDim
Definition: simpleDDMSimple1516.h:237
rti1516::ParameterHandleValueMap myParamValues
Definition: simpleDDMSimple1516.h:232
void setFedFileName(const wchar_t *newFedName)
Definition: simpleDDMSimple1516.h:288
std::wstring myClassName
Definition: simpleDDMSimple1516.h:210
Definition: rtiSimpleFedAmb13dlc.h:15
void setEnableScopeAdvisories(bool yesNo)
Definition: simpleDDMSimple1516.h:275
std::wstring myUTCDimensionName
Definition: simpleDDMSimple1516.h:240
void changeBounds(int lower, int upper, int UTCZone)
bool isPublisher
Definition: simpleDDMFedAmb13.h:36
void sendUpdate(int currentPosition)
void setPosition(int data)
std::map< std::string, RTI::ParameterHandle > DtParamNameHandleMap
Definition: simpleDDMSimple13.h:27
virtual ~simpleDDMFederate1516()
std::wstring myQuarterlyInteraction
Definition: simpleDDMSimple1516.h:204
ULong ObjectClassHandle
Definition: RTItypes13.h:104
bool isPublisher() const
Definition: simpleDDMFederate.h:328
MyFederateAmbassador * myFedAmb
Definition: simpleDDMSimple1516.h:219
rti1516::AttributeHandleSet myAttrHandles
Definition: simpleDDMSimple1516.h:256
bool publishAndSubscribeInteraction()
std::wstring DtToWString(const char *in_val)
Definition: rtiSimpleStringUtil.h:13
char * getFedFileName() const
Definition: simpleDDMSimple1516.h:298
std::wstring myInterClassName
Definition: simpleDDMSimple1516.h:207
int myCurrentposition
Definition: simpleDDMFederate.h:267
rti1516::RTIambassador * myRTIamb
Definition: simpleDDMSimple1516.h:216
bool myIsPublisher
Definition: simpleDDMFederate.h:251
bool myEnableScopeAdvisories
Definition: simpleDDMFederate.h:281

Document ID: Generated on Sun Jul 20 16:15:30 EDT 2025 from SVN revision 277985
Copyright © 2005-2025 MAK Technologies Inc. All Rights Reserved (www.mak.com)