aca-device-modules 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b69086f2a1f7cedc0f6ee28a9dba6f771233396
4
- data.tar.gz: 6080121ffbf65e399205c885be16959f7b7603d7
3
+ metadata.gz: 42450f49d3ea6b361c2165a538da7fb1fcfaefe4
4
+ data.tar.gz: c329004ee38ae2d1c1307b0f6bf5756b903319cc
5
5
  SHA512:
6
- metadata.gz: 38add061a9db39ec6ed34d2cfb9bba11c2d7c395f0498c1f74a2089c3a606cfafc4b0e4df7f9e62b460567dbb03108cc66507b4d573fcf8cbdd654c5b10d00ee
7
- data.tar.gz: 7a5c4ecc2012e09c552bb0a48f6af767d33a1e61c47a7a850463653c4d972695e2de8ba2f7e7a6fde05d59a87d65d4094684e0a0f0b02c1ab335e841987e08a9
6
+ metadata.gz: 143e793dec4c59c3a2ef93abd089ea7cea306d334a0e5b1c9ba347f52e9810f3a6ac7edb69253a0d630046351e47ee3fce40c5d8f3c5171d8d776ee26d271b8f
7
+ data.tar.gz: 4dda6028de6a8d3104d59ee381a5a14f883d2b28e8ae5b500982c750d70c8233dae3f3adfc9b6b53c9c687f0c834c5cc34907fe8d135def7835b9c90000f68a1
@@ -1,3 +1,3 @@
1
1
  module AcaDeviceModules
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -0,0 +1,71 @@
1
+ module Aca; end
2
+
3
+ # Logic module
4
+ # Abstracts screen or projector lift up and down control
5
+ # Where the DigitalIO device supports plusing deals with the timers
6
+
7
+ class Aca::LifterLogicAuto
8
+ include ::Orchestrator::Constants
9
+
10
+ def on_load
11
+ on_update
12
+ end
13
+
14
+ def on_update
15
+ @module = setting(:module) || :DigitalIO
16
+ @index = setting(:index) || 1
17
+
18
+ # {"up": [[index, state, time]]}
19
+ @up_config = setting(:up)
20
+ @down_config = setting(:down)
21
+
22
+ # {"rotate": [{"active": [index, state, time], "inactive": [index, state, time]}]}
23
+ @rotate_config = setting(:rotate)
24
+ end
25
+
26
+
27
+ def state(val, index = 1)
28
+ if is_affirmative?(val)
29
+ down(index)
30
+ else
31
+ up(index)
32
+ end
33
+ end
34
+
35
+ def up(index = 1)
36
+ pos = index - 1
37
+ mod = system.get(@module, @index)
38
+ cmd = @up_config[pos]
39
+
40
+ # Send twice as screen will stop if moving the first pulse
41
+ # Then the second pulse will cause it to change direction
42
+ mod.relay(*cmd)
43
+ mod.relay(*cmd) if cmd.length > 2
44
+
45
+ self[:"lifter#{index}"] = :up
46
+ end
47
+
48
+ def down(index = 1)
49
+ pos = index - 1
50
+ mod = system.get(@module, @index)
51
+ cmd = @down_config[pos]
52
+
53
+ mod.relay(*cmd)
54
+ mod.relay(*cmd) if cmd.length > 2
55
+
56
+ self[:"lifter#{index}"] = :down
57
+ end
58
+
59
+ def rotate(state, index = 1)
60
+ pos = index - 1
61
+ mod = system.get(@module, @index)
62
+
63
+ type = is_affirmative?(state) ? :active : :inactive
64
+ cmd = @rotate_config[pos][type]
65
+
66
+ mod.relay(*cmd)
67
+ mod.relay(*cmd) if cmd.length > 2
68
+
69
+ self[:"lifter#{index}_rotation"] = type
70
+ end
71
+ end
@@ -0,0 +1,105 @@
1
+ module Aca; end
2
+
3
+ # Logic module
4
+ # Abstracts screen or projector lift up and down control
5
+ # Where the DigitalIO does not have a pulse command and timers are required
6
+
7
+ class Aca::LifterLogicManual
8
+ include ::Orchestrator::Constants
9
+
10
+ def on_load
11
+ @next = {}
12
+ @pulsing = {}
13
+
14
+ on_update
15
+ end
16
+
17
+ def on_update
18
+ @module = setting(:module) || :DigitalIO
19
+ @index = setting(:index) || 1
20
+
21
+ # {"up": [[index, state, time]]}
22
+ @up_config = setting(:up)
23
+ @down_config = setting(:down)
24
+
25
+ # {"rotate": [{"active": [index, state, time], "inactive": [index, state, time]}]}
26
+ @rotate_config = setting(:rotate)
27
+ end
28
+
29
+
30
+ def state(val, index = 1)
31
+ if is_affirmative?(val)
32
+ down(index)
33
+ else
34
+ up(index)
35
+ end
36
+ end
37
+
38
+ def up(index = 1)
39
+ pos = index - 1
40
+ mod = system.get(@module, @index)
41
+ cmd = @up_config[pos]
42
+
43
+ # Send twice as screen will stop if moving the first pulse
44
+ # Then the second pulse will cause it to change direction
45
+ pulse(mod, *cmd)
46
+ pulse(mod, *cmd) if cmd.length > 2
47
+
48
+ self[:"lifter#{index}"] = :up
49
+ end
50
+
51
+ def down(index = 1)
52
+ pos = index - 1
53
+ mod = system.get(@module, @index)
54
+ cmd = @down_config[pos]
55
+
56
+ pulse(mod, *cmd)
57
+ pulse(mod, *cmd) if cmd.length > 2
58
+
59
+ self[:"lifter#{index}"] = :down
60
+ end
61
+
62
+ def rotate(state, index = 1)
63
+ pos = index - 1
64
+ mod = system.get(@module, @index)
65
+
66
+ type = is_affirmative?(state) ? :active : :inactive
67
+ cmd = @rotate_config[pos][type]
68
+
69
+ pulse(mod, *cmd)
70
+ pulse(mod, *cmd) if cmd.length > 2
71
+
72
+ self[:"lifter#{index}_rotation"] = type
73
+ end
74
+
75
+
76
+ protected
77
+
78
+
79
+ def pulse(mod, relay, state, time = nil)
80
+
81
+ if time.nil?
82
+ # On == up and Off == down etc
83
+ mod.relay relay, state
84
+
85
+ elsif time && @pulsing[relay].nil?
86
+ # Pulse to move up / down
87
+ mod.relay relay, state
88
+
89
+ @pulsing[relay] = schedule.in("#{time}s") do
90
+ @pulsing.delete(relay)
91
+ mod.relay relay, !state
92
+
93
+ if @next[relay]
94
+ args = @next[relay]
95
+ @next.delete(relay)
96
+ pulse *args
97
+ end
98
+ end
99
+ else
100
+
101
+ # A pulse is already in progress. Lets wait it out
102
+ @next[relay] = [mod, relay, state, time]
103
+ end
104
+ end
105
+ end
@@ -2,141 +2,141 @@ module Aca; end
2
2
 
