-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathExtronMPS409.rb
69 lines (64 loc) · 2.03 KB
/
ExtronMPS409.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Copyright (C) 2014 Wesleyan University
#
# This file is part of cmdr-devices.
#
# cmdr-devices is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cmdr-devices is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cmdr-devices. If not, see <http://www.gnu.org/licenses/>.
#---
#{
# "name": "ExtronMPS409",
# "depends_on": "VideoSwitcher",
# "description": "Controls the MPS409 Extron switcher",
# "author": "Brian Gapinski",
# "email": "[email protected]",
# "abstract": true,
# "type": "Video Switcher"
#}
#---
class ExtronMPS409 < VideoSwitcher
AUDIO_HASH = {1 => "1*1", 2 => "1*2", 3 => "2*1", 4 => "2*2", 5 => "3*1", 6 => "3*2", 7 => "3*3", 8 => "4*1", 9 => "4*2"}
def initialize(name, options)
super(name, options)
end
managed_state_var :video,
:type => :option,
:display_order => 1,
:options => ("1".."6").to_a,
:response => :channel,
:action => proc{|input|
"#{input}!"
}
managed_state_var :audio,
:type => :option,
:display_order => 2,
:options => ("1".."6").to_a,
:response => :channel,
:action => proc{|input|
"#{AUDIO_HASH[input]}$"
}
responses do
match :audio, /Mod(\d+) (\d)G(\d) (\d)G(\d) (\d)G(\d) (\d)G(\d)=(\d)G(\d)/, proc{|m|
x1, x2 = [m[10].to_i, m[11].to_i]
self.audio = "#{x1}*#{x2}"
}
match :video, /Mod(\d+) (\d)G(\d) (\d)G(\d) (\d)G(\d) (\d)G(\d)=(\d)G(\d)/, proc{|m|
for i in (1..4)
if m[2*i+1] != 0
v1, v2 = [m[2*i].to_i, m[2*i+1].to_i]
break
end
end
self.video = (v1 < 3 ? ((v1-1)*2 + (v2-1) % 2 + 1) : ((v1-3)*3 + (v2-1) % 3 + 5))
}
end
end