MAK RTIspy API Documentation for HLA 1516
simpleTimeFedAmb1516.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002 ** Copyright (c) 2004 MaK Technologies, Inc.
00003 ** All rights reserved.
00004 *******************************************************************************/
00005 /*******************************************************************************
00006 ** $RCSfile: simpleTimeFedAmb1516.h,v $ $Revision: 1.2 $ $State: Exp $
00007 *******************************************************************************/
00008 
00009 #ifndef MyFederateAmbassador_H_
00010 #define MyFederateAmbassador_H_
00011 
00012 #ifdef WIN32
00013 #pragma warning(disable: 4251)
00014 #pragma warning(disable: 4786)
00015 #pragma warning(disable: 4290)
00016 #endif
00017 
00018 #include <RTI/RTI1516.h>
00019 #include <RTI/NullFederateAmbassador.h>
00020 #include "simpleTimeStringUtil.h"
00021 #include "simpleTimeTimeManagedEntity.h"
00022 #include <string>
00023 #include <map>
00024 
00025 using namespace rti1516;
00026 
00027 typedef std::map<std::wstring, AttributeHandle> DtAttrNameHandleMap;
00028 typedef std::map<std::wstring, ParameterHandle> DtParamNameHandleMap;
00029 
00030 class DtTalkAmbData
00031 {
00032 
00033 public:
00034    DtTalkAmbData();
00035    ~DtTalkAmbData();
00036 
00037 
00038 public:
00039    bool myNameReservationReturned;
00040    bool myNameReservationSucceeded;
00041    std::map<ObjectClassHandle, std::wstring> objectClassMap;
00042    std::map<ObjectInstanceHandle, std::wstring> objectInstanceMap;
00043    std::map<InteractionClassHandle,std::wstring> interactionClassMap;
00044    std::map<ObjectInstanceHandle, AttributeHandleSet*> updateRequestMap;
00045 
00046    // Map between strings and attribute handles
00047    DtAttrNameHandleMap theAttrNameHandleMap;
00048 
00049    // Map between strings and paramterHandles
00050    DtParamNameHandleMap theParamNameHandleMap;
00051 
00052    // The set of Attributes that this federate's published objects will contain.
00053    std::set<std::string> ourAttrs;
00054 
00055    // the Set of Parameters that this federate's published interactions will contain.
00056    std::set<std::string> ourParms;
00057 
00058    // This federation of simple objects has a single master object, (determined by command line arguments)
00059    //  The master federate will keep the other federates from entering their main loop of execution until
00060    //  all of numFederates have joined.
00061    bool isMaster;
00062 
00063    // numFederates is the number of federates (including the master) that the master should wait to join the 
00064     //  federation before it allows any federate to enter its main loop. 
00065     // This variable is only used by the master federate.
00066    int numFederates;
00067 
00068    AttributeHandleValueMap* attrValues;
00069    ParameterHandleValueMap* paramValues;
00070    bool isConstrained;
00071    bool isRegulating;
00072    bool timeAdvanced;
00073    int otherFederatesReady;
00074    bool registerFailed;
00075    bool registerSucceeded;
00076    bool announceSyncReceived;
00077    bool federationIsSynchronized;
00078    timeManagedEntity timeManagedObject;
00079 };
00080 
00081 class MyFederateAmbassador : public NullFederateAmbassador
00082 {
00083 public:
00084 
00085    MyFederateAmbassador(DtTalkAmbData & data);
00086 
00087    virtual ~MyFederateAmbassador() 
00088      throw ();
00089 
00090     // 6.3
00091     virtual
00092     void
00093     objectInstanceNameReservationSucceeded(std::wstring const &
00094                                            theObjectInstanceName)
00095       throw (UnknownName,
00096              FederateInternalError);
00097 
00098     virtual
00099     void
00100     objectInstanceNameReservationFailed(std::wstring const &
00101                                         theObjectInstanceName)
00102       throw (UnknownName,
00103              FederateInternalError);
00104 
00105     // 6.5
00106    virtual void discoverObjectInstance (
00107       ObjectInstanceHandle theObject,
00108       ObjectClassHandle theObjectClass,
00109       std::wstring const & theObjectInstanceName)
00110       throw (
00111          CouldNotDiscover,
00112          ObjectClassNotKnown,
00113          FederateInternalError);
00114 
00115     // 6.7
00116     virtual
00117     void
00118     reflectAttributeValues
00119     (ObjectInstanceHandle theObject,
00120      AttributeHandleValueMap const & theAttributeValues,
00121      VariableLengthData const & theUserSuppliedTag,
00122      OrderType sentOrder,
00123      TransportationType theType)
00124       throw (ObjectInstanceNotKnown,
00125              AttributeNotRecognized,
00126              AttributeNotSubscribed,
00127              FederateInternalError);
00128 
00129     virtual
00130     void
00131     reflectAttributeValues
00132     (ObjectInstanceHandle theObject,
00133      AttributeHandleValueMap const & theAttributeValues,
00134      VariableLengthData const & theUserSuppliedTag,
00135      OrderType sentOrder,
00136      TransportationType theType,
00137      RegionHandleSet const & theSentRegionHandleSet)
00138       throw (ObjectInstanceNotKnown,
00139              AttributeNotRecognized,
00140              AttributeNotSubscribed,
00141              FederateInternalError);
00142 
00143     virtual
00144     void
00145     reflectAttributeValues
00146     (ObjectInstanceHandle theObject,
00147      AttributeHandleValueMap const & theAttributeValues,
00148      VariableLengthData const & theUserSuppliedTag,
00149      OrderType sentOrder,
00150      TransportationType theType,
00151      LogicalTime const & theTime,
00152      OrderType receivedOrder)
00153       throw (ObjectInstanceNotKnown,
00154              AttributeNotRecognized,
00155              AttributeNotSubscribed,
00156              FederateInternalError);
00157   
00158     virtual
00159     void
00160     reflectAttributeValues
00161     (ObjectInstanceHandle theObject,
00162      AttributeHandleValueMap const & theAttributeValues,
00163      VariableLengthData const & theUserSuppliedTag,
00164      OrderType sentOrder,
00165      TransportationType theType,
00166      LogicalTime const & theTime,
00167      OrderType receivedOrder,
00168      RegionHandleSet const & theSentRegionHandleSet)
00169       throw (ObjectInstanceNotKnown,
00170              AttributeNotRecognized,
00171              AttributeNotSubscribed,
00172              FederateInternalError);
00173   
00174     virtual
00175     void
00176     reflectAttributeValues
00177     (ObjectInstanceHandle theObject,
00178      AttributeHandleValueMap const & theAttributeValues,
00179      VariableLengthData const & theUserSuppliedTag,
00180      OrderType sentOrder,
00181      TransportationType theType,
00182      LogicalTime const & theTime,
00183      OrderType receivedOrder,
00184      MessageRetractionHandle theHandle)
00185       throw (ObjectInstanceNotKnown,
00186              AttributeNotRecognized,
00187              AttributeNotSubscribed,
00188              InvalidLogicalTime,
00189              FederateInternalError);
00190 
00191     virtual
00192     void
00193     reflectAttributeValues
00194     (ObjectInstanceHandle theObject,
00195      AttributeHandleValueMap const & theAttributeValues,
00196      VariableLengthData const & theUserSuppliedTag,
00197      OrderType sentOrder,
00198      TransportationType theType,
00199      LogicalTime const & theTime,
00200      OrderType receivedOrder,
00201      MessageRetractionHandle theHandle,
00202      RegionHandleSet const & theSentRegionHandleSet)
00203       throw (ObjectInstanceNotKnown,
00204              AttributeNotRecognized,
00205              AttributeNotSubscribed,
00206              InvalidLogicalTime,
00207              FederateInternalError);
00208 
00209 
00210     // 6.9
00211     virtual
00212     void
00213     receiveInteraction
00214     (InteractionClassHandle theInteraction,
00215      ParameterHandleValueMap const & theParameterValues,
00216      VariableLengthData const & theUserSuppliedTag,
00217      OrderType sentOrder,
00218      TransportationType theType)
00219       throw (InteractionClassNotRecognized,
00220              InteractionParameterNotRecognized,
00221              InteractionClassNotSubscribed,
00222              FederateInternalError);
00223 
00224     virtual
00225     void
00226     receiveInteraction
00227     (InteractionClassHandle theInteraction,
00228      ParameterHandleValueMap const & theParameterValues,
00229      VariableLengthData const & theUserSuppliedTag,
00230      OrderType sentOrder,
00231      TransportationType theType,
00232      RegionHandleSet const & theSentRegionHandleSet)
00233       throw (InteractionClassNotRecognized,
00234              InteractionParameterNotRecognized,
00235              InteractionClassNotSubscribed,
00236              FederateInternalError);
00237 
00238     virtual
00239     void
00240     receiveInteraction
00241     (InteractionClassHandle theInteraction,
00242      ParameterHandleValueMap const & theParameterValues,
00243      VariableLengthData const & theUserSuppliedTag,
00244      OrderType sentOrder,
00245      TransportationType theType,
00246      LogicalTime const & theTime,
00247      OrderType receivedOrder)
00248       throw (InteractionClassNotRecognized,
00249              InteractionParameterNotRecognized,
00250              InteractionClassNotSubscribed,
00251              FederateInternalError);
00252 
00253     virtual
00254     void
00255     receiveInteraction
00256     (InteractionClassHandle theInteraction,
00257      ParameterHandleValueMap const & theParameterValues,
00258      VariableLengthData const & theUserSuppliedTag,
00259      OrderType sentOrder,
00260      TransportationType theType,
00261      LogicalTime const & theTime,
00262      OrderType receivedOrder,
00263      RegionHandleSet const & theSentRegionHandleSet)
00264       throw (InteractionClassNotRecognized,
00265              InteractionParameterNotRecognized,
00266              InteractionClassNotSubscribed,
00267              FederateInternalError);
00268 
00269     virtual
00270     void
00271     receiveInteraction
00272     (InteractionClassHandle theInteraction,
00273      ParameterHandleValueMap const & theParameterValues,
00274      VariableLengthData const & theUserSuppliedTag,
00275      OrderType sentOrder,
00276      TransportationType theType,
00277      LogicalTime const & theTime,
00278      OrderType receivedOrder,
00279      MessageRetractionHandle theHandle)
00280       throw (InteractionClassNotRecognized,
00281              InteractionParameterNotRecognized,
00282              InteractionClassNotSubscribed,
00283              InvalidLogicalTime,
00284              FederateInternalError);
00285 
00286     virtual
00287     void
00288     receiveInteraction
00289     (InteractionClassHandle theInteraction,
00290      ParameterHandleValueMap const & theParameterValues,
00291      VariableLengthData const & theUserSuppliedTag,
00292      OrderType sentOrder,
00293      TransportationType theType,
00294      LogicalTime const & theTime,
00295      OrderType receivedOrder,
00296      MessageRetractionHandle theHandle,
00297      RegionHandleSet const & theSentRegionHandleSet)
00298       throw (InteractionClassNotRecognized,
00299              InteractionParameterNotRecognized,
00300              InteractionClassNotSubscribed,
00301              InvalidLogicalTime,
00302              FederateInternalError);
00303     
00304     virtual
00305     void
00306     removeObjectInstance(ObjectInstanceHandle theObject,
00307                          VariableLengthData const & theUserSuppliedTag,
00308                          OrderType sentOrder)
00309       throw (ObjectInstanceNotKnown,
00310              FederateInternalError);
00311 
00312     virtual
00313     void
00314     removeObjectInstance(ObjectInstanceHandle theObject,
00315                          VariableLengthData const & theUserSuppliedTag,
00316                          OrderType sentOrder,
00317                          LogicalTime const & theTime,
00318                          OrderType receivedOrder)
00319       throw (ObjectInstanceNotKnown,
00320              FederateInternalError);
00321 
00322     virtual
00323     void
00324     removeObjectInstance(ObjectInstanceHandle theObject,
00325                          VariableLengthData const & theUserSuppliedTag,
00326                          OrderType sentOrder,
00327                          LogicalTime const & theTime,
00328                          OrderType receivedOrder,
00329                          MessageRetractionHandle theHandle)
00330       throw (ObjectInstanceNotKnown,
00331              InvalidLogicalTime,
00332              FederateInternalError);
00333   
00334     virtual
00335     void
00336     provideAttributeValueUpdate(ObjectInstanceHandle theObject,
00337      AttributeHandleSet const & theAttributes,
00338      VariableLengthData const & theUserSuppliedTag)
00339       throw (ObjectInstanceNotKnown,
00340              AttributeNotRecognized,
00341              AttributeNotOwned,
00342              FederateInternalError);
00343 
00344     virtual
00345     void
00346     timeRegulationEnabled(LogicalTime const & theFederateTime)
00347       throw (InvalidLogicalTime,
00348              NoRequestToEnableTimeRegulationWasPending,
00349              FederateInternalError);
00350 
00351     
00352     virtual
00353     void
00354     timeConstrainedEnabled(LogicalTime const & theFederateTime)
00355       throw (InvalidLogicalTime,
00356              NoRequestToEnableTimeConstrainedWasPending,
00357              FederateInternalError);
00358     
00359     virtual
00360     void
00361     timeAdvanceGrant(LogicalTime const & theTime)
00362       throw (InvalidLogicalTime,
00363              JoinedFederateIsNotInTimeAdvancingState,
00364              FederateInternalError);
00365     
00366     virtual
00367     void
00368     requestRetraction(MessageRetractionHandle theHandle)
00369       throw (FederateInternalError);
00370 
00371 
00372     virtual
00373     void
00374     synchronizationPointRegistrationSucceeded(std::wstring const & label )
00375       throw (FederateInternalError);
00376     virtual
00377     void
00378     synchronizationPointRegistrationFailed(std::wstring const & label,
00379                                            SynchronizationFailureReason reason)
00380       throw (FederateInternalError);
00381 
00382     virtual
00383     void
00384     announceSynchronizationPoint(std::wstring  const & label,
00385                                  VariableLengthData const & theUserSuppliedTag)
00386       throw (FederateInternalError);
00387 
00388     virtual
00389     void
00390     federationSynchronized(std::wstring const & label)
00391       throw (FederateInternalError);
00392 
00393 
00394 public:
00395    DtTalkAmbData & myData;
00396 };
00397 
00398 #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)