Less control before process the CAN message.
[apps/agl-service-can-low-level.git] / src / utils / signals.hpp
index e575bd1..00b9e3e 100644 (file)
 #include <fnmatch.h>
 
 #include "openxc.pb.h"
-#include "can/can-signals.hpp"
-#include "obd2/obd2-signals.hpp"
+#include "../configuration.hpp"
+#include "../can/can-signals.hpp"
+#include "../obd2/obd2-signals.hpp"
+
+#include "../low-can-binding.hpp"
 
 extern std::mutex subscribed_signals_mutex;
 std::mutex& get_subscribed_signals_mutex();
@@ -31,7 +34,7 @@ std::mutex& get_subscribed_signals_mutex();
 /**
  * @brief return the subscribed_signals map.
  * 
- * return std::map<std::string, struct afb_event> - map of subscribed signals.
+ * return Map of subscribed signals.
  */
 extern std::map<std::string, struct afb_event> subscribed_signals;
 std::map<std::string, struct afb_event>& get_subscribed_signals();
@@ -41,7 +44,9 @@ void lookup_signals_by_name(const std::string& key, std::vector<T>& signals, std
 {
        for(T& s : signals)
        {
-               if(::fnmatch(key.c_str(), s.generic_name, FNM_CASEFOLD) == 0)
+               if(::fnmatch(key.c_str(), s.get_generic_name().c_str(), FNM_CASEFOLD) == 0)
+                       found_signals.push_back(&s);
+               if(::fnmatch(key.c_str(), s.get_name().c_str(), FNM_CASEFOLD) == 0)
                        found_signals.push_back(&s);
        }
 }
@@ -49,10 +54,12 @@ void lookup_signals_by_name(const std::string& key, std::vector<T>& signals, std
 template <typename T>
 void lookup_signals_by_name(const std::string& key, std::vector<T>& signals, std::vector<std::string>& found_signals_name)
 {
-       for(const T& s : signals)
+       for(T& s : signals)
        {
-               if(::fnmatch(key.c_str(), s.generic_name, FNM_CASEFOLD) == 0)
-                       found_signals_name.push_back(s.generic_name);
+               if(::fnmatch(key.c_str(), s.get_generic_name().c_str(), FNM_CASEFOLD) == 0)
+                       found_signals_name.push_back(s.get_generic_name());
+               if(::fnmatch(key.c_str(), s.get_name().c_str(), FNM_CASEFOLD) == 0)
+                       found_signals_name.push_back(s.get_generic_name());
        }
 }
 
@@ -61,7 +68,7 @@ void lookup_signals_by_id(const double key, std::vector<T>& signals, std::vector
 {
        for(T& s : signals)
        {
-               if(get_signal_id(s) == key)
+               if(configuration_t::instance().get_signal_id(s) == key)
                {
                        found_signals.push_back(&s);
                }
@@ -71,11 +78,11 @@ void lookup_signals_by_id(const double key, std::vector<T>& signals, std::vector
 template <typename T>
 void lookup_signals_by_id(const double key, std::vector<T>& signals, std::vector<std::string>& found_signals_name)
 {
-       for(const T& s : signals)
+       for(T& s : signals)
        {
-               if(get_signal_id(s) == key)
+               if(configuration_t::instance().get_signal_id(s) == key)
                {
-                       found_signals_name.push_back(s.generic_name);
+                       found_signals_name.push_back(s.get_name());
                }
        }
 }