minilab 2.0.0-x86-mingw32 → 2.0.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.yardopts +1 -0
- data/CHANGES +7 -3
- data/README.rdoc +3 -3
- data/Rakefile +0 -8
- data/lib/minilab/analog_io.rb +1 -1
- data/lib/minilab/connection_state.rb +1 -1
- data/lib/minilab/digital_auxport_io.rb +1 -1
- data/lib/minilab/digital_configuration.rb +1 -1
- data/lib/minilab/digital_port_io.rb +1 -1
- data/lib/minilab/library_translator.rb +1 -1
- data/lib/minilab/minilab.rb +48 -41
- data/lib/minilab/minilab_constants.rb +4 -3
- data/lib/minilab/minilab_context.rb +1 -1
- data/lib/minilab/minilab_hardware.rb +1 -1
- data/lib/minilab/minilab_wrapper.rb +1 -1
- data/lib/minilab/version.rb +1 -1
- data/spec/unit/minilab_spec.rb +2 -2
- metadata +4 -4
- data/.document +0 -2
data/.gitignore
CHANGED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
lib/**/*.rb --no-private -r README.rdoc - CHANGES LICENSE
|
data/CHANGES
CHANGED
@@ -1,11 +1,15 @@
|
|
1
|
+
== 2.0.1
|
2
|
+
* converted a significant amount of documentation to yardoc format
|
3
|
+
* some of Minilab's instance methods now return [true] instead of [whatever]
|
4
|
+
|
1
5
|
== 2.0.0
|
2
6
|
* minilab now requires Ruby 1.9 to run and is built for the RubyInstaller package.
|
3
7
|
minilab's public interface has not changed.
|
4
8
|
* Now using the latest and greatest bundler techniques for gem development.
|
5
9
|
* Two libraries minilab used for testing (hardmock and systir) do not run on Ruby 1.9. Therefore, minilab now uses:
|
6
|
-
|
7
|
-
|
8
|
-
|
10
|
+
* RSpec as a test harness
|
11
|
+
* steak as an acceptance test harness
|
12
|
+
* rr for mocking in unit tests
|
9
13
|
|
10
14
|
== 1.1.1
|
11
15
|
* Lots of little things changed as part of the Rubyforge -> Gemcutter/GitHub/rdoc.info migration
|
data/README.rdoc
CHANGED
@@ -62,8 +62,8 @@ See the end of this document for an outline of how a miniLAB and DB37 connector
|
|
62
62
|
* Reading analog values only supports single-ended mode. As you can probably guess, I didn't need differential mode, so I didn't add support for it.
|
63
63
|
|
64
64
|
== Contact information
|
65
|
-
* Matt Fletcher
|
66
|
-
* Atomic Object
|
65
|
+
* Matt Fletcher (mailto:fletcher@atomicobject.com)
|
66
|
+
* Atomic Object (http://atomicobject.com)
|
67
67
|
|
68
68
|
== Appendix
|
69
69
|
=== DB37 pin to port mapping
|
@@ -73,7 +73,7 @@ Pin:: Port
|
|
73
73
|
26-29:: :portcl
|
74
74
|
22-25:: :portch
|
75
75
|
|
76
|
-
===
|
76
|
+
=== Acceptance test setup
|
77
77
|
|
78
78
|
On top of the miniLAB:
|
79
79
|
CH0 IN:: D/A OUT 1
|
data/Rakefile
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require "rake/rdoctask"
|
2
1
|
require "rspec/core/rake_task"
|
3
2
|
|
4
3
|
desc "Run the unit specs"
|
@@ -16,10 +15,3 @@ namespace :spec do
|
|
16
15
|
desc "all tests"
|
17
16
|
task :all => %w[ spec:unit spec:acceptance ]
|
18
17
|
end
|
19
|
-
|
20
|
-
Rake::RDocTask.new do |rdoc|
|
21
|
-
rdoc.rdoc_dir = "rdoc"
|
22
|
-
rdoc.title = "minilab: Ruby library for the miniLAB 1008"
|
23
|
-
rdoc.options = %w[ --main README.rdoc --title minilab ]
|
24
|
-
rdoc.rdoc_files.include("lib/minilab.rb", "README.rdoc", "CHANGES", "LICENSE")
|
25
|
-
end
|
data/lib/minilab/analog_io.rb
CHANGED
data/lib/minilab/minilab.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
|
+
# @author Matt Fletcher (fletcher@atomicobject.com)
|
1
2
|
module Minilab
|
2
|
-
#
|
3
|
-
#
|
3
|
+
# Constructs Minilab objects.
|
4
|
+
# @return [Minilab] an unconnected Minilab object. Use {Minilab#connect}
|
5
|
+
# to connect it to the physical device.
|
4
6
|
def self.build
|
5
7
|
MinilabContext.new.build[:minilab]
|
6
8
|
end
|
7
9
|
|
8
10
|
# The main interface to the minilab library. Create one of these objects
|
9
|
-
# using the
|
10
|
-
# use the
|
11
|
+
# using the {Minilab.build} method. After you've created a minilab object,
|
12
|
+
# use the {#connect} method to establish the connection to the device.
|
11
13
|
# Minilab objects are not usable until they've been connected.
|
14
|
+
# @author Matt Fletcher (fletcher@atomicobject.com)
|
12
15
|
class Minilab
|
13
16
|
include MinilabConstants
|
14
17
|
constructor :minilab_wrapper, :analog_io, :digital_auxport_io, :digital_port_io, :connection_state
|
@@ -17,18 +20,22 @@ module Minilab
|
|
17
20
|
# * Error reporting from MCC's universal library is set to print
|
18
21
|
# errors to standard out instead of popping up a Windows dialog.
|
19
22
|
# * Each of the DB37 digital ports is setup for input.
|
23
|
+
# @return [true]
|
20
24
|
def connect
|
21
25
|
@minilab_wrapper.setup_error_handling(DONTPRINT, STOPALL)
|
22
26
|
@minilab_wrapper.declare_revision(CURRENTREVNUM)
|
23
27
|
@connection_state.connected = true
|
24
28
|
DigitalConfiguration::PORTS.each { |port| configure_input_port(port) }
|
29
|
+
true
|
25
30
|
end
|
26
31
|
|
27
|
-
# Read from one of the eight analog channels
|
32
|
+
# Read from one of the eight analog channels on top of the device.
|
28
33
|
#
|
29
34
|
# Single-ended mode is the only analog mode supported.
|
30
35
|
#
|
31
|
-
#
|
36
|
+
# @param [Fixnum] channel the analog channel (0 - 7)
|
37
|
+
# @return [Float] the voltage
|
38
|
+
# @raise [RuntimeError] the channel number is invalid
|
32
39
|
def read_analog(channel)
|
33
40
|
ensure_connected_to_device
|
34
41
|
@analog_io.read_analog(channel)
|
@@ -39,8 +46,10 @@ module Minilab
|
|
39
46
|
#
|
40
47
|
# Single-ended mode is the only analog mode supported.
|
41
48
|
#
|
42
|
-
#
|
43
|
-
# voltage
|
49
|
+
# @param [Fixnum] channel the analog channel (0 or 1)
|
50
|
+
# @param [Float] volts the voltage (0.0 - 5.0)
|
51
|
+
# @raise [RuntimeError] the channel number is invalid
|
52
|
+
# @raise [RuntimeError] the voltage is out of range
|
44
53
|
def write_analog(channel, volts)
|
45
54
|
ensure_connected_to_device
|
46
55
|
@analog_io.write_analog(channel, volts)
|
@@ -48,9 +57,10 @@ module Minilab
|
|
48
57
|
|
49
58
|
# Configure one of the DB37 ports for input.
|
50
59
|
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
60
|
+
# @param [Symbol] port the port. Valid ports are
|
61
|
+
# :porta, :portb, :portcl, and :portch.
|
62
|
+
# @return [true]
|
63
|
+
# @raise [RuntimeError] the port is invalid
|
54
64
|
def configure_input_port(port)
|
55
65
|
ensure_connected_to_device
|
56
66
|
@digital_port_io.configure_input_port(port)
|
@@ -58,44 +68,42 @@ module Minilab
|
|
58
68
|
|
59
69
|
# Configure one of the DB37 ports for output.
|
60
70
|
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
71
|
+
# @param (see #configure_input_port)
|
72
|
+
# @return [true]
|
73
|
+
# @raise (see #configure_input_port)
|
64
74
|
def configure_output_port(port)
|
65
75
|
ensure_connected_to_device
|
66
76
|
@digital_port_io.configure_output_port(port)
|
67
77
|
end
|
68
78
|
|
69
|
-
# Read a single bit from one of the
|
79
|
+
# Read a single bit from one of the auxport pins (on the top of the
|
80
|
+
# device) or from a DB37 pin. Ensure the pin has been configured for
|
81
|
+
# input (see {#configure_input_port}) before using this method.
|
82
|
+
# auxport pins do not need to be configured.
|
70
83
|
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
# An error is raised if you specify a pin that doesn't exist or if you
|
78
|
-
# try to read from a DB37 pin on a port that is not configured for input.
|
79
|
-
# The digital pins on the top of the device do not need to be configured.
|
84
|
+
# @param [String, Fixnum] pin a String name of the auxport (e.g. "DIO1")
|
85
|
+
# or a Fixnum DB37 pin number (e.g. 13)
|
86
|
+
# @return [Fixnum] the bit value
|
87
|
+
# @raise [RuntimeError] the given pin doesn't exist
|
88
|
+
# @raise [RuntimeError] the DB37 pin has not been configured for input
|
80
89
|
def read_digital(pin)
|
81
90
|
ensure_connected_to_device
|
82
91
|
perform_digital_op(pin, :read, pin)
|
83
92
|
end
|
84
93
|
|
85
|
-
# Write a single bit to one of the
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
# auxport pins), then specify the pin as a string with its label (e.g.
|
90
|
-
# write_digital("DIO2", 0)). Alternatively, if you'd like to write to one
|
91
|
-
# of the DB37 pins, specify the pin as the number it's labeled with (e.g.
|
92
|
-
# write_digital(17, 1)).
|
94
|
+
# Write a single bit to one of the auxport pins (on the top of the
|
95
|
+
# device) or to a DB37 pin. Ensure the pin has been configured for
|
96
|
+
# output (see {#configure_output_port}) before using this method.
|
97
|
+
# auxport pins do not need to be configured.
|
93
98
|
#
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
+
# @param [String, Fixnum] pin a String name of the auxport (e.g. "DIO1")
|
100
|
+
# or a Fixnum DB37 pin number (e.g. 13)
|
101
|
+
# @param [Fixnum] value the value (0 or 1) to write. values above 1 are
|
102
|
+
# interpreted as 1.
|
103
|
+
# @return [true]
|
104
|
+
# @raise [RuntimeError] the given pin doesn't exist
|
105
|
+
# @raise [RuntimeError] the DB37 pin has not been configured for input
|
106
|
+
# @raise [RuntimeError] a negative value is given
|
99
107
|
def write_digital(pin, value)
|
100
108
|
ensure_connected_to_device
|
101
109
|
perform_digital_op(pin, :write, pin, value)
|
@@ -103,10 +111,9 @@ module Minilab
|
|
103
111
|
|
104
112
|
# Read a byte from one of the DB37 ports.
|
105
113
|
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
# An error is raised if an invalid port is given.
|
114
|
+
# @param (see #configure_input_port)
|
115
|
+
# @return [Fixnum] the byte value
|
116
|
+
# @raise (see #configure_input_port)
|
110
117
|
def read_digital_byte(port)
|
111
118
|
ensure_connected_to_device
|
112
119
|
@digital_port_io.read_port(port)
|
@@ -1,7 +1,8 @@
|
|
1
|
-
# Lifted from cbw.h. Let's hope these don't change often.
|
2
|
-
# Using revision number 5.90.
|
3
1
|
module Minilab
|
4
|
-
module MinilabConstants
|
2
|
+
module MinilabConstants #@private
|
3
|
+
# Lifted from cbw.h. Let's hope these don't change often.
|
4
|
+
# Using revision number 5.90.
|
5
|
+
|
5
6
|
CURRENTREVNUM = 5.90
|
6
7
|
|
7
8
|
BOARDNUM = 0
|
data/lib/minilab/version.rb
CHANGED
data/spec/unit/minilab_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe Minilab::Minilab do
|
|
19
19
|
@digital_port_io.configure_input_port(port)
|
20
20
|
end
|
21
21
|
|
22
|
-
subject.connect
|
22
|
+
assert subject.connect
|
23
23
|
end
|
24
24
|
|
25
25
|
it "bomb out if trying to use a method but haven't connected yet" do
|
@@ -58,7 +58,7 @@ describe Minilab::Minilab do
|
|
58
58
|
@connection_state.connected?.returns true
|
59
59
|
@digital_auxport_io.write_digital('DIO3', 0).returns(true)
|
60
60
|
|
61
|
-
subject.write_digital('DIO3', 0)
|
61
|
+
assert subject.write_digital('DIO3', 0)
|
62
62
|
end
|
63
63
|
|
64
64
|
it "use the digital port object when the pin is a numbered pin for read_digital" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 2
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 2.0.
|
8
|
+
- 1
|
9
|
+
version: 2.0.1
|
10
10
|
platform: x86-mingw32
|
11
11
|
authors:
|
12
12
|
- Matt Fletcher
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-04 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -99,8 +99,8 @@ extra_rdoc_files:
|
|
99
99
|
- CHANGES
|
100
100
|
- LICENSE
|
101
101
|
files:
|
102
|
-
- .document
|
103
102
|
- .gitignore
|
103
|
+
- .yardopts
|
104
104
|
- CHANGES
|
105
105
|
- Gemfile
|
106
106
|
- LICENSE
|
data/.document
DELETED