750926b9f643e37f76222092d2ccb7e52631978e
[src/low-level-can-generator.git] / src / openxc / signal.hpp
1 #pragma once\r
2 \r
3 #include <string>\r
4 #include <map>\r
5 #include <vector>\r
6 #include <cstdint>\r
7 #include <json.hpp>\r
8 \r
9 namespace openxc\r
10 {\r
11         class signal\r
12         {\r
13         private:\r
14                 std::string                                                                                     id_;\r
15                 std::string                                                                                     generic_name_;\r
16                 std::uint32_t                                                                           bit_position_;\r
17                 std::uint32_t                                                                           bit_size_;\r
18                 float                                                                                           factor_;\r
19                 float                                                                                           offset_;\r
20                 std::string                                                                                     decoder_;\r
21                 bool                                                                                            ignore_;\r
22                 bool                                                                                            enabled_;\r
23                 std::map<std::string, std::vector<std::uint32_t>>       states_;\r
24                 float                                                                                           max_frequency_;\r
25                 bool                                                                                            send_same_;\r
26                 bool                                                                                            force_send_changed_;\r
27                 bool                                                                                            writable_;\r
28                 std::string                                                                                     encoder_;\r
29                 std::pair<bool,int>                                                                     multiplex_;\r
30                 bool                                                                                            is_big_endian_;\r
31                 bool                                                                                            is_signed_;\r
32                 std::string                                                                                     unit_;\r
33 \r
34         public:\r
35                 std::string id() const;\r
36                 void id(const std::string& id);\r
37                 std::string generic_name() const;\r
38                 std::uint32_t bit_position() const;\r
39                 std::uint32_t bit_size() const;\r
40                 float factor() const;\r
41                 float offset() const;\r
42                 std::string decoder() const;\r
43                 bool ignore() const;\r
44                 bool enabled() const;\r
45                 const std::map<std::string, std::vector<std::uint32_t>>& states() const;\r
46                 float max_frequency() const;\r
47                 bool send_same() const;\r
48                 bool force_send_changed() const;\r
49                 bool writable() const;\r
50                 std::string encoder() const;\r
51                 std::pair<bool,int> multiplex() const;\r
52                 bool is_big_endian() const;\r
53                 bool is_signed() const;\r
54                 std::string unit() const;\r
55 \r
56                 void from_json(const nlohmann::json& j);\r
57                 nlohmann::json to_json() const;\r
58         };\r
59 \r
60         void to_json(nlohmann::json& j, const signal& p);\r
61         void from_json(const nlohmann::json& j, signal& p);\r
62 }\r