Change directory architecture to use 2 separated projects.
[apps/low-level-can-service.git] / CAN-binder / low-can-binding / can / can-message-definition.hpp
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 /**
19  * @class can_message_definition_t
20  *
21  * @brief The definition of a CAN message. This includes a lot of metadata, so
22  * to save memory this struct should not be used for storing incoming and
23  * outgoing CAN messages.
24  */
25
26 #pragma once
27
28 #include <vector>
29 #include <memory>
30
31 #include "can-bus-dev.hpp"
32 #include "can-message.hpp"
33 #include "../utils/timer.hpp"
34
35 class can_message_definition_t
36 {
37 private:
38         std::uint8_t message_set_id_;
39         std::string bus_; /*!< bus_ - Address of CAN bus device. */
40         uint32_t id_; /*!< id_ - The ID of the message.*/
41         can_message_format_t format_; /*!< format_ - the format of the message's ID.*/
42         frequency_clock_t frequency_clock_; /*!<  clock_ - an optional frequency clock to control the output of this
43                                                         *      message, if sent raw, or simply to mark the max frequency for custom
44                                                         *      handlers to retrieve.*/
45         bool force_send_changed_; /*!< force_send_changed_ - If true, regardless of the frequency, it will send CAN
46                                                          *      message if it has changed when using raw passthrough.*/
47         std::vector<uint8_t> last_value_; /*!< last_value_ - The last received value of the message. Defaults to undefined.
48                                                                                   *     This is required for the forceSendChanged functionality, as the stack
49                                                                                   *     needs to compare an incoming CAN message with the previous frame.*/
50         
51 public:
52         can_message_definition_t(std::uint8_t message_set_id, const std::string bus);
53         can_message_definition_t(std::uint8_t message_set_id, const std::string bus, uint32_t id, frequency_clock_t frequency_clock, bool force_send_changed);
54         can_message_definition_t(std::uint8_t message_set_id, const std::string bus, uint32_t id, can_message_format_t format, frequency_clock_t frequency_clock, bool force_send_changed);
55
56         uint32_t get_id() const;
57 };