Bladeren bron

Remove unused includes and add trace in dtss::Simulator class.

Eric Ramat 11 jaren geleden
bovenliggende
commit
5d84260b27
5 gewijzigde bestanden met toevoegingen van 52 en 27 verwijderingen
  1. 0 8
      src/dtss/Coordinator.hpp
  2. 51 1
      src/dtss/Simulator.hpp
  3. 0 5
      src/pdevs/Coordinator.hpp
  4. 0 13
      src/pdevs/Simulator.hpp
  5. 1 0
      src/tests/dtss_tests.cpp

+ 0 - 8
src/dtss/Coordinator.hpp

@@ -27,16 +27,8 @@
 #ifndef DTSS_COORDINATOR
 #define DTSS_COORDINATOR 1
 
-#include <common/Bag.hpp>
 #include <common/Coordinator.hpp>
-#include <common/ExternalEvent.hpp>
-#include <common/Links.hpp>
-#include <common/Node.hpp>
-#include <common/Trace.hpp>
 
-#include <dtss/Simulator.hpp>
-
-#include <algorithm>
 #include <cassert>
 #include <iostream>
 

+ 51 - 1
src/dtss/Simulator.hpp

@@ -29,6 +29,7 @@
 
 #include <common/Coordinator.hpp>
 #include <common/Simulator.hpp>
+#include <common/Trace.hpp>
 
 #include <cassert>
 
@@ -47,9 +48,22 @@ public :
 
     common::Time start(common::Time t)
     {
+        common::Trace::trace() << common::TraceElement(get_name(), t,
+                                                       common::I_MESSAGE)
+                               << ": BEFORE => "
+                               << "tl = " << _tl << " ; tn = " << _tn;
+        common::Trace::trace().flush();
+
         _dynamics.start(t);
         _tl = t;
         _tn = t;
+
+        common::Trace::trace() << common::TraceElement(get_name(), t,
+                                                       common::I_MESSAGE)
+                               << ": AFTER => "
+                               << "tl = " << _tl << " ; tn = " << _tn;
+        common::Trace::trace().flush();
+
         return _tn;
     }
 
@@ -60,6 +74,11 @@ public :
 
     void output(common::Time t)
     {
+        common::Trace::trace() << common::TraceElement(get_name(), t,
+                                                       common::OUTPUT)
+                               << ": BEFORE";
+        common::Trace::trace().flush();
+
         if(t == _tn) {
             common::Bag bag = _dynamics.lambda(t);
 
@@ -71,23 +90,54 @@ public :
                     ->dispatch_events(bag, t);
             }
         }
+
+        common::Trace::trace() << common::TraceElement(get_name(), t,
+                                                       common::OUTPUT)
+                               << ": AFTER";
+        common::Trace::trace().flush();
+
     }
 
-    void post_event(common::Time /* t */,
+    void post_event(common::Time t,
                     const common::ExternalEvent& event)
     {
+
+        common::Trace::trace() << common::TraceElement(get_name(), t,
+                                                       common::POST_EVENT)
+                               << ": BEFORE => " << event.to_string();
+        common::Trace::trace().flush();
+
         add_event(event);
+
+        common::Trace::trace() << common::TraceElement(get_name(), t,
+                                                       common::POST_EVENT)
+                               << ": AFTER => " << event.to_string();
+        common::Trace::trace().flush();
+
     }
 
     common::Time transition(common::Time t)
     {
 
+        common::Trace::trace() << common::TraceElement(get_name(), t,
+                                                       common::S_MESSAGE)
+                               << ": BEFORE => "
+                               << "tl = " << _tl << " ; tn = " << _tn;
+        common::Trace::trace().flush();
+
         assert(t == _tn);
 
         _dynamics.transition(get_bag(), t);
         _tl = t;
         _tn = t + _time_step;
         clear_bag();
+
+        common::Trace::trace() << common::TraceElement(get_name(), t,
+                                                       common::S_MESSAGE)
+                               << ": AFTER => "
+                               << "tl = " << _tl << " ; tn = " << _tn;
+        common::Trace::trace().flush();
+
         return _tn;
     }
 

+ 0 - 5
src/pdevs/Coordinator.hpp

@@ -27,13 +27,8 @@
 #ifndef PDEVS_COORDINATOR
 #define PDEVS_COORDINATOR 1
 
-#include <common/Bag.hpp>
 #include <common/Coordinator.hpp>
 #include <common/EventTable.hpp>
-#include <common/Links.hpp>
-#include <common/ExternalEvent.hpp>
-#include <common/Node.hpp>
-#include <common/Trace.hpp>
 
 #include <cassert>
 #include <iostream>

+ 0 - 13
src/pdevs/Simulator.hpp

@@ -173,19 +173,6 @@ public :
         return _tn;
     }
 
-    // Simulator(Dynamics* dynamics);
-    // virtual ~Simulator();
-
-    // virtual void observation(std::ostream& file) const;
-    // virtual void output(common::Time /* t */);
-    // virtual void post_event(common::Time /* t */,
-    //                         const common::ExternalEvent& /* event */);
-    // virtual common::Time start(common::Time /* t */);
-    // virtual common::Time transition(common::Time /* t */);
-
-    // virtual Dynamics* get_dynamics() const
-    // { return _dynamics; }
-
 private :
     Dynamics _dynamics;
 };

+ 1 - 0
src/tests/dtss_tests.cpp

@@ -31,6 +31,7 @@
 
 #include <dtss/Coordinator.hpp>
 #include <dtss/GraphManager.hpp>
+#include <dtss/Simulator.hpp>
 
 #define CATCH_CONFIG_MAIN
 #include "catch.hpp"