2 * Copyright (C) 2015, 2016 "IoT.bzh"
3 * Author "Romain Forlot" <romain.forlot@iot.bzh>
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include "can-signals.hpp"
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"
28 std::string can_signal_t::prefix_ = "messages";
30 can_signal_t::can_signal_t(can_message_definition_t& message, std::string generic_name, uint8_t bit_position, uint8_t bit_size,
31 float factor, float offset, float min_value, float max_value, frequency_clock_t frequency, bool send_same, bool force_send_changed,
32 std::map<int, std::string> states, bool writable, SignalDecoder decoder, SignalEncoder encoder, bool received)
33 : message_{message}, generic_name_{generic_name}, bit_position_{bit_position}, bit_size_{bit_size}, factor_{factor}, offset_{offset},
34 min_value_{min_value}, max_value_{max_value}, frequency_{frequency}, send_same_{send_same}, force_send_changed_{force_send_changed}, states_{states},
35 writable_{writable}, decoder_{decoder}, encoder_{encoder}, received_{received}, last_value_{(float)NULL}
38 can_message_definition_t& can_signal_t::get_message()
43 const std::string& can_signal_t::get_generic_name() const
48 const std::string can_signal_t::get_name() const
50 return prefix_ + "." + generic_name_;
53 const std::string& can_signal_t::get_prefix() const
58 uint8_t can_signal_t::get_bit_position() const
63 uint8_t can_signal_t::get_bit_size() const
68 float can_signal_t::get_factor() const
73 float can_signal_t::get_offset() const
78 float can_signal_t::get_min_value() const
83 float can_signal_t::get_max_value() const
88 frequency_clock_t& can_signal_t::get_frequency()
93 bool can_signal_t::get_send_same() const
98 bool can_signal_t::get_force_send_changed() const
100 return force_send_changed_;
103 std::map<int, std::string> can_signal_t::get_state() const
108 size_t can_signal_t::get_state_count() const
110 return states_.size();
113 bool can_signal_t::get_writable() const
118 SignalDecoder& can_signal_t::get_decoder()
123 SignalEncoder& can_signal_t::get_encoder()
128 bool can_signal_t::get_received() const
132 float can_signal_t::get_last_value() const
137 void can_signal_t::set_prefix(std::string val)
142 void can_signal_t::set_received(bool r)
147 void can_signal_t::set_last_value(float val)