Bladeren bron

dtss: use time step parameter of coordinator

Eric Ramat 2 jaren geleden
bovenliggende
commit
f1350d5228
2 gewijzigde bestanden met toevoegingen van 53 en 78 verwijderingen
  1. 3 3
      src/tests/dtss/graph_manager.hpp
  2. 50 75
      src/tests/mixed/graph_manager.hpp

+ 3 - 3
src/tests/dtss/graph_manager.hpp

@@ -56,7 +56,7 @@ public:
                                 artis::dtss::Parameters<common::DoubleTime>,
                                 artis::common::NoParameters>(
           coordinator, parameters, graph_parameters),
-      a("a", parameters)
+      a("a", parameters, parameters.time_step)
   {
     add_child(OneA, &a);
   }
@@ -86,8 +86,8 @@ public:
                                 artis::dtss::Parameters<common::DoubleTime>,
                                 artis::common::NoParameters>(
           coordinator, parameters, graph_parameters),
-      a("a", parameters),
-      b("b", parameters)
+      a("a", parameters, parameters.time_step),
+      b("b", parameters, parameters.time_step)
   {
     add_child(OneA, &a);
     add_child(OneB, &b);

+ 50 - 75
src/tests/mixed/graph_manager.hpp

@@ -42,26 +42,22 @@ namespace artis {
 namespace tests {
 namespace mixed {
 
-class S1GraphManager : public pdevs::GraphManager<common::DoubleTime>
-{
+class S1GraphManager : public pdevs::GraphManager<common::DoubleTime> {
 public:
-  enum submodels
-  {
+  enum submodels {
     OneA, OneB
   };
-  enum outputs
-  {
+  enum outputs {
     OUT
   };
 
   S1GraphManager(common::Coordinator<common::DoubleTime> *coordinator,
                  const artis::common::NoParameters &parameters,
                  const artis::common::NoParameters &graph_parameters)
-      :
-      pdevs::GraphManager<common::DoubleTime>(coordinator, parameters, graph_parameters),
-      a("a1", parameters),
-      b("b1", parameters)
-  {
+    :
+    pdevs::GraphManager<common::DoubleTime>(coordinator, parameters, graph_parameters),
+    a("a1", parameters),
+    b("b1", parameters) {
     add_child(OneA, &a);
     add_child(OneB, &b);
 
@@ -79,26 +75,22 @@ private:
 };
 
 class S2GraphManager :
-    public dtss::GraphManager<common::DoubleTime, artis::dtss::Parameters<common::DoubleTime>>
-{
+  public dtss::GraphManager<common::DoubleTime, artis::dtss::Parameters<common::DoubleTime>> {
 public:
-  enum submodels
-  {
+  enum submodels {
     OneA, OneB
   };
-  enum inputs
-  {
+  enum inputs {
     IN
   };
 
   S2GraphManager(common::Coordinator<common::DoubleTime> *coordinator,
                  const artis::dtss::Parameters<common::DoubleTime> &parameters,
                  const artis::common::NoParameters &graph_parameters)
-      :
-      dtss::GraphManager<common::DoubleTime, artis::dtss::Parameters<common::DoubleTime>>(
-          coordinator, parameters, graph_parameters),
-      a("a2", parameters), b("b2", parameters)
-  {
+    :
+    dtss::GraphManager<common::DoubleTime, artis::dtss::Parameters<common::DoubleTime>>(
+      coordinator, parameters, graph_parameters),
+    a("a2", parameters, parameters.time_step), b("b2", parameters, parameters.time_step) {
     add_child(OneA, &a);
     add_child(OneB, &b);
 
@@ -115,22 +107,19 @@ private:
   dtss::Simulator<common::DoubleTime, B2, artis::dtss::Parameters<common::DoubleTime>> b;
 };
 
-class RootGraphManager : public pdevs::GraphManager<common::DoubleTime>
-{
+class RootGraphManager : public pdevs::GraphManager<common::DoubleTime> {
 public:
-  enum submodels
-  {
+  enum submodels {
     OneS1, OneS2
   };
 
   RootGraphManager(common::Coordinator<common::DoubleTime> *coordinator,
                    const artis::common::NoParameters &parameters,
                    const artis::common::NoParameters &graph_parameters)
-      :
-      pdevs::GraphManager<common::DoubleTime>(coordinator, parameters, graph_parameters),
-      S1("S1", artis::common::NoParameters(), artis::common::NoParameters()),
-      S2("S2", {2}, artis::common::NoParameters())
-  {
+    :
+    pdevs::GraphManager<common::DoubleTime>(coordinator, parameters, graph_parameters),
+    S1("S1", artis::common::NoParameters(), artis::common::NoParameters()),
+    S2("S2", {2}, artis::common::NoParameters()) {
     add_child(OneS1, &S1);
     add_child(OneS2, &S2);
 
@@ -142,29 +131,27 @@ public:
 private:
   artis::pdevs::Coordinator<common::DoubleTime, S1GraphManager> S1;
   artis::dtss::Coordinator<
-      common::DoubleTime,
-      artis::dtss::LastBagPolicy,
-      S2GraphManager,
-      artis::dtss::Parameters<common::DoubleTime>> S2;
+    common::DoubleTime,
+    artis::dtss::LastBagPolicy,
+    S2GraphManager,
+    artis::dtss::Parameters<common::DoubleTime>> S2;
 };
 
 template<int size>
-class LinearGraphManager : public pdevs::GraphManager<common::DoubleTime>
-{
+class LinearGraphManager : public pdevs::GraphManager<common::DoubleTime> {
 public:
   LinearGraphManager(common::Coordinator<common::DoubleTime> *coordinator,
                      const artis::common::NoParameters &parameters,
                      const artis::common::NoParameters &graph_parameters)
-      :
-      pdevs::GraphManager<common::DoubleTime>(coordinator, parameters, graph_parameters)
-  {
+    :
+    pdevs::GraphManager<common::DoubleTime>(coordinator, parameters, graph_parameters) {
     for (unsigned int i = 1; i <= size; ++i) {
       std::ostringstream ss;
 
       ss << "a" << i;
       _models.push_back(
-          new pdevs::Simulator<common::DoubleTime, Beep, artis::common::NoParameters>(
-              ss.str(), artis::common::NoParameters()));
+        new pdevs::Simulator<common::DoubleTime, Beep, artis::common::NoParameters>(
+          ss.str(), artis::common::NoParameters()));
     }
     for (unsigned int i = 0; i < size; ++i) {
       LinearGraphManager<size>::add_child(i, _models[i]);
@@ -174,8 +161,7 @@ public:
     }
   }
 
-  ~LinearGraphManager() override
-  {
+  ~LinearGraphManager() override {
     for (unsigned int i = 0; i < size; ++i) {
       delete _models[i];
     }
@@ -185,31 +171,27 @@ private:
   std::vector<pdevs::Simulator<common::DoubleTime, Beep, artis::common::NoParameters> *> _models;
 };
 
-class Linear2GraphManager : public pdevs::GraphManager<common::DoubleTime>
-{
+class Linear2GraphManager : public pdevs::GraphManager<common::DoubleTime> {
 public:
-  enum inputs
-  {
+  enum inputs {
     IN
   };
-  enum outputs
-  {
+  enum outputs {
     OUT
   };
 
   Linear2GraphManager(common::Coordinator<common::DoubleTime> *coordinator,
                       const artis::common::NoParameters &parameters,
                       const artis::common::NoParameters &graph_parameters)
-      :
-      pdevs::GraphManager<common::DoubleTime>(coordinator, parameters, graph_parameters)
-  {
+    :
+    pdevs::GraphManager<common::DoubleTime>(coordinator, parameters, graph_parameters) {
     for (unsigned int i = 1; i <= 100; ++i) {
       std::ostringstream ss;
 
       ss << "a" << i;
       _models.push_back(
-          new pdevs::Simulator<common::DoubleTime, Beep, artis::common::NoParameters>(
-              ss.str(), artis::common::NoParameters()));
+        new pdevs::Simulator<common::DoubleTime, Beep, artis::common::NoParameters>(
+          ss.str(), artis::common::NoParameters()));
     }
     for (unsigned int i = 0; i < 100; ++i) {
       add_child(i, _models[i]);
@@ -225,8 +207,7 @@ public:
     out({_models[99], Beep::OUT}) >> out({coordinator, OUT});
   }
 
-  ~Linear2GraphManager() override
-  {
+  ~Linear2GraphManager() override {
     for (unsigned int i = 0; i < 100; ++i) {
       delete _models[i];
     }
@@ -236,11 +217,9 @@ private:
   std::vector<pdevs::Simulator<common::DoubleTime, Beep, artis::common::NoParameters> *> _models;
 };
 
-class Root2GraphManager : public pdevs::GraphManager<common::DoubleTime>
-{
+class Root2GraphManager : public pdevs::GraphManager<common::DoubleTime> {
 public:
-  enum submodels
-  {
+  enum submodels {
     OneS1, OneS2
   };
 
@@ -248,11 +227,10 @@ public:
                     const artis::common::NoParameters &parameters,
                     const artis::common::NoParameters &graph_parameters
   )
-      :
-      pdevs::GraphManager<common::DoubleTime>(coordinator, parameters, graph_parameters),
-      S1("S1", artis::common::NoParameters(), artis::common::NoParameters()),
-      S2("S2", artis::common::NoParameters(), artis::common::NoParameters())
-  {
+    :
+    pdevs::GraphManager<common::DoubleTime>(coordinator, parameters, graph_parameters),
+    S1("S1", artis::common::NoParameters(), artis::common::NoParameters()),
+    S2("S2", artis::common::NoParameters(), artis::common::NoParameters()) {
     add_child(OneS1, &S1);
     add_child(OneS2, &S2);
 
@@ -266,11 +244,9 @@ private:
   artis::pdevs::Coordinator<common::DoubleTime, Linear2GraphManager> S2;
 };
 
-class Root3GraphManager : public pdevs::GraphManager<common::DoubleTime>
-{
+class Root3GraphManager : public pdevs::GraphManager<common::DoubleTime> {
 public:
-  enum submodels
-  {
+  enum submodels {
     OneS1, OneS2
   };
 
@@ -278,11 +254,10 @@ public:
                     const artis::common::NoParameters &parameters,
                     const artis::common::NoParameters &graph_parameters
   )
-      :
-      pdevs::GraphManager<common::DoubleTime>(coordinator, parameters, graph_parameters),
-      S1("S1", artis::common::NoParameters(), artis::common::NoParameters()),
-      S2("S2", artis::common::NoParameters(), artis::common::NoParameters())
-  {
+    :
+    pdevs::GraphManager<common::DoubleTime>(coordinator, parameters, graph_parameters),
+    S1("S1", artis::common::NoParameters(), artis::common::NoParameters()),
+    S2("S2", artis::common::NoParameters(), artis::common::NoParameters()) {
     add_child(OneS1, &S1);
     add_child(OneS2, &S2);