somfy_sdn 2.4.0 → 2.5.0
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.
- checksums.yaml +4 -4
- data/exe/somfy_sdn +1 -0
- data/lib/sdn/cli/mqtt/group.rb +11 -0
- data/lib/sdn/cli/mqtt/motor.rb +25 -1
- data/lib/sdn/cli/mqtt/p_queue.rb +6 -0
- data/lib/sdn/cli/mqtt/read.rb +46 -47
- data/lib/sdn/cli/mqtt/subscriptions.rb +8 -0
- data/lib/sdn/cli/mqtt/write.rb +67 -27
- data/lib/sdn/cli/mqtt.rb +296 -211
- data/lib/sdn/cli/provisioner.rb +34 -1
- data/lib/sdn/cli/simulator.rb +78 -11
- data/lib/sdn/cli.rb +6 -0
- data/lib/sdn/client.rb +42 -2
- data/lib/sdn/message/control.rb +136 -12
- data/lib/sdn/message/get.rb +57 -0
- data/lib/sdn/message/helpers.rb +64 -0
- data/lib/sdn/message/ilt2/get.rb +24 -0
- data/lib/sdn/message/ilt2/master_control.rb +10 -0
- data/lib/sdn/message/ilt2/post.rb +79 -13
- data/lib/sdn/message/ilt2/set.rb +112 -7
- data/lib/sdn/message/post.rb +181 -20
- data/lib/sdn/message/set.rb +166 -8
- data/lib/sdn/message.rb +121 -14
- data/lib/sdn/version.rb +2 -1
- data/lib/sdn.rb +13 -5
- metadata +5 -18
data/lib/sdn/message/ilt2/set.rb
CHANGED
|
@@ -3,18 +3,29 @@
|
|
|
3
3
|
module SDN
|
|
4
4
|
class Message
|
|
5
5
|
module ILT2
|
|
6
|
+
# Command that writes the ILT2 IR channel bitmask.
|
|
6
7
|
class SetIRConfig < PostIRConfig
|
|
8
|
+
# (see Ack::MSG)
|
|
7
9
|
MSG = 0x59
|
|
8
10
|
|
|
11
|
+
# Creates an ILT2 IR configuration write command.
|
|
12
|
+
#
|
|
13
|
+
# @param dest [(Integer, Integer, Integer), nil] destination address
|
|
14
|
+
# @param channels [Integer, nil] IR channel bitmask
|
|
15
|
+
# @param kwargs [Hash] additional message options
|
|
9
16
|
def initialize(dest = nil, channels = nil, **kwargs)
|
|
10
17
|
kwargs[:dest] ||= dest
|
|
11
18
|
super(channels, **kwargs)
|
|
12
19
|
end
|
|
13
20
|
end
|
|
14
21
|
|
|
22
|
+
# Command that applies or clears an ILT2 lock target.
|
|
15
23
|
class SetLockStatus < Message
|
|
24
|
+
# (see Ack::MSG)
|
|
16
25
|
MSG = 0x5B
|
|
26
|
+
# (see Ack::PARAMS_LENGTH)
|
|
17
27
|
PARAMS_LENGTH = 3
|
|
28
|
+
# Mapping from symbolic lock targets to SDN parameter values.
|
|
18
29
|
TARGET_TYPE = {
|
|
19
30
|
current: 0,
|
|
20
31
|
up_limit: 1,
|
|
@@ -23,9 +34,27 @@ module SDN
|
|
|
23
34
|
unlock: 5
|
|
24
35
|
}.freeze
|
|
25
36
|
|
|
37
|
+
# @!attribute [rw] target_type
|
|
38
|
+
#
|
|
26
39
|
# when target_type is down_limit, target is number of 10ms intervals it's still allowed to roll up
|
|
27
|
-
|
|
28
|
-
|
|
40
|
+
# Requested ILT2 lock target selector.
|
|
41
|
+
#
|
|
42
|
+
# @return [:current, :up_limit, :down_limit, :ip, :unlock]
|
|
43
|
+
attr_reader :target_type
|
|
44
|
+
|
|
45
|
+
# @return [Integer, nil]
|
|
46
|
+
attr_reader :target
|
|
47
|
+
|
|
48
|
+
# @return [Integer]
|
|
49
|
+
attr_reader :priority
|
|
50
|
+
|
|
51
|
+
# Creates an ILT2 lock status write command.
|
|
52
|
+
#
|
|
53
|
+
# @param dest [(Integer, Integer, Integer), nil] destination address
|
|
54
|
+
# @param target_type [Symbol] lock target selector
|
|
55
|
+
# @param target [Integer, nil] target value
|
|
56
|
+
# @param priority [Integer] lock priority
|
|
57
|
+
# @param kwargs [Hash] additional message options
|
|
29
58
|
def initialize(dest = nil, target_type = :unlock, target = nil, priority = 1, **kwargs)
|
|
30
59
|
kwargs[:dest] ||= dest
|
|
31
60
|
super(**kwargs)
|
|
@@ -34,6 +63,7 @@ module SDN
|
|
|
34
63
|
self.priority = priority
|
|
35
64
|
end
|
|
36
65
|
|
|
66
|
+
# (see Message#parse)
|
|
37
67
|
def parse(params)
|
|
38
68
|
super
|
|
39
69
|
self.target_type = TARGET_TYPE.invert[to_number(params[0])]
|
|
@@ -60,17 +90,35 @@ module SDN
|
|
|
60
90
|
@priority = value
|
|
61
91
|
end
|
|
62
92
|
|
|
93
|
+
# (see Message#params)
|
|
63
94
|
def params
|
|
64
95
|
transform_param(TARGET_TYPE[target_type]) + transform_param(target) + transform_param(priority)
|
|
65
96
|
end
|
|
66
97
|
end
|
|
67
98
|
|
|
99
|
+
# Command that writes an ILT2 intermediate position slot.
|
|
68
100
|
class SetMotorIP < Message
|
|
101
|
+
# (see Ack::MSG)
|
|
69
102
|
MSG = 0x53
|
|
103
|
+
# (see Ack::PARAMS_LENGTH)
|
|
70
104
|
PARAMS_LENGTH = 3
|
|
71
105
|
|
|
72
|
-
|
|
73
|
-
|
|
106
|
+
# @!attribute [rw] ip
|
|
107
|
+
#
|
|
108
|
+
# Requested ILT2 intermediate position slot in the range 1..16.
|
|
109
|
+
#
|
|
110
|
+
# @return [Integer, nil]
|
|
111
|
+
attr_reader :ip
|
|
112
|
+
|
|
113
|
+
# @return [Integer, nil]
|
|
114
|
+
attr_reader :value
|
|
115
|
+
|
|
116
|
+
# Creates an ILT2 intermediate position write command.
|
|
117
|
+
#
|
|
118
|
+
# @param dest [(Integer, Integer, Integer), nil] destination address
|
|
119
|
+
# @param ip [Integer] intermediate position slot
|
|
120
|
+
# @param value [Integer, nil] stored value
|
|
121
|
+
# @param kwargs [Hash] additional message options
|
|
74
122
|
def initialize(dest = nil, ip = 1, value = nil, **kwargs)
|
|
75
123
|
kwargs[:dest] ||= dest
|
|
76
124
|
super(**kwargs)
|
|
@@ -78,6 +126,7 @@ module SDN
|
|
|
78
126
|
self.value = value
|
|
79
127
|
end
|
|
80
128
|
|
|
129
|
+
# (see Message#parse)
|
|
81
130
|
def parse(params)
|
|
82
131
|
super
|
|
83
132
|
self.ip = to_number(params[0]) + 1
|
|
@@ -94,18 +143,25 @@ module SDN
|
|
|
94
143
|
@value = value&.& 0xffff
|
|
95
144
|
end
|
|
96
145
|
|
|
146
|
+
# (see Message#params)
|
|
97
147
|
def params
|
|
98
148
|
transform_param(ip - 1) + from_number(value, 2)
|
|
99
149
|
end
|
|
100
150
|
end
|
|
101
151
|
|
|
152
|
+
# ILT2 motor-limit command whose payload is not yet decoded.
|
|
102
153
|
class SetMotorLimits < UnknownMessage
|
|
154
|
+
# (see Ack::MSG)
|
|
103
155
|
MSG = 0x5C
|
|
104
156
|
end
|
|
105
157
|
|
|
158
|
+
# Command that moves an ILT2 motor to a specific target.
|
|
106
159
|
class SetMotorPosition < Message
|
|
160
|
+
# (see Ack::MSG)
|
|
107
161
|
MSG = 0x54
|
|
162
|
+
# (see Ack::PARAMS_LENGTH)
|
|
108
163
|
PARAMS_LENGTH = 3
|
|
164
|
+
# Mapping from symbolic ILT2 move targets to SDN parameter values.
|
|
109
165
|
TARGET_TYPE = {
|
|
110
166
|
up_limit: 1,
|
|
111
167
|
down_limit: 2,
|
|
@@ -121,8 +177,35 @@ module SDN
|
|
|
121
177
|
position_percent: 16
|
|
122
178
|
}.freeze
|
|
123
179
|
|
|
124
|
-
|
|
125
|
-
|
|
180
|
+
# @!attribute [rw] target_type
|
|
181
|
+
#
|
|
182
|
+
# Requested ILT2 movement target selector.
|
|
183
|
+
#
|
|
184
|
+
# @return [:up_limit,
|
|
185
|
+
# :down_limit,
|
|
186
|
+
# :stop,
|
|
187
|
+
# :ip,
|
|
188
|
+
# :next_ip_up,
|
|
189
|
+
# :next_ip_down,
|
|
190
|
+
# :position_pulses,
|
|
191
|
+
# :jog_up_ms,
|
|
192
|
+
# :jog_down_ms,
|
|
193
|
+
# :jog_up_pulses,
|
|
194
|
+
# :jog_down_pulses,
|
|
195
|
+
# :position_percent]
|
|
196
|
+
attr_reader :target_type
|
|
197
|
+
|
|
198
|
+
# @!attribute [rw] target
|
|
199
|
+
#
|
|
200
|
+
# @return [Integer, Numeric, nil]
|
|
201
|
+
attr_reader :target
|
|
202
|
+
|
|
203
|
+
# Creates an ILT2 motor positioning command.
|
|
204
|
+
#
|
|
205
|
+
# @param dest [(Integer, Integer, Integer), nil] destination address
|
|
206
|
+
# @param target_type [Symbol] target selector
|
|
207
|
+
# @param target [Integer, Numeric] target value
|
|
208
|
+
# @param kwargs [Hash] additional message options
|
|
126
209
|
def initialize(dest = nil, target_type = :up_limit, target = 0, **kwargs)
|
|
127
210
|
kwargs[:dest] ||= dest
|
|
128
211
|
super(**kwargs)
|
|
@@ -130,6 +213,7 @@ module SDN
|
|
|
130
213
|
self.target = target
|
|
131
214
|
end
|
|
132
215
|
|
|
216
|
+
# (see Message#parse)
|
|
133
217
|
def parse(params)
|
|
134
218
|
super
|
|
135
219
|
self.target_type = TARGET_TYPE.invert[to_number(params[0])]
|
|
@@ -157,6 +241,7 @@ module SDN
|
|
|
157
241
|
end
|
|
158
242
|
end
|
|
159
243
|
|
|
244
|
+
# (see Message#params)
|
|
160
245
|
def params
|
|
161
246
|
param = target
|
|
162
247
|
param = (param * 255 / 100).to_i if target_type == :position_percent
|
|
@@ -168,11 +253,27 @@ module SDN
|
|
|
168
253
|
# the motor does not move, and just stores the new values
|
|
169
254
|
# flags of 1 is reverse direction, but you have to set it every time
|
|
170
255
|
class SetMotorSettings < UnknownMessage
|
|
256
|
+
# (see Ack::MSG)
|
|
171
257
|
MSG = 0x52
|
|
258
|
+
# (see Ack::PARAMS_LENGTH)
|
|
172
259
|
PARAMS_LENGTH = 5
|
|
173
260
|
|
|
174
|
-
|
|
261
|
+
# @return [Integer]
|
|
262
|
+
attr_accessor :flags
|
|
263
|
+
|
|
264
|
+
# @return [Integer]
|
|
265
|
+
attr_accessor :down_limit
|
|
266
|
+
|
|
267
|
+
# @return [Integer]
|
|
268
|
+
attr_accessor :position_pulses
|
|
175
269
|
|
|
270
|
+
# Creates an ILT2 motor settings write command.
|
|
271
|
+
#
|
|
272
|
+
# @param dest [(Integer, Integer, Integer), nil] destination address
|
|
273
|
+
# @param flags [Integer] settings flags
|
|
274
|
+
# @param down_limit [Integer] configured lower limit
|
|
275
|
+
# @param position_pulses [Integer] stored current position
|
|
276
|
+
# @param kwargs [Hash] additional message options
|
|
176
277
|
def initialize(dest = nil, flags = 0, down_limit = 0, position_pulses = 0, **kwargs)
|
|
177
278
|
kwargs[:dest] ||= dest
|
|
178
279
|
super(**kwargs)
|
|
@@ -181,6 +282,7 @@ module SDN
|
|
|
181
282
|
self.position_pulses = position_pulses
|
|
182
283
|
end
|
|
183
284
|
|
|
285
|
+
# (see Message#parse)
|
|
184
286
|
def parse(params)
|
|
185
287
|
super
|
|
186
288
|
self.flags = to_number(params[0])
|
|
@@ -188,12 +290,15 @@ module SDN
|
|
|
188
290
|
self.position_pulses = to_number(params[3..4])
|
|
189
291
|
end
|
|
190
292
|
|
|
293
|
+
# (see Message#params)
|
|
191
294
|
def params
|
|
192
295
|
transform_param(flags) + from_number(down_limit, 2) + from_number(position_pulses, 2)
|
|
193
296
|
end
|
|
194
297
|
end
|
|
195
298
|
|
|
299
|
+
# ILT2 node-label write variant with a larger maximum payload.
|
|
196
300
|
class SetNodeLabel < ::SDN::Message::SetNodeLabel
|
|
301
|
+
# Maximum label length, in bytes
|
|
197
302
|
MAX_LENGTH = 32
|
|
198
303
|
end
|
|
199
304
|
end
|
data/lib/sdn/message/post.rb
CHANGED
|
@@ -2,60 +2,104 @@
|
|
|
2
2
|
|
|
3
3
|
module SDN
|
|
4
4
|
class Message
|
|
5
|
+
# Response carrying a motor's group address for a specific slot.
|
|
5
6
|
class PostGroupAddr < Message
|
|
7
|
+
# (see Ack::MSG)
|
|
6
8
|
MSG = 0x61
|
|
9
|
+
# (see Ack::PARAMS_LENGTH)
|
|
7
10
|
PARAMS_LENGTH = 4
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
# Creates a group address response message.
|
|
13
|
+
#
|
|
14
|
+
# @param group_index [Integer, nil] group slot number
|
|
15
|
+
# @param group_address [(Integer, Integer, Integer), nil] group address bytes
|
|
16
|
+
def initialize(group_index = nil, group_address = nil, **)
|
|
17
|
+
super(**)
|
|
11
18
|
self.group_index = group_index
|
|
12
19
|
self.group_address = group_address
|
|
13
20
|
end
|
|
14
21
|
|
|
15
|
-
|
|
22
|
+
# Reported group slot number.
|
|
23
|
+
#
|
|
24
|
+
# @return [Integer, nil]
|
|
25
|
+
attr_accessor :group_index
|
|
16
26
|
|
|
27
|
+
# Reported group address for the slot.
|
|
28
|
+
#
|
|
29
|
+
# @return [(Integer, Integer, Integer), nil]
|
|
30
|
+
attr_accessor :group_address
|
|
31
|
+
|
|
32
|
+
# (see Message#parse)
|
|
17
33
|
def parse(params)
|
|
18
34
|
super
|
|
19
35
|
self.group_index = to_number(params[0]) + 1
|
|
20
36
|
self.group_address = transform_param(params[1..3])
|
|
21
|
-
self.group_address = nil if
|
|
37
|
+
self.group_address = nil if [[0, 0, 0], [0x01, 0x01, 0xff]].include?(group_address)
|
|
22
38
|
end
|
|
23
39
|
|
|
40
|
+
# (see Message#params)
|
|
24
41
|
def params
|
|
25
42
|
from_number(group_index - 1) + transform_param(group_address || [0, 0, 0])
|
|
26
43
|
end
|
|
27
44
|
|
|
45
|
+
# (see Message#class_inspect)
|
|
28
46
|
def class_inspect
|
|
29
47
|
", group_index=#{group_index.inspect}, group_address=#{group_address ? print_address(group_address) : "nil"}"
|
|
30
48
|
end
|
|
31
49
|
end
|
|
32
50
|
|
|
51
|
+
# Response carrying a motor's configured rotation direction.
|
|
33
52
|
class PostMotorDirection < Message
|
|
53
|
+
# (see Ack::MSG)
|
|
34
54
|
MSG = 0x32
|
|
55
|
+
# (see Ack::PARAMS_LENGTH)
|
|
35
56
|
PARAMS_LENGTH = 1
|
|
57
|
+
# Mapping from symbolic direction names to SDN parameter values.
|
|
36
58
|
DIRECTION = { standard: 0x00, reversed: 0x01 }.freeze
|
|
37
59
|
|
|
60
|
+
# Reported motor rotation direction.
|
|
61
|
+
#
|
|
62
|
+
# @return [:standard, :reversed, nil]
|
|
38
63
|
attr_accessor :direction
|
|
39
64
|
|
|
65
|
+
# (see Message#parse)
|
|
40
66
|
def parse(params)
|
|
41
67
|
super
|
|
42
68
|
self.direction = DIRECTION.invert[to_number(params[0])]
|
|
43
69
|
end
|
|
44
70
|
end
|
|
45
71
|
|
|
72
|
+
# Response carrying a stored intermediate position value.
|
|
46
73
|
class PostMotorIP < Message
|
|
74
|
+
# (see Ack::MSG)
|
|
47
75
|
MSG = 0x35
|
|
76
|
+
# (see Ack::PARAMS_LENGTH)
|
|
48
77
|
PARAMS_LENGTH = 4
|
|
49
78
|
|
|
50
|
-
|
|
79
|
+
# Reported intermediate position slot.
|
|
80
|
+
#
|
|
81
|
+
# @return [Integer, nil]
|
|
82
|
+
attr_accessor :ip
|
|
83
|
+
|
|
84
|
+
# @return [Integer, nil]
|
|
85
|
+
attr_accessor :position_pulses
|
|
86
|
+
|
|
87
|
+
# @return [Integer, nil]
|
|
88
|
+
attr_accessor :position_percent
|
|
51
89
|
|
|
52
|
-
|
|
53
|
-
|
|
90
|
+
# Creates a motor IP response message.
|
|
91
|
+
#
|
|
92
|
+
# @param ip [Integer, nil] intermediate position slot
|
|
93
|
+
# @param position_pulses [Integer, nil] stored pulse value
|
|
94
|
+
# @param position_percent [Integer, nil] stored percentage value
|
|
95
|
+
def initialize(ip = nil, position_pulses = nil, position_percent = nil, **)
|
|
96
|
+
super(**)
|
|
54
97
|
self.ip = ip
|
|
55
98
|
self.position_pulses = position_pulses
|
|
56
99
|
self.position_percent = position_percent
|
|
57
100
|
end
|
|
58
101
|
|
|
102
|
+
# (see Message#parse)
|
|
59
103
|
def parse(params)
|
|
60
104
|
super
|
|
61
105
|
self.ip = to_number(params[0])
|
|
@@ -63,47 +107,79 @@ module SDN
|
|
|
63
107
|
self.position_percent = to_number(params[3], nillable: true)
|
|
64
108
|
end
|
|
65
109
|
|
|
110
|
+
# (see Message#params)
|
|
66
111
|
def params
|
|
67
112
|
from_number(ip) + from_number(position_pulses, 2) + from_number(position_percent)
|
|
68
113
|
end
|
|
69
114
|
end
|
|
70
115
|
|
|
116
|
+
# Response carrying a motor's upper and lower travel limits.
|
|
71
117
|
class PostMotorLimits < Message
|
|
118
|
+
# (see Ack::MSG)
|
|
72
119
|
MSG = 0x31
|
|
120
|
+
# (see Ack::PARAMS_LENGTH)
|
|
73
121
|
PARAMS_LENGTH = 4
|
|
74
122
|
|
|
75
|
-
|
|
123
|
+
# @return [Integer, nil]
|
|
124
|
+
attr_accessor :up_limit
|
|
76
125
|
|
|
77
|
-
|
|
78
|
-
|
|
126
|
+
# @return [Integer, nil]
|
|
127
|
+
attr_accessor :down_limit
|
|
128
|
+
|
|
129
|
+
# Creates a motor limits response message.
|
|
130
|
+
#
|
|
131
|
+
# @param up_limit [Integer, nil] upper limit in pulses
|
|
132
|
+
# @param down_limit [Integer, nil] lower limit in pulses
|
|
133
|
+
def initialize(up_limit = nil, down_limit = nil, **)
|
|
134
|
+
super(**)
|
|
79
135
|
self.up_limit = up_limit
|
|
80
136
|
self.down_limit = down_limit
|
|
81
137
|
end
|
|
82
138
|
|
|
139
|
+
# (see Message#parse)
|
|
83
140
|
def parse(params)
|
|
84
141
|
super
|
|
85
142
|
self.up_limit = to_number(params[0..1], nillable: true)
|
|
86
143
|
self.down_limit = to_number(params[2..3], nillable: true)
|
|
87
144
|
end
|
|
88
145
|
|
|
146
|
+
# (see Message#params)
|
|
89
147
|
def params
|
|
90
148
|
from_number(up_limit, 2) + from_number(down_limit, 2)
|
|
91
149
|
end
|
|
92
150
|
end
|
|
93
151
|
|
|
152
|
+
# Response carrying a motor's current position and active intermediate position.
|
|
94
153
|
class PostMotorPosition < Message
|
|
154
|
+
# (see Ack::MSG)
|
|
95
155
|
MSG = 0x0d
|
|
156
|
+
# (see Ack::PARAMS_LENGTH)
|
|
96
157
|
PARAMS_LENGTH = 5
|
|
97
158
|
|
|
98
|
-
|
|
159
|
+
# @return [Integer, nil]
|
|
160
|
+
attr_accessor :position_pulses
|
|
161
|
+
|
|
162
|
+
# @return [Integer, nil]
|
|
163
|
+
attr_accessor :position_percent
|
|
164
|
+
|
|
165
|
+
# Reported active intermediate position slot.
|
|
166
|
+
#
|
|
167
|
+
# @return [Integer, nil]
|
|
168
|
+
attr_accessor :ip
|
|
99
169
|
|
|
100
|
-
|
|
101
|
-
|
|
170
|
+
# Creates a motor position response message.
|
|
171
|
+
#
|
|
172
|
+
# @param position_pulses [Integer, nil] current position in pulses
|
|
173
|
+
# @param position_percent [Integer, nil] current position in percent
|
|
174
|
+
# @param ip [Integer, nil] active intermediate position slot
|
|
175
|
+
def initialize(position_pulses = nil, position_percent = nil, ip = nil, **)
|
|
176
|
+
super(**)
|
|
102
177
|
self.position_pulses = position_pulses
|
|
103
178
|
self.position_percent = position_percent
|
|
104
179
|
self.ip = ip
|
|
105
180
|
end
|
|
106
181
|
|
|
182
|
+
# (see Message#parse)
|
|
107
183
|
def parse(params)
|
|
108
184
|
super
|
|
109
185
|
self.position_pulses = to_number(params[0..1], nillable: true)
|
|
@@ -111,17 +187,29 @@ module SDN
|
|
|
111
187
|
self.ip = to_number(params[4], nillable: true)
|
|
112
188
|
end
|
|
113
189
|
|
|
190
|
+
# (see Message#params)
|
|
114
191
|
def params
|
|
115
|
-
from_number(position_pulses, 2) + from_number(position_percent) + from_number(ip)
|
|
192
|
+
from_number(position_pulses, 2) + from_number(position_percent) + from_number(0) + from_number(ip)
|
|
116
193
|
end
|
|
117
194
|
end
|
|
118
195
|
|
|
196
|
+
# Response carrying a motor's rolling speed configuration.
|
|
119
197
|
class PostMotorRollingSpeed < Message
|
|
198
|
+
# (see Ack::MSG)
|
|
120
199
|
MSG = 0x33
|
|
200
|
+
# (see Ack::PARAMS_LENGTH)
|
|
121
201
|
PARAMS_LENGTH = 6
|
|
122
202
|
|
|
123
|
-
|
|
203
|
+
# @return [Integer, nil]
|
|
204
|
+
attr_accessor :up_speed
|
|
124
205
|
|
|
206
|
+
# @return [Integer, nil]
|
|
207
|
+
attr_accessor :down_speed
|
|
208
|
+
|
|
209
|
+
# @return [Integer, nil]
|
|
210
|
+
attr_accessor :slow_speed
|
|
211
|
+
|
|
212
|
+
# (see Message#parse)
|
|
125
213
|
def parse(params)
|
|
126
214
|
super
|
|
127
215
|
self.up_speed = to_number(params[0])
|
|
@@ -131,12 +219,19 @@ module SDN
|
|
|
131
219
|
end
|
|
132
220
|
end
|
|
133
221
|
|
|
222
|
+
# Response carrying a motor's movement state and last-action metadata.
|
|
134
223
|
class PostMotorStatus < Message
|
|
224
|
+
# (see Ack::MSG)
|
|
135
225
|
MSG = 0x0f
|
|
226
|
+
# (see Ack::PARAMS_LENGTH)
|
|
136
227
|
PARAMS_LENGTH = 4
|
|
228
|
+
# Mapping from symbolic motor states to SDN parameter values.
|
|
137
229
|
STATE = { stopped: 0x00, running: 0x01, blocked: 0x02, locked: 0x03 }.freeze
|
|
230
|
+
# Mapping from symbolic directions to SDN parameter values.
|
|
138
231
|
DIRECTION = { down: 0x00, up: 0x01 }.freeze
|
|
232
|
+
# Mapping from symbolic action sources to SDN parameter values.
|
|
139
233
|
SOURCE = { internal: 0x00, network: 0x01, dct: 0x02 }.freeze
|
|
234
|
+
# Mapping from symbolic action causes to SDN parameter values.
|
|
140
235
|
CAUSE = { target_reached: 0x00,
|
|
141
236
|
explicit_command: 0x01,
|
|
142
237
|
wink: 0x02,
|
|
@@ -148,8 +243,37 @@ module SDN
|
|
|
148
243
|
over_current_protection: 0x21,
|
|
149
244
|
thermal_protection: 0x22 }.freeze
|
|
150
245
|
|
|
151
|
-
|
|
152
|
-
|
|
246
|
+
# Reported current motor state.
|
|
247
|
+
#
|
|
248
|
+
# @return [:stopped, :running, :blocked, :locked, nil]
|
|
249
|
+
attr_accessor :state
|
|
250
|
+
|
|
251
|
+
# Reported direction of the last movement.
|
|
252
|
+
#
|
|
253
|
+
# @return [:down, :up, nil]
|
|
254
|
+
attr_accessor :last_direction
|
|
255
|
+
|
|
256
|
+
# Reported source of the last action.
|
|
257
|
+
#
|
|
258
|
+
# @return [:internal, :network, :dct, nil]
|
|
259
|
+
attr_accessor :last_action_source
|
|
260
|
+
|
|
261
|
+
# Reported cause of the last action.
|
|
262
|
+
#
|
|
263
|
+
# @return [:target_reached,
|
|
264
|
+
# :explicit_command,
|
|
265
|
+
# :wink,
|
|
266
|
+
# :limits_not_set,
|
|
267
|
+
# :ip_not_set,
|
|
268
|
+
# :polarity_not_checked,
|
|
269
|
+
# :in_configuration_mode,
|
|
270
|
+
# :obstacle_detection,
|
|
271
|
+
# :over_current_protection,
|
|
272
|
+
# :thermal_protection,
|
|
273
|
+
# nil]
|
|
274
|
+
attr_accessor :last_action_cause
|
|
275
|
+
|
|
276
|
+
# (see Message#parse)
|
|
153
277
|
def parse(params)
|
|
154
278
|
super
|
|
155
279
|
self.state = STATE.invert[to_number(params[0])]
|
|
@@ -159,22 +283,42 @@ module SDN
|
|
|
159
283
|
end
|
|
160
284
|
end
|
|
161
285
|
|
|
286
|
+
# Response carrying the network lock payload in an undecoded form.
|
|
162
287
|
class PostNetworkLock < UnknownMessage
|
|
288
|
+
# (see Ack::MSG)
|
|
163
289
|
MSG = 0x36
|
|
290
|
+
# (see Ack::PARAMS_LENGTH)
|
|
164
291
|
PARAMS_LENGTH = 5
|
|
165
292
|
end
|
|
166
293
|
|
|
294
|
+
# Response used during node address discovery.
|
|
167
295
|
class PostNodeAddr < Message
|
|
296
|
+
# (see Ack::MSG)
|
|
168
297
|
MSG = 0x60
|
|
298
|
+
# (see Ack::PARAMS_LENGTH)
|
|
169
299
|
PARAMS_LENGTH = 0
|
|
170
300
|
end
|
|
171
301
|
|
|
302
|
+
# Response carrying a node's application version details.
|
|
172
303
|
class PostNodeAppVersion < Message
|
|
304
|
+
# (see Ack::MSG)
|
|
173
305
|
MSG = 0x75
|
|
306
|
+
# (see Ack::PARAMS_LENGTH)
|
|
174
307
|
PARAMS_LENGTH = 6
|
|
175
308
|
|
|
176
|
-
|
|
309
|
+
# @return [Integer, nil]
|
|
310
|
+
attr_accessor :reference
|
|
311
|
+
|
|
312
|
+
# @return [String, nil]
|
|
313
|
+
attr_accessor :index_letter
|
|
314
|
+
|
|
315
|
+
# @return [Integer, <Integer>, nil]
|
|
316
|
+
attr_accessor :index_number
|
|
317
|
+
|
|
318
|
+
# @return [Integer, <Integer>, nil]
|
|
319
|
+
attr_accessor :profile
|
|
177
320
|
|
|
321
|
+
# (see Message#parse)
|
|
178
322
|
def parse(params)
|
|
179
323
|
super
|
|
180
324
|
self.reference = to_number(params[0..2])
|
|
@@ -184,27 +328,38 @@ module SDN
|
|
|
184
328
|
end
|
|
185
329
|
end
|
|
186
330
|
|
|
331
|
+
# Response carrying a node's configured label.
|
|
187
332
|
class PostNodeLabel < Message
|
|
333
|
+
# (see Ack::MSG)
|
|
188
334
|
MSG = 0x65
|
|
335
|
+
# Maximum label length, in bytes
|
|
189
336
|
MAX_LENGTH = 16
|
|
190
337
|
|
|
338
|
+
# @return [String, nil]
|
|
191
339
|
attr_accessor :label
|
|
192
340
|
|
|
193
|
-
|
|
194
|
-
|
|
341
|
+
# Creates a node label response message.
|
|
342
|
+
#
|
|
343
|
+
# @param label [String, nil] node label
|
|
344
|
+
def initialize(label = nil, **)
|
|
345
|
+
super(**)
|
|
195
346
|
self.label = label
|
|
196
347
|
end
|
|
197
348
|
|
|
349
|
+
# (see Message#parse)
|
|
198
350
|
def parse(params)
|
|
199
351
|
@label = to_string(params)
|
|
200
352
|
end
|
|
201
353
|
|
|
354
|
+
# (see Message#params)
|
|
202
355
|
def params
|
|
203
356
|
from_string(label, self.class::MAX_LENGTH)
|
|
204
357
|
end
|
|
205
358
|
end
|
|
206
359
|
|
|
360
|
+
# Response carrying a node's serial number string.
|
|
207
361
|
class PostNodeSerialNumber < Message
|
|
362
|
+
# (see Ack::MSG)
|
|
208
363
|
MSG = 0x6c
|
|
209
364
|
|
|
210
365
|
# format is NNNNNNMMYYWW
|
|
@@ -212,14 +367,20 @@ module SDN
|
|
|
212
367
|
# M = Manufacturer ID
|
|
213
368
|
# Y = Year (last two digits)
|
|
214
369
|
# W = Week
|
|
370
|
+
# Reported node serial number string.
|
|
371
|
+
#
|
|
372
|
+
# @return [String, nil]
|
|
215
373
|
attr_accessor :serial_number
|
|
216
374
|
|
|
375
|
+
# (see Message#parse)
|
|
217
376
|
def parse(params)
|
|
218
377
|
@serial_number = to_string(params)
|
|
219
378
|
end
|
|
220
379
|
end
|
|
221
380
|
|
|
381
|
+
# Response carrying a node's protocol stack version details.
|
|
222
382
|
class PostNodeStackVersion < PostNodeAppVersion
|
|
383
|
+
# (see Ack::MSG)
|
|
223
384
|
MSG = 0x71
|
|
224
385
|
end
|
|
225
386
|
end
|