DEVSWrapper.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // Created by rcardenas on 3/9/20.
  3. //
  4. #ifndef DEVSTONE_ADEVS_DEVSWRAPPER_HPP
  5. #define DEVSTONE_ADEVS_DEVSWRAPPER_HPP
  6. #include "DummyAtomic.hpp"
  7. class DEVSWrapper: public adevs::Digraph<int> {
  8. private:
  9. int depth;
  10. int width;
  11. int intDelay, extDelay; // TODO include Dhrystone stuff
  12. double procTime;
  13. public:
  14. /// Model input port
  15. static const int in;
  16. /// Model output port
  17. static const int out;
  18. DEVSWrapper(int depthIn, int widthIn, int intDelayIn, int extDelayIn, double procTimeIn): adevs::Digraph<int>() {
  19. depth = depthIn;
  20. width = widthIn;
  21. intDelay = intDelayIn;
  22. extDelay = extDelayIn;
  23. procTime = procTimeIn;
  24. if (depth == 1) {
  25. DummyAtomic *a = new DummyAtomic(intDelay, extDelay, procTime);
  26. add(a);
  27. couple(this, this->in, a, a->in);
  28. couple(a, a->out, this, this->out);
  29. } else {
  30. DEVSWrapper c = generateCoupled();
  31. add(c);
  32. couple(this, this->in, c, c->in);
  33. couple(c, c->out, this, this->out);
  34. }
  35. for (int i = 0; i < width - 1; ++i) {
  36. DummyAtomic a = DummyAtomic(intDelay, extDelay, procTime);
  37. add(a);
  38. }
  39. }
  40. virtual DEVSWrapper generateCoupled();
  41. };
  42. #endif //DEVSTONE_ADEVS_DEVSWRAPPER_HPP