TimeManagement.hh

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 // CERTI - HLA RunTime Infrastructure
00003 // Copyright (C) 2002-2005  ONERA
00004 //
00005 // This file is part of CERTI
00006 //
00007 // CERTI is free software ; you can redistribute it and/or modify
00008 // it under the terms of the GNU General Public License as published by
00009 // the Free Software Foundation ; either version 2 of the License, or
00010 // (at your option) any later version.
00011 //
00012 // CERTI is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY ; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with this program ; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00020 //
00021 // $Id: TimeManagement.hh,v 3.19 2009/04/08 10:47:18 approx Exp $
00022 // ----------------------------------------------------------------------------
00023 
00024 #ifndef CERTI_RTIA_TIME_MANAGEMENT_HH
00025 #define CERTI_RTIA_TIME_MANAGEMENT_HH
00026 
00027 // Project
00028 #include "certi.hh"
00029 #include "Communications.hh"
00030 #include "FederationManagement.hh"
00031 #include "DeclarationManagement.hh"
00032 #include "ObjectManagement.hh"
00033 #include "OwnershipManagement.hh"
00034 #include "Files.hh"
00035 #include "LBTS.hh"
00036 #include "Message.hh"
00037 #include "Communications.hh"
00038 #include "PrettyDebug.hh"
00039 
00040 // Standard libraries
00041 #ifdef _WIN32
00042 #include <windows.h>
00043 #else
00044 #include <iostream>
00045 #include <sys/types.h>
00046 #include <sys/stat.h>
00047 #include <unistd.h>
00048 #include <stdlib.h>
00049 #endif
00050 
00051 using std::cout ;
00052 using std::endl ;
00053 
00054 namespace certi {
00055 namespace rtia {
00056 
00057 class OwnershipManagement ;
00058 
00059 typedef enum {
00060     PAS_D_AVANCEE=1,
00061     TAR, // TimeAdvanceRequest
00062     NER, // NextEventRequest
00063     TARA, // TimeAdvanceRequestAvailable
00064     NERA // NextEventRequestAvailable
00065 } TypeAvancee ;
00066 
00067 typedef enum {
00068     AFTER_TAR_OR_NER=1,
00069     AFTER_TAR_OR_NER_WITH_ZERO_LK,
00070     AFTER_TARA_OR_NERA
00071 } TypeGrantedState ;
00072 
00073 class TimeManagement : public LBTS
00074 {
00075 public:
00076     TimeManagement(Communications *,
00077                    Queues*,
00078                    FederationManagement *,
00079            DeclarationManagement *,
00080                    ObjectManagement *,
00081                    OwnershipManagement *);
00082 
00083 
00084     // Advance Time Methods
00085     void nextEventRequest(FederationTime heure_logique, TypeException &e);
00086     void nextEventRequestAvailable(FederationTime heure_logique, TypeException &e);
00087     bool tick(TypeException &e);
00088     void timeAdvanceRequest(FederationTime heure_logique, TypeException &e);
00089     void timeAdvanceRequestAvailable(FederationTime heure_logique, TypeException &e);
00090     bool testValidTime(FederationTime theTime);
00091 
00092     // Change Federate Time State
00093     void setLookahead(FederationTimeDelta lookahead, TypeException &e);
00094     void setTimeConstrained(bool etat, TypeException &e);
00095     void setTimeRegulating(bool etat,FederationTime heure_logique,
00096                            FederationTimeDelta lookahead, TypeException &e);
00097     void StopperAvanceTemps() {
00098         _avancee_en_cours = PAS_D_AVANCEE ;
00099     };
00100 
00101     // Request Attribute Methods
00102     FederationTime requestFederationTime();
00103     FederationTime requestFederateTime() { return(_heure_courante); };
00104     FederationTimeDelta requestLookahead();
00105     FederationTime requestMinNextEventTime();
00106     FederationTime requestLBTS() { return _LBTS ; };
00107     bool requestContraintState() { return _est_contraint ; };
00108     bool requestRegulateurState() { return _est_regulateur ; };
00109 
00110     // Attribute
00111     enum {
00112         NO_TICK,
00113         TICK_BLOCKING,
00114         TICK_NEXT,
00115         TICK_CALLBACK,
00116         TICK_RETURN
00117     } _tick_state;
00118     bool _tick_multiple;  // process multiple callbacks
00119     bool _tick_result;  // tick() return value
00120     RTI::TickTime _tick_timeout;
00121     RTI::TickTime _tick_stop_time;
00122     bool _asynchronous_delivery ;
00123 
00124 private:
00125     // Methods
00126     void advance(bool &msg_restant, TypeException &e);
00127     void timeAdvance(bool &msg_restant, TypeException &e);
00128     void nextEventAdvance(bool &msg_restant, TypeException &e);
00129     void timeAdvanceGrant(FederationTime, TypeException &);
00130     void flushQueueRequest(FederationTime, TypeException &);
00131     bool executeFederateService(NetworkMessage &msg);
00132     void sendNullMessage(FederationTime heure_logique);
00133     void timeRegulationEnabled(FederationTime, TypeException &e);
00134     void timeConstrainedEnabled(FederationTime, TypeException &e);
00135 
00136     // Other RTIA Objects
00137     Communications *comm ;
00138     Queues *queues ;
00139     FederationManagement *fm ;
00140     DeclarationManagement *dm ;
00141     ObjectManagement *om ;
00142     OwnershipManagement *owm ;
00143 
00145     FederationTime lastNullMessageDate ;
00146 
00148     TypeAvancee _avancee_en_cours ;
00149     FederationTime date_avancee ;
00150     TypeGrantedState _type_granted_state ; 
00151 
00152     // Federate Data
00153     FederationTime _heure_courante ;
00154     FederationTimeDelta _lookahead_courant ;
00155     bool _est_regulateur ;
00156     bool _est_contraint ;
00157 
00158 };
00159 
00160 }} // namespace certi/rtia
00161 
00162 #endif // CERTI_RTIA_TIME_MANAGEMENT_HH
00163 
00164 // $Id: TimeManagement.hh,v 3.19 2009/04/08 10:47:18 approx Exp $

Generated on Thu Apr 30 15:53:50 2009 for CERTIDeveloperDocumentation by doxygen 1.5.5