2 * Copyright (C) 2015, 2016 "IoT.bzh"
3 * Author "Romain Forlot" <romain.forlot@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include "signals.hpp"
22 signals_manager_t::signals_manager_t()
25 /// @brief Return singleton instance of configuration object.
26 signals_manager_t& signals_manager_t::instance()
28 static signals_manager_t sm;
32 /// @brief Return Subscribed signals map mutex.
33 std::mutex& signals_manager_t::get_subscribed_signals_mutex()
35 return subscribed_signals_mutex_;
39 /// @brief return the subscribed_signals map.
41 /// @return Map of subscribed signals.
42 std::map<int, std::shared_ptr<low_can_subscription_t> >& signals_manager_t::get_subscribed_signals()
44 return subscribed_signals_;
48 /// @fn std::vector<std::string> find_signals(const openxc_DynamicField &key)
49 /// @brief return signals name found searching through CAN_signals and OBD2 pid
51 /// @param[in] key : can contain numeric or string value in order to search against
52 /// can signals or obd2 signals name.
54 /// @return Vector of signals name found.
56 struct signals_found signals_manager_t::find_signals(const openxc_DynamicField &key)
58 struct signals_found sf;
62 case openxc_DynamicField_Type::openxc_DynamicField_Type_STRING:
63 lookup_signals_by_name(key.string_value, application_t::instance().get_all_can_signals(), sf.can_signals);
64 lookup_signals_by_name(key.string_value, application_t::instance().get_diagnostic_messages(), sf.diagnostic_messages);
66 case openxc_DynamicField_Type::openxc_DynamicField_Type_NUM:
67 lookup_signals_by_id(key.numeric_value, application_t::instance().get_all_can_signals(), sf.can_signals);
68 lookup_signals_by_id(key.numeric_value, application_t::instance().get_diagnostic_messages(), sf.diagnostic_messages);
71 ERROR(binder_interface, "%s: wrong openxc_DynamicField specified. Use openxc_DynamicField_Type_NUM or openxc_DynamicField_Type_STRING type only.", __FUNCTION__);
74 DEBUG(binder_interface, "%s: Found %d signal(s)", __FUNCTION__, (int)(sf.can_signals.size() + sf.diagnostic_messages.size()));