open_lighting 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/Guardfile +9 -0
- data/LICENSE +22 -0
- data/README.md +42 -0
- data/Rakefile +8 -0
- data/lib/open_lighting.rb +3 -0
- data/lib/open_lighting/devices/comscan_led.rb +32 -0
- data/lib/open_lighting/dmx_controller.rb +94 -0
- data/lib/open_lighting/dmx_device.rb +43 -0
- data/lib/open_lighting/version.rb +3 -0
- data/open_lighting.gemspec +27 -0
- data/spec/open_lighting/devices/comscan_led_spec.rb +20 -0
- data/spec/open_lighting/dmx_controller_spec.rb +151 -0
- data/spec/open_lighting/dmx_device_spec.rb +112 -0
- data/spec/spec_helper.rb +7 -0
- metadata +162 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec', :version => 2, :all_after_pass => true, :cli => "--color --format nested" do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
end
|
9
|
+
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Marshall Yount
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# OpenLighting
|
2
|
+
|
3
|
+
`open_lighting` is a light-weight Ruby wrapper for the
|
4
|
+
[Open Lighting Architecture](http://www.opendmx.net/index.php/Open_Lighting_Architecture) project.
|
5
|
+
|
6
|
+
[![Build Status](https://secure.travis-ci.org/marshally/open_lighting_rb.png?branch=master)](http://travis-ci.org/marshally/open_lighting_rb)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
### OS X
|
11
|
+
|
12
|
+
brew tap marshally/homebrew-alt
|
13
|
+
brew install open_lighting
|
14
|
+
|
15
|
+
### Linux
|
16
|
+
|
17
|
+
### Ruby Installation
|
18
|
+
|
19
|
+
Add this line to your application's Gemfile:
|
20
|
+
|
21
|
+
gem 'open_lighting'
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
$ bundle
|
26
|
+
|
27
|
+
Or install it yourself as:
|
28
|
+
|
29
|
+
$ gem install open_lighting
|
30
|
+
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
TODO: Write usage instructions here
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
1. Fork it
|
39
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
41
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
42
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'open_lighting/dmx_device'
|
2
|
+
|
3
|
+
module OpenLighting
|
4
|
+
module Devices
|
5
|
+
# ComscanLed is an example subclass of DmxDevice which supplies sensible defaults
|
6
|
+
class ComscanLed < DmxDevice
|
7
|
+
def initialize(options = {})
|
8
|
+
options[:points] ||= {}
|
9
|
+
options[:points][:center] ||= {:pan => 127, :tilt => 127}
|
10
|
+
|
11
|
+
options[:points][:strobe_slow] ||= {:strobe => 16}
|
12
|
+
options[:points][:strobe_fast] ||= {:strobe => 131}
|
13
|
+
options[:points][:strobe_slow_fast] ||= {:strobe => 140}
|
14
|
+
options[:points][:strobe_fast_slow] ||= {:strobe => 190}
|
15
|
+
options[:points][:strobe_random] ||= {:strobe => 247}
|
16
|
+
|
17
|
+
options[:points][:yellow] ||= {:gobo => 8}
|
18
|
+
options[:points][:red] ||= {:gobo => 15}
|
19
|
+
options[:points][:green] ||= {:gobo => 22}
|
20
|
+
options[:points][:blue] ||= {:gobo => 29}
|
21
|
+
options[:points][:teardrop] ||= {:gobo => 36}
|
22
|
+
options[:points][:polka] ||= {:gobo => 43}
|
23
|
+
options[:points][:teal] ||= {:gobo => 50}
|
24
|
+
options[:points][:rings] ||= {:gobo => 57}
|
25
|
+
|
26
|
+
options[:capabilities] ||= [:pan, :tilt, :strobe, :gobo, :dimmer]
|
27
|
+
|
28
|
+
super(options)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module OpenLighting
|
2
|
+
# The DmxController class is responsible for sending control messages across
|
3
|
+
# the DMX bus.
|
4
|
+
#
|
5
|
+
# Due to idiosynchricies of the underlying open_lighting subsytem, all devices
|
6
|
+
# must receive a control signal each time anything on the bus receives a
|
7
|
+
# control signal. The DmxController class is responsible for aggregating this
|
8
|
+
# information from the DmxDevice instances and sending it down the bus.
|
9
|
+
class DmxController
|
10
|
+
attr_accessor :fps, :devices, :universe, :cmd, :read_pipe, :write_pipe, :test_mode
|
11
|
+
def initialize(options = {})
|
12
|
+
@devices = []
|
13
|
+
(options[:devices] || []).each {|dev| @devices << dev}
|
14
|
+
self.fps = options[:fps] || 40
|
15
|
+
self.universe = options[:universe] || 1
|
16
|
+
self.cmd = options[:cmd] || "ola_streaming_client -u #{universe}"
|
17
|
+
|
18
|
+
if options[:test]
|
19
|
+
self.test_mode = true
|
20
|
+
self.read_pipe, self.write_pipe = IO.pipe
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def devices
|
25
|
+
@devices
|
26
|
+
end
|
27
|
+
|
28
|
+
def <<(val)
|
29
|
+
val.controller = self
|
30
|
+
@devices << val
|
31
|
+
end
|
32
|
+
|
33
|
+
def set(options = {})
|
34
|
+
@devices.each {|device| device.set(options)}
|
35
|
+
end
|
36
|
+
|
37
|
+
def write!(values=current_values)
|
38
|
+
self.write_pipe ||= IO.popen(self.cmd, "w")
|
39
|
+
|
40
|
+
# DMX only wants integer inputs
|
41
|
+
values.map!{|i| i.to_i}
|
42
|
+
|
43
|
+
self.write_pipe.write "#{values.join ","}\n"
|
44
|
+
self.write_pipe.flush
|
45
|
+
end
|
46
|
+
|
47
|
+
def instant!(options = {})
|
48
|
+
set(options)
|
49
|
+
write!
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_dmx
|
53
|
+
# dmx addresses start at 1, ruby arrays start at zero
|
54
|
+
current_values.join ","
|
55
|
+
end
|
56
|
+
|
57
|
+
def current_values
|
58
|
+
results = []
|
59
|
+
@devices.each do |d|
|
60
|
+
results[d.start_address, d.start_address+d.capabilities.count] = d.current_values
|
61
|
+
end
|
62
|
+
# backfill unknown values with zero, in case of gaps due to starting_address errors
|
63
|
+
results.map{|i| i.nil? ? 0 : i}.drop(1)
|
64
|
+
end
|
65
|
+
|
66
|
+
def ticks(seconds)
|
67
|
+
[1, (seconds.to_f * self.fps.to_f).to_i].max
|
68
|
+
end
|
69
|
+
|
70
|
+
def wait_time
|
71
|
+
1.0 / self.fps.to_f
|
72
|
+
end
|
73
|
+
|
74
|
+
def transition!(options = {})
|
75
|
+
previous = current_values
|
76
|
+
set(options)
|
77
|
+
count = ticks(options[:seconds])
|
78
|
+
|
79
|
+
count.times do |i|
|
80
|
+
# interpolate previous to current
|
81
|
+
write! interpolate(previous, current_values, count, i+1)
|
82
|
+
sleep(wait_time) unless self.test_mode==true
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def interpolate(first, last, total, i)
|
87
|
+
results = []
|
88
|
+
first.count.times do |j|
|
89
|
+
results[j] = (last[j] - first[j])*i.to_f/total + first[j]
|
90
|
+
end
|
91
|
+
results
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module OpenLighting
|
2
|
+
# A DmxDevice represents a single controllable piece of physical hardware
|
3
|
+
# that can be controlled via DMX signals.
|
4
|
+
#
|
5
|
+
# DmxDevice can be subclassed with sensible defaults for various pieces of
|
6
|
+
# hardware.
|
7
|
+
|
8
|
+
class DmxDevice
|
9
|
+
attr_accessor :controller, :start_address, :capabilities, :points, :current_values, :defaults
|
10
|
+
def initialize(options = {})
|
11
|
+
self.start_address = options[:start_address]
|
12
|
+
self.capabilities = options[:capabilities] || []
|
13
|
+
self.defaults = options[:defaults] || {}
|
14
|
+
self.current_values = capabilities.map{|c| defaults[c] || 0 }
|
15
|
+
self.points = options[:points] || {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def set(options)
|
19
|
+
return if options.nil?
|
20
|
+
|
21
|
+
if pt = options.delete(:point)
|
22
|
+
set points[pt]
|
23
|
+
end
|
24
|
+
|
25
|
+
capabilities.each_with_index do |c, i|
|
26
|
+
unless options[c].nil?
|
27
|
+
current_values[i] = options[c]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def point(key)
|
33
|
+
# d { key }
|
34
|
+
# d { self.points }
|
35
|
+
|
36
|
+
self.points[key]
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_dmx
|
40
|
+
current_values.join ","
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/open_lighting/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Marshall Yount"]
|
6
|
+
gem.email = ["marshall@yountlabs.com"]
|
7
|
+
gem.description = %q{A ruby gem wrapper for the Open Lighting Architecture project}
|
8
|
+
gem.summary = %q{A ruby gem wrapper for the Open Lighting Architecture project}
|
9
|
+
gem.homepage = "https://github.com/marshally/open_lighting_rb"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "open_lighting"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = OpenLighting::VERSION
|
17
|
+
|
18
|
+
if RUBY_VERSION.to_f == 1.9
|
19
|
+
gem.add_development_dependency 'simplecov', '~> 0.6.4'
|
20
|
+
end
|
21
|
+
|
22
|
+
gem.add_development_dependency 'rake', '~> 0.8.7'
|
23
|
+
gem.add_development_dependency 'rspec', '~> 2.11.0'
|
24
|
+
gem.add_development_dependency 'growl', '~> 1.0.3'
|
25
|
+
gem.add_development_dependency 'guard', '~> 1.2.3'
|
26
|
+
gem.add_development_dependency 'guard-rspec', '~> 1.2.0'
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "open_lighting/devices/comscan_led"
|
3
|
+
|
4
|
+
module OpenLighting
|
5
|
+
module Devices
|
6
|
+
describe ComscanLed do
|
7
|
+
before(:each) do
|
8
|
+
@device = ComscanLed.new
|
9
|
+
end
|
10
|
+
|
11
|
+
context ".initialize" do
|
12
|
+
context "without arguments" do
|
13
|
+
it "should know gobo wheel points" do
|
14
|
+
@device.point(:red).should == {:gobo => 15}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "open_lighting/dmx_controller"
|
3
|
+
require "open_lighting/dmx_device"
|
4
|
+
|
5
|
+
module OpenLighting
|
6
|
+
describe DmxController do
|
7
|
+
describe '.initialize' do
|
8
|
+
context 'given default values' do
|
9
|
+
it 'uses default fps' do
|
10
|
+
c = DmxController.new
|
11
|
+
c.fps.should == 40
|
12
|
+
end
|
13
|
+
it 'uses default universe' do
|
14
|
+
c = DmxController.new
|
15
|
+
c.universe.should == 1
|
16
|
+
end
|
17
|
+
it 'uses default cmd' do
|
18
|
+
c = DmxController.new(:universe => 2)
|
19
|
+
c.cmd.should == "ola_streaming_client -u 2"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
context 'given updated values' do
|
23
|
+
it 'updates fps value' do
|
24
|
+
c = DmxController.new(:fps => 20)
|
25
|
+
c.fps.should == 20
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe ".devices" do
|
31
|
+
before(:each) do
|
32
|
+
@controller = DmxController.new
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when adding devices' do
|
36
|
+
before(:each) do
|
37
|
+
@controller << DmxDevice.new(:start_address => 1)
|
38
|
+
@controller << DmxDevice.new(:start_address => 6)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should return devices in the same order as added' do
|
42
|
+
@controller.devices.count.should == 2
|
43
|
+
@controller.devices.first.start_address.should == 1
|
44
|
+
@controller.devices.last.start_address.should == 6
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should attach controller to devices' do
|
48
|
+
@controller.devices.first.controller.should == @controller
|
49
|
+
@controller.devices.last.controller.should == @controller
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe ".to_dmx" do
|
55
|
+
before(:each) do
|
56
|
+
@controller = DmxController.new
|
57
|
+
@controller << DmxDevice.new(:start_address => 1, :capabilities => [:pan, :tilt, :dimmer])
|
58
|
+
@controller << DmxDevice.new(:start_address => 4, :capabilities => [:pan, :tilt, :dimmer])
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should serialize all DmxDevices" do
|
62
|
+
@controller.to_dmx.should == "0,0,0,0,0,0"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should honor overlapping start_address" do
|
66
|
+
@controller << DmxDevice.new(:start_address => 5, :capabilities => [:pan, :tilt, :dimmer])
|
67
|
+
@controller.set(:pan => 127)
|
68
|
+
@controller.to_dmx.should == "127,0,0,127,127,0,0"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should insert zeros for missing data points" do
|
72
|
+
@controller << DmxDevice.new(:start_address => 9, :capabilities => [:pan, :tilt, :dimmer])
|
73
|
+
@controller.set(:pan => 127)
|
74
|
+
@controller.to_dmx.should == "127,0,0,127,0,0,0,0,127,0,0"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe ".instant!" do
|
79
|
+
before(:each) do
|
80
|
+
@controller = DmxController.new(:test => true)
|
81
|
+
@controller << DmxDevice.new(:start_address => 1, :capabilities => [:pan, :tilt, :dimmer])
|
82
|
+
@controller << DmxDevice.new(:start_address => 4, :capabilities => [:pan, :tilt, :dimmer])
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should write to the pipe" do
|
86
|
+
@controller.instant!(:pan => 127)
|
87
|
+
@controller.read_pipe.gets.should == "127,0,0,127,0,0\n"
|
88
|
+
@controller.write_pipe.close
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe ".ticks" do
|
93
|
+
before(:each) do
|
94
|
+
@controller = DmxController.new(:fps => 0.1)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should always have at least 1 tick" do
|
98
|
+
@controller.ticks(1).should == 1
|
99
|
+
@controller.ticks(-1).should == 1
|
100
|
+
@controller.ticks(-100000).should == 1
|
101
|
+
@controller.ticks(0).should == 1
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should round down to fewer ticks" do
|
105
|
+
@controller.ticks(25).should == 2
|
106
|
+
@controller.ticks(30).should == 3
|
107
|
+
@controller.ticks(35).should == 3
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe ".interpolate" do
|
112
|
+
context "with fps equal to one" do
|
113
|
+
before(:each) do
|
114
|
+
@controller = DmxController.new
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should handle one step" do
|
118
|
+
@controller.interpolate([1,1,1], [2,2,2], 1, 1).should == [2,2,2]
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should handle multiple steps" do
|
122
|
+
@controller.interpolate([1,1,1], [2,2,2], 2, 1).should == [1.5,1.5,1.5]
|
123
|
+
@controller.interpolate([1,1,1], [2,2,2], 2, 2).should == [2,2,2]
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should handle fractional input" do
|
127
|
+
@controller.interpolate([1.5,1.5,1.5], [4.5,4.5,4.5], 2, 1).should == [3.0,3.0,3.0]
|
128
|
+
@controller.interpolate([1.5,1.5,1.5], [4.5,4.5,4.5], 2, 2).should == [4.5,4.5,4.5]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe ".transition!" do
|
134
|
+
before(:each) do
|
135
|
+
@controller = DmxController.new(:fps => 1, :test => true)
|
136
|
+
@controller << DmxDevice.new(:start_address => 1, :capabilities => [:pan, :tilt, :dimmer])
|
137
|
+
@controller << DmxDevice.new(:start_address => 4, :capabilities => [:pan, :tilt, :dimmer])
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should write interpolated values to the pipe" do
|
141
|
+
@controller.transition!(:seconds => 5, :pan => 25)
|
142
|
+
@controller.read_pipe.gets.should == "5,0,0,5,0,0\n"
|
143
|
+
@controller.read_pipe.gets.should == "10,0,0,10,0,0\n"
|
144
|
+
@controller.read_pipe.gets.should == "15,0,0,15,0,0\n"
|
145
|
+
@controller.read_pipe.gets.should == "20,0,0,20,0,0\n"
|
146
|
+
@controller.read_pipe.gets.should == "25,0,0,25,0,0\n"
|
147
|
+
@controller.write_pipe.close
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "open_lighting/dmx_controller"
|
3
|
+
require "open_lighting/dmx_device"
|
4
|
+
|
5
|
+
module OpenLighting
|
6
|
+
describe DmxDevice do
|
7
|
+
context ".initialize" do
|
8
|
+
end
|
9
|
+
|
10
|
+
context ".current_values" do
|
11
|
+
context "when there are no capabilities" do
|
12
|
+
it "current_values should be an empty array" do
|
13
|
+
@device = DmxDevice.new
|
14
|
+
@device.current_values.should == []
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when there are some capabilities" do
|
19
|
+
it "current_values should be the same size array" do
|
20
|
+
@device = DmxDevice.new(:capabilities => [:one, :two, :three])
|
21
|
+
@device.current_values.should == [0, 0, 0]
|
22
|
+
end
|
23
|
+
|
24
|
+
it "current_values should be set with the defaults" do
|
25
|
+
@device = DmxDevice.new(:capabilities => [:one, :two, :three], :defaults => {:one => 127, :two => 0, :three => 255})
|
26
|
+
@device.current_values.should == [127, 0, 255]
|
27
|
+
end
|
28
|
+
|
29
|
+
it "current_values should be set with incomplete defaults" do
|
30
|
+
@device = DmxDevice.new(:capabilities => [:one, :two, :three], :defaults => {:two => 0, :three => 255})
|
31
|
+
@device.current_values.should == [0, 0, 255]
|
32
|
+
end
|
33
|
+
|
34
|
+
it "current_values should be set with too many incomplete defaults" do
|
35
|
+
@device = DmxDevice.new(:capabilities => [:one, :two, :three], :defaults => {:wtf => 99, :two => 0, :three => 255})
|
36
|
+
@device.current_values.should == [0, 0, 255]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context ".set" do
|
42
|
+
before(:each) do
|
43
|
+
@device = DmxDevice.new(:capabilities => [:pan, :tilt, :dimmer])
|
44
|
+
end
|
45
|
+
|
46
|
+
context "when setting correct capabilities" do
|
47
|
+
it "should update current_values" do
|
48
|
+
@device.current_values.should == [0, 0, 0]
|
49
|
+
@device.set(:pan => 127)
|
50
|
+
@device.current_values.should == [127, 0, 0]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "when setting incorrect capabilities" do
|
55
|
+
it "should not update current_values" do
|
56
|
+
@device.current_values.should == [0, 0, 0]
|
57
|
+
@device.set(:some_junk => 127)
|
58
|
+
@device.current_values.should == [0, 0, 0]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context ".to_dmx" do
|
64
|
+
it "should make comma laden magics" do
|
65
|
+
@device = DmxDevice.new(:capabilities => [:pan, :tilt, :dimmer])
|
66
|
+
@device.to_dmx.should == "0,0,0"
|
67
|
+
@device.set(:pan => 127)
|
68
|
+
@device.to_dmx.should == "127,0,0"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context ".point" do
|
73
|
+
context "when not initialized with points" do
|
74
|
+
it "should return nil for unknown points" do
|
75
|
+
device = OpenLighting::DmxDevice.new
|
76
|
+
device.points.should == {}
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context "when initialized with points" do
|
81
|
+
before(:each) do
|
82
|
+
@device = OpenLighting::DmxDevice.new(:capabilities => [:pan, :tilt, :dimmer], :points => {:on => {:dimmer => 255}, :center => {:pan => 127, :tilt => 127}})
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should return correct values for points" do
|
86
|
+
@device.point(:center)[:pan].should == 127
|
87
|
+
@device.point(:center)[:tilt].should == 127
|
88
|
+
end
|
89
|
+
|
90
|
+
context "when setting a point" do
|
91
|
+
it "should fail silently for incorrect point" do
|
92
|
+
@device.set(:point => :off)
|
93
|
+
@device.current_values.should == [0, 0, 0]
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should update current_values" do
|
97
|
+
@device.set(:point => :center)
|
98
|
+
@device.current_values.should == [127, 127, 0]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context "when setting multiple points" do
|
103
|
+
it "should update current_values" do
|
104
|
+
@device.set(:point => :center)
|
105
|
+
@device.set(:point => :on)
|
106
|
+
@device.current_values.should == [127, 127, 255]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: open_lighting
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Marshall Yount
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: simplecov
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.6.4
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.6.4
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.8.7
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.8.7
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.11.0
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.11.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: growl
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.0.3
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.0.3
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: guard
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.2.3
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.2.3
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: guard-rspec
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.2.0
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.2.0
|
110
|
+
description: A ruby gem wrapper for the Open Lighting Architecture project
|
111
|
+
email:
|
112
|
+
- marshall@yountlabs.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- .gitignore
|
118
|
+
- .travis.yml
|
119
|
+
- Gemfile
|
120
|
+
- Guardfile
|
121
|
+
- LICENSE
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- lib/open_lighting.rb
|
125
|
+
- lib/open_lighting/devices/comscan_led.rb
|
126
|
+
- lib/open_lighting/dmx_controller.rb
|
127
|
+
- lib/open_lighting/dmx_device.rb
|
128
|
+
- lib/open_lighting/version.rb
|
129
|
+
- open_lighting.gemspec
|
130
|
+
- spec/open_lighting/devices/comscan_led_spec.rb
|
131
|
+
- spec/open_lighting/dmx_controller_spec.rb
|
132
|
+
- spec/open_lighting/dmx_device_spec.rb
|
133
|
+
- spec/spec_helper.rb
|
134
|
+
homepage: https://github.com/marshally/open_lighting_rb
|
135
|
+
licenses: []
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
none: false
|
142
|
+
requirements:
|
143
|
+
- - ! '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ! '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 1.8.24
|
155
|
+
signing_key:
|
156
|
+
specification_version: 3
|
157
|
+
summary: A ruby gem wrapper for the Open Lighting Architecture project
|
158
|
+
test_files:
|
159
|
+
- spec/open_lighting/devices/comscan_led_spec.rb
|
160
|
+
- spec/open_lighting/dmx_controller_spec.rb
|
161
|
+
- spec/open_lighting/dmx_device_spec.rb
|
162
|
+
- spec/spec_helper.rb
|