3
3
  #
4
4
  # Settings required:
5
- # * domain (domain that we will be authenticating against)
6
- # * username (username for authentication)
7
- # * password (password for authentication)
5
+ # * domain (domain that we will be authenticating against)
6
+ # * username (username for authentication)
7
+ # * password (password for authentication)
8
8
  #
9
9
  # (built in)
10
10
  # connected
11
11
  #
12
12
  class Aca::PcControl
13
- include ::Orchestrator::Constants
13
+ include ::Orchestrator::Constants
14
14
  include ::Orchestrator::Transcoder
15
15
 
16
- #
17
- # initialize will not have access to settings
18
- #
19
- def on_load
20
-
21
- #
22
- # Setup constants
23
- #
24
- self[:authenticated] = 0
16
+ #
17
+ # initialize will not have access to settings
18
+ #
19
+ def on_load
20
+
21
+ #
22
+ # Setup constants
23
+ #
24
+ self[:authenticated] = 0
25
25
 
26
- config({
27
- tokenize: true,
28
- delimiter: "\x03",
29
- indicator: "\x02"
30
- })
31
- end
32
-
33
- def connected
34
- @polling_timer = schedule.every('60s') do
26
+ config({
27
+ tokenize: true,
28
+ delimiter: "\x03",
29
+ indicator: "\x02"
30
+ })
31
+ end
32
+
33
+ def connected
34
+ @polling_timer = schedule.every('60s') do
35
35
  logger.debug "-- Polling Computer"
