ansible4ozw 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ansible.rb +47 -0
- data/lib/ansible/ansible_callback.rb +142 -0
- data/lib/ansible/ansible_device.rb +68 -0
- data/lib/ansible/ansible_value.rb +179 -0
- data/lib/ansible/config.rb +92 -0
- data/lib/ansible/devices/ansible_dimmer.rb +80 -0
- data/lib/ansible/devices/ansible_switch.rb +66 -0
- data/lib/ansible/knx/EIBConnection.rb +2371 -0
- data/lib/ansible/knx/dpt/canonical_1bit.rb +54 -0
- data/lib/ansible/knx/dpt/dpt1.rb +224 -0
- data/lib/ansible/knx/dpt/dpt10.rb +85 -0
- data/lib/ansible/knx/dpt/dpt11.rb +72 -0
- data/lib/ansible/knx/dpt/dpt12.rb +61 -0
- data/lib/ansible/knx/dpt/dpt13.rb +100 -0
- data/lib/ansible/knx/dpt/dpt14.rb +87 -0
- data/lib/ansible/knx/dpt/dpt15.rb +72 -0
- data/lib/ansible/knx/dpt/dpt16.rb +67 -0
- data/lib/ansible/knx/dpt/dpt17.rb +65 -0
- data/lib/ansible/knx/dpt/dpt18.rb +66 -0
- data/lib/ansible/knx/dpt/dpt19.rb +100 -0
- data/lib/ansible/knx/dpt/dpt2.rb +156 -0
- data/lib/ansible/knx/dpt/dpt3.rb +104 -0
- data/lib/ansible/knx/dpt/dpt4.rb +75 -0
- data/lib/ansible/knx/dpt/dpt5.rb +124 -0
- data/lib/ansible/knx/dpt/dpt6.rb +73 -0
- data/lib/ansible/knx/dpt/dpt7.rb +146 -0
- data/lib/ansible/knx/dpt/dpt8.rb +118 -0
- data/lib/ansible/knx/dpt/dpt9.rb +204 -0
- data/lib/ansible/knx/dpt/tests/test_dpt10.rb +45 -0
- data/lib/ansible/knx/dpt/tests/test_dpt9.rb +60 -0
- data/lib/ansible/knx/hexdump.rb +113 -0
- data/lib/ansible/knx/knx_dpt.rb +58 -0
- data/lib/ansible/knx/knx_dpt_scalar.rb +62 -0
- data/lib/ansible/knx/knx_eistypes.rb +76 -0
- data/lib/ansible/knx/knx_protocol.rb +99 -0
- data/lib/ansible/knx/knx_scene.rb +48 -0
- data/lib/ansible/knx/knx_tools.rb +76 -0
- data/lib/ansible/knx/knx_transceiver.rb +237 -0
- data/lib/ansible/knx/knx_value.rb +327 -0
- data/lib/ansible/openzwave/ozw_constants.rb +11 -0
- data/lib/ansible/openzwave/ozw_headers.rb +80 -0
- data/lib/ansible/openzwave/ozw_remote_manager.rb +7615 -0
- data/lib/ansible/openzwave/ozw_types.rb +406 -0
- data/lib/ansible/orbiter_proxy.rb +12 -0
- data/lib/ansible/transceiver.rb +63 -0
- data/lib/ansible/zwave/types/valuetype_bool.rb +74 -0
- data/lib/ansible/zwave/types/valuetype_button.rb +63 -0
- data/lib/ansible/zwave/types/valuetype_byte.rb +78 -0
- data/lib/ansible/zwave/types/valuetype_decimal.rb +64 -0
- data/lib/ansible/zwave/types/valuetype_int.rb +63 -0
- data/lib/ansible/zwave/types/valuetype_list.rb +64 -0
- data/lib/ansible/zwave/types/valuetype_short.rb +63 -0
- data/lib/ansible/zwave/types/valuetype_string.rb +61 -0
- data/lib/ansible/zwave/zwave_command_classes.rb +113 -0
- data/lib/ansible/zwave/zwave_node.rb +5 -0
- data/lib/ansible/zwave/zwave_protocol.rb +52 -0
- data/lib/ansible/zwave/zwave_transceiver.rb +435 -0
- data/lib/ansible/zwave/zwave_value.rb +193 -0
- metadata +108 -0
@@ -0,0 +1,100 @@
|
|
1
|
+
=begin
|
2
|
+
Project Ansible - An extensible home automation scripting framework
|
3
|
+
----------------------------------------------------
|
4
|
+
Copyright (c) 2011 Elias Karakoulakis <elias.karakoulakis@gmail.com>
|
5
|
+
|
6
|
+
SOFTWARE NOTICE AND LICENSE
|
7
|
+
|
8
|
+
Project Ansible is free software: you can redistribute it and/or modify
|
9
|
+
it under the terms of the GNU Lesser General Public License as published
|
10
|
+
by the Free Software Foundation, either version 3 of the License,
|
11
|
+
or (at your option) any later version.
|
12
|
+
|
13
|
+
Project Ansible is distributed in the hope that it will be useful,
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
GNU Lesser General Public License for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU Lesser General Public License
|
19
|
+
along with Project Ansible. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
21
|
+
for more information on the LGPL, see:
|
22
|
+
http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License
|
23
|
+
=end
|
24
|
+
|
25
|
+
module Ansible
|
26
|
+
|
27
|
+
module KNX
|
28
|
+
|
29
|
+
#
|
30
|
+
# DPT19: 8-byte Date and Time
|
31
|
+
#
|
32
|
+
module DPT19
|
33
|
+
|
34
|
+
class DPT19_Frame < DPTFrame
|
35
|
+
# byte 8 (MSB)
|
36
|
+
uint8 :year, {
|
37
|
+
:display_name => "Year"
|
38
|
+
}
|
39
|
+
# byte 7
|
40
|
+
bit4 :pad7
|
41
|
+
bit4 :month, {
|
42
|
+
:display_name => "Month"
|
43
|
+
}
|
44
|
+
# byte 6
|
45
|
+
bit3 :pad6
|
46
|
+
bit5 :dayofmonth, {
|
47
|
+
:display_name => "Day of month"
|
48
|
+
}
|
49
|
+
# byte 5
|
50
|
+
bit3 :dayofweek, {
|
51
|
+
:display_name => "Day of week"
|
52
|
+
}
|
53
|
+
bit5 :hourofday, {
|
54
|
+
:display_name => "Hour of day"
|
55
|
+
}
|
56
|
+
# byte 4
|
57
|
+
bit2 :pad4
|
58
|
+
bit6 :minutes, {
|
59
|
+
:display_name => "Minutes"
|
60
|
+
}
|
61
|
+
# byte 3
|
62
|
+
bit2 :pad3
|
63
|
+
bit6 :seconds, {
|
64
|
+
:display_name => "Seconds"
|
65
|
+
}
|
66
|
+
# byte 2
|
67
|
+
bit1 :flag_F #
|
68
|
+
bit1 :flag_WD #
|
69
|
+
bit1 :flag_NWD # no week day
|
70
|
+
bit1 :flag_NY # no year
|
71
|
+
bit1 :flag_ND # no day
|
72
|
+
bit1 :flag_NDOW # no day of week
|
73
|
+
bit1 :flag_NT # no time
|
74
|
+
bit1 :flag_SUTI # summertime
|
75
|
+
# byte 1
|
76
|
+
bit1 :flag_CLQ #clock accuracy
|
77
|
+
bit7 :pad1
|
78
|
+
end
|
79
|
+
|
80
|
+
# DPT18 basetype info
|
81
|
+
Basetype = {
|
82
|
+
:bitlength => 8,
|
83
|
+
:valuetype => :composite,
|
84
|
+
:desc => "8-bit Scene Activate/Learn + number"
|
85
|
+
}
|
86
|
+
|
87
|
+
# DPT9 subtypes
|
88
|
+
Subtypes = {
|
89
|
+
# 9.001 temperature (oC)
|
90
|
+
"001" => {
|
91
|
+
:name => "DPT_SceneControl", :desc => "scene control"
|
92
|
+
},
|
93
|
+
}
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
@@ -0,0 +1,156 @@
|
|
1
|
+
=begin
|
2
|
+
Project Ansible - An extensible home automation scripting framework
|
3
|
+
----------------------------------------------------
|
4
|
+
Copyright (c) 2011 Elias Karakoulakis <elias.karakoulakis@gmail.com>
|
5
|
+
|
6
|
+
SOFTWARE NOTICE AND LICENSE
|
7
|
+
|
8
|
+
Project Ansible is free software: you can redistribute it and/or modify
|
9
|
+
it under the terms of the GNU Lesser General Public License as published
|
10
|
+
by the Free Software Foundation, either version 3 of the License,
|
11
|
+
or (at your option) any later version.
|
12
|
+
|
13
|
+
Project Ansible is distributed in the hope that it will be useful,
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
GNU Lesser General Public License for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU Lesser General Public License
|
19
|
+
along with Project Ansible. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
21
|
+
for more information on the LGPL, see:
|
22
|
+
http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License
|
23
|
+
=end
|
24
|
+
|
25
|
+
require 'knx/dpt/canonical_1bit'
|
26
|
+
|
27
|
+
module Ansible
|
28
|
+
|
29
|
+
module KNX
|
30
|
+
|
31
|
+
#
|
32
|
+
# DPT2: 2-bit control value
|
33
|
+
#
|
34
|
+
module DPT2
|
35
|
+
|
36
|
+
# DPT2 frame description.
|
37
|
+
# Always 8-bit aligned.
|
38
|
+
class DPT2_Frame < DPTFrame
|
39
|
+
bit2 :apci_pad, {
|
40
|
+
:display_name => "APCI info (not useful)"
|
41
|
+
}
|
42
|
+
bit4 :pad1
|
43
|
+
bit1 :priority, {
|
44
|
+
:display_name => "0=No Control 1=Priority"
|
45
|
+
}
|
46
|
+
bit1 :data, :display_name => "Value"
|
47
|
+
end
|
48
|
+
|
49
|
+
include Canonical_1bit
|
50
|
+
|
51
|
+
# DPT basetype info hash
|
52
|
+
Basetype = {
|
53
|
+
:bitlength => 2,
|
54
|
+
:valuetype => :composite,
|
55
|
+
:desc => "1-bit value with priority"
|
56
|
+
}
|
57
|
+
|
58
|
+
# DPT subtypes info hash
|
59
|
+
Subtypes = {
|
60
|
+
# 2.001 switch control
|
61
|
+
"001" => { :use => "G",
|
62
|
+
:name => "DPT_Switch_Control",
|
63
|
+
:desc => "switch with priority",
|
64
|
+
:enc => { 0 => "Off", 1 => "On" }
|
65
|
+
},
|
66
|
+
# 2.002 boolean control
|
67
|
+
"002" => { :use => "G",
|
68
|
+
:name => "DPT_Bool_Control",
|
69
|
+
:desc => "boolean with priority",
|
70
|
+
:enc => { 0 => "false", 1 => "true" }
|
71
|
+
},
|
72
|
+
# 2.003 enable control
|
73
|
+
"003" => { :use => "FB",
|
74
|
+
:name => "DPT_Emable_Control",
|
75
|
+
:desc => "enable with priority",
|
76
|
+
:enc => { 0 => "Disabled", 1 => "Enabled" }
|
77
|
+
},
|
78
|
+
|
79
|
+
# 2.004 ramp control
|
80
|
+
"004" => { :use => "FB",
|
81
|
+
:name => "DPT_Ramp_Control",
|
82
|
+
:desc => "ramp with priority",
|
83
|
+
:enc => { 0 => "No ramp", 1 => "Ramp" }
|
84
|
+
},
|
85
|
+
|
86
|
+
# 2.005 alarm control
|
87
|
+
"005" => { :use => "FB",
|
88
|
+
:name => "DPT_Alarm_Control",
|
89
|
+
:desc => "alarm with priority",
|
90
|
+
:enc => { 0 => "No alarm", 1 => "Alarm" }
|
91
|
+
},
|
92
|
+
|
93
|
+
# 2.006 binary value control
|
94
|
+
"006" => { :use => "FB",
|
95
|
+
:name => "DPT_BinaryValue_Control",
|
96
|
+
:desc => "binary value with priority",
|
97
|
+
:enc => { 0 => "Off", 1 => "On" }
|
98
|
+
},
|
99
|
+
|
100
|
+
# 2.007 step control
|
101
|
+
"007" => { :use => "FB",
|
102
|
+
:name => "DPT_Step_Control",
|
103
|
+
:desc => "step with priority",
|
104
|
+
:enc => { 0 => "Off", 1 => "On" }
|
105
|
+
},
|
106
|
+
|
107
|
+
# 2.008 Direction1 control
|
108
|
+
"008" => { :use => "FB",
|
109
|
+
:name => "DPT_Direction1_Control",
|
110
|
+
:desc => "direction 1 with priority",
|
111
|
+
:enc => { 0 => "Off", 1 => "On" }
|
112
|
+
},
|
113
|
+
|
114
|
+
# 2.009 Direction2 control
|
115
|
+
"009" => { :use => "FB",
|
116
|
+
:name => "DPT_Direction2_Control",
|
117
|
+
:desc => "direction 2 with priority",
|
118
|
+
:enc => { 0 => "Off", 1 => "On" }
|
119
|
+
},
|
120
|
+
|
121
|
+
# 2.010 start control
|
122
|
+
"001" => { :use => "FB",
|
123
|
+
:name => "DPT_Start_Control",
|
124
|
+
:desc => "start with priority",
|
125
|
+
:enc => { 0..1 => "No control", 2 => "Off", 3 => "On" }
|
126
|
+
},
|
127
|
+
|
128
|
+
# 2.011 state control
|
129
|
+
"001" => { :use => "FB",
|
130
|
+
:name => "DPT_Switch_Control", :desc => "switch",
|
131
|
+
:enc => { 0..1 => "No control", 2 => "Off", 3 => "On" }
|
132
|
+
},
|
133
|
+
|
134
|
+
# 2.012 invert control
|
135
|
+
"001" => { :use => "FB",
|
136
|
+
:name => "DPT_Switch_Control", :desc => "switch",
|
137
|
+
:enc => { 0..1 => "No control", 2 => "Off", 3 => "On" }
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
end #class
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
=begin
|
148
|
+
puts KNX_DPT2.bit_length
|
149
|
+
puts KNX_DPT2.new([0x00].pack('c')).inspect #
|
150
|
+
puts KNX_DPT2.new([0x01].pack('c')).inspect #
|
151
|
+
puts KNX_DPT2.new([0x02].pack('c')).inspect #
|
152
|
+
puts KNX_DPT2.new([0x03].pack('c')).inspect #
|
153
|
+
|
154
|
+
puts [0x02].pack('c').inspect
|
155
|
+
=begin
|
156
|
+
=end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
=begin
|
2
|
+
Project Ansible - An extensible home automation scripting framework
|
3
|
+
----------------------------------------------------
|
4
|
+
Copyright (c) 2011 Elias Karakoulakis <elias.karakoulakis@gmail.com>
|
5
|
+
|
6
|
+
SOFTWARE NOTICE AND LICENSE
|
7
|
+
|
8
|
+
Project Ansible is free software: you can redistribute it and/or modify
|
9
|
+
it under the terms of the GNU Lesser General Public License as published
|
10
|
+
by the Free Software Foundation, either version 3 of the License,
|
11
|
+
or (at your option) any later version.
|
12
|
+
|
13
|
+
Project Ansible is distributed in the hope that it will be useful,
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
GNU Lesser General Public License for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU Lesser General Public License
|
19
|
+
along with Project Ansible. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
21
|
+
for more information on the LGPL, see:
|
22
|
+
http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License
|
23
|
+
=end
|
24
|
+
|
25
|
+
module Ansible
|
26
|
+
|
27
|
+
module KNX
|
28
|
+
|
29
|
+
#
|
30
|
+
# DPT3.*: 4-bit dimming/blinds control
|
31
|
+
#
|
32
|
+
module DPT3
|
33
|
+
|
34
|
+
# Bitstruct to parse a DPT3 frame.
|
35
|
+
# Always 8-bit aligned.
|
36
|
+
class DPT3_Frame < DPTFrame
|
37
|
+
bit2 :apci_pad, :display_name => "APCI data"
|
38
|
+
bit2 :pad1
|
39
|
+
bit1 :decr_incr, :display_name => "Decrease(0) / Increase(1)"
|
40
|
+
bit3 :data, {
|
41
|
+
:display_name => "0=break, 1-7 = amount of intervals between 1..100%",
|
42
|
+
:enc => {
|
43
|
+
0 => "break",
|
44
|
+
1 => "ival=50%",
|
45
|
+
2 => "ival=25%",
|
46
|
+
3 => "ival=12,5%",
|
47
|
+
4 => "ival=6,25%",
|
48
|
+
5 => "ival=3,125%",
|
49
|
+
6 => "ival=1,5625%",
|
50
|
+
7 => "ival=0.78125%"
|
51
|
+
}
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
Basetype = {
|
56
|
+
:bitlength => 4,
|
57
|
+
:valuetype => :composite,
|
58
|
+
:desc => "4-bit relative dimming control"
|
59
|
+
}
|
60
|
+
|
61
|
+
Subtypes = {
|
62
|
+
# 3.007 dimming control
|
63
|
+
"3.007" => {
|
64
|
+
:name => "DPT_Control_Dimming",
|
65
|
+
:desc => "dimming control"
|
66
|
+
},
|
67
|
+
|
68
|
+
# 3.008 blind control
|
69
|
+
"3.008" => {
|
70
|
+
:name => "DPT_Control_Blinds",
|
71
|
+
:desc => "blinds control"
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
=begin
|
82
|
+
2.6.3.5 Behavior
|
83
|
+
Status
|
84
|
+
off dimming actuator switched off
|
85
|
+
on dimming actuator switched on, constant brightness, at least
|
86
|
+
minimal brightness dimming
|
87
|
+
dimming actuator switched on, moving from actual value in direction of
|
88
|
+
set value
|
89
|
+
Events
|
90
|
+
position = 0 off command
|
91
|
+
position = 1 on command
|
92
|
+
control = up dX command, dX more bright dimming
|
93
|
+
control = down dX command, dX less bright dimming
|
94
|
+
control = stop stop command
|
95
|
+
value = 0 dimming value = off
|
96
|
+
value = x% dimming value = x% (not zero)
|
97
|
+
value_reached actual value reached set value
|
98
|
+
|
99
|
+
The step size dX for up and down dimming may be 1/1, 1/2, 1/4, 1/8, 1/16, 1/32 and 1/64 of
|
100
|
+
the full dimming range (0 - FFh).
|
101
|
+
|
102
|
+
3.007 dimming control
|
103
|
+
3.008 blind control
|
104
|
+
=end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
=begin
|
2
|
+
Project Ansible - An extensible home automation scripting framework
|
3
|
+
----------------------------------------------------
|
4
|
+
Copyright (c) 2011 Elias Karakoulakis <elias.karakoulakis@gmail.com>
|
5
|
+
|
6
|
+
SOFTWARE NOTICE AND LICENSE
|
7
|
+
|
8
|
+
Project Ansible is free software: you can redistribute it and/or modify
|
9
|
+
it under the terms of the GNU Lesser General Public License as published
|
10
|
+
by the Free Software Foundation, either version 3 of the License,
|
11
|
+
or (at your option) any later version.
|
12
|
+
|
13
|
+
Project Ansible is distributed in the hope that it will be useful,
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
GNU Lesser General Public License for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU Lesser General Public License
|
19
|
+
along with Project Ansible. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
21
|
+
for more information on the LGPL, see:
|
22
|
+
http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License
|
23
|
+
=end
|
24
|
+
|
25
|
+
module Ansible
|
26
|
+
|
27
|
+
module KNX
|
28
|
+
|
29
|
+
#
|
30
|
+
# DPT4: 8-bit character
|
31
|
+
#
|
32
|
+
module DPT4
|
33
|
+
|
34
|
+
# Bitstruct to parse a DPT4 frame.
|
35
|
+
# Always 8-bit aligned.
|
36
|
+
class DPT4_Frame < DPTFrame
|
37
|
+
uint8 :data, :display_name => "Character"
|
38
|
+
end
|
39
|
+
|
40
|
+
Basetype = {
|
41
|
+
:bitlength => 8,
|
42
|
+
:valuetype => :basic,
|
43
|
+
:desc => "8-bit character"
|
44
|
+
}
|
45
|
+
|
46
|
+
Subtypes = {
|
47
|
+
# 4.001 character (ASCII)
|
48
|
+
"001" => {
|
49
|
+
:name => "DPT_Char_ASCII",
|
50
|
+
:desc => "ASCII character (0-127)",
|
51
|
+
:range => 0..127,
|
52
|
+
:use => "G",
|
53
|
+
},
|
54
|
+
# 4.002 character (ISO-8859-1)
|
55
|
+
"002" => {
|
56
|
+
:name => "DPT_Char_8859_1",
|
57
|
+
:desc => "ISO-8859-1 character (0..255)",
|
58
|
+
:use => "G",
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
=begin
|
68
|
+
puts KNX_DPT2.bit_length
|
69
|
+
puts KNX_DPT2.new([0x00].pack('c')).inspect #
|
70
|
+
puts KNX_DPT2.new([0x01].pack('c')).inspect #
|
71
|
+
puts KNX_DPT2.new([0x02].pack('c')).inspect #
|
72
|
+
puts KNX_DPT2.new([0x03].pack('c')).inspect #
|
73
|
+
|
74
|
+
puts [0x02].pack('c').inspect
|
75
|
+
=end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# encoding: ISO-8859-1
|
2
|
+
|
3
|
+
=begin
|
4
|
+
Project Ansible - An extensible home automation scripting framework
|
5
|
+
----------------------------------------------------
|
6
|
+
Copyright (c) 2011 Elias Karakoulakis <elias.karakoulakis@gmail.com>
|
7
|
+
|
8
|
+
SOFTWARE NOTICE AND LICENSE
|
9
|
+
|
10
|
+
Project Ansible is free software: you can redistribute it and/or modify
|
11
|
+
it under the terms of the GNU Lesser General Public License as published
|
12
|
+
by the Free Software Foundation, either version 3 of the License,
|
13
|
+
or (at your option) any later version.
|
14
|
+
|
15
|
+
Project Ansible is distributed in the hope that it will be useful,
|
16
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18
|
+
GNU Lesser General Public License for more details.
|
19
|
+
|
20
|
+
You should have received a copy of the GNU Lesser General Public License
|
21
|
+
along with Project Ansible. If not, see <http://www.gnu.org/licenses/>.
|
22
|
+
|
23
|
+
for more information on the LGPL, see:
|
24
|
+
http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License
|
25
|
+
=end
|
26
|
+
|
27
|
+
require 'knx_dpt_scalar'
|
28
|
+
|
29
|
+
module Ansible
|
30
|
+
|
31
|
+
module KNX
|
32
|
+
|
33
|
+
#
|
34
|
+
# DPT5: 8-bit unsigned value
|
35
|
+
#
|
36
|
+
module DPT5
|
37
|
+
|
38
|
+
# DPT5 is the only (AFAIK) DPT with scalar datatypes (5.001 and 5.003)
|
39
|
+
include ScalarValue
|
40
|
+
|
41
|
+
# Bitstruct to parse a DPT5 frame.
|
42
|
+
# Always 8-bit aligned.
|
43
|
+
class DPT5_Frame < DPTFrame
|
44
|
+
uint8 :data, {
|
45
|
+
:display_name => "8-bit unsigned value",
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
# DPT base type
|
50
|
+
Basetype = {
|
51
|
+
:bitlength => 8,
|
52
|
+
:range => 0..255,
|
53
|
+
:valuetype => :basic,
|
54
|
+
:desc => "8-bit unsigned value"
|
55
|
+
}
|
56
|
+
|
57
|
+
# DPT subtypes
|
58
|
+
Subtypes = {
|
59
|
+
# 5.001 percentage (0=0..ff=100%)
|
60
|
+
"001" => {
|
61
|
+
:name => "DPT_Scaling", :desc => "percent",
|
62
|
+
:unit => "%", :scalar_range => 0..100
|
63
|
+
},
|
64
|
+
|
65
|
+
# 5.003 angle (degrees 0=0, ff=360)
|
66
|
+
"003" => {
|
67
|
+
:name => "DPT_Angle", :desc => "angle degrees",
|
68
|
+
:unit => "°", :scalar_range => 0..360
|
69
|
+
},
|
70
|
+
|
71
|
+
# 5.004 percentage (0..255%)
|
72
|
+
"004" => {
|
73
|
+
:name => "DPT_Percent_U8", :desc => "percent",
|
74
|
+
:unit => "%",
|
75
|
+
},
|
76
|
+
|
77
|
+
# 5.005 ratio (0..255)
|
78
|
+
"005" => {
|
79
|
+
:name => "DPT_DecimalFactor", :desc => "ratio",
|
80
|
+
:unit => "ratio",
|
81
|
+
},
|
82
|
+
|
83
|
+
# 5.006 tariff (0..255)
|
84
|
+
"006" => {
|
85
|
+
:name => "DPT_Tariff", :desc => "tariff",
|
86
|
+
:unit => "tariff",
|
87
|
+
},
|
88
|
+
|
89
|
+
# 5.010 counter pulses (0..255)
|
90
|
+
"010" => {
|
91
|
+
:name => "DPT_Value_1_Ucount", :desc => "counter pulses",
|
92
|
+
:unit => "pulses",
|
93
|
+
},
|
94
|
+
}
|
95
|
+
|
96
|
+
# DPT5 canonical values
|
97
|
+
# ---------------------
|
98
|
+
# use scalar conversion, if applicable
|
99
|
+
# otherwise just return the data value
|
100
|
+
def as_canonical_value()
|
101
|
+
return nil if current_value.nil?
|
102
|
+
# get and apply field's scalar range, if any (only in DPT5 afaik)
|
103
|
+
if (sr = getparam(:scalar_range) and range = getparam(:range)) then
|
104
|
+
return to_scalar(current_value.data.value, range, sr)
|
105
|
+
else
|
106
|
+
return current_value.data.value
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
#
|
111
|
+
#
|
112
|
+
def to_protocol_value(v)
|
113
|
+
if (sr = getparam(:scalar_range) and range = getparam(:range)) then
|
114
|
+
return from_scalar(v, range, sr)
|
115
|
+
else
|
116
|
+
return v
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|