Implements new verbs to write on CAN bus
[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 #include "low-can-socket.hpp"
23
24 /// @brief Return singleton instance of configuration object.
25 application_t& application_t::instance()
26 {
27         static application_t config;
28         return config;
29 }
30
31 can_bus_t& application_t::get_can_bus_manager()
32 {
33         return can_bus_manager_;
34 }
35
36 std::map<std::string, std::shared_ptr<low_can_socket_t> >& application_t::get_can_devices()
37 {
38         return can_devices_;
39 }
40
41 diagnostic_manager_t& application_t::get_diagnostic_manager()
42 {
43         return diagnostic_manager_;
44 }
45
46 uint8_t application_t::get_active_message_set() const
47 {
48         return active_message_set_;
49 }
50
51 std::vector<std::shared_ptr<can_message_set_t> > application_t::get_can_message_set()
52 {
53         return can_message_set_;
54 }
55
56 std::vector<std::shared_ptr<can_signal_t> > application_t::get_all_can_signals()
57 {
58         return can_message_set_[active_message_set_]->get_all_can_signals();
59 }
60
61 std::vector<std::shared_ptr<diagnostic_message_t> >& application_t::get_diagnostic_messages()
62 {
63         return can_message_set_[active_message_set_]->get_diagnostic_messages();
64 }
65
66 std::vector<std::shared_ptr<can_message_definition_t> >& application_t::get_can_message_definition()
67 {
68         return can_message_set_[active_message_set_]->get_can_message_definition();
69 }
70
71 uint32_t application_t::get_signal_id(diagnostic_message_t& sig) const
72 {
73         return sig.get_pid();
74 }
75
76 uint32_t application_t::get_signal_id(can_signal_t& sig) const
77 {
78         return sig.get_message()->get_id();
79 }
80
81 void application_t::set_active_message_set(uint8_t id)
82 {
83         active_message_set_ = id;
84 }