36
36
  do_send({:control => "app", :command => 'do_nothing'}, {wait: false})
37
37
  end
38
- end
39
-
40
- def disconnected
41
- self[:authenticated] = 0
42
- @polling_timer.cancel unless @polling_timer.nil?
38
+ end
39
+
40
+ def disconnected
41
+ self[:authenticated] = 0
42
+ @polling_timer.cancel unless @polling_timer.nil?
43
43
  @polling_timer = nil
44
- end
45
-
46
- def launch_application(app, *args)
47
- do_send({:control => "app", :command => app, :args => args})
48
- end
44
+ end
45
+
46
+ def launch_application(app, *args)
47
+ do_send({:control => "app", :command => app, :args => args})
48
+ end
49
49
 
50
- def wake(broadcast = nil)
51
- mac = setting(:mac_address)
50
+ def wake(broadcast = nil)
51
+ mac = setting(:mac_address)
52
52
  if mac
53
53
  # config is the database model representing this device
54
54
  wake_device(mac, broadcast || '<broadcast>')
55
55
  end
56
56
  logger.debug "Waking computer #{mac} #{broadcast}"
57
57
  nil
58
- end
58
+ end
59
59
 
60
- def shutdown
61
- launch_application 'shutdown.exe', '/s', '/t', '0'
62
- end
60
+ def shutdown
61
+ launch_application 'shutdown.exe', '/s', '/t', '0'
62
+ end
63
63
 
64
- def logoff
65
- launch_application 'shutdown.exe', '/l', '/t', '0'
66
- end
64
+ def logoff
65
+ launch_application 'shutdown.exe', '/l', '/t', '0'
66
+ end
67
67
 
68
- def restart
69
- launch_application 'shutdown.exe', '/r', '/t', '0'
70
- end
71
-
68
+ def restart
69
+ launch_application 'shutdown.exe', '/r', '/t', '0'
70
+ end
71
+
72
72
 
73
73
 
