Make low-can use afb-genskel by default
[apps/agl-service-can-low-level.git] / low-can-binding / binding / application.cpp
1 /*
2  * Copyright (C) 2015, 2016 "IoT.bzh"
3  * Author "Romain Forlot" <romain.forlot@iot.bzh>
4  *
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
8  *
9  *       http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17 #include "application.hpp"
18
19 #include "../utils/signals.hpp"
20 #include "../utils/openxc-utils.hpp"
21 #include "low-can-socket.hpp"
22
23 /// @brief Return singleton instance of configuration object.
24 application_t& application_t::instance()
25 {
26         static application_t config;
27         return config;
28 }
29
30 can_bus_t& application_t::get_can_bus_manager()
31 {
32         return can_bus_manager_;
33 }
34
35 std::map<std::string, std::shared_ptr<low_can_socket_t> >& application_t::get_can_devices()
36 {
37         return can_devices_;
38 }
39
40 diagnostic_manager_t& application_t::get_diagnostic_manager()
41 {
42         return diagnostic_manager_;
43 }
44
45 uint8_t application_t::get_active_message_set() const
46 {
47         return active_message_set_;
48 }
49
50 std::vector<std::shared_ptr<can_message_set_t> > application_t::get_can_message_set()
51 {
52         return can_message_set_;
53 }
54
55 std::vector<std::shared_ptr<can_signal_t> > application_t::get_all_can_signals()
56 {
57         return can_message_set_[active_message_set_]->get_all_can_signals();
58 }
59
60 std::vector<std::shared_ptr<diagnostic_message_t> >& application_t::get_diagnostic_messages()
61 {
62         return can_message_set_[active_message_set_]->get_diagnostic_messages();
63 }
64
65 std::vector<std::shared_ptr<can_message_definition_t> >& application_t::get_can_message_definition()
66 {
67         return can_message_set_[active_message_set_]->get_can_message_definition();
68 }
69
70 uint32_t application_t::get_signal_id(diagnostic_message_t& sig) const
71 {
72         return sig.get_pid();
73 }
74
75 uint32_t application_t::get_signal_id(can_signal_t& sig) const
76 {
77         return sig.get_message()->get_id();
78 }
79
80 void application_t::set_active_message_set(uint8_t id)
81 {
82         active_message_set_ = id;
83 }