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.
20 #include "can/can-bus.hpp"
21 #include "can/can-signals.hpp"
22 #include "obd2/diagnostic-manager.hpp"
25 * @brief Class representing a configuration attached to the binding.
27 * @desc It regroups all needed objects instance from other class
28 * that will be used along the binding life. It gets a global vision
29 * on which signals are implemented for that binding.
30 * Here, it is only the definition of the class with predefined accessors
31 * methods used in the binding.
33 * It will be the reference point to needed objects.
36 #include "low-can-binding.hpp"
41 can_bus_t can_bus_manager_(afb_daemon_rootdir_open_locale(binder_interface->daemon, "can_buses.json", O_RDONLY, NULL));
42 diagnostic_manager_t diagnostic_manager_;
43 uint8_t active_message_set_ = 0;
46 const std::vector<obd2_signals_t> obd2_signals_;
47 const std::vector<can_message_set_t> can_message_set_;
48 const std::vector<std::vector<can_signal_t>> can_signals_;
49 const std::vector<std::vector<can_message_definition_t>> can_message_definition_;
51 configuration_t& get_configuration()
56 can_bus_t& get_can_bus_manager()
58 return can_bus_manager_;
61 diagnostic_manager_t& get_diagnostic_manager()
63 return diagnostic_manager_;
66 uint8_t get_active_message_set()
68 return active_message_set_;
71 std::vector<can_message_set>& get_can_message_set()
73 return can_message_set_;
76 std::vector<can_signal>& get_can_signals()
78 return can_signal_[active_message_set_];
81 std::vector<CanSignal>& get_can_signals()
83 return SIGNALS[active_message_set_];
86 std::vector<can_message_definition>& get_can_message_definition()
88 return can_message_definition_[active_message_set_];
91 std::vector<obd2_signals_t>& get_obd2_signals()
96 std::vector<obd2_signals_t>& get_obd2_signals()
101 uint32_t get_signal_id(obd2_signals_t& sig)
103 return sig.get_pid();
106 uint32_t get_signal_id(const CanSignal& sig)
108 return sig.message->id;
111 void set_active_message_set(uint8_t id)
113 active_message_set_ = id;