MAK RTIspy API Documentation for HLA 1.3
simpleDDMSimple13dlc.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 2009 MaK Technologies, Inc.
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 /******************************************************************************
00006 ** $RCSfile: simpleDDMSimple13dlc.h,v $ $Revision: 1.1 $ $State: Exp $
00007 ******************************************************************************/
00008 
00009 #ifndef REGIONEXAMPLE13_H_
00010 #define REGIONEXAMPLE13_H_
00011 
00012 // A wrapper around the RTI Ambassador calls that incorporates
00013 // Data Distribution Management (DDM).
00014 // The typical calls are supported such as create/destroy, join/resign,
00015 // publish/subscribe, register/delete object, update object, and send interaction.
00016 // The DDM calls to create and maintain regions are also supported and regions
00017 // are used with the other services where appropriate.
00018 
00019 #include "simpleDDMFederate.h"
00020 #include <string.h>
00021 #include "RTI13.h"
00022 #include "simpleDDMFedAmb13dlc.h"
00023 
00024 // Map between strings and attribute handles
00025 typedef std::map<std::string, AttributeHandle>  DtAttrNameHandleMap;
00026 // Map between strings and parameter handles
00027 typedef std::map<std::string, ParameterHandle>  DtParamNameHandleMap;
00028 
00029 using namespace rti13;
00030 
00031 class simpleDDMFederate13 : public simpleDDMFederate
00032 {
00033 public:
00034 
00036 // Default Constructor
00038    simpleDDMFederate13();
00039 
00041 // Constructor
00043    simpleDDMFederate13(simpleDDMFederate13& data);
00044 
00046 // Destructor
00048    ~simpleDDMFederate13();
00049 
00050 // RTI Wrappers
00051 
00053 // Initialize the RTI
00055    void initializeRTI();
00056 
00058 // Create a federation execution
00060    bool createFedEx();
00061 
00063 // Join a federation execution
00065    bool joinFedEx();
00066 
00068 // Resign from the federation execution and destroy it
00070    void resignAndDestroy();
00071 
00073 // Create the Region and initialize its bounds
00075    bool createAndInitializeRegions();
00076 
00078 // Publish and subscribe the object class attributes.
00079 // Register an object instance of the class.
00081    bool publishSubscribeAndRegisterObject();
00082 
00084 // Publish and Subscribe to an interaction class
00086    bool publishAndSubscribeInteraction();
00087 
00089 // Send the default update with Region.  A less simple federate would have to
00090 // specify which attributes need be updated.  This on merely passes in the
00091 // position which is sent with Region as the object update.
00093    void sendUpdate(int currentPosition );
00094 
00096 // Send Interactions with Region.  The following two interactions are meant to
00097 // emulate a cuckoo clock with both an hourly chime, and a quarterly chime.
00099 
00101 // Send the hourly interaction with Region. This is an interaction that in this
00102 // example occurs for each hour that is passed on the clock that is not
00103 // {12,3,6,9}.
00105    void sendInteraction_hourly();
00106 
00108 // Send the quarterly interaction with Region.  This is an interaction that in
00109 // this example occurs for each hour that is passed on the clock that is in the
00110 // following set {12,3,6,9}
00112    void sendInteraction_quarterly();
00113 
00115 // Perform the tick or evokeCallback method.
00117    void tick(double atMost=0.0f);
00118 
00120 // Perform the tick or evokeCallback method.
00122    void tick(double atLeast, double atMost);
00123 
00125 // changeBounds sets the subscription of publication bounds of this federate.
00127    void changeBounds(int lower, int upper, int UTCZone) ;
00128 
00130 // Set the RTI's enable advisory switch
00132    void setEnableScopeAdvisories(bool yesNo);
00133 
00134    // Simulation Methods
00135 
00137 // Set federate as publisher (true) or subscriber (false)
00139    void setIsPublisher(bool yesNo);
00140 
00142 // Get the position (number of seconds)
00144    int  position();
00145 
00147 // Set the position (number of seconds)   
00149    void setPosition(int data);
00150    
00152 // Set the Fed File Name
00154    void setFedFileName(const char* newFedName);
00155 
00157 // Set the Fed File Name
00159 void setFedFileName(const wchar_t* newFedName);
00160    
00162 // Get the Fed File Name
00164 char* getFedFileName() const;
00165 
00166    
00167 protected:
00168 
00169    // Map between strings and attribute handles
00170    DtAttrNameHandleMap myAttrNameHandleMap;
00171 
00172    // Map between strings and parameter handles
00173    DtParamNameHandleMap myParamNameHandleMap;
00174 
00175    static const unsigned int myNumAttributes;
00176    static const unsigned long myNumExtents;
00177 
00178    // Array of attributeHandles.
00179    AttributeHandle* myAttrHandlesArray;
00180 
00181    AttributeHandleSet* myAttrHandlesSet;
00182 
00183    AttributeHandleValuePairSet *myAttrValues;
00184 
00185    // Data shared between federate and federate ambassador
00186    DtTalkAmbData myAmbData;
00187 
00188 private:
00189    // Federate and Federation info
00190    std::string myFederationName;
00191    std::string myFederationFile;
00192    std::string myFederateType;
00193 
00194    // An interaction published at {1, 2, 4, 5, 7, 8, 10 , 11}
00195    std::string myHourlyInteraction;
00196 
00197    // An interaction published at {3,6,9,12}
00198    std::string myQuarterlyInteraction;
00199 
00200    // The interaction class name
00201    std::string myInterClassName;
00202 
00203    // The object class name
00204    std::string myClassName;
00205 
00206    // The attribute name
00207    std::string myAttrName;
00208 
00209    // The number of dimensions
00210    unsigned int myNumberOfDimensions;
00211 
00212    // The RTI Ambassador
00213    RTIambassador* myRTIamb;
00214 
00215    // The Federate Ambassador
00216    MyFederateAmbassador* myFedAmb;
00217 
00218    // the Handle for the hourlyInteraction, (to be retrieved from RTI).
00219    ParameterHandle myHourlyHandle;
00220 
00221    // the Handle for the quarterlyInteraction, (to be retrieved from RTI).
00222    ParameterHandle myQuarterlyHandle;
00223 
00224 
00225    // Construct a parameter handle value pair set with the
00226    // values containing the parameter names
00227    ParameterHandleValuePairSet* myParamValues;
00228 
00229    // The name of the dimension is specified in your FED file.
00230    std::string mySecondsDimensionName;
00231 
00232    // The time zone dimension name
00233    std::string myUTCDimensionName;
00234 
00235    // The routing space name
00236    std::string mySpaceName;
00237 
00238    // The object class handle (to be retrieved from RTI).
00239    ObjectClassHandle myClassHandle;
00240 
00241    //The object instance handle ( to be retrieved from the rti).
00242    ObjectHandle myObjectHandle;
00243 
00244    // The interaction class handle (to be retrieved from RTI).
00245    InteractionClassHandle myInterClassHandle;
00246 
00247    // The Seconds dimension handle (to be retrieved from the RTI).
00248    DimensionHandle mySecondsDimHandle;
00249 
00250    // The UTC dimension handle (to be retrieved from the RTI).
00251    DimensionHandle myUTCDimHandle;
00252 
00253    // The listen region
00254    Region* myListenRegion;
00255 
00256    // The publish region
00257    Region* mySendRegion;
00258 
00259 
00260 };
00261 
00262 inline void simpleDDMFederate13::setIsPublisher(bool yesNo)
00263 {
00264    myIsPublisher = yesNo;
00265    myAmbData.isPublisher = yesNo;
00266 }
00267 
00268 inline void simpleDDMFederate13::setEnableScopeAdvisories(bool yesNo)
00269 {
00270    myEnableScopeAdvisories = yesNo;
00271    myAmbData.enableScopeAdvisories = yesNo;
00272 }
00273 
00274 inline int simpleDDMFederate13::position()
00275 {
00276    if (!isPublisher())
00277       myCurrentposition = myAmbData.position;
00278    return myCurrentposition;
00279 }
00280 
00281 inline void simpleDDMFederate13::setFedFileName(const char* newFedName)
00282 {
00283    myFederationFile = std::string(newFedName);
00284 }
00285 
00286 inline void simpleDDMFederate13::setFedFileName(const wchar_t* newFedName)
00287 {
00288    myFederationFile = DtToString(std::wstring(newFedName));
00289 }
00290 
00291 inline char* simpleDDMFederate13::getFedFileName() const 
00292 {
00293    return strdup(myFederationFile.c_str());
00294 }
00295 
00296 
00297 
00298 #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)