MAK RTIspy API Documentation for HLA 1516
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
simpleDDMSimple1516_2025.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2025 MAK Technologies
3 ** All rights reserved.
4 ******************************************************************************/
5 
6 #pragma once
7 
8 // A wrapper around the RTI Ambassador calls that incorporates
9 // Data Distribution Management (DDM).
10 // The typical calls are supported such as create/destroy, join/resign,
11 // publish/subscribe, register/delete object, update object, and send interaction.
12 // The DDM calls to create and maintain regions are also supported and regions
13 // are used with the other services where appropriate.
14 #ifdef DtHLA1516_2025
15 #include <wchar.h>
16 #include "simpleDDMFederate.h"
17 #include <string.h>
18 
19 #include <RTI/RTI1516.h>
22 
23 // Map between strings and attribute handles
24 typedef std::map<std::wstring, rti1516_2025::AttributeHandle> DtAttrNameHandleMap;
25 // Map between strings and parameter handles
26 typedef std::map<std::wstring, rti1516_2025::ParameterHandle> DtParamNameHandleMap;
27 
28 
29 class simpleDDMFederate1516_2025 : public simpleDDMFederate
30 {
31 public:
32 
34  // Default Constructor
36  simpleDDMFederate1516_2025();
37 
39  // Constructor
41  simpleDDMFederate1516_2025(simpleDDMFederate1516_2025& data);
42 
44  // Destructor
46  virtual ~simpleDDMFederate1516_2025();
47 
48  // RTI Wrappers
49 
51  // Initialize the RTI
53  void initializeRTI();
54 
56  // Connect
58  void connect(rti1516_2025::RTIambassador & rtiAmb, MyFederateAmbassador & fedAmb);
59 
61  // Create a federation execution
63  bool createFedEx();
64 
66  // Join a federation execution
68  bool joinFedEx();
69 
71  // Resign from the federation execution and destroy it
73  void resignAndDestroy();
74 
76  // Create the Region and initialize its bounds
79 
81  // Publish and subscribe the object class attributes.
82  // Register an object instance of the class.
85 
87  // Publish and Subscribe to an interaction class
90 
92  // Send the default update with Region. A less simple federate would have to
93  // specify which attributes need be updated. This on merely passes in the
94  // position which is sent with Region as the object update.
96  void sendUpdate(int currentPosition);
97 
99  // Send Interactions with Region. The following two interactions are meant to
100  // emulate a cuckoo clock with both an hourly chime, and a quarterly chime.
102 
104  // Send the hourly interaction with Region. This is an interaction that in this
105  // example occurs for each hour that is passed on the clock that is not
106  // {12,3,6,9}.
108  void sendInteraction_hourly();
109 
111  // Send the quarterly interaction with Region. This is an interaction that in
112  // this example occurs for each hour that is passed on the clock that is in the
113  // following set {12,3,6,9}
116 
118  // Perform the tick or evokeCallback method.
120  bool tick(double atMost=0.0f);
121 
123  // Perform the tick or evokeCallback method.
125  bool tick(double atLeast, double atMost);
126 
128  // changeBounds sets the subscription of publication bounds of this federate.
130  void changeBounds(int lower, int upper, int UTCZone) ;
131 
133  // Set the RTI's enable advisory switch
135  void setEnableScopeAdvisories(bool yesNo);
136 
137  // Simulation Methods
138 
140  // Set federate as publisher (true) or subscriber (false)
142  void setIsPublisher(bool yesNo);
143 
145  // Get the position (number of seconds)
147  int position();
148 
150  // Set the position (number of seconds)
152  void setPosition(int data);
153 
154 
156  // Set the Fed File Name
158  void setFedFileName(const wchar_t* newFedName);
159 
161  // Set the Fed File Name with a std::string.
163  void setFedFileName(const char* newFedName);
164 
165 
167  // Get the Fed File Name
169  char* getFedFileName() const;
170 
171 
172 protected:
173 
175  // Map between strings and attribute handles
177  DtAttrNameHandleMap myAttrNameHandleMap;
178 
180  // Map between strings and parameter handles
182  DtParamNameHandleMap myParamNameHandleMap;
183 
185  // Construct an attribute handle value pair set with the
186  // values containing the attribute names
189 
191  // Data shared between federate and federate ambassador
193  DtTalkAmbData theAmbData;
194 
195 private:
196  // Federate and Federation info
197  std::wstring myFederationName;
198  std::wstring myFederationFile;
199  std::wstring myFederateType;
200 
201  // An interaction published at {1, 2, 4, 5, 7, 8, 10 , 11}
202  std::wstring myHourlyInteraction;
203 
204  // An interaction published at {3,6,9,12}
205  std::wstring myQuarterlyInteraction;
206 
207  // The interaction class name
208  std::wstring myInterClassName;
209 
210  // The object class name
211  std::wstring myClassName;
212 
213  // The attribute name
214  std::wstring myAttrName;
215 
216  // The RTI Ambassador
217  rti1516_2025::RTIambassador* myRTIamb;
218 
219  // The Federate Ambassador
220  MyFederateAmbassador* myFedAmb;
221 
222  // the Handle for the hourlyInteraction, (to be retrieved from rti1516).
223  rti1516_2025::ParameterHandle myHourlyHandle;
224 
225  // the Handle for the quarterlyInteraction, (to be retrieved from rti1516).
226  rti1516_2025::ParameterHandle myQuarterlyHandle;
227 
228  // The dimension handle Set.
229  rti1516_2025::DimensionHandleSet myDimHandleSet;
230 
231  // Construct a parameter handle value pair set with the
232  // values containing the parameter names
234 
235  // The name of the seconds dimension as specified in your FED file.
236  std::wstring mySecondsDimensionName;
237  // seconds dimension handle
238  rti1516_2025::DimensionHandle mySecondsDim;
239 
240  // The name of the UTC dimension as specified in your FED file.
241  std::wstring myUTCDimensionName;
242  // UTC dimension handle
243  rti1516_2025::DimensionHandle myUTCDim;
244 
245  // The object class handle (to be retrieved from rti1516).
246  rti1516_2025::ObjectClassHandle myClassHandle;
247 
248  //The object instance handle ( to be retrieved from the rti).
249  rti1516_2025::ObjectInstanceHandle myObjectInstanceHandle;
250 
251  // The interaction class handle (to be retrieved from rti1516).
252  rti1516_2025::InteractionClassHandle myInterClassHandle;
253 
255 
256  // Array of attributeHandles.
257  rti1516_2025::AttributeHandleSet myAttrHandles;
258 
259  // Region handle list
261 
262  // The listen region
263  rti1516_2025::RegionHandle myListenRegion;
264 
265  // The send region
266  rti1516_2025::RegionHandle mySendRegion;
267 };
268 
269 
270 inline void simpleDDMFederate1516_2025::setIsPublisher(bool yesNo)
271 {
272  myIsPublisher = yesNo;
273  theAmbData.isPublisher = yesNo;
274 }
275 
276 inline void simpleDDMFederate1516_2025::setEnableScopeAdvisories(bool yesNo)
277 {
278  myEnableScopeAdvisories = yesNo;
279  theAmbData.enableScopeAdvisories = yesNo;
280 }
281 
282 inline int simpleDDMFederate1516_2025::position()
283 {
284  if (!isPublisher())
285  myCurrentposition = theAmbData.position;
286  return myCurrentposition;
287 }
288 
289 inline void simpleDDMFederate1516_2025::setFedFileName(const wchar_t* newFedName)
290 {
291  myFederationFile = std::wstring(newFedName);
292 }
293 
294 inline void simpleDDMFederate1516_2025::setFedFileName(const char* newFedName)
295 {
296  myFederationFile = DtToWString(newFedName);
297 }
298 
299 inline char* simpleDDMFederate1516_2025::getFedFileName() const
300 {
301  return strdup(DtToString(myFederationFile).c_str());
302 }
303 
304 #endif
A convenience header provided for developers that would like to include everything all at once...
std::map< std::string, RTI::AttributeHandle > DtAttrNameHandleMap
Definition: simpleDDMSimple13.h:25
virtual bool publishAndSubscribeInteraction()=0
virtual void resignAndDestroy()=0
virtual void sendInteraction_hourly()=0
Basic federate ambassador service callback implementation.
Definition: rtiSimpleFedAmb13.h:35
virtual void changeBounds(int lower, int upper, int UTCZone)=0
virtual void setIsPublisher(bool yesNo)=0
std::set< RegionHandle > RegionHandleSet
Definition: Typedefs.h:31
std::string DtToString(const std::wstring &in_val)
Definition: rtiSimpleStringUtil.h:22
virtual void initializeRTI()=0
virtual void sendInteraction_quarterly()=0
virtual bool joinFedEx()=0
std::set< DimensionHandle > DimensionHandleSet
Definition: Typedefs.h:30
virtual bool createAndInitializeRegions()=0
virtual void sendUpdate(int currentPosition)=0
virtual char * getFedFileName() const =0
virtual void setFedFileName(const wchar_t *newFedName)=0
virtual bool publishSubscribeAndRegisterObject()=0
Definition: simpleDDMFederate.h:25
virtual bool createFedEx()=0
std::map< ParameterHandle, VariableLengthData > ParameterHandleValueMap
Definition: Typedefs.h:41
std::map< AttributeHandle, VariableLengthData > AttributeHandleValueMap
Definition: Typedefs.h:36
Definition: rtiSimpleFedAmb13dlc.h:15
std::set< AttributeHandle > AttributeHandleSet
Definition: Typedefs.h:27
virtual void setEnableScopeAdvisories(bool yesNo)=0
std::vector< AttributeHandleSetRegionHandleSetPair > AttributeHandleSetRegionHandleSetPairVector
Definition: Typedefs.h:49
virtual void setPosition(int data)=0
std::map< std::string, RTI::ParameterHandle > DtParamNameHandleMap
Definition: simpleDDMSimple13.h:27
virtual int position()=0
virtual bool tick(double atMost=0.0f)=0
std::wstring DtToWString(const char *in_val)
Definition: rtiSimpleStringUtil.h:13
This file contains the rti1516_2025::RTIambassadorFactory which can be used to make an implementation...

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)