Add gitlab issue/merge request templates
[apps/agl-service-can-low-level.git] / low-can-binding / binding / application.cpp
index 063a11d..4c9641c 100644 (file)
 #define MICROSECONDS_IN_SECOND 1000000
 #define ENGINE_VALUE_TIMEOUT   5
 
+application_t::application_t()
+       : can_bus_manager_{}
+       , message_set_{}
+{}
+
 /// @brief Return singleton instance of configuration object.
 application_t& application_t::instance()
 {
@@ -66,10 +71,13 @@ int application_t::add_message_set(std::shared_ptr<message_set_t> new_message_se
                                        return -1;
                        }
 
-                       for(auto new_diag_msg : new_message_set->get_diagnostic_messages())
+                       if(diagnostic_manager_.is_initialized())
                        {
-                               if(old_msg_set->add_diagnostic_message(new_diag_msg) < 0)
-                                       return -1;
+                               for(auto new_diag_msg : new_message_set->get_diagnostic_messages())
+                               {
+                                       if(old_msg_set->add_diagnostic_message(new_diag_msg) < 0)
+                                               return -1;
+                               }
                        }
                        return 0;
                }
@@ -146,13 +154,9 @@ bool application_t::is_engine_on()
 
                if(sf.signals.front()->get_last_value_with_timestamp().first > 0 &&
                   std::difftime(std::time(nullptr), last_timestamp_in_s) < ENGINE_VALUE_TIMEOUT)
-               {
                        engine_on = true;
-               }
                else
-               {
                        AFB_NOTICE("is_engine_on: engine.speed CAN signal found, but engine seems off");
-               }
        }
        else
        {
@@ -166,13 +170,9 @@ bool application_t::is_engine_on()
 
                if(sf.diagnostic_messages.front()->get_last_value_with_timestamp().first > 0 &&
                   std::difftime(std::time(nullptr), last_timestamp_in_s) < ENGINE_VALUE_TIMEOUT)
-               {
                        engine_on = true;
-               }
                else
-               {
                        AFB_NOTICE("is_engine_on: engine.speed diagnostic message found, but engine seems off");
-               }
        }
        else
        {