sc_runner_timed.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Timer Service for SCTUnit
  3. */
  4. #ifndef SC_TIMER_SERVICE_H_
  5. #define SC_TIMER_SERVICE_H_
  6. #include <list>
  7. #include "sc_types.h"
  8. #include "StatemachineInterface.h"
  9. #include "TimedStatemachineInterface.h"
  10. #include "TimerInterface.h"
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. class TimedSctUnitRunner : public TimerInterface {
  15. public:
  16. TimedSctUnitRunner(StatemachineInterface * statemachine, bool event_driven, sc_integer cycle_period);
  17. virtual ~TimedSctUnitRunner(){};
  18. void proceed_time(sc_integer time_ms);
  19. void proceed_cycles(sc_integer cycles);
  20. virtual void setTimer(TimedStatemachineInterface* statemachine, sc_eventid event, sc_integer time_ms, sc_boolean isPeriodic);
  21. virtual void unsetTimer(TimedStatemachineInterface* statemachine, sc_eventid event);
  22. virtual void cancel();
  23. private:
  24. class SctTimer;
  25. StatemachineInterface * statemachine;
  26. bool event_driven;
  27. sc_integer cycle_period;
  28. sc_integer current_time_ms;
  29. std::list<SctTimer> timer_queue;
  30. void insert_timer(SctTimer timer);
  31. };
  32. class TimedSctUnitRunner::SctTimer {
  33. friend class TimedSctUnitRunner;
  34. public:
  35. SctTimer(sc_integer time_ms, bool periodic, sc_eventid evid, sc_integer priority, sc_boolean is_runcycle);
  36. ~SctTimer(){}
  37. sc_integer compare(SctTimer * other);
  38. private:
  39. sc_integer rel_time_ms;
  40. sc_integer abs_time_ms;
  41. sc_boolean periodic;
  42. sc_eventid pt_evid;
  43. sc_integer priority;
  44. sc_boolean is_runcycle;
  45. };
  46. #ifdef __cplusplus
  47. }
  48. #endif
  49. #endif /* SC_TIMER_SERVICE_H_ */