sp_executor.h

Go to the documentation of this file.
00001 
00004 /* 
00005    FAU Discrete Event Systems Library (libfaudes)
00006 
00007    Copyright (C) 2007  Ruediger Berndt
00008    Copyright (C) 2007  Thomas Moor
00009    Exclusive copyright is granted to Klaus Schmidt
00010 
00011 
00012 */
00013 
00014 
00015 
00016 #ifndef FAUDES_SP_EXECUTOR_H
00017 #define FAUDES_SP_EXECUTOR_H
00018 
00019 #include "corefaudes.h"
00020 #include "tp_include.h"
00021 
00022 
00023 // debugging: executor level
00024 #ifdef FAUDES_DEBUG_EXECUTOR
00025 #define FD_DX(message) std::cerr << "FAUDES_EXECUTOR: " << message << std::endl
00026 #else
00027 #define FD_DX(message)
00028 #endif
00029 
00030 // debugging: executor level
00031 #ifdef FAUDES_DEBUG_SIMULATOR
00032 #define FD_DS(message) std::cerr << "FAUDES_SIMULATOR: " << message << std::endl
00033 #else
00034 #define FD_DS(message)
00035 #endif
00036 
00037 // debugging: executor level
00038 #ifdef FAUDES_DEBUG_SIMULATOR_SYNC
00039 #define FD_DS_SYNC(message) std::cerr << "FAUDES_RUNSYNC: " << message << std::endl
00040 #else
00041 #define FD_DS_SYNC(message)
00042 #endif
00043 
00044 
00045 
00046 namespace faudes {
00047 
00048 
00053 typedef struct {
00054   Idx Event;
00055   tpTime::Type Time;
00056 } TimedEvent;
00057 
00086 class Executor : private tGenerator {      
00087     public:
00088            
00089 
00091     typedef struct {
00092       Idx State;                       // discrete state
00093       std::map<Idx,tpTime::Type> ClockValue; // map clockindex to value
00094     } TimedState;
00095 
00096 
00100     Executor(void);
00101 
00115     Executor(const tGenerator& rGen);
00116 
00128     Executor(const std::string& rFileName);
00129 
00141     void Read(const std::string& rFileName);
00142 
00154     void Read(TokenReader& rTr);
00155 
00165     void Write(TokenWriter& rTw) const { tGenerator::Write(rTw); };
00166 
00178     void Write(const std::string& rFileName, std::ios::openmode openmode = std::ios::out|std::ios::trunc)
00179     { tGenerator::Write(rFileName,"",0,openmode); };
00180 
00187     void Generator(const tGenerator& rGen);
00188   
00189 
00196     const tGenerator& Generator(void) const;
00197       
00202     std::string Name(void) const {return tGenerator::Name();} ;
00203 
00208     std::string StateName(Idx idx) const {return tGenerator::StateName(idx);} ;
00209 
00210   
00215     std::string EventName(Idx idx) const {return tGenerator::EventName(idx);} ;
00216 
00217   
00222     void Clear(void);
00223 
00224 
00228     void Reset();
00229 
00237     const TimeInterval& EnabledTime() const;
00238 
00245     const EventSet& EnabledEvents() const;
00246 
00253     const EventSet& DisabledEvents() const;
00254 
00261     const TimeInterval& EnabledInterval() const;
00262   
00263 
00274     TimeInterval EnabledEventTime(Idx event) const;
00275 
00276 
00287     TimeInterval EnabledGuardTime(Idx event) const;
00288 
00289 
00296     const EventSet& ActiveEventSet(void) const;
00297 
00304     const TransSet& ActiveTransSet(void) const;
00305 
00315      bool ExecuteTime(tpTime::Type time);
00316 
00326      bool ExecuteEvent(Idx event);
00327 
00337      bool CurrentTimedState(const TimedState& tstate);
00338  
00345      const TimedState& CurrentTimedState(void) const;
00346  
00357      bool CurrentState(Idx index);
00358  
00365      Idx CurrentState(void) const;
00366  
00378       bool CurrentClockValue(Idx clock, tpTime::Type time);
00379       
00388       tpTime::Type CurrentClockValue(Idx clock) const;
00389                     
00396       void CurrentTime(tpTime::Type time);
00397 
00404       tpTime::Type CurrentTime(void) const;
00405 
00412       void CurrentStep(int step);
00413 
00414     
00419       int CurrentStep(void) const;
00420 
00426       bool IsDeadlocked() const;
00427       
00428       
00436       virtual bool Valid(void) const {return true;};
00437 
00438 
00442       std::string CurrentTimedStateStr(void) const;
00443       
00447       std::string TSStr(const TimedState& tstate) const;
00448 
00452       std::string TEStr(const TimedEvent& tevent) const;
00453 
00457       std::string CStr(Idx idx) const;
00458 
00462       std::string EStr(Idx idx) const;
00463 
00467       std::string SStr(Idx idx) const;
00468 
00469 
00470  private:
00471      
00473     TimedState mCurrentTimedState;
00474 
00476     tpTime::Type mCurrentTime;
00477 
00479     int mCurrentStep;
00480 
00482     void Compile(void);
00483 
00485     void ComputeEnabled(void) const;
00486 
00488     void ComputeEnabledNonConst(void);
00489 
00491     TimeInterval mETime;
00492 
00494     EventSet mEEvents;
00495 
00497     TimeInterval mEInterval;
00498 
00500     std::map<Idx,TimeInterval> mEGuardInterval;
00501 
00503     EventSet mDEvents;
00504 
00506     EventSet mAEvents;
00507 
00509     TransSet mATrans;
00510 
00512     bool mEValid;
00513 
00515     std::map<Transition, std::map<Idx,TimeInterval> > mTransClockIntervalMap;
00516 
00518     std::map<Idx, std::map<Idx,TimeInterval> > mStateClockIntervalMap;
00519 
00520 }; // end class Executor
00521 
00522 
00523 
00524 } // namespace faudes
00525 
00526 
00527 #endif
00528 

Generated on Mon Nov 10 08:13:15 2008 for libFAUDES 2.11v by  doxygen 1.4.4