|
@@ -0,0 +1,191 @@
|
|
|
|
+/**
|
|
|
|
+ * @file tests/qss/graph_manager.cpp
|
|
|
|
+ * @author The ARTIS Development Team
|
|
|
|
+ * See the AUTHORS or Authors.txt file
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * ARTIS - the multimodeling and simulation environment
|
|
|
|
+ * This file is a part of the ARTIS environment
|
|
|
|
+ *
|
|
|
|
+ * Copyright (C) 2013-2019 ULCO http://www.univ-littoral.fr
|
|
|
|
+ *
|
|
|
|
+ * This program is free software: you can redistribute it and/or modify
|
|
|
|
+ * it under the terms of the GNU General Public License as published by
|
|
|
|
+ * the Free Software Foundation, either version 3 of the License, or
|
|
|
|
+ * (at your option) any later version.
|
|
|
|
+ *
|
|
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
+ * GNU General Public License for more details.
|
|
|
|
+ *
|
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
|
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+#ifndef TESTS_QSS_GRAPH_MANAGER_HPP
|
|
|
|
+#define TESTS_QSS_GRAPH_MANAGER_HPP 1
|
|
|
|
+
|
|
|
|
+#include <tests/qss/models.hpp>
|
|
|
|
+
|
|
|
|
+#include <artis-star/kernel/pdevs/Coordinator.hpp>
|
|
|
|
+#include <artis-star/kernel/pdevs/qss/GraphManager.hpp>
|
|
|
|
+
|
|
|
|
+namespace artis {
|
|
|
|
+ namespace tests {
|
|
|
|
+ namespace qss {
|
|
|
|
+
|
|
|
|
+ class ConstantGraphManager :
|
|
|
|
+ public artis::pdevs::qss::GraphManager<common::DoubleTime, Constant> {
|
|
|
|
+ public:
|
|
|
|
+ ConstantGraphManager(common::Coordinator<common::DoubleTime>* coordinator,
|
|
|
|
+ const artis::pdevs::qss::QSSParameters<artis::common::NoParameters>& parameters,
|
|
|
|
+ const artis::common::NoParameters& graph_parameters)
|
|
|
|
+ :
|
|
|
|
+ artis::pdevs::qss::GraphManager<common::DoubleTime, Constant>(coordinator,
|
|
|
|
+ parameters, graph_parameters) { }
|
|
|
|
+
|
|
|
|
+ ~ConstantGraphManager() override = default;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ class OnlyOneGraphManager :
|
|
|
|
+ public artis::pdevs::qss::GraphManager<common::DoubleTime, Constant> {
|
|
|
|
+ public:
|
|
|
|
+ enum submodels {
|
|
|
|
+ A
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ OnlyOneGraphManager(common::Coordinator<common::DoubleTime>* coordinator,
|
|
|
|
+ const artis::pdevs::qss::QSSParameters<artis::common::NoParameters>& parameters,
|
|
|
|
+ const artis::common::NoParameters& graph_parameters)
|
|
|
|
+ :
|
|
|
|
+ artis::pdevs::qss::GraphManager<common::DoubleTime, Constant>(coordinator,
|
|
|
|
+ parameters, graph_parameters),
|
|
|
|
+ S("a", parameters, graph_parameters)
|
|
|
|
+ {
|
|
|
|
+ add_child(A, &S);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ~OnlyOneGraphManager() override = default;
|
|
|
|
+
|
|
|
|
+ private:
|
|
|
|
+ artis::pdevs::Coordinator<common::DoubleTime, ConstantGraphManager, artis::pdevs::qss::QSSParameters<artis::common::NoParameters>> S;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ class ParabolaGraphManager :
|
|
|
|
+ public artis::pdevs::qss::GraphManager<common::DoubleTime, Parabola, ParabolaParameters> {
|
|
|
|
+ public:
|
|
|
|
+ ParabolaGraphManager(common::Coordinator<common::DoubleTime>* coordinator,
|
|
|
|
+ const artis::pdevs::qss::QSSParameters<ParabolaParameters>& parameters,
|
|
|
|
+ const artis::common::NoParameters& graph_parameters)
|
|
|
|
+ :
|
|
|
|
+ artis::pdevs::qss::GraphManager<common::DoubleTime, Parabola, ParabolaParameters>(
|
|
|
|
+ coordinator, parameters, graph_parameters) { }
|
|
|
|
+
|
|
|
|
+ ~ParabolaGraphManager() override = default;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ class OnlyOneParabolaGraphManager :
|
|
|
|
+ public artis::pdevs::GraphManager<common::DoubleTime, artis::pdevs::qss::QSSParameters<ParabolaParameters>> {
|
|
|
|
+ public:
|
|
|
|
+ enum submodels {
|
|
|
|
+ A
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ OnlyOneParabolaGraphManager(common::Coordinator<common::DoubleTime>* coordinator,
|
|
|
|
+ const artis::pdevs::qss::QSSParameters<ParabolaParameters>& parameters,
|
|
|
|
+ const artis::common::NoParameters& graph_parameters)
|
|
|
|
+ :
|
|
|
|
+ artis::pdevs::GraphManager<common::DoubleTime, artis::pdevs::qss::QSSParameters<ParabolaParameters>>(
|
|
|
|
+ coordinator, parameters, graph_parameters),
|
|
|
|
+ S("a", parameters, graph_parameters)
|
|
|
|
+ {
|
|
|
|
+ add_child(A, &S);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ~OnlyOneParabolaGraphManager() override = default;
|
|
|
|
+
|
|
|
|
+ private:
|
|
|
|
+ artis::pdevs::Coordinator<common::DoubleTime, ParabolaGraphManager, artis::pdevs::qss::QSSParameters<ParabolaParameters>> S;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ class PredatorGraphManager :
|
|
|
|
+ public artis::pdevs::qss::GraphManager<common::DoubleTime, Predator, PreyPredatorParameters> {
|
|
|
|
+ public:
|
|
|
|
+ enum inputs {
|
|
|
|
+ IN_X
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ PredatorGraphManager(common::Coordinator<common::DoubleTime>* coordinator,
|
|
|
|
+ const artis::pdevs::qss::QSSParameters<PreyPredatorParameters>& parameters,
|
|
|
|
+ const artis::common::NoParameters& graph_parameters)
|
|
|
|
+ :
|
|
|
|
+ artis::pdevs::qss::GraphManager<common::DoubleTime, Predator, PreyPredatorParameters>(
|
|
|
|
+ coordinator, parameters, graph_parameters) {
|
|
|
|
+ coordinator->input_port({IN_X, "in_x"});
|
|
|
|
+ in({coordinator, IN_X}) >> in({derivative(), Predator::IN_X});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ~PredatorGraphManager() override = default;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ class PreyGraphManager :
|
|
|
|
+ public artis::pdevs::qss::GraphManager<common::DoubleTime, Prey, PreyPredatorParameters> {
|
|
|
|
+ public:
|
|
|
|
+ enum inputs {
|
|
|
|
+ IN_Y
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ PreyGraphManager(common::Coordinator<common::DoubleTime>* coordinator,
|
|
|
|
+ const artis::pdevs::qss::QSSParameters<PreyPredatorParameters>& parameters,
|
|
|
|
+ const artis::common::NoParameters& graph_parameters)
|
|
|
|
+ :
|
|
|
|
+ artis::pdevs::qss::GraphManager<common::DoubleTime, Prey, PreyPredatorParameters>(
|
|
|
|
+ coordinator, parameters, graph_parameters) {
|
|
|
|
+ coordinator->input_port({IN_Y, "in_y"});
|
|
|
|
+ in({coordinator, IN_Y}) >> in({derivative(), Prey::IN_Y});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ~PreyGraphManager() override = default;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ struct PreyPredatorGraphManagerParameters {
|
|
|
|
+ artis::pdevs::qss::QSSParameters<PreyPredatorParameters> _predator;
|
|
|
|
+ artis::pdevs::qss::QSSParameters<PreyPredatorParameters> _prey;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ class PreyPredatorGraphManager :
|
|
|
|
+ public artis::pdevs::GraphManager<common::DoubleTime, PreyPredatorGraphManagerParameters> {
|
|
|
|
+ public:
|
|
|
|
+ enum submodels {
|
|
|
|
+ PREDATOR, PREY
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ PreyPredatorGraphManager(common::Coordinator<common::DoubleTime>* coordinator,
|
|
|
|
+ const PreyPredatorGraphManagerParameters& parameters,
|
|
|
|
+ const artis::common::NoParameters& graph_parameters)
|
|
|
|
+ :
|
|
|
|
+ artis::pdevs::GraphManager<common::DoubleTime, PreyPredatorGraphManagerParameters>(
|
|
|
|
+ coordinator, parameters, graph_parameters),
|
|
|
|
+ _predator("predator", parameters._predator, graph_parameters),
|
|
|
|
+ _prey("prey", parameters._prey, graph_parameters)
|
|
|
|
+ {
|
|
|
|
+ add_child(PREDATOR, &_predator);
|
|
|
|
+ add_child(PREY, &_prey);
|
|
|
|
+ out({&_predator, PredatorGraphManager::OUT}) >> in({&_prey, PreyGraphManager::IN_Y});
|
|
|
|
+ out({&_prey, PreyGraphManager::OUT}) >> in({&_predator, PredatorGraphManager::IN_X});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ~PreyPredatorGraphManager() override = default;
|
|
|
|
+
|
|
|
|
+ private:
|
|
|
|
+ artis::pdevs::Coordinator<common::DoubleTime, PredatorGraphManager, artis::pdevs::qss::QSSParameters<PreyPredatorParameters>> _predator;
|
|
|
|
+ artis::pdevs::Coordinator<common::DoubleTime, PreyGraphManager, artis::pdevs::qss::QSSParameters<PreyPredatorParameters>> _prey;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+} // namespace artis tests qss
|
|
|
|
+
|
|
|
|
+#endif
|