MAK RTIspy API Documentation for HLA 1.3
ballController1516e.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 BallController1516e_H_
00010 #define BallController1516e_H_
00011 
00012 #include "ballData.h"
00013 #include "ballController.h"
00014 #include <RTI/RTI1516.h>
00015 
00016 class HlaBounceFederateAmbassador;
00017 class ObjectParams1516e;
00018 
00019 // Class that updates owned balls and processes updates on
00020 // other balls for 1516e federates
00021 class BallController1516e : public BallController
00022 {
00023 public:
00024 
00025    BallController1516e(BallMap* data, DdmRegionMap* regionData);
00026    virtual ~BallController1516e();
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(ObjectParams1516e* objParams);
00072 
00073    // Process removal of another federate's ball
00074    void ballRemoved(rti1516e::ObjectInstanceHandle handle);
00075 
00076    // Process the movement of the ball into a visible area
00077    void ballVisible(rti1516e::ObjectInstanceHandle handle);
00078 
00079    // Process the movement of the ball out of a visible area
00080    void ballNotVisible(rti1516e::ObjectInstanceHandle handle);
00081 
00082    // Process update of an existing ball
00083    void ballUpdated(rti1516e::ObjectInstanceHandle handle,
00084       const rti1516e::AttributeHandleValueMap& attrVals);
00085 
00086    // Process a display text interaction
00087    void displayInteractionText(rti1516e::InteractionClassHandle handle,
00088       const rti1516e::ParameterHandleValueMap& paramVals);
00089 
00090    // Tries to release ownership of the requested object
00091    void releaseOwnership(rti1516e::ObjectInstanceHandle theObject,
00092       rti1516e::AttributeHandleSet const & attributes);
00093 
00094    // Takes control of the ball which the federate has successfully acquired
00095    // ownership of
00096    void ownershipAcquired(rti1516e::ObjectInstanceHandle theObject,
00097       rti1516e::AttributeHandleSet const & attributes);
00098 
00099    // Tries to assume ownership of the object being divested
00100    void assumeOwnership(rti1516e::ObjectInstanceHandle theObject,
00101       rti1516e::AttributeHandleSet const & attributes);
00102 
00103    // Confirms that the object is divested
00104    void confirmDivestiture(rti1516e::ObjectInstanceHandle theObject,
00105       rti1516e::AttributeHandleSet const & attributes);
00106 
00107    // Sets the field dimensions
00108    virtual void setDimensions(int minX, int minY, int maxX, int maxY);
00109 
00110    // Returns the federate ID (based on the federate handle)
00111    virtual const std::wstring& federateId() const;
00112 
00113    // Returns the federate type
00114    virtual const std::wstring& federateType() const;
00115 
00116    // Returns the federate name
00117    virtual const std::wstring& federateName() const;
00118 
00119    // Returns the federation name
00120    virtual const std::wstring& federationName() const;
00121 
00122    // Returns true. Federate name is supported in HLA Evolved.
00123    virtual bool isFederateNameSupported() const;
00124 
00125    // Returns true. The interaction FOM module extension is supported
00126    // in HLA Evolved.
00127    virtual bool isInteractionExtensionSupported() const;
00128 
00129 protected:
00130 
00131    // Sends updates on all owned balls to other federates in the federation
00132    virtual void sendUpdates();
00133 
00134    // Receives updates on balls from other federates in the federation
00135    virtual void receiveUpdates();
00136 
00137    // Request the RTI to create the a new ball
00138    virtual void requestNewBall(Ball* ball, const std::wstring name);
00139 
00140    // Loads the AttributeHandleValueMap with the data from the given ball
00141    void setAttributesForBall(rti1516e::AttributeHandleValueMap& attrVals,
00142       const Ball* ball);
00143 
00144    // Loads the Ball with the data from the given attributes
00145    void setBallFromAttributes(Ball* ball,
00146       const rti1516e::AttributeHandleValueMap& attrVals);
00147 
00148    // Loads the TextEvent with the data from the given parameters
00149    void setTextEventFromParameters(TextEvent& textEvent,
00150       const rti1516e::ParameterHandleValueMap& paramVals);
00151 
00152    // Subscribes to the default region
00153    void subscribeToDefaultRegion();
00154 
00155    // Unsubscribes from the default region. Based on input parameter, either
00156    // deletes the discovered balls or marks them as out of scope.
00157    void unsubscribeFromDefaultRegion(bool deleteDiscoveredBalls);
00158 
00159    // Subscribes to the text interaction class.
00160    void subscribeInteractionClass();
00161 
00162    // Unsubscribes from the text interaction class.
00163    void unsubscribeInteractionClass();
00164 
00165    // Deletes known balls. Can delete owned, not owned, or both.
00166    virtual void deleteKnownBalls(bool deleteOwned, bool deleteOthers);
00167 
00168    // Marks all balls this federate does not own as out of scope
00169    void markBallsOutOfScope();
00170 
00171    // Creates a publication region for the given ball and sets ball's object 
00172    // parameters with the new region handle.
00173    bool createPublicationRegion(Ball* ball);
00174 
00175    // Constructs a user supplied tag for the given ball object parameters.
00176    // Not really relevant to federate operations.
00177    rti1516e::VariableLengthData constructTag(const Ball* ball) const;
00178 
00179 private:
00180 
00181    // No default constructor
00182    BallController1516e();
00183 
00184 protected:
00185 
00186    BallMap myUnnamedBalls;
00187    BallMap myPendingBalls;
00188 
00189    std::auto_ptr < rti1516e::RTIambassador > myRtiAmbassador;
00190    HlaBounceFederateAmbassador* myFederateAmbassador;
00191 
00192    rti1516e::FederateHandle myFederateHandle;
00193    std::wstring myFederateHandleString;
00194    std::wstring myFederateType;
00195    std::wstring myFederationName;
00196 
00197    bool myIsSubscribedToDefaultRegion;
00198 
00199    int myDdmXRangeConv;
00200    int myDdmYRangeConv;
00201 
00202    rti1516e::ObjectClassHandle myBallClass;
00203    rti1516e::AttributeHandle myColorAttr;
00204    rti1516e::AttributeHandle mySizeAttr;
00205    rti1516e::AttributeHandle myXAttr;
00206    rti1516e::AttributeHandle myYAttr;
00207    rti1516e::AttributeHandle mySpeedAttr;
00208    rti1516e::AttributeHandle myDirectionAttr;
00209    rti1516e::AttributeHandleSet myAllBallAttrs;
00210    rti1516e::AttributeHandle myPrivToDeleteAttr;
00211    rti1516e::DimensionHandle myXDim;
00212    rti1516e::DimensionHandle myYDim;
00213 
00214    bool myIsUsingInteractionModule;
00215    rti1516e::InteractionClassHandle myTextClass;
00216    rti1516e::ParameterHandle myTextParam;
00217    rti1516e::ParameterHandle myTextXParam;
00218    rti1516e::ParameterHandle myTextYParam;
00219    rti1516e::ParameterHandle myTextSizeParam;
00220    rti1516e::ParameterHandle myTextIntervalParam;
00221    rti1516e::ParameterHandleSet myAllTextParams;
00222 
00223    static const std::wstring theFddFile;
00224    static const std::wstring theBallClassName;
00225    static const std::wstring theColorAttrName;
00226    static const std::wstring theSizeAttrName;
00227    static const std::wstring theXAttrName;
00228    static const std::wstring theYAttrName;
00229    static const std::wstring theSpeedAttrName;
00230    static const std::wstring theDirectionAttrName;
00231    static const std::wstring thePrivToDeleteAttrName;
00232    static const std::wstring theXDimName;
00233    static const std::wstring theYDimName;
00234 
00235    static const std::wstring theInteractionFomModule;
00236    static const std::wstring theTextClassName;
00237    static const std::wstring theTextParamName;
00238    static const std::wstring theTextXParamName;
00239    static const std::wstring theTextYParamName;
00240    static const std::wstring theTextSizeParamName;
00241    static const std::wstring theTextIntervalParamName;
00242 
00243 };
00244 
00245 #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)