GraphManager.hpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /**
  2. * @file 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-2023 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 ARTIS_STAR_ADDONS_QSS_GRAPH_MANAGER
  26. #define ARTIS_STAR_ADDONS_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::addons::qss {
  32. template<class DerivativeParameters>
  33. struct QSSParameters
  34. {
  35. artis::qss::IntegratorParameters integrator;
  36. artis::qss::QuantifierParameters quantifier;
  37. DerivativeParameters derivative;
  38. };
  39. template<class Time,
  40. class Derivative,
  41. class DerivativeParameters = artis::common::NoParameters>
  42. class GraphManager :
  43. public artis::pdevs::GraphManager<Time,
  44. QSSParameters<DerivativeParameters>,
  45. artis::common::NoParameters>
  46. {
  47. public:
  48. struct submodel
  49. {
  50. enum values
  51. {
  52. S_Derivative, S_Integrator, S_Quantifier
  53. };
  54. };
  55. struct input
  56. {
  57. enum values
  58. {
  59. RESET
  60. };
  61. };
  62. struct output
  63. {
  64. enum values
  65. {
  66. OUT
  67. };
  68. };
  69. GraphManager(common::Coordinator <Time> *coordinator,
  70. const QSSParameters<DerivativeParameters> &parameters,
  71. const artis::common::NoParameters &graph_parameters)
  72. :
  73. artis::pdevs::GraphManager<Time,
  74. QSSParameters<DerivativeParameters>,
  75. artis::common::NoParameters>(
  76. coordinator,
  77. parameters,
  78. graph_parameters
  79. ),
  80. _derivative("d", parameters.derivative),
  81. _integrator("i", parameters.integrator),
  82. _quantifier("q", parameters.quantifier)
  83. {
  84. this->add_child(submodel::S_Derivative, &_derivative);
  85. this->add_child(submodel::S_Integrator, &_integrator);
  86. this->add_child(submodel::S_Quantifier, &_quantifier);
  87. coordinator->input_port({input::RESET, "reset"});
  88. coordinator->output_port({output::OUT, "out"});
  89. this->in({coordinator, input::RESET})
  90. >> this->in({&_derivative, Derivative::input::RESET});
  91. this->in({coordinator, input::RESET})
  92. >> this->in({&_integrator, Integrator<Time>::input::RESET});
  93. this->in({coordinator, input::RESET})
  94. >> this->in({&_quantifier, Quantifier<Time>::input::RESET});
  95. this->out({&_derivative, Derivative::output::OUT})
  96. >> this->in({&_integrator, Integrator<Time>::input::X_DOT});
  97. this->out({&_integrator, Integrator<Time>::output::OUT})
  98. >> this->in({&_quantifier, Quantifier<Time>::input::IN});
  99. this->out({&_quantifier, Quantifier<Time>::output::OUT})
  100. >> this->in({&_integrator, Integrator<Time>::input::QUANTA});
  101. this->out({&_integrator, Integrator<Time>::output::OUT})
  102. >> this->out({coordinator, output::OUT});
  103. this->out({&_integrator, Integrator<Time>::output::OUT})
  104. >> this->in({&_derivative, Derivative::input::IN});
  105. }
  106. ~GraphManager() override = default;
  107. artis::pdevs::Simulator<Time, Derivative, DerivativeParameters> *
  108. derivative()
  109. { return &_derivative; }
  110. private:
  111. artis::pdevs::Simulator<Time, Derivative, DerivativeParameters> _derivative;
  112. artis::pdevs::Simulator<Time, artis::qss::Integrator<Time>, artis::qss::IntegratorParameters>
  113. _integrator;
  114. artis::pdevs::Simulator<Time, artis::qss::Quantifier<Time>, artis::qss::QuantifierParameters>
  115. _quantifier;
  116. };
  117. }
  118. #endif