Separation Generator to a dedicated repo
[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
18 #include "application.hpp"
19
20 #include "../utils/signals.hpp"
21 #include "../utils/openxc-utils.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 diagnostic_manager_t& application_t::get_diagnostic_manager()
36 {
37         return diagnostic_manager_;
38 }
39
40 uint8_t application_t::get_active_message_set() const
41 {
42         return active_message_set_;
43 }
44
45 std::vector<std::shared_ptr<can_message_set_t> > application_t::get_can_message_set()
46 {
47         return can_message_set_;
48 }
49
50 std::vector<std::shared_ptr<can_signal_t> > application_t::get_all_can_signals()
51 {
52         return can_message_set_[active_message_set_]->get_all_can_signals();
53 }
54
55 std::vector<std::shared_ptr<diagnostic_message_t> >& application_t::get_diagnostic_messages()
56 {
57         return can_message_set_[active_message_set_]->get_diagnostic_messages();
58 }
59
60 std::vector<std::shared_ptr<can_message_definition_t> >& application_t::get_can_message_definition()
61 {
62         return can_message_set_[active_message_set_]->get_can_message_definition();
63 }
64
65 uint32_t application_t::get_signal_id(diagnostic_message_t& sig) const
66 {
67         return sig.get_pid();
68 }
69
70 uint32_t application_t::get_signal_id(can_signal_t& sig) const
71 {
72         return sig.get_message()->get_id();
73 }
74
75 void application_t::set_active_message_set(uint8_t id)
76 {
77         active_message_set_ = id;
78 }