![]() |
MAK RTIspy API Documentation for HLA 1516
|
00001 /******************************************************************************* 00002 ** Copyright (c) 2010 MaK Technologies, Inc. 00003 ** All rights reserved. 00004 *******************************************************************************/ 00005 /******************************************************************************* 00006 ** $RCSfile: .h,v $ $Revision: 1.2 $ $State: Exp $ 00007 *******************************************************************************/ 00008 00009 #ifndef BallController13_H_ 00010 #define BallController13_H_ 00011 00012 #include "ballData.h" 00013 #include "ballController.h" 00014 #include <RTI.hh> 00015 00016 class HlaBounceFederateAmbassador; 00017 class ObjectParams13; 00018 00019 // Class that updates owned balls and processes updates on 00020 // other balls for 1516 federates 00021 class BallController13 : public BallController 00022 { 00023 public: 00024 00025 BallController13(BallMap* data, DdmRegionMap* regionData); 00026 virtual ~BallController13(); 00027 00028 // Creates (if not already created) and joins the given federation. 00029 // Returns success indicator. federateName is not used in 1516. 00030 virtual bool createAndJoinFederation(const std::wstring& federation, 00031 const std::wstring& federateType, 00032 const std::wstring& federateName = std::wstring(), 00033 bool includeInterExt = false); 00034 00035 // Resigns from and attempts to destroy the current federation. 00036 // Returns success indicator. 00037 virtual bool resignAndDestroyFederation(); 00038 00039 // Subscribes to the ball class and all its attributes. Must already have 00040 // created and joined the federation. Returns success indicator. 00041 virtual bool subscribe(); 00042 00043 // Unsubscribes to the ball class and all its attributes. Must already have 00044 // created and joined the federation. Returns success indicator. 00045 virtual bool unsubscribe(); 00046 00047 // Deletes the ball with the given ID 00048 virtual void deleteBall(const std::wstring id); 00049 00050 // Attempts to acquire the ball with the given ID 00051 virtual void acquireBall(const std::wstring id); 00052 00053 // Attempts to divest the owned ball with the given ID 00054 virtual void divestBall(const std::wstring id); 00055 00056 // Adds a new DDM subscription region 00057 virtual bool subscribeWithRegion(int xLowerBound, int yLowerBound, 00058 int xUpperBound, int yUpperBound); 00059 00060 // Unsubscribes from the current DDM regions. If resubscribeWithoutRegion is 00061 // set, automatically resubscribes without regions. 00062 virtual bool unsubscribeWithRegions(bool resubscribeWithoutRegion); 00063 00064 // Unsubscribes from the current DDM regions, but does not delete the region 00065 // information. Needed when adding a new region extent. If 00066 // resubscribeWithoutRegion is set, automatically resubscribes without regions. 00067 virtual bool unsubscribeWithRegionsKeepRegionInfo(bool resubscribeWithoutRegion); 00068 00069 // Process discovery of a new ball 00070 void ballDiscovered(ObjectParams13* objParams); 00071 00072 // Process removal of another federate's ball 00073 void ballRemoved(RTI::ObjectHandle handle); 00074 00075 // Process the movement of the ball into a visible area 00076 void ballVisible(RTI::ObjectHandle handle); 00077 00078 // Process the movement of the ball out of a visible area 00079 void ballNotVisible(RTI::ObjectHandle handle); 00080 00081 // Process update of an existing ball 00082 void ballUpdated(RTI::ObjectHandle handle, 00083 const RTI::AttributeHandleValuePairSet& attrVals); 00084 00085 // Tries to release ownership of the requested object 00086 void releaseOwnership(RTI::ObjectHandle theObject, 00087 RTI::AttributeHandleSet const & attributes); 00088 00089 // Takes control of the ball which the federate has successfully acquired 00090 // ownership of 00091 void ownershipAcquired(RTI::ObjectHandle theObject, 00092 RTI::AttributeHandleSet const & attributes); 00093 00094 // Tries to assume ownership of the object being divested 00095 void assumeOwnership(RTI::ObjectHandle theObject, 00096 RTI::AttributeHandleSet const & attributes); 00097 00098 // Discontinues updates for the ball which the federate has successfully 00099 // divested ownership of 00100 void ownershipDivested(RTI::ObjectHandle theObject, 00101 RTI::AttributeHandleSet const & attributes); 00102 00103 // Sets the field dimensions 00104 virtual void setDimensions(int minX, int minY, int maxX, int maxY); 00105 00106 // Returns the federate ID (based on the federate handle) 00107 virtual const std::wstring& federateId() const; 00108 00109 // Returns the federate type 00110 virtual const std::wstring& federateType() const; 00111 00112 // Returns the federate name 00113 virtual const std::wstring& federateName() const; 00114 00115 // Returns the federation name 00116 virtual const std::wstring& federationName() const; 00117 00118 // Returns false. Federate name is not supported in 1.3. 00119 virtual bool isFederateNameSupported() const; 00120 00121 // Returns false. The interaction FOM module extension is not supported 00122 // in 1.3. 00123 virtual bool isInteractionExtensionSupported() const; 00124 00125 protected: 00126 00127 // Sends updates on all owned balls to other federates in the federation 00128 virtual void sendUpdates(); 00129 00130 // Receives updates on balls from other federates in the federation 00131 virtual void receiveUpdates(); 00132 00133 // Request the RTI to create the a new ball 00134 virtual void requestNewBall(Ball* ball, const std::wstring name); 00135 00136 // Loads the AttributeHandleValuePairSet with the data from the given ball 00137 void setAttributesForBall(RTI::AttributeHandleValuePairSet& attrVals, 00138 const Ball* ball); 00139 00140 // Loads the Ball with the data from the given attributes 00141 void setBallFromAttributes(Ball* ball, 00142 const RTI::AttributeHandleValuePairSet& attrVals); 00143 00144 // Subscribes to the default region 00145 void subscribeToDefaultRegion(); 00146 00147 // Unsubscribes from the default region. Based on input parameter, either 00148 // deletes the discovered balls or marks them as out of scope. 00149 void unsubscribeFromDefaultRegion(bool deleteDiscoveredBalls); 00150 00151 // Deletes known balls. Can delete owned, not owned, or both. 00152 virtual void deleteKnownBalls(bool deleteOwned, bool deleteOthers); 00153 00154 // Marks all balls this federate does not own as out of scope 00155 void markBallsOutOfScope(); 00156 00157 // Creates a publication region for the given ball and sets ball's object 00158 // parameters with the new region handle. 00159 bool createPublicationRegion(Ball* ball); 00160 00161 // Constructs a user supplied tag for the given ball object parameters. 00162 // Not really relevant to federate operations. 00163 std::string constructTag(const Ball* ball) const; 00164 00165 private: 00166 00167 // No default constructor 00168 BallController13(); 00169 00170 protected: 00171 00172 BallMap myPendingBalls; 00173 00174 RTI::RTIambassador* myRtiAmbassador; 00175 HlaBounceFederateAmbassador* myFederateAmbassador; 00176 00177 RTI::FederateHandle myFederateHandle; 00178 std::wstring myFederateHandleString; 00179 std::wstring myFederateType; 00180 std::wstring myFederationName; 00181 00182 bool myIsSubscribedToDefaultRegion; 00183 RTI::Region* mySubscriptionRegion; 00184 00185 int myDdmXRangeConv; 00186 int myDdmYRangeConv; 00187 00188 RTI::ObjectClassHandle myBallClass; 00189 RTI::AttributeHandle myColorAttr; 00190 RTI::AttributeHandle mySizeAttr; 00191 RTI::AttributeHandle myXAttr; 00192 RTI::AttributeHandle myYAttr; 00193 RTI::AttributeHandle mySpeedAttr; 00194 RTI::AttributeHandle myDirectionAttr; 00195 RTI::AttributeHandleSet* myAllBallAttrs; 00196 RTI::AttributeHandleValuePairSet* myAttrVals; 00197 RTI::AttributeHandle myPrivToDeleteAttr; 00198 RTI::SpaceHandle myXYSpace; 00199 RTI::DimensionHandle myXDim; 00200 RTI::DimensionHandle myYDim; 00201 00202 static const std::string theFedFile; 00203 static const std::string theBallClassName; 00204 static const std::string theColorAttrName; 00205 static const std::string theSizeAttrName; 00206 static const std::string theXAttrName; 00207 static const std::string theYAttrName; 00208 static const std::string theSpeedAttrName; 00209 static const std::string theDirectionAttrName; 00210 static const std::string thePrivToDeleteAttrName; 00211 static const std::string theXYSpaceName; 00212 static const std::string theXDimName; 00213 static const std::string theYDimName; 00214 }; 00215 00216 #endif