00001
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef FAUDES_PEXECUTOR_H
00015 #define FAUDES_PEXECUTOR_H
00016
00017 #include "definitions.h"
00018 #include "corefaudes.h"
00019 #include "tp_include.h"
00020 #include "sp_executor.h"
00021 #include "sp_simconditionset.h"
00022
00023
00024 namespace faudes {
00025
00065 class ParallelExecutor : FAUDES_TYPE {
00066
00067 public:
00069 typedef std::vector<Idx> ParallelState;
00070
00072 typedef std::vector< std::map<Idx,tpTime::Type> > ParallelClock;
00073
00075 class ParallelTimedState : FAUDES_TYPE {
00076 public:
00077 ParallelState State;
00078 ParallelClock Clock;
00079 protected:
00080 virtual void DoRead(TokenReader& rTr, const std::string& rLabel = "", const Type* pContext=0);
00081 virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
00082 };
00083
00085 typedef Executor::TimedState TimedState;
00086
00090 ParallelExecutor(void);
00091
00105 ParallelExecutor(const std::string& rFileName);
00106
00107
00111 virtual ~ParallelExecutor(void);
00112
00118 virtual void Clear(void);
00119
00124 Idx Size(void) const;
00125
00126
00142 void Insert(const std::string& rFileName);
00143
00155 void Insert(const tGenerator& rGen);
00156
00161 const EventSet& Alphabet(void) const;
00162
00166 virtual void Reset(void);
00167
00168
00169
00174 typedef std::vector<Executor>::const_iterator Iterator;
00175 Iterator Begin(void) const { return mExecutors.begin(); };
00176 Iterator End(void) const { return mExecutors.end(); };
00177 const Executor& At(int i) const { return mExecutors.at(i); };
00178
00179
00191 Idx EventIndex(const std::string& rName) const { return mAlphabet.Index(rName); };
00192
00204 std::string EventName(Idx index) const { return mAlphabet.SymbolicName(index); };
00205
00210 tpTime::Type CurrentTime(void) const;
00211
00216 int CurrentStep(void) const;
00217
00228 bool IsDeadlocked() const;
00229
00238 virtual bool Valid(void) const {return true;};
00239
00250 const ParallelTimedState& CurrentParallelTimedState(void) const;
00251
00261 const ParallelState& CurrentParallelState(void) const;
00262
00271 virtual void CurrentTime(tpTime::Type time);
00272
00284 virtual void CurrentStep(int step);
00285
00295 virtual bool CurrentParallelTimedState(const ParallelTimedState& ptstate);
00296
00306 virtual bool ExecuteTime(tpTime::Type duration);
00307
00319 virtual bool ExecuteEvent(Idx event);
00320
00327 const TimeInterval& EnabledTime() const;
00328
00339 const EventSet& EnabledEvents() const;
00340
00350 const EventSet& DisabledEvents() const;
00351
00360 const TimeInterval& EnabledInterval() const;
00361
00373 TimeInterval EnabledEventTime(Idx event) const;
00374
00386 TimeInterval EnabledGuardTime(Idx event) const;
00387
00399 EventSet ActiveEventSet(const ParallelState& stateVec) const;
00400
00415 bool Active(Idx ev, const ParallelState& stateVec) const;
00416
00429 bool Active(Idx ev) const;
00430
00434 std::string PTSStr(const ParallelTimedState& ptstate) const;
00435
00439 std::string PSStr(const ParallelState& pstate) const;
00440
00444 std::string TEStr(const TimedEvent& tevent) const;
00445
00449 std::string CStr(Idx clock) const;
00450
00454 std::string EStr(Idx event) const;
00455
00459 std::string CurrentParallelTimedStateStr(void) const;
00460
00464 std::string CurrentParallelStateStr(void) const;
00465
00468 void ComputeEnabled(void) const;
00469
00471 void ComputeEnabledNonConst(void);
00472
00473
00474
00475 protected:
00476
00492 virtual void DoRead(TokenReader& rTr, const std::string& rLabel = "", const Type* pContext=0);
00493
00508 virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="", const Type* pContext=0) const;
00509
00521 virtual void DoReadGenerators(TokenReader& rTr);
00522
00532 virtual void DoWriteGenerators(TokenWriter& rTw) const;
00533
00534
00536 virtual void Compile();
00537
00538
00540 Idx mRecentEvent;
00541
00542 private:
00543
00545 std::vector<Executor> mExecutors;
00546
00548 std::vector<std::string> mExecutorNames;
00549
00551 typedef std::vector<Executor>::iterator iterator;
00552
00554 EventSet mAlphabet;
00555
00557 tpTime::Type mCurrentTime;
00558
00560 int mCurrentStep;
00561
00563 TimeInterval mETime;
00564
00566 EventSet mEEvents;
00567
00569 EventSet mDEvents;
00570
00572 TimeInterval mEInterval;
00573
00575 bool mEValid;
00576
00578 ParallelTimedState mCurrentParallelTimedState;
00579
00581 void UpdateParallelTimedState(void);
00582
00583
00584
00585
00586 };
00587
00588
00589
00590 }
00591
00592
00593 #endif
00594