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.
22 #include "can/can-bus.hpp"
23 #include "can/can-signals.hpp"
24 #include "can/can-message.hpp"
25 #include "obd2/diagnostic-manager.hpp"
27 #include "low-can-binding.hpp"
30 * @brief Class representing a configuration attached to the binding.
32 * @desc It regroups all needed objects instance from other class
33 * that will be used along the binding life. It gets a global vision
34 * on which signals are implemented for that binding.
35 * Here, it is only the definition of the class with predefined accessors
36 * methods used in the binding.
38 * It will be the reference point to needed objects.
43 can_bus_t can_bus_manager_ = can_bus_t(afb_daemon_rootdir_open_locale(binder_interface->daemon, "can_buses.json", O_RDONLY, NULL));
44 diagnostic_manager_t diagnostic_manager_;
45 uint8_t active_message_set_ = 0;
48 const std::vector<obd2_signal_t> obd2_signals_;
49 const std::vector<can_message_set_t> can_message_set_;
50 const std::vector<std::vector<can_signal_t>> can_signals_;
51 const std::vector<std::vector<can_message_definition_t>> can_message_definition_;
53 configuration_t& get_configuration()
58 can_bus_t& get_can_bus_manager()
60 return can_bus_manager_;
63 diagnostic_manager_t& get_diagnostic_manager()
65 return diagnostic_manager_;
68 uint8_t get_active_message_set()
70 return active_message_set_;
73 std::vector<can_message_set>& get_can_message_set()
75 return can_message_set_;
78 std::vector<can_signal>& get_can_signals()
80 return can_signal_[active_message_set_];
83 std::vector<CanSignal>& get_can_signals()
85 return SIGNALS[active_message_set_];
88 std::vector<can_message_definition>& get_can_message_definition()
90 return can_message_definition_[active_message_set_];
93 std::vector<obd2_signal_t>& get_obd2_signals()
98 std::vector<obd2_signal_t>& get_obd2_signals()
103 uint32_t get_signal_id(obd2_signal_t& sig)
105 return sig.get_pid();
108 uint32_t get_signal_id(const CanSignal& sig)
110 return sig.message->id;
113 void set_active_message_set(uint8_t id)
115 active_message_set_ = id;