libknx
dpt.hpp
1 #pragma once
2 
3 #include "debug.hpp"
4 
5 #include "dpt_types.hpp"
6 
7 #include <ostream>
8 #include <utility>
9 #include <array>
10 
15 namespace knx {
16 
17 template<int MAJOR>
18 class MappingMajor {};
19 
20 #define KNX_MAP_MAJOR(major, size, type) \
21 template<> class MappingMajor<major> { public: enum { SIZE = size }; typedef type set_type; };
22 
23 KNX_MAP_MAJOR( 1, 1, bool );
24 KNX_MAP_MAJOR( 2, 1, dpt_2::data );
25 KNX_MAP_MAJOR( 3, 1, dpt_3::data );
26 KNX_MAP_MAJOR( 4, 2, char );
27 KNX_MAP_MAJOR( 5, 2, uint8_t );
28 KNX_MAP_MAJOR( 6, 2, int8_t );
29 KNX_MAP_MAJOR( 7, 3, uint16_t );
30 KNX_MAP_MAJOR( 8, 3, int16_t );
31 KNX_MAP_MAJOR( 9, 3, float );
32 KNX_MAP_MAJOR( 10, 4, dpt_10::data );
33 KNX_MAP_MAJOR( 11, 4, dpt_11::data );
34 KNX_MAP_MAJOR( 12, 5, uint32_t );
35 KNX_MAP_MAJOR( 13, 5, int32_t );
36 KNX_MAP_MAJOR( 14, 5, float );
37 KNX_MAP_MAJOR( 15, 5, dpt_15::data );
38 KNX_MAP_MAJOR( 16, 15, dpt_16::data );
39 KNX_MAP_MAJOR( 17, 2, dpt_17::data );
40 KNX_MAP_MAJOR( 18, 2, dpt_18::data );
41 KNX_MAP_MAJOR( 19, 8, dpt_19::data );
42 KNX_MAP_MAJOR( 20, 2, uint8_t );
43 KNX_MAP_MAJOR( 26, 2, dpt_26::data );
44 KNX_MAP_MAJOR(219, 6, dpt_219::data );
45 KNX_MAP_MAJOR(232, 3, dpt_232::data );
46 
48 template<int MAJOR, int MINOR>
50 
52 template<int MAJOR, int MINOR>
53 class dpt
54 {
55 private:
57  dpt_private<MAJOR,MINOR> * dpt_private_pointer;
58 public:
61 
64 
67 
69  dpt();
70 
72  ~dpt();
73 
75  static unsigned int get_index();
76 
78  template<class TYPE>
79  void set(const TYPE value);
80 
82  template<class TYPE>
83  void get(TYPE & value) const;
84 
86  template<int MAJOR2, int MINOR2>
87  friend std::ostream & operator<<(std::ostream & os, dpt<MAJOR2,MINOR2> & data);
88 };
89 
91 template<int MAJOR, int MINOR>
92 std::ostream & operator<<(std::ostream & os, dpt<MAJOR,MINOR> & data);
93 
94 
96 class dpt_1_001 : public dpt<1,001>
97 {
98 public:
100  KNX_IMPORT_EXPORT static const dpt<1,001>::set_type ON;
102  KNX_IMPORT_EXPORT static const dpt<1,001>::set_type OFF;
103 };
104 
106 class dpt_2_001 : public dpt<2,001>
107 {
108 public:
110  KNX_IMPORT_EXPORT static const dpt<2,001>::set_type NO_CONTROL;
112  KNX_IMPORT_EXPORT static const dpt<2,001>::set_type CONTROL_VALUE_ZERO;
114  KNX_IMPORT_EXPORT static const dpt<2,001>::set_type CONTROL_VALUE_ONE;
115 };
116 
117 
119 class dpt_3_007 : public dpt<3,007>
120 {};
121 
122 
124 class dpt_4_001 : public dpt<4,001>
125 {};
126 
128 
129 class dpt_5_001 : public dpt<5,001>
130 {};
131 
133 class dpt_6_001 : public dpt<6,001>
134 {};
135 
137 class dpt_7_001 : public dpt<7,001>
138 {};
139 
141 class dpt_8_001 : public dpt<8,001>
142 {};
143 
145 class dpt_9_001 : public dpt<9,001>
146 {
147 public:
149  KNX_IMPORT_EXPORT static const uint16_t INVALID_DATA;
151  KNX_IMPORT_EXPORT static const uint16_t MAX;
153  KNX_IMPORT_EXPORT static const uint16_t MIN;
155  KNX_IMPORT_EXPORT static const float MAX_FLOAT;
157  KNX_IMPORT_EXPORT static const float MIN_FLOAT;
158 };
159 
161 class dpt_10_001 : public dpt<10,001>
162 {
163 public:
164  typedef dpt_10::data time;
165 };
166 
168 class dpt_11_001 : public dpt<11,001>
169 {
170 public:
171  typedef dpt_11::data date;
172 };
173 
175 class dpt_12_001 : public dpt<12,001> {};
176 
178 class dpt_13_001 : public dpt<13,001> {};
179 
181 class dpt_14_000 : public dpt<14,000> {};
182 
184 class dpt_15_000 : public dpt<15,000> {};
185 
187 class dpt_16_000 : public dpt<16,000> {};
188 
190 class dpt_17_001 : public dpt<17,001> {};
191 
193 class dpt_18_001 : public dpt<18,001> {};
194 
196 class dpt_19_001 : public dpt<19,001> {};
197 
199 class dpt_20_001 : public dpt<20,001> {};
200 
202 class dpt_26_001 : public dpt<26,001> {};
203 
205 class dpt_219_001 : public dpt<219,001> {};
206 
208 class dpt_232_600 : public dpt<232,600> {};
209 
212 
215 
216 }
Representation of date with day, month and year. Year has a value from 0 to 99 where values bigger th...
Definition: dpt.hpp:168
A 6 bit scene number with control field.
Definition: dpt.hpp:193
static KNX_IMPORT_EXPORT const dpt< 1, 001 >::set_type ON
Static variable for switching on.
Definition: dpt.hpp:100
static KNX_IMPORT_EXPORT const dpt< 1, 001 >::set_type OFF
Static variable for switching off.
Definition: dpt.hpp:102
Dimming control with direction and step value as 2^(value-1) subdivisions of the interval 0 to 100 pe...
Definition: dpt.hpp:119
A 6 bit scene number.
Definition: dpt.hpp:190
static KNX_IMPORT_EXPORT const float MAX_FLOAT
Maximal value as float.
Definition: dpt.hpp:155
Data container for this dpt.
Definition: dpt_types.hpp:173
Data container for this dpt.
Definition: dpt_types.hpp:49
Data container for this dpt.
Definition: dpt_types.hpp:89
Access data with six 4 byte fields.
Definition: dpt.hpp:184
Data container for this dpt.
Definition: dpt_types.hpp:111
Data container for this dpt.
Definition: dpt_types.hpp:152
Data container for this dpt.
Definition: dpt_types.hpp:196
Data container for this dpt.
Definition: dpt_types.hpp:221
Data container for this dpt.
Definition: dpt_types.hpp:289
dpt< MAJOR, MINOR > own_type
Assigning the type for later access.
Definition: dpt.hpp:63
Forward declaration of hidden implementation.
Definition: dpt.hpp:49
Unsigned value with 16 bit. Range from 0 to 65535.
Definition: dpt.hpp:137
Encoding of a status. Here autonomous(0), skave (1) and master (2).
Definition: dpt.hpp:199
Simple single ascii character.
Definition: dpt.hpp:124
Alarm information.
Definition: dpt.hpp:205
static KNX_IMPORT_EXPORT const uint16_t MAX
Maximal value in binary.
Definition: dpt.hpp:151
Data container for this dpt.
Definition: dpt_types.hpp:11
Unsigned value with 8 bit. Scaling represents range 0 to 100 percent.
Definition: dpt.hpp:129
Data container for this dpt.
Definition: dpt_types.hpp:30
dpt_private< MAJOR, MINOR > private_type
Assigning type of private implementation.
Definition: dpt.hpp:66
Binary single bit value with additional control bit. Either on or off.
Definition: dpt.hpp:106
Unsigned 32 bit. Here as counter.
Definition: dpt.hpp:175
Template definition of each dpt.
Definition: dpt.hpp:53
dpt_10_001 dpt_timeofday
Alias for dpt 10.001.
Definition: dpt.hpp:214
static KNX_IMPORT_EXPORT const dpt< 2, 001 >::set_type NO_CONTROL
Control bit is off so value is not used.
Definition: dpt.hpp:110
Color information.
Definition: dpt.hpp:208
Representation of time with day, hours, minutes and seconds.
Definition: dpt.hpp:161
static KNX_IMPORT_EXPORT const float MIN_FLOAT
Minimal value as float.
Definition: dpt.hpp:157
Float value with 16 bit. Non IEEE definition. Range from -671088.64 to 670760.96. Here interpreted as...
Definition: dpt.hpp:145
An ascii string with max 14 ascii characters.
Definition: dpt.hpp:187
Signed 32 bit. Here as counter.
Definition: dpt.hpp:178
separated namespace to embed all libknx related classes
Definition: connection.hpp:14
static KNX_IMPORT_EXPORT const uint16_t INVALID_DATA
Invalid value.
Definition: dpt.hpp:149
Float as 32 bit with IEEE 754 notation. Here as acceleration in ms^-2.
Definition: dpt.hpp:181
Combinaton of date and time as 8 byte value.
Definition: dpt.hpp:196
Signed value with 16 bit. Range from -32768 to 32767.
Definition: dpt.hpp:141
static KNX_IMPORT_EXPORT const dpt< 2, 001 >::set_type CONTROL_VALUE_ONE
Control bit is on and value is on.
Definition: dpt.hpp:114
Data container for this dpt.
Definition: dpt_types.hpp:349
dpt_1_001 dpt_switch
Alias for dpt 1.001.
Definition: dpt.hpp:211
Definition: dpt.hpp:18
Data container for this dpt.
Definition: dpt_types.hpp:314
MappingMajor< MAJOR >::set_type set_type
Fetching the set value type from mapping.
Definition: dpt.hpp:60
Signed value with 8 bit. Percent represents range -128 to 127 percent.
Definition: dpt.hpp:133
static KNX_IMPORT_EXPORT const dpt< 2, 001 >::set_type CONTROL_VALUE_ZERO
Control bit is on and value is off.
Definition: dpt.hpp:112
Binary single bit value. Either on or off.
Definition: dpt.hpp:96
static KNX_IMPORT_EXPORT const uint16_t MIN
Minimal value in binary.
Definition: dpt.hpp:153
Scene information with filed indicating if scene is active or not.
Definition: dpt.hpp:202