-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSocketExtron.rb
111 lines (106 loc) · 3.46 KB
/
SocketExtron.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
108
109
110
111
# 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 SocketExtron < SocketVideoSwitcher
configure do
#DaemonKit.logger.info "@Initializing SocketExtron at URI #{options[:uri]} with name #{name}"
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|
"q#{input}!"
}
managed_state_var :audio,
:type => :option,
:display_order => 2,
:options => ("1".."6").to_a,
:response => :channel,
:action => proc{|input|
"q#{input}$"
}
managed_state_var :volume,
:type => :percentage,
:display_order => 3,
:response => :volume,
:action => proc{|volume|
"q#{(volume*100).to_i}V"
}
managed_state_var :mute,
:type => :boolean,
:display_order => 4,
:response => :mute,
:action => proc{|on|
on ? "q1Z" : "q0Z"
}
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 => 5, :editable => false
responses do
match :channel, /Chn(\d)/, proc{|m| self.video = 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 :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]
#DaemonKit.logger.debug("INPUT = (#{i}, #{x1}, #{x2})")
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)) if (v1 && v2)
#DaemonKit.logger.info "Received video input #{v1} and #{v2}"
}
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