Separation of classes in the same file.
[apps/agl-service-can-low-level.git] / src / can / can-signals.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 <fnmatch.h>
19
20 #include "can-signals.hpp"
21
22 #include "../configuration.hpp"
23 #include "../utils/signals.hpp"
24 #include "can-decoder.hpp"
25 #include "../obd2/obd2-signals.hpp"
26 #include "../low-can-binding.hpp"
27
28 std::string can_signal_t::prefix_ = "messages";
29
30 can_message_definition_t& can_signal_t::get_message()
31 {
32         return message_;
33 }
34
35 const std::string& can_signal_t::get_generic_name() const
36 {
37         return generic_name_;
38 }
39
40 const std::string can_signal_t::get_name() const
41 {
42         return prefix_ + "." + generic_name_;
43 }
44
45 const std::string& can_signal_t::get_prefix() const
46 {
47         return prefix_;
48 }
49
50 uint8_t can_signal_t::get_bit_position() const
51 {
52         return bit_position_;
53 }
54
55 uint8_t can_signal_t::get_bit_size() const
56 {
57         return bit_size_;
58 }
59
60 float can_signal_t::get_factor() const
61 {
62         return factor_;
63 }
64
65 float can_signal_t::get_offset() const
66 {
67         return offset_;
68 }
69
70 float can_signal_t::get_min_value() const
71 {
72         return min_value_;
73 }       
74
75 float can_signal_t::get_max_value() const
76 {
77         return max_value_;
78 }
79
80 frequency_clock_t& can_signal_t::get_frequency()
81 {
82         return frequency_;
83 }
84
85 bool can_signal_t::get_send_same() const
86 {
87         return send_same_;
88 }
89
90 bool can_signal_t::get_force_send_changed() const
91 {
92         return force_send_changed_;
93 }
94
95 std::map<int, std::string> can_signal_t::get_state() const
96 {
97         return states_;
98 }
99
100 size_t can_signal_t::get_state_count() const
101 {
102         return states_.size();
103 }
104
105 bool can_signal_t::get_writable() const
106 {
107         return writable_;
108 }
109
110 SignalDecoder& can_signal_t::get_decoder()
111 {
112         return decoder_;
113 }
114
115 SignalEncoder& can_signal_t::get_encoder()
116 {
117         return encoder_;
118 }
119
120 bool can_signal_t::get_received() const
121 {
122         return received_;
123 }
124 float can_signal_t::get_last_value() const
125 {
126         return last_value_;
127 }
128
129 void can_signal_t::set_prefix(std::string val)
130 {
131         prefix_ = val;
132 }
133
134 void can_signal_t::set_received(bool r)
135 {
136         received_ = r;
137 }
138
139 void can_signal_t::set_last_value(float val)
140 {
141         last_value_ = val;
142 }