98b38a5d6a46310b8313533a0e0f65074cc4a7c2
[src/low-level-can-generator.git] / src / openxc / can_message.hpp
1 #pragma once\r
2 \r
3 #include <string>\r
4 #include <vector>\r
5 #include <json.hpp>\r
6 \r
7 #include "signal.hpp"\r
8 \r
9 namespace openxc\r
10 {\r
11         class can_message\r
12         {\r
13         private:\r
14                 std::string                                             id_;\r
15                 std::string                                             bus_;\r
16                 bool                                                    bit_numbering_inverted_;\r
17                 std::vector<signal>                             signals_;\r
18                 std::string                                             name_;\r
19                 std::vector<std::string>                handlers_;\r
20                 bool                                                    enabled_;\r
21                 float                                                   max_frequency_;\r
22                 float                                                   max_signal_frequency_;\r
23                 bool                                                    force_send_changed_;\r
24                 bool                                                    force_send_changed_signals_;\r
25                 bool                                                    is_fd_;\r
26                 bool                                                    is_extended_;\r
27                 bool                                                    is_j1939_;\r
28                 uint32_t                                                length_;\r
29                 float                                                   min_value;\r
30                 float                                                   max_value;\r
31 \r
32         public:\r
33                 std::string id() const;\r
34                 void id(const std::string& id);\r
35                 void is_fd(const bool is_fd);\r
36                 bool is_fd() const;\r
37                 void is_extended(const bool is_extended);\r
38                 bool is_extended() const;\r
39                 void is_j1939(const bool is_j1939);\r
40                 bool is_j1939() const;\r
41                 std::string     bus() const;\r
42                 bool bit_numbering_inverted() const;\r
43                 const std::vector<signal>& signals() const;\r
44                 std::string name() const;\r
45                 std::vector<std::string> handlers() const;\r
46                 bool enabled() const;\r
47                 float max_frequency() const;\r
48                 float max_signal_frequency() const;\r
49                 bool force_send_changed() const;\r
50                 bool force_send_changed_signals() const;\r
51                 uint32_t length() const;\r
52 \r
53                 void from_json(const nlohmann::json& j);\r
54                 nlohmann::json to_json() const;\r
55 \r
56                 std::uint32_t get_signals_count() const;\r
57         };\r
58 \r
59         void to_json(nlohmann::json& j, const can_message& p);\r
60         void from_json(const nlohmann::json& j, can_message& p);\r
61         void from_json(const nlohmann::json& j, can_message& p, const std::string& id);\r
62 }\r