GraphManager.hpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /**
  2. * @file kernel/qss/GraphManager.hpp
  3. * @author The ARTIS Development Team
  4. * See the AUTHORS or Authors.txt file
  5. */
  6. /*
  7. * ARTIS - the multimodeling and simulation environment
  8. * This file is a part of the ARTIS environment
  9. *
  10. * Copyright (C) 2013-2019 ULCO http://www.univ-littoral.fr
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation, either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. #ifndef QSS_GRAPH_MANAGER
  26. #define QSS_GRAPH_MANAGER
  27. #include <artis-star/kernel/pdevs/GraphManager.hpp>
  28. #include <artis-star/kernel/qss/Derivative.hpp>
  29. #include <artis-star/kernel/qss/Integrator.hpp>
  30. #include <artis-star/kernel/qss/Quantifier.hpp>
  31. namespace artis {
  32. namespace qss {
  33. template<class DerivativeParameters>
  34. struct QSSParameters
  35. {
  36. artis::qss::IntegratorParameters integrator;
  37. artis::qss::QuantifierParameters quantifier;
  38. DerivativeParameters derivative;
  39. };
  40. template<class Time,
  41. class Derivative,
  42. class DerivativeParameters = artis::common::NoParameters>
  43. class GraphManager :
  44. public artis::pdevs::GraphManager<Time,
  45. QSSParameters<DerivativeParameters>,
  46. artis::common::NoParameters>
  47. {
  48. public:
  49. struct submodel
  50. {
  51. enum values
  52. {
  53. S_Derivative, S_Integrator, S_Quantifier
  54. };
  55. };
  56. struct input
  57. {
  58. enum values
  59. {
  60. RESET
  61. };
  62. };
  63. struct output
  64. {
  65. enum values
  66. {
  67. OUT
  68. };
  69. };
  70. GraphManager(common::Coordinator <Time> *coordinator,
  71. const QSSParameters<DerivativeParameters> &parameters,
  72. const artis::common::NoParameters &graph_parameters)
  73. :
  74. artis::pdevs::GraphManager<Time,
  75. QSSParameters<DerivativeParameters>,
  76. artis::common::NoParameters>(
  77. coordinator,
  78. parameters,
  79. graph_parameters
  80. ),
  81. _derivative("d", parameters.derivative),
  82. _integrator("i", parameters.integrator),
  83. _quantifier("q", parameters.quantifier)
  84. {
  85. this->add_child(submodel::S_Derivative, &_derivative);
  86. this->add_child(submodel::S_Integrator, &_integrator);
  87. this->add_child(submodel::S_Quantifier, &_quantifier);
  88. coordinator->input_port({input::RESET, "reset"});
  89. coordinator->output_port({output::OUT, "out"});
  90. this->in({coordinator, input::RESET})
  91. >> this->in({&_derivative, Derivative::input::RESET});
  92. this->in({coordinator, input::RESET})
  93. >> this->in({&_integrator, Integrator<Time>::input::RESET});
  94. this->in({coordinator, input::RESET})
  95. >> this->in({&_quantifier, Quantifier<Time>::input::RESET});
  96. this->out({&_derivative, Derivative::output::OUT})
  97. >> this->in({&_integrator, Integrator<Time>::input::X_DOT});
  98. this->out({&_integrator, Integrator<Time>::output::OUT})
  99. >> this->in({&_quantifier, Quantifier<Time>::input::IN});
  100. this->out({&_quantifier, Quantifier<Time>::output::OUT})
  101. >> this->in({&_integrator, Integrator<Time>::input::QUANTA});
  102. this->out({&_integrator, Integrator<Time>::output::OUT})
  103. >> this->out({coordinator, output::OUT});
  104. this->out({&_integrator, Integrator<Time>::output::OUT})
  105. >> this->in({&_derivative, Derivative::input::IN});
  106. }
  107. ~GraphManager() override = default;
  108. artis::pdevs::Simulator<Time, Derivative, DerivativeParameters> *
  109. derivative()
  110. { return &_derivative; }
  111. private:
  112. artis::pdevs::Simulator<Time, Derivative, DerivativeParameters> _derivative;
  113. artis::pdevs::Simulator<Time, artis::qss::Integrator<Time>, artis::qss::IntegratorParameters>
  114. _integrator;
  115. artis::pdevs::Simulator<Time, artis::qss::Quantifier<Time>, artis::qss::QuantifierParameters>
  116. _quantifier;
  117. };
  118. }
  119. }
  120. #endif