MAK RTIspy API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
simpleDDMFederate.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2006 MaK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 /******************************************************************************
6 ** $RCSfile: simpleDDMFederate.h,v $ $Revision: 1.17 $ $State: Exp $
7 ******************************************************************************/
8 
9 #ifndef REGIONEXAMPLE_H_
10 #define REGIONEXAMPLE_H_
11 
12 // Base class for wrappers around the RTI Ambassador calls.
13 
14 #include <sstream>
15 #include <string>
16 #include <iostream>
17 #include <iomanip>
18 #include <vector>
19 
20 
21 #include "simpleDDMStringUtil.h"
22 
23 
24 
26 {
27 public:
29 // Default Constructor
32 
34 // Constructor
37 
39 // Destructor
41  virtual ~simpleDDMFederate();
42 
43 // RTI Wrappers
44 
46 // Initialize the RTI
48  virtual void initializeRTI() = 0;
49 
51 // Create a federation execution
53  virtual bool createFedEx() = 0;
54 
56 // Join a federation execution
58  virtual bool joinFedEx() = 0;
59 
61 // Resign from the federation execution and destroy it
63  virtual void resignAndDestroy() = 0;
64 
66 // Create the Region and initialize its bounds
68  virtual bool createAndInitializeRegions() = 0;
69 
71 // Publish and subscribe the object class attributes.
72 // Register an object instance of the class.
74  virtual bool publishSubscribeAndRegisterObject() = 0;
75 
77 // Publish and Subscribe to an interaction class
79  virtual bool publishAndSubscribeInteraction() = 0;
80 
82 // Send the default update with Region. A less simple federate would have to
83 // specify which attributes need be updated. This on merely passes in the
84 // position which is sent with Region as the object update.
86  virtual void sendUpdate(int currentPosition ) = 0;
87 
89 // Send Interactions with Region. The following two interactions are meant to
90 // emulate a cuckoo clock with both an hourly chime, and a quarterly chime.
92 
94 // Send the hourly interaction with Region. This is an interaction that in this
95 // example occurs for each hour that is passed on the clock that is not
96 // {12,3,6,9}.
98  virtual void sendInteraction_hourly() = 0;
99 
101 // Send the quarterly interaction with Region. This is an interaction that in
102 // this example occurs for each hour that is passed on the clock that is in the
103 // following set {12,3,6,9}
105  virtual void sendInteraction_quarterly() = 0;
106 
108 // changeBounds sets the subscription of publication bounds of this federate.
110  virtual void changeBounds(int lower, int upper, int UTCZone) = 0;
111 
113 // Set the RTI's enable advisory switch
115  virtual void setEnableScopeAdvisories(bool yesNo) = 0;
116 
118 // Get scope advisory setting
120  bool enableScopeAdvisories() const ;
121 
123 // Perform the tick or evokeCallback method.
125  virtual bool tick(double atMost=0.0f) = 0;
126 
128 // Perform the tick or evokeCallback method.
130  virtual bool tick(double atLeast, double atMost) = 0;
131 
132  // Simulation Methods
133 
135 // Set federate as publisher (true) or subscriber (false)
137  virtual void setIsPublisher(bool yesNo) = 0;
138 
140 // Return true if this federate is publishing
142  bool isPublisher() const ;
143 
145 // Set the position (number of seconds)
147  virtual void setPosition(int data) = 0;
148 
150 // Get the position (number of seconds)
152  virtual int position() = 0;
153 
155 // Set the number of seconds to increment each cycle
157  void setSizeToInc(int data);
158 
160 // Get the number of seconds to increment each cycle
162  int sizeToInc() const ;
163 
165 // Get the zone used to send or listen
167  int zone() const ;
168 
169  // Region Range Bound Methods
170 
172 // Set the update range (number of seconds ahead of current position)
173 // This value should be at least large enough to have the next update fall
174 // within the range.
176  void setSendRangeSize(int data);
177 
179 // Get the update range (number of seconds ahead of current position)
181  int sendRangeSize() const ;
182 
184 // Get this listen upper bound
186  int listenUpperBound() const ;
187 
189 // Get this listen lower bound
191  int listenLowerBound() const ;
192 
194 // Get the send upper bound
196  int sendUpperBound() const ;
197 
199 // Get the send lower bound
201  int sendLowerBound() const;
202 
203 
205 // Set the Fed File Name
207 virtual void setFedFileName(const wchar_t* newFedName) = 0;
208 
210 // Set the Fed File Name with a std::string.
212 virtual void setFedFileName(const char* newFedName) = 0;
213 
215 // Get the Fed File Name
217 virtual char* getFedFileName() const = 0;
218 
219  // Constants used in calculations
220  static const unsigned int NUMSECONDSPERMINUTE;
221  static const unsigned int NUMMINUTESPERHOUR;
222  static const unsigned int NUMSECONDSPERHOUR;
223 
224  // 0 seconds is the minimum.
225  static const unsigned int LOWESTSecondsInRegion;
226  //60 seconds * 60 minutes * 360 degrees.
227  static const unsigned int GREATESTSecondsInRegion;
228  // 0 is the default UTC
229  static const unsigned int LOWESTUTCInRegion;
230  // For this example, the World has only 24 distinct Time Zones. (GREATESTUTCInRegion = 23)
231  static const unsigned int GREATESTUTCInRegion;
232 
234  {
237  };
238 
239 protected:
240 
241  // Our upper bound is the number of seconds in a circle.
242  // This is our default upper bound of interest extent in our region.
244 
245  // This is our default lower bound of interest extent in our region.
247 
248  // Is this instance the publisher. The Simple DDM example has one federate
249  // publishing and the other federate publishing no information,
250  // simply subscribing.
252 
253  //******************************************//
254  // The following are publisher specific data
255  //******************************************//
256  // This is our default upper area of interest extent in our region.
258  // This is our default lower area of interest extent in our region.
260  // This is the default time increment between ticks (seconds)
262  // This is the calculated range of the sender
264  // This represents the current position of the executing federate.
265  // The valid range for this int is between
266  // [positionLowerBound, positionUpperBound)
268 
269  // The number of updates sent
271 
273 
274  //******************************************//
275  // The following is subscriber specific data
276  //******************************************//
277  // This boolean enables the scope Advisory callback from the rti1516.
278  // The scoping callback is issued when an object that is subscribed with
279  // region changes visibility to the federate. i.e. When the subscribed and
280  // published region start to instersect and cease to intersect.
282 
283  //initialized represents whether or not the QT process has Initialized,
284  // After main launches a QT thread,
285  // main waits for QT to set initialized before proceeding
287  // closed is a global representing whether the main loop has exited for any
288  // reason including the user closing the dialog.
289  // The main loop sets it prior to exiting and the QT thread
290  // exits when it detects the main loop has closed.
291  bool myClosed;
292 
295 
296 private:
297  // Assignment Operator not implemented: Copy not allowed
299 };
300 
301 
302 inline void simpleDDMFederate::setSizeToInc(int data)
303 {
304  mySizeToInc = data;
305 }
307 {
308  if ( data < (int)(GREATESTSecondsInRegion - LOWESTSecondsInRegion) )
309  {
310  mySendRangeSize = (float)data;
311  }
312  else
313  {
315  }
316 }
317 
319 {
320  return myListenUpperBound;
321 }
322 
324 {
325  return myListenLowerBound;
326 }
327 
329 {
330  return myIsPublisher;
331 }
332 
334 {
335  return mySendUpperBound;
336 }
337 
339 {
340  return mySendLowerBound;
341 }
342 
344 {
345  return mySizeToInc;
346 }
347 
349 {
350  return (int)mySendRangeSize;
351 }
352 
354 {
356 }
357 
358 inline int simpleDDMFederate::zone() const
359 {
360  return myUTCZone;
361 }
362 
363 #endif
bool myRegionValid
Definition: simpleDDMFederate.h:293
void setSizeToInc(int data)
Definition: simpleDDMFederate.h:302
virtual bool publishAndSubscribeInteraction()=0
virtual void resignAndDestroy()=0
virtual void sendInteraction_hourly()=0
virtual void changeBounds(int lower, int upper, int UTCZone)=0
int mySendLowerBound
Definition: simpleDDMFederate.h:259
int mySizeToInc
Definition: simpleDDMFederate.h:261
virtual void setIsPublisher(bool yesNo)=0
static const unsigned int LOWESTUTCInRegion
Definition: simpleDDMFederate.h:229
static const unsigned int GREATESTUTCInRegion
Definition: simpleDDMFederate.h:231
simpleDDMFederate & operator=(const simpleDDMFederate &)
bool enableScopeAdvisories() const
Definition: simpleDDMFederate.h:353
static const unsigned int LOWESTSecondsInRegion
Definition: simpleDDMFederate.h:225
simpleAttributeHandleIndex
Definition: simpleDDMFederate.h:233
int listenLowerBound() const
Definition: simpleDDMFederate.h:323
int sendLowerBound() const
Definition: simpleDDMFederate.h:338
int mySendUpperBound
Definition: simpleDDMFederate.h:257
int myListenLowerBound
Definition: simpleDDMFederate.h:246
virtual void initializeRTI()=0
virtual void sendInteraction_quarterly()=0
int myUpdateCount
Definition: simpleDDMFederate.h:270
virtual bool joinFedEx()=0
virtual bool createAndInitializeRegions()=0
bool myMapsInitialized
Definition: simpleDDMFederate.h:294
int zone() const
Definition: simpleDDMFederate.h:358
virtual void sendUpdate(int currentPosition)=0
virtual char * getFedFileName() const =0
virtual void setFedFileName(const wchar_t *newFedName)=0
static const unsigned int NUMMINUTESPERHOUR
Definition: simpleDDMFederate.h:221
int sendUpperBound() const
Definition: simpleDDMFederate.h:333
float mySendRangeSize
Definition: simpleDDMFederate.h:263
virtual bool publishSubscribeAndRegisterObject()=0
Definition: simpleDDMFederate.h:25
virtual bool createFedEx()=0
bool myClosed
Definition: simpleDDMFederate.h:291
int listenUpperBound() const
Definition: simpleDDMFederate.h:318
Definition: simpleDDMFederate.h:236
static const unsigned int GREATESTSecondsInRegion
Definition: simpleDDMFederate.h:227
void setSendRangeSize(int data)
Definition: simpleDDMFederate.h:306
int sendRangeSize() const
Definition: simpleDDMFederate.h:348
Definition: simpleDDMFederate.h:235
virtual ~simpleDDMFederate()
int myUTCZone
Definition: simpleDDMFederate.h:272
virtual void setEnableScopeAdvisories(bool yesNo)=0
static const unsigned int NUMSECONDSPERMINUTE
Definition: simpleDDMFederate.h:220
static const unsigned int NUMSECONDSPERHOUR
Definition: simpleDDMFederate.h:222
int myListenUpperBound
Definition: simpleDDMFederate.h:243
int sizeToInc() const
Definition: simpleDDMFederate.h:343
virtual void setPosition(int data)=0
virtual int position()=0
bool isPublisher() const
Definition: simpleDDMFederate.h:328
virtual bool tick(double atMost=0.0f)=0
bool myInitialized
Definition: simpleDDMFederate.h:286
int myCurrentposition
Definition: simpleDDMFederate.h:267
bool myIsPublisher
Definition: simpleDDMFederate.h:251
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)