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