GraphManager.hpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /**
  2. * @file kernel/pdevs/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. 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, QSSParameters<DerivativeParameters>, artis::common::NoParameters> {
  44. public:
  45. enum submodels {
  46. S_Derivative, S_Integrator, S_Quantifier
  47. };
  48. enum inputs {
  49. RESET
  50. };
  51. enum outputs {
  52. OUT
  53. };
  54. GraphManager(common::Coordinator<Time>* coordinator,
  55. const QSSParameters<DerivativeParameters>& parameters,
  56. const artis::common::NoParameters& graph_parameters)
  57. :
  58. artis::pdevs::GraphManager<Time, QSSParameters<DerivativeParameters>, artis::common::NoParameters>(
  59. coordinator,
  60. parameters,
  61. graph_parameters
  62. ),
  63. _derivative("d", parameters.derivative),
  64. _integrator("i", parameters.integrator),
  65. _quantifier("q", parameters.quantifier)
  66. {
  67. this->add_child(S_Derivative, &_derivative);
  68. this->add_child(S_Integrator, &_integrator);
  69. this->add_child(S_Quantifier, &_quantifier);
  70. coordinator->input_port({RESET, "reset"});
  71. coordinator->output_port({OUT, "out"});
  72. this->in({coordinator, RESET})
  73. >> this->in({&_derivative, Derivative::RESET});
  74. this->in({coordinator, RESET})
  75. >> this->in({&_integrator, Integrator<Time>::RESET});
  76. this->in({coordinator, RESET})
  77. >> this->in({&_quantifier, Quantifier<Time>::RESET});
  78. this->out({&_derivative, Derivative::OUT})
  79. >> this->in({&_integrator, Integrator<Time>::X_DOT});
  80. this->out({&_integrator, Integrator<Time>::OUT})
  81. >> this->in({&_quantifier, Quantifier<Time>::IN});
  82. this->out({&_quantifier, Quantifier<Time>::OUT})
  83. >> this->in({&_integrator, Integrator<Time>::QUANTA});
  84. this->out({&_integrator, Integrator<Time>::OUT})
  85. >> this->out({coordinator, OUT});
  86. this->out({&_integrator, Integrator<Time>::OUT})
  87. >> this->in({&_derivative, Derivative::IN});
  88. }
  89. ~GraphManager() override = default;
  90. artis::pdevs::Simulator<Time, Derivative, DerivativeParameters>*
  91. derivative() { return &_derivative; }
  92. private:
  93. artis::pdevs::Simulator<Time, Derivative, DerivativeParameters> _derivative;
  94. artis::pdevs::Simulator<Time, artis::qss::Integrator<Time>, artis::qss::IntegratorParameters> _integrator;
  95. artis::pdevs::Simulator<Time, artis::qss::Quantifier<Time>, artis::qss::QuantifierParameters> _quantifier;
  96. };
  97. }
  98. }
  99. #endif