Update to match current binding expectations
[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         enum sign_t\r
12         {\r
13                 UNSIGNED = 0,\r
14                 SIGN_BIT = 1,\r
15                 ONES_COMPLEMENT = 2,\r
16                 TWOS_COMPLEMENT = 3,\r
17                 SIGN_BIT_EXTERN = 4\r
18         };\r
19 \r
20         class signal\r
21         {\r
22         private:\r
23                 std::string                                                                                     id_;\r
24                 std::string                                                                                     generic_name_;\r
25                 std::uint32_t                                                                                   bit_position_;\r
26                 std::uint32_t                                                                                   bit_size_;\r
27                 float                                                                                           factor_;\r
28                 float                                                                                           offset_;\r
29                 std::string                                                                                     decoder_;\r
30                 bool                                                                                            ignore_;\r
31                 bool                                                                                            enabled_;\r
32                 std::map<std::string, std::vector<std::uint32_t>>                                               states_;\r
33                 float                                                                                           max_frequency_;\r
34                 bool                                                                                            send_same_;\r
35                 bool                                                                                            force_send_changed_;\r
36                 bool                                                                                            writable_;\r
37                 std::string                                                                                     encoder_;\r
38                 std::pair<bool,int>                                                                             multiplex_;\r
39                 sign_t                                                                                          sign_;\r
40                 std::int32_t                                                                                    bit_sign_position_;\r
41                 std::string                                                                                     unit_;\r
42 \r
43         public:\r
44                 std::string id() const;\r
45                 void id(const std::string& id);\r
46                 std::string generic_name() const;\r
47                 std::uint32_t bit_position() const;\r
48                 std::uint32_t bit_size() const;\r
49                 float factor() const;\r
50                 float offset() const;\r
51                 std::string decoder() const;\r
52                 bool ignore() const;\r
53                 bool enabled() const;\r
54                 const std::map<std::string, std::vector<std::uint32_t>>& states() const;\r
55                 float max_frequency() const;\r
56                 bool send_same() const;\r
57                 bool force_send_changed() const;\r
58                 bool writable() const;\r
59                 std::string encoder() const;\r
60                 std::pair<bool,int> multiplex() const;\r
61                 sign_t sign() const;\r
62                 std::int32_t bit_sign_position() const;\r
63                 std::string unit() const;\r
64 \r
65                 void from_json(const nlohmann::json& j);\r
66                 nlohmann::json to_json() const;\r
67         };\r
68 \r
69         void to_json(nlohmann::json& j, const signal& p);\r
70         void from_json(const nlohmann::json& j, signal& p);\r
71 }\r