MAK RTIspy API Documentation for HLA 1.3
ballController1516.h
Go to the documentation of this file.
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 BallController1516_H_
00010 #define BallController1516_H_
00011 
00012 #include "ballData.h"
00013 #include "ballController.h"
00014 #include <RTI/RTI1516.h>
00015 
00016 class HlaBounceFederateAmbassador;
00017 class ObjectParams1516;
00018 
00019 // Class that updates owned balls and processes updates on
00020 // other balls for 1516 federates
00021 class BallController1516 : public BallController
00022 {
00023 public:
00024 
00025    BallController1516(BallMap* data, DdmRegionMap* regionData);
00026    virtual ~BallController1516();
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    // Process a denial for a new ball name
00065    void nameReservationFailed(const std::wstring name);
00066 
00067    // Process an approval for a new ball name
00068    void nameReservationSucceeded(const std::wstring name);
00069 
00070    // Process discovery of a new ball
00071    void ballDiscovered(ObjectParams1516* objParams);
00072 
00073    // Process removal of another federate's ball
00074    void ballRemoved(rti1516::ObjectInstanceHandle handle);
00075 
00076    // Process the movement of the ball into a visible area
00077    void ballVisible(rti1516::ObjectInstanceHandle handle);
00078 
00079    // Process the movement of the ball out of a visible area
00080    void ballNotVisible(rti1516::ObjectInstanceHandle handle);
00081 
00082    // Process update of an existing ball
00083    void ballUpdated(rti1516::ObjectInstanceHandle handle,
00084       const rti1516::AttributeHandleValueMap& attrVals);
00085 
00086    // Tries to release ownership of the requested object
00087    void releaseOwnership(rti1516::ObjectInstanceHandle theObject,
00088       rti1516::AttributeHandleSet const & attributes);
00089 
00090    // Takes control of the ball which the federate has successfully acquired
00091    // ownership of
00092    void ownershipAcquired(rti1516::ObjectInstanceHandle theObject,
00093       rti1516::AttributeHandleSet const & attributes);
00094 
00095    // Tries to assume ownership of the object being divested
00096    void assumeOwnership(rti1516::ObjectInstanceHandle theObject,
00097       rti1516::AttributeHandleSet const & attributes);
00098 
00099    // Confirms that the object is divested
00100    void confirmDivestiture(rti1516::ObjectInstanceHandle theObject,
00101       rti1516::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 1516.
00119    virtual bool isFederateNameSupported() const;
00120 
00121    // Returns false. The interaction FOM module extension is not supported
00122    // in 1516.
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 AttributeHandleValueMap with the data from the given ball
00137    void setAttributesForBall(rti1516::AttributeHandleValueMap& attrVals,
00138       const Ball* ball);
00139 
00140    // Loads the Ball with the data from the given attributes
00141    void setBallFromAttributes(Ball* ball,
00142       const rti1516::AttributeHandleValueMap& 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    rti1516::VariableLengthData constructTag(const Ball* ball) const;
00164 
00165 private:
00166 
00167    // No default constructor
00168    BallController1516();
00169 
00170 protected:
00171 
00172    BallMap myUnnamedBalls;
00173    BallMap myPendingBalls;
00174 
00175    std::auto_ptr < rti1516::RTIambassador > myRtiAmbassador;
00176    HlaBounceFederateAmbassador* myFederateAmbassador;
00177 
00178    rti1516::FederateHandle myFederateHandle;
00179    std::wstring myFederateHandleString;
00180    std::wstring myFederateType;
00181    std::wstring myFederationName;
00182 
00183    bool myIsSubscribedToDefaultRegion;
00184 
00185    int myDdmXRangeConv;
00186    int myDdmYRangeConv;
00187 
00188    rti1516::ObjectClassHandle myBallClass;
00189    rti1516::AttributeHandle myColorAttr;
00190    rti1516::AttributeHandle mySizeAttr;
00191    rti1516::AttributeHandle myXAttr;
00192    rti1516::AttributeHandle myYAttr;
00193    rti1516::AttributeHandle mySpeedAttr;
00194    rti1516::AttributeHandle myDirectionAttr;
00195    rti1516::AttributeHandleSet myAllBallAttrs;
00196    rti1516::AttributeHandle myPrivToDeleteAttr;
00197    rti1516::DimensionHandle myXDim;
00198    rti1516::DimensionHandle myYDim;
00199 
00200    static const std::wstring theFddFile;
00201    static const std::wstring theBallClassName;
00202    static const std::wstring theColorAttrName;
00203    static const std::wstring theSizeAttrName;
00204    static const std::wstring theXAttrName;
00205    static const std::wstring theYAttrName;
00206    static const std::wstring theSpeedAttrName;
00207    static const std::wstring theDirectionAttrName;
00208    static const std::wstring thePrivToDeleteAttrName;
00209    static const std::wstring theXDimName;
00210    static const std::wstring theYDimName;
00211 };
00212 
00213 #endif

Document ID: Generated on Thu Jun 14 14:15:04 EDT 2012 from SVN revision 116116
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)