Parcourir la source

Added missing externals trace + traceInfo

gbeurier il y a 7 ans
Parent
commit
225ca4fa17
3 fichiers modifiés avec 47 ajouts et 5 suppressions
  1. 24 2
      src/artis/kernel/Externals.hpp
  2. 1 0
      src/artis/kernel/Simulator.hpp
  3. 22 3
      src/artis/utils/Trace.hpp

+ 24 - 2
src/artis/kernel/Externals.hpp

@@ -85,6 +85,17 @@ public:
             }
             externals[it->index] = std::make_pair(-1, it->var);
             external_names[it->index] = it->name;
+
+#ifdef WITH_TRACE
+            utils::Trace < utils::DoubleTime >::trace()
+                    << utils::TraceElement < utils::DoubleTime >("KERNEL", -1,
+                                                                 utils::KERNEL)
+                    << "EXTERNAL - "
+                    << typeid(T).name()
+                    << " declare "
+                    << it->name;
+            utils::Trace < utils::DoubleTime >::trace().flush();
+#endif
         }
     }
 
@@ -97,6 +108,17 @@ public:
         }
         externals[index] = std::make_pair(-1, var);
         external_names[index] = name;
+
+#ifdef WITH_TRACE
+            utils::Trace < utils::DoubleTime >::trace()
+                    << utils::TraceElement < utils::DoubleTime >("KERNEL", -1,
+                                                                 utils::KERNEL)
+                    << "EXTERNAL - "
+                    << typeid(T).name()
+                    << " declare "
+                    << name;
+            utils::Trace < utils::DoubleTime >::trace().flush();
+#endif
     }
 
     bool is_ready(typename U::type t, unsigned int index) const
@@ -125,9 +147,9 @@ public:
                     << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
                                                                  utils::KERNEL)
                     << "PUT - "
-                    << external_names[index] << " = " << get(index).to_string(dynamic_cast < const T* >(this))
+                    << get(index).to_string(dynamic_cast < const T* >(this))
                     << " in "
-                    << typeid(T).name();
+                    << typeid(T).name() << ":" << external_names[index];
             utils::Trace < utils::DoubleTime >::trace().flush();
 #endif
     }

+ 1 - 0
src/artis/kernel/Simulator.hpp

@@ -54,6 +54,7 @@ public:
     {
         _model->init(time, parameters);
         _observer.init();
+
     }
 
     const observer::Observer < U, V >& observer() const

+ 22 - 3
src/artis/utils/Trace.hpp

@@ -32,11 +32,30 @@
 #include <vector>
 
 #include <artis/utils/DateTime.hpp>
+#include <artis/kernel/Any.hpp>
 
 namespace artis { namespace utils {
 
 enum TraceType { NONE = 0, CHECK, COMPUTE, INIT, KERNEL, PUT };
 
+enum InformationType { CONSTRUCTION, DESTRUCTION,
+                       BEFORE_COMPUTE, AFTER_COMPUTE, INTERNAL_VALUE,
+                       EXTERNAL_VALUE, PUT_TO_EXTERNAL, LINK_INTERNAL };
+
+struct TraceInfo
+{
+
+    std::string         _src_model_name;
+    artis::kernel::Any  _value;
+    InformationType     _type;
+    std::string         _tgt_model_model;
+
+    TraceInfo(const std::string& src_model_name, artis::kernel::Any value,
+                 InformationType type, const std::string& tgt_model_model = "") :
+        _src_model_name(src_model_name), _value(value), _type(type), _tgt_model_model(tgt_model_model)
+    { }
+};
+
 template < class Time >
 class TraceElement
 {
@@ -124,9 +143,9 @@ public:
         for (typename TraceElements < Time >::const_iterator it =
                  TraceElements < Time >::begin();
              it != TraceElements < Time >::end(); ++it) {
-            std::string date = it->get_time() == -1 ? "start" :
-                                    it->get_time() == 0 ? "end" :
-                                                 utils::DateTime::toJulianDay(it->get_time());
+            std::string date = it->get_time() == -1 ? "construction" :
+                                    it->get_time() == 0 ? "initialization" :
+                                         utils::DateTime::toJulianDay(it->get_time());
             ss << "TRACE: " << it->get_model_name() << " at "
                << date << " <";
             switch (it->get_type())