74
- #
75
- # Camera controls
76
- #
77
- CAM_OPERATIONS = [:up, :down, :left, :right, :center, :zoomin, :zoomout]
78
-
79
- #
80
- # Automatically creates a callable function for each command
81
- # http://blog.jayfields.com/2007/10/ruby-defining-class-methods.html
82
- # http://blog.jayfields.com/2008/02/ruby-dynamically-define-method.html
83
- #
84
- CAM_OPERATIONS.each do |command|
85
- define_method command do |*args|
86
- # Cam control is low priority in case a camera is not plugged in
87
- do_send({:control => "cam", :command => command.to_s, :args => []}, {:priority => 0, :retries => 0})
88
- end
89
- end
90
-
91
- def zoom(val)
92
- do_send({:control => "cam", :command => "zoom", :args => [val.to_s]})
93
- end
94
-
95
- def received(data, resolve, command)
96
-
97
- #
98
- # Convert the message into a native object
99
- #
100
- data = JSON.parse(data, {:symbolize_names => true})
101
-
102
- #
103
- # Process the response
104
- #
105
- if data[:command] == "authenticate"
106
- command = {:control => "auth", :command => setting(:domain), :args => [setting(:username), setting(:password)]}
107
- if self[:authenticated] > 0
108
- #
109
- # Token retry (probably always fail - at least we can see in the logs)
110
- # We don't want to flood the network with useless commands
111
- #
112
- schedule.in('60s') do
113
- do_send(command)
114
- end
115
- logger.info "-- Pod Computer, is refusing authentication"
116
- else
117
- do_send(command)
118
- end
119
- self[:authenticated] += 1
120
- logger.debug "-- Pod Computer, requested authentication"
121
- elsif data[:type] != nil
122
- self["#{data[:device]}_#{data[:type]}"] = data # zoom, tilt, pan
123
- return nil # This is out of order data
124
- else
125
- if !data[:result]
126
- logger.warn "-- Pod Computer, request failed for command: #{command ? command[:data] : "(resp #{data})"}"
127
- return false
128
- end
129
- end
130
-
131
- return true # Command success
132
- end
133
-
134
-
135
- private
136
-
74
+ #
75
+ # Camera controls
76
+ #
77
+ CAM_OPERATIONS = [:up, :down, :left, :right, :center, :zoomin, :zoomout]
78
+
79
+ #
80
+ # Automatically creates a callable function for each command
81
+ # http://blog.jayfields.com/2007/10/ruby-defining-class-methods.html
82
+ # http://blog.jayfields.com/2008/02/ruby-dynamically-define-method.html
83
+ #
84
+ CAM_OPERATIONS.each do |command|
85
+ define_method command do |*args|
86
+ # Cam control is low priority in case a camera is not plugged in
87
+ do_send({:control => "cam", :command => command.to_s, :args => []}, {:priority => 0, :retries => 0})
88
+ end
89
+ end
90
+
91
+ def zoom(val)
92
+ do_send({:control => "cam", :command => "zoom", :args => [val.to_s]})
93
+ end
94
+
95
+ def received(data, resolve, command)
96
+
97
+ #
98
+ # Convert the message into a native object
99
+ #
100
+ data = JSON.parse(data, {:symbolize_names => true})
101
+
102
+ #
103
+ # Process the response
104
+ #
105
+ if data[:command] == "authenticate"
106
+ command = {:control => "auth", :command => setting(:domain), :args => [setting(:username), setting(:password)]}
107
+ if self[:authenticated] > 0
108
+ #
109
+ # Token retry (probably always fail - at least we can see in the logs)
110
+ # We don't want to flood the network with useless commands
111
+ #
112
+ schedule.in('60s') do
113
+ do_send(command)
114
+ end
115
+ logger.info "-- Pod Computer, is refusing authentication"
116
+ else
117
+ do_send(command)
118
+ end
119
+ self[:authenticated] += 1
120
+ logger.debug "-- Pod Computer, requested authentication"
121
+ elsif data[:type] != nil
122
+ self["#{data[:device]}_#{data[:type]}"] = data # zoom, tilt, pan
123
+ return nil # This is out of order data
124
+ else
125
+ if !data[:result]
126
+ logger.warn "-- Pod Computer, request failed for command: #{command ? command[:data] : "(resp #{data})"}"
127
+ return false
128
+ end
129
+ end
130
+
131
+ return true # Command success
132
+ end
133
+
134
+
135
+ private
136
+
137
137
 
138
- def do_send(command, options = {})
139
- send("\x02#{JSON.generate(command)}\x03", options)
140
- end
138
+ def do_send(command, options = {})
139
+ send("\x02#{JSON.generate(command)}\x03", options)
140
+ end
141
141
  end
142
142
 
@@ -28,8 +28,9 @@ class Axis::Camera::Vapix
28
28
  self[:tilt_min] = -180.0
29
29
  self[:tilt_center] = 0.0
30
30
 
31
- self[:joy_left] = -100
32
- self[:joy_right] = 100
31
+ # Actual limits are -100 to 100 this just improves usability
32
+ self[:joy_left] = -50
33
+ self[:joy_right] = 50
33
34
  self[:joy_center] = 0
34
35
 
35
36
  self[:zoom_max] = 9999
@@ -84,9 +85,15 @@ class Axis::Camera::Vapix
84
85
  end
85
86
 
86
87
  options = {}
87
- options[:retries] = is_centered ? 1 : 0
88
88
  options[:name] = :joystick
89
89
 
90
+ if is_centered
91
+ options[:clear_queue] = true
92
+ else
93
+ options[:priority] = 10
94
+ options[:retries] = 0
95
+ end
96
+
90
97
  logger.debug("Sending camera: #{pan_speed}#{tilt_speed}")
91
98
 
92
99
  req(:ptz, "continuouspantiltmove=#{pan_speed},#{tilt_speed}", options) do |data, resolve|