x10-cm17a 1.0.1-i386-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +204 -0
- data/ext/cm17a_api/MANIFEST +4 -0
- data/ext/cm17a_api/cm17a.c +443 -0
- data/ext/cm17a_api/cm17a.h +63 -0
- data/ext/cm17a_api/cm17a_api.c +130 -0
- data/ext/cm17a_api/extconf.rb +17 -0
- data/lib/i386-mswin32/cm17a_api.so +0 -0
- data/lib/x10.rb +102 -0
- data/lib/x10/cm17a.rb +29 -0
- data/lib/x10/cm17a_device.rb +61 -0
- data/lib/x10/cm17a_remote.rb +25 -0
- data/setup.rb +1360 -0
- data/test/test_cm17a_controller.rb +35 -0
- data/test/test_cm17a_device.rb +141 -0
- data/test/test_x10.rb +36 -0
- metadata +53 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'x10/cm17a'
|
5
|
+
require 'rbconfig'
|
6
|
+
|
7
|
+
# There's not much we can test on the api code without assuming a
|
8
|
+
# bunch of hardware. The output of the API is a sequence of on/off
|
9
|
+
# states in the DTS/RTS RS-232 signals. See the file
|
10
|
+
# cm17a_protocol.txt in the doc directory for details.
|
11
|
+
#
|
12
|
+
class TestApi < Test::Unit::TestCase
|
13
|
+
DEV = (Config::CONFIG['arch'] =~ /win32/) ? "COM1" : "/dev/ttyS0"
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
X10.controller.close if X10.controller
|
17
|
+
X10.controller = nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_default_create
|
21
|
+
cm = X10::Cm17a::Controller.new
|
22
|
+
assert_not_nil cm
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_specific_create
|
26
|
+
cm = X10::Cm17a::Controller.new(DEV)
|
27
|
+
assert_not_nil cm
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_bad_create
|
31
|
+
assert_raises(X10::X10Error) {
|
32
|
+
cm = X10::Cm17a::Controller.new("/dev/bad device")
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'rubygems'
|
5
|
+
rescue LoadError
|
6
|
+
# nothing
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'test/unit'
|
10
|
+
require 'flexmock'
|
11
|
+
require 'x10/cm17a'
|
12
|
+
|
13
|
+
######################################################################
|
14
|
+
class NoopClass
|
15
|
+
def method_missing(sym, *args, &block)
|
16
|
+
self
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
NOOP = NoopClass.new
|
21
|
+
|
22
|
+
######################################################################
|
23
|
+
class MockController < FlexMock
|
24
|
+
class << self
|
25
|
+
def setup_controller(controller)
|
26
|
+
X10.controller = controller
|
27
|
+
controller.mock_handle(:device, 1) { |house, unit|
|
28
|
+
X10::Cm17a::Device.new(house, unit, controller)
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def use
|
33
|
+
super do |mock|
|
34
|
+
setup_controller(mock)
|
35
|
+
yield(mock)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
######################################################################
|
42
|
+
class TestCm17a < Test::Unit::TestCase
|
43
|
+
def setup
|
44
|
+
end
|
45
|
+
|
46
|
+
def teardown
|
47
|
+
X10.controller = nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_create
|
51
|
+
MockController.use do |controller|
|
52
|
+
dev = X10.device('a1')
|
53
|
+
assert_not_nil(dev)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_on
|
58
|
+
MockController.use do |controller|
|
59
|
+
controller.mock_handle(:command, 1) { |house, unit, cmd, step|
|
60
|
+
assert_equal :on, cmd
|
61
|
+
assert_equal 0, step
|
62
|
+
}
|
63
|
+
dev = X10.device('a1')
|
64
|
+
dev.on
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_off
|
69
|
+
MockController.use do |controller|
|
70
|
+
controller.mock_handle(:command, 1) { |house, unit, cmd, step|
|
71
|
+
assert_equal :off, cmd
|
72
|
+
assert_equal 0, step
|
73
|
+
}
|
74
|
+
dev = X10.device('a1')
|
75
|
+
dev.off
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_adjust
|
80
|
+
MockController.use do |controller|
|
81
|
+
controller.mock_handle(:command, 2) { |house, unit, cmd, step|
|
82
|
+
if step == 4
|
83
|
+
assert_equal 4, step
|
84
|
+
assert_equal :brighten, cmd
|
85
|
+
else
|
86
|
+
assert_equal 3, step
|
87
|
+
assert_equal :dim, cmd
|
88
|
+
end
|
89
|
+
}
|
90
|
+
dev = X10.device('a1')
|
91
|
+
dev.step(4)
|
92
|
+
dev.step(-3)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_big_adjustments
|
97
|
+
MockController.use do |controller|
|
98
|
+
controller.mock_handle(:command, 2) { |house, unit, cmd, step|
|
99
|
+
assert_equal :dim, cmd
|
100
|
+
if step == 6
|
101
|
+
assert_equal 6, step
|
102
|
+
else
|
103
|
+
assert_equal 3, step
|
104
|
+
end
|
105
|
+
}
|
106
|
+
dev = X10.device('a1')
|
107
|
+
dev.step(-9)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_small_adjustments
|
112
|
+
MockController.use do |controller|
|
113
|
+
controller.mock_handle(:command, 0) { }
|
114
|
+
dev = X10.device('a1')
|
115
|
+
dev.step(0)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_device_addressing
|
120
|
+
MockController.use do |controller|
|
121
|
+
controller.mock_handle(:command) { |house, unit, cmd, step|
|
122
|
+
assert_equal 1, house
|
123
|
+
assert_equal 2, unit
|
124
|
+
}
|
125
|
+
dev = X10.device('b3')
|
126
|
+
dev.off
|
127
|
+
dev.on
|
128
|
+
dev.step(1)
|
129
|
+
dev.step(-1)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
######################################################################
|
135
|
+
class TestCm17aController < Test::Unit::TestCase
|
136
|
+
def test_create
|
137
|
+
X10.controller = X10::Cm17a::Controller.new
|
138
|
+
d = X10.device('a1')
|
139
|
+
assert_not_nil d
|
140
|
+
end
|
141
|
+
end
|
data/test/test_x10.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class TestX10 < Test::Unit::TestCase
|
6
|
+
def test_parse_name
|
7
|
+
assert_equal [0, 0], X10.parse_address("a1")
|
8
|
+
assert_equal [0, 0], X10.parse_address("A1")
|
9
|
+
assert_equal [1, 0], X10.parse_address("b1")
|
10
|
+
assert_equal [0, 1], X10.parse_address("a2")
|
11
|
+
assert_equal [7, 5], X10.parse_address("h6")
|
12
|
+
assert_equal [7, 5], X10.parse_address("H6")
|
13
|
+
assert_equal [15, 15], X10.parse_address("p16")
|
14
|
+
assert_equal [15, 15], X10.parse_address("P16")
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_bad_house
|
18
|
+
assert_raises(X10::X10Error) { X10.parse_address("11") }
|
19
|
+
assert_raises(X10::X10Error) { X10.parse_address("?1") }
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_bad_format
|
23
|
+
assert_raises(X10::X10Error) { X10.parse_address("") }
|
24
|
+
assert_raises(X10::X10Error) { X10.parse_address("abcd12") }
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_bad_unit
|
28
|
+
assert_raises(X10::X10Error) { X10.parse_address("a0") }
|
29
|
+
assert_raises(X10::X10Error) { X10.parse_address("a17") }
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_reverse_name
|
33
|
+
assert_equal "b10", X10.make_address(1, 9)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.3
|
3
|
+
specification_version: 1
|
4
|
+
name: x10-cm17a
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 1.0.1
|
7
|
+
date: 2005-01-18
|
8
|
+
summary: Ruby based X10 CM17A Firecracker Controller
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
- lib
|
12
|
+
- lib/i386-mswin32
|
13
|
+
email: jim@weirichhouse.org
|
14
|
+
homepage: http://x10-cm17a.rubyforge.org
|
15
|
+
rubyforge_project:
|
16
|
+
description: ''
|
17
|
+
autorequire:
|
18
|
+
default_executable:
|
19
|
+
bindir: bin
|
20
|
+
has_rdoc: true
|
21
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
22
|
+
requirements:
|
23
|
+
-
|
24
|
+
- ">"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.0
|
27
|
+
version:
|
28
|
+
platform: i386-mswin32
|
29
|
+
authors:
|
30
|
+
- Jim Weirich
|
31
|
+
files:
|
32
|
+
- Rakefile
|
33
|
+
- setup.rb
|
34
|
+
- test/test_cm17a_controller.rb
|
35
|
+
- test/test_cm17a_device.rb
|
36
|
+
- test/test_x10.rb
|
37
|
+
- lib/x10.rb
|
38
|
+
- lib/x10/cm17a.rb
|
39
|
+
- lib/x10/cm17a_device.rb
|
40
|
+
- lib/x10/cm17a_remote.rb
|
41
|
+
- ext/cm17a_api/MANIFEST
|
42
|
+
- ext/cm17a_api/cm17a.h
|
43
|
+
- ext/cm17a_api/cm17a.c
|
44
|
+
- ext/cm17a_api/cm17a_api.c
|
45
|
+
- ext/cm17a_api/extconf.rb
|
46
|
+
- lib/i386-mswin32/cm17a_api.so
|
47
|
+
test_files: []
|
48
|
+
rdoc_options: []
|
49
|
+
extra_rdoc_files: []
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
requirements: []
|
53
|
+
dependencies: []
|