-
Notifications
You must be signed in to change notification settings - Fork 2
/
ExtronVideoSwitcher.rb
107 lines (101 loc) · 3.09 KB
/
ExtronVideoSwitcher.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# 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": "ExtronVideoSwitcher",
# "depends_on": "VideoSwitcher",
# "description": "Controls Extron video switchers that support SIS",
# "author": "Micah Wylde",
# "email": "[email protected]"
#}
#---
class ExtronVideoSwitcher < VideoSwitcher
configure do
baud 9600
message_end "\r\n"
end
managed_state_var :input,
:type => :option,
:display_order => 1,
:options => ("1".."6").to_a,
:response => :channel,
:action => proc{|input|
"#{input}!"
}
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|
"#{input}$"
}
managed_state_var :volume,
:type => :percentage,
:display_order => 2,
:response => :volume,
:action => proc{|volume|
"#{(volume*100).to_i}V"
}
managed_state_var :mute,
:type => :boolean,
:display_order => 3,
:response => :mute,
:action => proc{|on|
on ? "1Z" : "0Z"
}
state_var :model, :type => 'string', :editable => false
state_var :firmware_version, :type => 'string', :editable => false
state_var :part_number, :type => 'string', :editable => false
state_var :clipping, :type => 'boolean', :display_order => 4, :editable => false
responses do
match :channel, /Chn(\d)/, proc{|m| self.input = m[1].to_i.to_s}
match :volume, /Vol(\d+)/, proc{|m| self.volume = m[1].to_i/100.0}
match :mute, /Amt(\d+)/, proc{|m| self.mute = m[1] == "1"}
match :status, /Vid(\d+) Aud(\d+) Clp(\d)/, proc{|m|
self.input = m[1].to_i if m[1].to_i > 0
#self.video = m[1].to_i if m[1].to_i > 0
#self.audio = m[2].to_i if m[2].to_i > 0
self.clipping = (m[3] == "1")
}
match :input, /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]
if x1 < 3
i = (x1-1)*2 + (x2-1) % 2 + 1
else
i = (x1-3)*3 + (x2-1) % 3 + 5
end
#DaemonKit.logger.debug("INPUT = (#{i}, #{x1}, #{x2})")
self.input = i
}
end
requests do
send :input, "I", 0.5
send :video, "I", 0.5
send :audio, "I", 0.5
send :volume, "V", 0.5
send :mute, "Z", 0.5
end
end