somfy_sdn 1.0.11 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,18 +0,0 @@
1
- module SDN
2
- class Message
3
- module ILT2
4
- class PostMotorPosition < Message
5
- MSG = 0x64
6
- PARAMS_LENGTH = 3
7
-
8
- attr_accessor :position_pulses, :position_percent
9
-
10
- def parse(params)
11
- super
12
- self.position_pulses = to_number(params[0..1])
13
- self.position_percent = to_number(params[2]).to_f / 255 * 100
14
- end
15
- end
16
- end
17
- end
18
- end
@@ -1,59 +0,0 @@
1
- module SDN
2
- class Message
3
- module ILT2
4
- class SetMotorPosition < Message
5
- MSG = 0x54
6
- PARAMS_LENGTH = 3
7
- TARGET_TYPE = {
8
- up_limit: 1,
9
- down_limit: 2,
10
- stop: 3,
11
- ip: 4,
12
- next_ip_up: 5,
13
- next_ip_down: 6,
14
- jog_up: 10,
15
- jog_down: 11,
16
- position_percent: 16,
17
- }.freeze
18
-
19
- attr_reader :target_type, :target
20
-
21
- def initialize(dest = nil, target_type = :up_limit, target = 0, **kwargs)
22
- kwargs[:dest] ||= dest
23
- super(**kwargs)
24
- self.target_type = target_type
25
- self.target = target
26
- end
27
-
28
- def parse(params)
29
- super
30
- self.target_type = TARGET_TYPE.invert[to_number(params[0])]
31
- target = to_number(params[1..2])
32
- if target_type == :position_percent
33
- target = target.to_f / 255 * 100
34
- end
35
- self.target = target
36
- end
37
-
38
- def target_type=(value)
39
- raise ArgumentError, "target_type must be one of :up_limit, :down_limit, :stop, :ip, :next_ip_up, :next_ip_down, :jog_up, :jog_down, or :position_percent" unless TARGET_TYPE.keys.include?(value)
40
- @target_type = value
41
- end
42
-
43
- def target=(value)
44
- if target_type == :position_percent && value
45
- @target = [[0, value].max, 100].min
46
- else
47
- @target = value&. & 0xffff
48
- end
49
- end
50
-
51
- def params
52
- param = target
53
- param = (param * 255 / 100).to_i if target_type == :position_percent
54
- transform_param(TARGET_TYPE[target_type]) + from_number(param, 2)
55
- end
56
- end
57
- end
58
- end
59
- end