aca-device-modules 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aca-device-modules/version.rb +1 -1
- data/modules/sony/display/gdx_and_fwd.rb +295 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff402a8981cd00ad194800fedd2d640c8d523fc4
|
4
|
+
data.tar.gz: 4ea818c14ca5d2fa95ae79e1bb64a8267d70076c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 187d638e7b2d043344da2004d0484d8ef7df8dff6747b67ebc3e90ad708d9b464254304c1e624eb3bffcb949f6b32d51036eb07b98695bca2153f10ff2a85acf
|
7
|
+
data.tar.gz: 583975c1ae6bf240d3f63fc88320b74c4abf18f1be8d26fe2c4eb69fdf48fb8bb3608c37914dbf36e363856e32409deb2cd03ce52dbbd0b48b6d461d3b7bc1f8
|
@@ -0,0 +1,295 @@
|
|
1
|
+
module Sony; end
|
2
|
+
module Sony::Display; end
|
3
|
+
|
4
|
+
|
5
|
+
#
|
6
|
+
# Port: 53484
|
7
|
+
#
|
8
|
+
class Sony::Display::GdxAndFwd
|
9
|
+
include ::Orchestrator::Constants
|
10
|
+
include ::Orchestrator::Transcoder
|
11
|
+
|
12
|
+
def on_load
|
13
|
+
self[:brightness_min] = 0x00
|
14
|
+
self[:brightness_max] = 0x64
|
15
|
+
self[:contrast_min] = 0x00
|
16
|
+
self[:contrast_max] = 0x64
|
17
|
+
self[:volume_min] = 0x00
|
18
|
+
self[:volume_max] = 0x64
|
19
|
+
self[:power] = false
|
20
|
+
self[:type] = :lcd
|
21
|
+
|
22
|
+
on_update
|
23
|
+
end
|
24
|
+
|
25
|
+
def on_update
|
26
|
+
# Default community value is SONY - can be changed in displays settings
|
27
|
+
@community = str_to_array(setting(:community) || 'SONY')
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def connected
|
32
|
+
@polling_timer = schedule.every('60s', method(:do_poll))
|
33
|
+
end
|
34
|
+
|
35
|
+
def disconnected
|
36
|
+
@polling_timer.cancel unless @polling_timer.nil?
|
37
|
+
@polling_timer = nil
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
#
|
43
|
+
# Power commands
|
44
|
+
#
|
45
|
+
def power(state, opt = nil)
|
46
|
+
if is_affirmative?(state)
|
47
|
+
do_send(:power, 1)
|
48
|
+
logger.debug "-- sony display requested to power on"
|
49
|
+
else
|
50
|
+
do_send(:power, 0)
|
51
|
+
logger.debug "-- sony display requested to power off"
|
52
|
+
end
|
53
|
+
|
54
|
+
# Request status update
|
55
|
+
power?
|
56
|
+
end
|
57
|
+
|
58
|
+
def power?(options = {}, &block)
|
59
|
+
options[:emit] = block if block_given?
|
60
|
+
options[:priority] = 0
|
61
|
+
do_send(:power, options)
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
#
|
67
|
+
# Input selection
|
68
|
+
#
|
69
|
+
INPUTS = {
|
70
|
+
:vga => 0x08,
|
71
|
+
:dvi => 0x20,
|
72
|
+
:hdmi => 0x44,
|
73
|
+
:hdmi2 => 0x84,
|
74
|
+
:hdmi3 => 0x85
|
75
|
+
}
|
76
|
+
INPUTS.merge!(INPUTS.invert)
|
77
|
+
|
78
|
+
|
79
|
+
def switch_to(input)
|
80
|
+
input = input.to_sym
|
81
|
+
return unless INPUTS.has_key? input
|
82
|
+
|
83
|
+
do_send(:input, INPUTS[input])
|
84
|
+
logger.debug "-- sony display, requested to switch to: #{input}"
|
85
|
+
|
86
|
+
input?
|
87
|
+
end
|
88
|
+
|
89
|
+
def input?
|
90
|
+
do_send(:input, {:priority => 0})
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
#
|
95
|
+
# Mute Audio and Video
|
96
|
+
#
|
97
|
+
def mute
|
98
|
+
logger.debug "-- sony display, requested to mute"
|
99
|
+
do_send(:mute, 1)
|
100
|
+
mute?
|
101
|
+
end
|
102
|
+
|
103
|
+
def unmute
|
104
|
+
logger.debug "-- sony display, requested to unmute"
|
105
|
+
do_send(:mute, 0)
|
106
|
+
mute?
|
107
|
+
end
|
108
|
+
|
109
|
+
def mute?
|
110
|
+
do_send(:mute, {:priority => 0})
|
111
|
+
end
|
112
|
+
|
113
|
+
def audio_mute
|
114
|
+
logger.debug "-- sony display, requested to mute"
|
115
|
+
do_send(:audio_mute, 1)
|
116
|
+
audio_mute?
|
117
|
+
end
|
118
|
+
|
119
|
+
def audio_unmute
|
120
|
+
logger.debug "-- sony display, requested to unmute"
|
121
|
+
do_send(:audio_mute, 0)
|
122
|
+
audio_mute?
|
123
|
+
end
|
124
|
+
|
125
|
+
def audio_mute?
|
126
|
+
do_send(:audio_mute, {:priority => 0})
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
#
|
131
|
+
# Automatically creates a callable function for each command
|
132
|
+
# http://blog.jayfields.com/2007/10/ruby-defining-class-methods.html
|
133
|
+
# http://blog.jayfields.com/2008/02/ruby-dynamically-define-method.html
|
134
|
+
#
|
135
|
+
[:contrast, :brightness, :volume].each do |command|
|
136
|
+
# Query command
|
137
|
+
define_method :"#{command}?" do
|
138
|
+
do_send(command, {:priority => 0})
|
139
|
+
end
|
140
|
+
|
141
|
+
# Set value command
|
142
|
+
define_method command do |level|
|
143
|
+
do_send(command, level)
|
144
|
+
__send__(:"#{command}?")
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
ERRORS = {
|
151
|
+
:ERR1 => '1: Undefined control command'.freeze,
|
152
|
+
:ERR2 => '2: Out of parameter range'.freeze,
|
153
|
+
:ERR3 => '3: Busy state or no-acceptable period'.freeze,
|
154
|
+
:ERR4 => '4: Timeout or no-acceptable period'.freeze,
|
155
|
+
:ERR5 => '5: Wrong data length'.freeze,
|
156
|
+
:ERRA => 'A: Password mismatch'.freeze
|
157
|
+
}
|
158
|
+
|
159
|
+
RESP = {
|
160
|
+
0x00 => :success,
|
161
|
+
0x01 => :limit_over,
|
162
|
+
0x02 => :limit_under,
|
163
|
+
0x03 => :cancelled
|
164
|
+
}
|
165
|
+
|
166
|
+
|
167
|
+
def received(data, resolve, command) # Data is default received as a string
|
168
|
+
logger.debug "sony display sent: 0x#{byte_to_hex(data)}"
|
169
|
+
|
170
|
+
idt_header = data[0..1]
|
171
|
+
idt_community = data[2..5]
|
172
|
+
idt_command = str_to_array(data[6..9])
|
173
|
+
resp = str_to_array(data[10..-1])
|
174
|
+
|
175
|
+
if idt_command[0] == 0x01
|
176
|
+
# resp is now equal to the unit control codes
|
177
|
+
|
178
|
+
type = RESP[resp[1]]
|
179
|
+
|
180
|
+
case type
|
181
|
+
when :success
|
182
|
+
if resp.length > 3 && command
|
183
|
+
# This is a request response
|
184
|
+
cmd = command[:name]
|
185
|
+
|
186
|
+
case cmd
|
187
|
+
when :power, :audio_mute, :mute
|
188
|
+
self[cmd] = resp[3] == 0x01
|
189
|
+
when :input
|
190
|
+
self[cmd] = INPUTS[resp[3]]
|
191
|
+
when :signal_status
|
192
|
+
self[cmd] = resp[3] != 0x01
|
193
|
+
when :contrast, :brightness, :volume
|
194
|
+
self[cmd] = resp[3]
|
195
|
+
end
|
196
|
+
end
|
197
|
+
return :success
|
198
|
+
when :limit_over, :limit_under
|
199
|
+
warning = "sony display sent a value that was #{type}"
|
200
|
+
warning += " for command #{command[:name]}" if command
|
201
|
+
|
202
|
+
logger.warn warning
|
203
|
+
|
204
|
+
return :abort
|
205
|
+
when :cancelled
|
206
|
+
# Attempt the request again
|
207
|
+
return :retry
|
208
|
+
end
|
209
|
+
|
210
|
+
else
|
211
|
+
# Command failed.. value == error code
|
212
|
+
return :abort
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
protected
|
219
|
+
|
220
|
+
|
221
|
+
def do_poll(*args)
|
222
|
+
power?({:priority => 0}) do
|
223
|
+
if self[:power]
|
224
|
+
input?
|
225
|
+
mute?
|
226
|
+
audio_mute?
|
227
|
+
volume?
|
228
|
+
do_send(:signal_status, {:priority => 0})
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
# Constants as per manual page 18
|
234
|
+
# version, category
|
235
|
+
IdTalk_Header = [0x02, 0x10]
|
236
|
+
|
237
|
+
# Unit protocol as per manual page 21
|
238
|
+
# Dedicated unit protocol
|
239
|
+
IdTalk_Type = [0xF1, 0x00]
|
240
|
+
|
241
|
+
|
242
|
+
# category, command
|
243
|
+
COMMANDS = {
|
244
|
+
power: [0x00, 0x00],
|
245
|
+
input: [0x00, 0x01],
|
246
|
+
audio_mute: [0x00, 0x03],
|
247
|
+
signal_status: [0x00, 0x75],
|
248
|
+
mute: [0x00, 0x8D],
|
249
|
+
|
250
|
+
contrast: [0x10, 0x00],
|
251
|
+
brightness: [0x10, 0x01],
|
252
|
+
volume: [0x10, 0x30]
|
253
|
+
}
|
254
|
+
COMMANDS.merge!(COMMANDS.invert)
|
255
|
+
|
256
|
+
|
257
|
+
def build_checksum(command)
|
258
|
+
check = 0
|
259
|
+
command.each do |byte|
|
260
|
+
check = (check + byte) & 0xFF
|
261
|
+
end
|
262
|
+
[check]
|
263
|
+
end
|
264
|
+
|
265
|
+
|
266
|
+
def do_send(command, param = nil, options = {})
|
267
|
+
# Check for missing params
|
268
|
+
if param.is_a? Hash
|
269
|
+
options = param
|
270
|
+
param = nil
|
271
|
+
end
|
272
|
+
|
273
|
+
# Control + Mode
|
274
|
+
if param.nil?
|
275
|
+
options[:name] = command
|
276
|
+
cmd = [0x83] + COMMANDS[command] + [0xFF, 0xFF]
|
277
|
+
else
|
278
|
+
options[:name] = :"#{command}_cmd"
|
279
|
+
type = [0x8C] + COMMANDS[command]
|
280
|
+
if !param.is_a?(Array)
|
281
|
+
param = [param]
|
282
|
+
end
|
283
|
+
data = [param.length + 1] + param
|
284
|
+
cmd = type + data
|
285
|
+
end
|
286
|
+
|
287
|
+
cmd = cmd + build_checksum(cmd)
|
288
|
+
|
289
|
+
# Build the IDTalk header # set request every time?
|
290
|
+
idt_cmd = IdTalk_Header + @community + [0x00] + IdTalk_Type + [cmd.length] + cmd
|
291
|
+
|
292
|
+
send(idt_cmd, options)
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aca-device-modules
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen von Takach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- modules/panasonic/camera/he50.rb
|
66
66
|
- modules/panasonic/projector/pj_link.rb
|
67
67
|
- modules/samsung/displays/md_series.rb
|
68
|
+
- modules/sony/display/gdx_and_fwd.rb
|
68
69
|
- modules/vaddio/camera/clear_view_ptz_telnet.rb
|
69
70
|
homepage: http://cotag.me/
|
70
71
|
licenses:
|