MAK RTIspy API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ballController1516e.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2010 MaK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: .h,v $ $Revision: 1.2 $ $State: Exp $
7 *******************************************************************************/
8 
9 #ifndef BallController1516e_H_
10 #define BallController1516e_H_
11 
12 #include "ballData.h"
13 #include "ballController.h"
14 #include <RTI/RTI1516.h>
15 
17 class ObjectParams1516e;
18 
19 // Class that updates owned balls and processes updates on
20 // other balls for 1516e federates
22 {
23 public:
24 
25  BallController1516e(BallMap* data, DdmRegionMap* regionData);
26  virtual ~BallController1516e();
27 
28  // Creates (if not already created) and joins the given federation.
29  // Returns success indicator. federateName is not used in 1516.
30  virtual bool createAndJoinFederation(const std::wstring& federation,
31  const std::wstring& federateType,
32  const std::wstring& federateName = std::wstring(),
33  bool includeInterExt = false);
34 
35  // Resigns from and attempts to destroy the current federation.
36  // Returns success indicator.
37  virtual bool resignAndDestroyFederation();
38 
39  // Subscribes to the ball class and all its attributes. Must already have
40  // created and joined the federation. Returns success indicator.
41  virtual bool subscribe();
42 
43  // Unsubscribes to the ball class and all its attributes. Must already have
44  // created and joined the federation. Returns success indicator.
45  virtual bool unsubscribe();
46 
47  // Deletes the ball with the given ID
48  virtual void deleteBall(const std::wstring id);
49 
50  // Attempts to acquire the ball with the given ID
51  virtual void acquireBall(const std::wstring id);
52 
53  // Attempts to divest the owned ball with the given ID
54  virtual void divestBall(const std::wstring id);
55 
56  // Adds a new DDM subscription region
57  virtual bool subscribeWithRegion(int xLowerBound, int yLowerBound,
58  int xUpperBound, int yUpperBound);
59 
60  // Unsubscribes from the current DDM regions. If resubscribeWithoutRegion is
61  // set, automatically resubscribes without regions.
62  virtual bool unsubscribeWithRegions(bool resubscribeWithoutRegion);
63 
64  // Process a denial for a new ball name
65  void nameReservationFailed(const std::wstring& name);
66 
67  // Process an approval for a new ball name
68  void nameReservationSucceeded(const std::wstring& name);
69 
70  // Process discovery of a new ball
71  void ballDiscovered(ObjectParams1516e* objParams);
72 
73  // Process removal of another federate's ball
74  void ballRemoved(rti1516e::ObjectInstanceHandle handle);
75 
76  // Process the movement of the ball into a visible area
77  void ballVisible(rti1516e::ObjectInstanceHandle handle);
78 
79  // Process the movement of the ball out of a visible area
80  void ballNotVisible(rti1516e::ObjectInstanceHandle handle);
81 
82  // Process update of an existing ball
83  void ballUpdated(rti1516e::ObjectInstanceHandle handle,
84  const rti1516e::AttributeHandleValueMap& attrVals);
85 
86  // Process a display text interaction
87  void displayInteractionText(rti1516e::InteractionClassHandle handle,
88  const rti1516e::ParameterHandleValueMap& paramVals);
89 
90  // Tries to release ownership of the requested object
91  void releaseOwnership(rti1516e::ObjectInstanceHandle theObject,
92  rti1516e::AttributeHandleSet const & attributes);
93 
94  // Takes control of the ball which the federate has successfully acquired
95  // ownership of
96  void ownershipAcquired(rti1516e::ObjectInstanceHandle theObject,
97  rti1516e::AttributeHandleSet const & attributes);
98 
99  // Tries to assume ownership of the object being divested
100  void assumeOwnership(rti1516e::ObjectInstanceHandle theObject,
101  rti1516e::AttributeHandleSet const & attributes);
102 
103  // Confirms that the object is divested
104  void confirmDivestiture(rti1516e::ObjectInstanceHandle theObject,
105  rti1516e::AttributeHandleSet const & attributes);
106 
107  // Sets the field dimensions
108  virtual void setDimensions(int minX, int minY, int maxX, int maxY);
109 
110  // Returns the federate ID (based on the federate handle)
111  virtual const std::wstring& federateId() const;
112 
113  // Returns the federate type
114  virtual const std::wstring& federateType() const;
115 
116  // Returns the federate name
117  virtual const std::wstring& federateName() const;
118 
119  // Returns the federation name
120  virtual const std::wstring& federationName() const;
121 
122  // Returns true. Federate name is supported in HLA Evolved.
123  virtual bool isFederateNameSupported() const;
124 
125  // Returns true. The interaction FOM module extension is supported
126  // in HLA Evolved.
127  virtual bool isInteractionExtensionSupported() const;
128 
129 protected:
130 
131  // Sends updates on all owned balls to other federates in the federation
132  virtual void sendUpdates();
133 
134  // Receives updates on balls from other federates in the federation
135  virtual void receiveUpdates();
136 
137  // Request the RTI to create the a new ball
138  virtual void requestNewBall(Ball* ball, const std::wstring name);
139 
140  // Loads the AttributeHandleValueMap with the data from the given ball
142  const Ball* ball);
143 
144  // Loads the Ball with the data from the given attributes
145  void setBallFromAttributes(Ball* ball,
146  const rti1516e::AttributeHandleValueMap& attrVals);
147 
148  // Loads the TextEvent with the data from the given parameters
149  void setTextEventFromParameters(TextEvent& textEvent,
150  const rti1516e::ParameterHandleValueMap& paramVals);
151 
152  // Subscribes to the default region
154 
155  // Unsubscribes from the default region. Based on input parameter, either
156  // deletes the discovered balls or marks them as out of scope.
157  void unsubscribeFromDefaultRegion(bool deleteDiscoveredBalls);
158 
159  // Subscribes to the text interaction class.
161 
162  // Unsubscribes from the text interaction class.
164 
165  // Deletes known balls. Can delete owned, not owned, or both.
166  virtual void deleteKnownBalls(bool deleteOwned, bool deleteOthers);
167 
168  // Marks all balls this federate does not own as out of scope
169  void markBallsOutOfScope();
170 
171  // Creates a publication region for the given ball and sets ball's object
172  // parameters with the new region handle.
173  bool createPublicationRegion(Ball* ball);
174 
175  // Constructs a user supplied tag for the given ball object parameters.
176  // Not really relevant to federate operations.
178 
179 private:
180 
181  // No default constructor
183 
184 protected:
185 
188 
189  std::auto_ptr < rti1516e::RTIambassador > myRtiAmbassador;
191 
192  rti1516e::FederateHandle myFederateHandle;
194  std::wstring myFederateType;
195  std::wstring myFederationName;
196 
198 
201 
202  rti1516e::ObjectClassHandle myBallClass;
203  rti1516e::AttributeHandle myColorAttr;
204  rti1516e::AttributeHandle mySizeAttr;
205  rti1516e::AttributeHandle myXAttr;
206  rti1516e::AttributeHandle myYAttr;
207  rti1516e::AttributeHandle mySpeedAttr;
208  rti1516e::AttributeHandle myDirectionAttr;
210  rti1516e::AttributeHandle myPrivToDeleteAttr;
211  rti1516e::DimensionHandle myXDim;
212  rti1516e::DimensionHandle myYDim;
213 
215  rti1516e::InteractionClassHandle myTextClass;
216  rti1516e::ParameterHandle myTextParam;
217  rti1516e::ParameterHandle myTextXParam;
218  rti1516e::ParameterHandle myTextYParam;
219  rti1516e::ParameterHandle myTextSizeParam;
220  rti1516e::ParameterHandle myTextIntervalParam;
222 
223  static const std::wstring theFddFile;
224  static const std::wstring theBallClassName;
225  static const std::wstring theColorAttrName;
226  static const std::wstring theSizeAttrName;
227  static const std::wstring theXAttrName;
228  static const std::wstring theYAttrName;
229  static const std::wstring theSpeedAttrName;
230  static const std::wstring theDirectionAttrName;
231  static const std::wstring thePrivToDeleteAttrName;
232  static const std::wstring theXDimName;
233  static const std::wstring theYDimName;
234 
235  static const std::wstring theInteractionFomModule;
236  static const std::wstring theTextClassName;
237  static const std::wstring theTextParamName;
238  static const std::wstring theTextXParamName;
239  static const std::wstring theTextYParamName;
240  static const std::wstring theTextSizeParamName;
241  static const std::wstring theTextIntervalParamName;
242 
243 };
244 
245 #endif
rti1516e::ObjectClassHandle myBallClass
Definition: ballController1516e.h:202
bool myIsSubscribedToDefaultRegion
Definition: ballController1516e.h:197
A convenience header provided for developers that would like to include everything all at once...
static const std::wstring theTextSizeParamName
Definition: ballController1516e.h:240
std::set< AttributeHandle > AttributeHandleSet
Definition: Typedefs.h:35
std::wstring myFederationName
Definition: ballController1516e.h:195
std::set< ParameterHandle > ParameterHandleSet
Definition: Typedefs.h:36
rti1516e::AttributeHandle myColorAttr
Definition: ballController1516e.h:203
virtual void deleteKnownBalls(bool deleteOwned, bool deleteOthers)
Definition: ballData.h:47
Definition: hlaBounceFedAmb13.h:23
virtual void divestBall(const std::wstring id)
virtual void deleteBall(const std::wstring id)
virtual void receiveUpdates()
void unsubscribeInteractionClass()
rti1516e::ParameterHandle myTextYParam
Definition: ballController1516e.h:218
void unsubscribeFromDefaultRegion(bool deleteDiscoveredBalls)
rti1516e::ParameterHandle myTextIntervalParam
Definition: ballController1516e.h:220
virtual void setDimensions(int minX, int minY, int maxX, int maxY)
static const std::wstring theYAttrName
Definition: ballController1516e.h:228
rti1516e::AttributeHandle myXAttr
Definition: ballController1516e.h:205
virtual const std::wstring & federateType() const
virtual bool resignAndDestroyFederation()
void ballUpdated(rti1516e::ObjectInstanceHandle handle, const rti1516e::AttributeHandleValueMap &attrVals)
rti1516e::AttributeHandleSet myAllBallAttrs
Definition: ballController1516e.h:209
virtual bool unsubscribeWithRegions(bool resubscribeWithoutRegion)
int myDdmXRangeConv
Definition: ballController1516e.h:199
void nameReservationSucceeded(const std::wstring &name)
static const std::wstring theInteractionFomModule
Definition: ballController1516e.h:235
rti1516e::VariableLengthData constructTag(const Ball *ball) const
void ballNotVisible(rti1516e::ObjectInstanceHandle handle)
std::wstring myFederateType
Definition: ballController1516e.h:194
virtual bool createAndJoinFederation(const std::wstring &federation, const std::wstring &federateType, const std::wstring &federateName=std::wstring(), bool includeInterExt=false)
rti1516e::AttributeHandle myYAttr
Definition: ballController1516e.h:206
static const std::wstring theBallClassName
Definition: ballController1516e.h:224
virtual const std::wstring & federateId() const
std::map< std::wstring, Ball * > BallMap
Definition: ballData.h:118
virtual const std::wstring & federateName() const
bool createPublicationRegion(Ball *ball)
Definition: VariableLengthData.h:34
static const std::wstring thePrivToDeleteAttrName
Definition: ballController1516e.h:231
Definition: textData.h:13
void setAttributesForBall(rti1516e::AttributeHandleValueMap &attrVals, const Ball *ball)
virtual void sendUpdates()
static const std::wstring theColorAttrName
Definition: ballController1516e.h:225
bool myIsUsingInteractionModule
Definition: ballController1516e.h:214
BallMap myPendingBalls
Definition: ballController1516e.h:187
static const std::wstring theYDimName
Definition: ballController1516e.h:233
void subscribeInteractionClass()
void subscribeToDefaultRegion()
static const std::wstring theXAttrName
Definition: ballController1516e.h:227
static const std::wstring theTextYParamName
Definition: ballController1516e.h:239
rti1516e::ParameterHandleSet myAllTextParams
Definition: ballController1516e.h:221
rti1516e::InteractionClassHandle myTextClass
Definition: ballController1516e.h:215
static const std::wstring theTextXParamName
Definition: ballController1516e.h:238
static const std::wstring theSizeAttrName
Definition: ballController1516e.h:226
static const std::wstring theTextIntervalParamName
Definition: ballController1516e.h:241
Definition: ballController.h:21
int myDdmYRangeConv
Definition: ballController1516e.h:200
HlaBounceFederateAmbassador * myFederateAmbassador
Definition: ballController1516e.h:190
virtual bool subscribe()
virtual bool isInteractionExtensionSupported() const
void confirmDivestiture(rti1516e::ObjectInstanceHandle theObject, rti1516e::AttributeHandleSet const &attributes)
rti1516e::DimensionHandle myXDim
Definition: ballController1516e.h:211
static const std::wstring theTextParamName
Definition: ballController1516e.h:237
void releaseOwnership(rti1516e::ObjectInstanceHandle theObject, rti1516e::AttributeHandleSet const &attributes)
void ballDiscovered(ObjectParams1516e *objParams)
virtual void requestNewBall(Ball *ball, const std::wstring name)
std::wstring myFederateHandleString
Definition: ballController1516e.h:193
void ballRemoved(rti1516e::ObjectInstanceHandle handle)
rti1516e::FederateHandle myFederateHandle
Definition: ballController1516e.h:192
static const std::wstring theXDimName
Definition: ballController1516e.h:232
void assumeOwnership(rti1516e::ObjectInstanceHandle theObject, rti1516e::AttributeHandleSet const &attributes)
rti1516e::ParameterHandle myTextParam
Definition: ballController1516e.h:216
rti1516e::AttributeHandle myDirectionAttr
Definition: ballController1516e.h:208
rti1516e::AttributeHandle myPrivToDeleteAttr
Definition: ballController1516e.h:210
static const std::wstring theDirectionAttrName
Definition: ballController1516e.h:230
std::map< AttributeHandle, VariableLengthData > AttributeHandleValueMap
Definition: Typedefs.h:44
virtual bool isFederateNameSupported() const
void ownershipAcquired(rti1516e::ObjectInstanceHandle theObject, rti1516e::AttributeHandleSet const &attributes)
rti1516e::AttributeHandle mySizeAttr
Definition: ballController1516e.h:204
Definition: objParams1516e.h:14
virtual const std::wstring & federationName() const
std::map< std::wstring, DdmRegion * > DdmRegionMap
Definition: regionData.h:59
virtual bool subscribeWithRegion(int xLowerBound, int yLowerBound, int xUpperBound, int yUpperBound)
void setTextEventFromParameters(TextEvent &textEvent, const rti1516e::ParameterHandleValueMap &paramVals)
static const std::wstring theFddFile
Definition: ballController1516e.h:223
virtual bool unsubscribe()
static const std::wstring theSpeedAttrName
Definition: ballController1516e.h:229
rti1516e::DimensionHandle myYDim
Definition: ballController1516e.h:212
virtual void acquireBall(const std::wstring id)
void nameReservationFailed(const std::wstring &name)
BallMap myUnnamedBalls
Definition: ballController1516e.h:186
rti1516e::ParameterHandle myTextXParam
Definition: ballController1516e.h:217
void displayInteractionText(rti1516e::InteractionClassHandle handle, const rti1516e::ParameterHandleValueMap &paramVals)
static const std::wstring theTextClassName
Definition: ballController1516e.h:236
std::auto_ptr< rti1516e::RTIambassador > myRtiAmbassador
Definition: ballController1516e.h:189
rti1516e::AttributeHandle mySpeedAttr
Definition: ballController1516e.h:207
void ballVisible(rti1516e::ObjectInstanceHandle handle)
virtual ~BallController1516e()
rti1516e::ParameterHandle myTextSizeParam
Definition: ballController1516e.h:219
Definition: ballController1516e.h:21
void setBallFromAttributes(Ball *ball, const rti1516e::AttributeHandleValueMap &attrVals)
std::map< ParameterHandle, VariableLengthData > ParameterHandleValueMap
Definition: Typedefs.h:49

Document ID: Generated on Mon Sep 7 15:40:32 EDT 2020 from SVN revision 217499
Copyright © 2005-2020 MAK Technologies Inc. All Rights Reserved (www.mak.com)