phidgets 0.0.5 → 0.1.0
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.
- data/History.txt +10 -2
- data/README.rdoc +41 -18
- data/Rakefile +31 -20
- data/bin/phidget +29 -44
- data/ext/phidgets/extconf.rb +14 -0
- data/ext/phidgets/phidgets.c +272 -0
- data/ext/phidgets/phidgets.h +82 -0
- data/ext/phidgets/phidgets_accelerometer.c +165 -0
- data/ext/phidgets/phidgets_advanced_servo.c +567 -0
- data/ext/phidgets/phidgets_analog.c +139 -0
- data/ext/phidgets/phidgets_bridge.c +263 -0
- data/ext/phidgets/phidgets_common.c +454 -0
- data/ext/phidgets/phidgets_dictionary.c +279 -0
- data/ext/phidgets/phidgets_encoder.c +249 -0
- data/ext/phidgets/phidgets_frequency_counter.c +241 -0
- data/ext/phidgets/phidgets_gps.c +235 -0
- data/ext/phidgets/phidgets_interface_kit.c +340 -0
- data/ext/phidgets/phidgets_ir.c +251 -0
- data/ext/phidgets/phidgets_led.c +178 -0
- data/ext/phidgets/phidgets_manager.c +366 -0
- data/ext/phidgets/phidgets_motor_control.c +642 -0
- data/ext/phidgets/phidgets_phsensor.c +208 -0
- data/ext/phidgets/phidgets_rfid.c +281 -0
- data/ext/phidgets/phidgets_servo.c +276 -0
- data/ext/phidgets/phidgets_spatial.c +369 -0
- data/ext/phidgets/phidgets_stepper.c +560 -0
- data/ext/phidgets/phidgets_temp_sensor.c +295 -0
- data/ext/phidgets/phidgets_text_lcd.c +381 -0
- data/ext/phidgets/phidgets_text_led.c +107 -0
- data/ext/phidgets/phidgets_weight_sensor.c +113 -0
- data/lib/phidgets/accelerometer.rb +25 -0
- data/lib/phidgets/advanced_servo.rb +49 -0
- data/lib/phidgets/analog.rb +8 -0
- data/lib/phidgets/bridge.rb +25 -0
- data/lib/phidgets/common.rb +75 -190
- data/lib/phidgets/dictionary.rb +53 -0
- data/lib/phidgets/encoder.rb +49 -0
- data/lib/phidgets/frequency_counter.rb +25 -0
- data/lib/phidgets/gps.rb +37 -0
- data/lib/phidgets/interfacekit.rb +38 -128
- data/lib/phidgets/ir.rb +50 -0
- data/lib/phidgets/led.rb +8 -0
- data/lib/phidgets/manager.rb +67 -119
- data/lib/phidgets/motor_control.rb +110 -0
- data/lib/phidgets/ph_sensor.rb +25 -0
- data/lib/phidgets/rfid.rb +38 -111
- data/lib/phidgets/servo.rb +12 -95
- data/lib/phidgets/spatial.rb +25 -0
- data/lib/phidgets/stepper.rb +61 -0
- data/lib/phidgets/temperature_sensor.rb +25 -0
- data/lib/phidgets/text_lcd.rb +8 -0
- data/lib/phidgets/text_led.rb +8 -0
- data/lib/phidgets/weight_sensor.rb +25 -0
- data/lib/phidgets.rb +22 -3
- data/phidgets.gemspec +42 -0
- data/test/test_accelerometer.rb +47 -0
- data/test/test_advanced_servo.rb +152 -0
- data/test/test_analog.rb +45 -0
- data/test/test_bridge.rb +77 -0
- data/test/test_common.rb +167 -0
- data/test/test_dictionary.rb +82 -0
- data/test/test_encoder.rb +67 -0
- data/test/test_frequency_counter.rb +67 -0
- data/test/test_gps.rb +67 -0
- data/test/test_helper.rb +1 -0
- data/test/test_interfacekit.rb +86 -182
- data/test/test_ir.rb +57 -0
- data/test/test_led.rb +55 -0
- data/test/test_manager.rb +94 -0
- data/test/test_motor_control.rb +172 -0
- data/test/test_phidgets.rb +14 -6
- data/test/test_phsensor.rb +62 -0
- data/test/test_rfid.rb +77 -0
- data/test/test_servo.rb +67 -0
- data/test/test_spatial.rb +112 -0
- data/test/test_stepper.rb +163 -0
- data/test/test_temp_sensor.rb +87 -0
- data/test/test_text_lcd.rb +115 -0
- data/test/test_text_led.rb +35 -0
- data/test/test_weight_sensor.rb +32 -0
- metadata +165 -75
- data/Manifest.txt +0 -21
- data/PostInstall.txt +0 -3
- data/README.txt +0 -87
- data/lib/phidgets/phidgets.rb +0 -225
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
@@ -0,0 +1,172 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestPhidgetsMotorControl < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_create
|
6
|
+
assert_nothing_raised {Phidgets::MotorControl.new}
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_get_motor_count
|
10
|
+
motor = Phidgets::MotorControl.new
|
11
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.motor_count}
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_get_velocity
|
15
|
+
motor = Phidgets::MotorControl.new
|
16
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.velocity 1}
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_set_velocity
|
20
|
+
motor = Phidgets::MotorControl.new
|
21
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.set_velocity 1, 33.5}
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_get_acceleration
|
25
|
+
motor = Phidgets::MotorControl.new
|
26
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.acceleration 1}
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_get_acceleration_min
|
30
|
+
motor = Phidgets::MotorControl.new
|
31
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.acceleration_min 1}
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_get_acceleration_max
|
35
|
+
motor = Phidgets::MotorControl.new
|
36
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.acceleration_max 1}
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_set_acceleration
|
40
|
+
motor = Phidgets::MotorControl.new
|
41
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.set_acceleration 1, 58.9}
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_get_current
|
45
|
+
motor = Phidgets::MotorControl.new
|
46
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.current 1}
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_get_input_count
|
50
|
+
motor = Phidgets::MotorControl.new
|
51
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.input_count}
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_get_input_state
|
55
|
+
motor = Phidgets::MotorControl.new
|
56
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.input_state 1}
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_get_encoder_count
|
60
|
+
motor = Phidgets::MotorControl.new
|
61
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.encoder_count}
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_get_encoder_position
|
65
|
+
motor = Phidgets::MotorControl.new
|
66
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.encoder_position 1}
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_set_encoder_position
|
70
|
+
motor = Phidgets::MotorControl.new
|
71
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.set_encoder_position 1, 1500}
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_get_back_emf
|
75
|
+
motor = Phidgets::MotorControl.new
|
76
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.back_emf 1}
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_get_back_emf_sensing_state
|
80
|
+
motor = Phidgets::MotorControl.new
|
81
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.back_emf_sensing_state 1}
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_set_back_emf_sensing_state
|
85
|
+
motor = Phidgets::MotorControl.new
|
86
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.set_back_emf_sensing_state 1, true}
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_get_supply_voltage
|
90
|
+
motor = Phidgets::MotorControl.new
|
91
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.supply_voltage}
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_get_braking
|
95
|
+
motor = Phidgets::MotorControl.new
|
96
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.braking 1}
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_set_braking
|
100
|
+
motor = Phidgets::MotorControl.new
|
101
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.set_braking 1, 34.5}
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_get_sensor_count
|
105
|
+
motor = Phidgets::MotorControl.new
|
106
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.sensor_count}
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_get_sensor_value
|
110
|
+
motor = Phidgets::MotorControl.new
|
111
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.sensor_value 1}
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_get_sensor_raw_value
|
115
|
+
motor = Phidgets::MotorControl.new
|
116
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.sensor_raw_value 1}
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_get_ratiometric
|
120
|
+
motor = Phidgets::MotorControl.new
|
121
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.ratiometric?}
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_set_ratiometric
|
125
|
+
motor = Phidgets::MotorControl.new
|
126
|
+
assert_raise(Phidgets::Error::NotAttached) {motor.ratiometric = true}
|
127
|
+
end
|
128
|
+
|
129
|
+
unless RUBY_VERSION < '1.9.0'
|
130
|
+
def test_set_on_velocity_change
|
131
|
+
motor = Phidgets::MotorControl.new
|
132
|
+
assert_nothing_raised {motor.on_velocity_change {puts 'hello'}}
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_set_on_current_change
|
136
|
+
motor = Phidgets::MotorControl.new
|
137
|
+
assert_nothing_raised {motor.on_current_change {puts 'hello'}}
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_set_on_current_update
|
141
|
+
motor = Phidgets::MotorControl.new
|
142
|
+
assert_nothing_raised {motor.on_current_update {puts 'hello'}}
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_set_on_input_change
|
146
|
+
motor = Phidgets::MotorControl.new
|
147
|
+
assert_nothing_raised {motor.on_input_change {puts 'hello'}}
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_set_on_encoder_position_change
|
151
|
+
motor = Phidgets::MotorControl.new
|
152
|
+
assert_nothing_raised {motor.on_encoder_position_change {puts 'hello'}}
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_set_on_encoder_position_update
|
156
|
+
motor = Phidgets::MotorControl.new
|
157
|
+
assert_nothing_raised {motor.on_encoder_position_update {puts 'hello'}}
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_set_on_back_emf_update
|
161
|
+
motor = Phidgets::MotorControl.new
|
162
|
+
assert_nothing_raised {motor.on_back_emf_update {puts 'hello'}}
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_set_on_sensor_update
|
166
|
+
motor = Phidgets::MotorControl.new
|
167
|
+
assert_nothing_raised {motor.on_sensor_update {puts 'hello'}}
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
|
data/test/test_phidgets.rb
CHANGED
@@ -1,15 +1,23 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
2
|
|
3
3
|
class TestPhidgets < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
end
|
7
4
|
|
8
5
|
def test_library_version
|
9
6
|
lib_ver = ""
|
10
|
-
assert_nothing_raised {
|
11
|
-
lib_ver = Phidgets.getLibraryVersion
|
12
|
-
}
|
7
|
+
assert_nothing_raised {lib_ver = Phidgets.getLibraryVersion}
|
13
8
|
assert lib_ver.split[0] == "Phidget21"
|
14
9
|
end
|
10
|
+
|
11
|
+
def test_enable_logging
|
12
|
+
assert_nothing_raised {Phidgets.enableLogging Phidgets::LOG_ERROR, 'test.log'}
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_disable_logging
|
16
|
+
assert_nothing_raised {Phidgets.disableLogging}
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_log
|
20
|
+
assert_nothing_raised {Phidgets.log Phidgets::LOG_INFO, 'TEST', 'This is a test'}
|
21
|
+
end
|
22
|
+
|
15
23
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestPhidgetsPHSensor < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_create
|
6
|
+
assert_nothing_raised {Phidgets::PHSensor.new}
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_get_ph
|
10
|
+
sensor = Phidgets::PHSensor.new
|
11
|
+
assert_raise(Phidgets::Error::NotAttached) {sensor.ph}
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_get_ph_min
|
15
|
+
sensor = Phidgets::PHSensor.new
|
16
|
+
assert_raise(Phidgets::Error::NotAttached) {sensor.ph_min}
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_get_ph_max
|
20
|
+
sensor = Phidgets::PHSensor.new
|
21
|
+
assert_raise(Phidgets::Error::NotAttached) {sensor.ph_max}
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_get_ph_change_trigger
|
25
|
+
sensor = Phidgets::PHSensor.new
|
26
|
+
assert_raise(Phidgets::Error::NotAttached) {sensor.ph_change_trigger}
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_set_ph_change_trigger
|
30
|
+
sensor = Phidgets::PHSensor.new
|
31
|
+
assert_raise(Phidgets::Error::NotAttached) {sensor.ph_change_trigger = 0.50}
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_get_potential
|
35
|
+
sensor = Phidgets::PHSensor.new
|
36
|
+
assert_raise(Phidgets::Error::NotAttached) {sensor.potential}
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_get_potential_min
|
40
|
+
sensor = Phidgets::PHSensor.new
|
41
|
+
assert_raise(Phidgets::Error::NotAttached) {sensor.potential_min}
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_get_potential_max
|
45
|
+
sensor = Phidgets::PHSensor.new
|
46
|
+
assert_raise(Phidgets::Error::NotAttached) {sensor.potential_max}
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_set_temperature
|
50
|
+
sensor = Phidgets::PHSensor.new
|
51
|
+
assert_raise(Phidgets::Error::NotAttached) {sensor.temperature = 26.5}
|
52
|
+
end
|
53
|
+
|
54
|
+
unless RUBY_VERSION < '1.9.0'
|
55
|
+
def test_set_on_ph_change
|
56
|
+
sensor = Phidgets::PHSensor.new
|
57
|
+
assert_nothing_raised {sensor.on_ph_change {puts 'hello'}}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
data/test/test_rfid.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestPhidgetsRFID < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_create
|
6
|
+
assert_nothing_raised {Phidgets::RFID.new}
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_get_output_count
|
10
|
+
rfid = Phidgets::RFID.new
|
11
|
+
assert_raise(Phidgets::Error::NotAttached) {rfid.output_count}
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_get_output_state
|
15
|
+
rfid = Phidgets::RFID.new
|
16
|
+
assert_raise(Phidgets::Error::NotAttached) {rfid.output_state 1}
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_set_output_state
|
20
|
+
rfid = Phidgets::RFID.new
|
21
|
+
assert_raise(Phidgets::Error::NotAttached) {rfid.set_output_state 1, true}
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_get_antenna_on
|
25
|
+
rfid = Phidgets::RFID.new
|
26
|
+
assert_raise(Phidgets::Error::NotAttached) {rfid.antenna_on?}
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_set_antenna_on
|
30
|
+
rfid = Phidgets::RFID.new
|
31
|
+
assert_raise(Phidgets::Error::NotAttached) {rfid.antenna_on = true}
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_get_led_on
|
35
|
+
rfid = Phidgets::RFID.new
|
36
|
+
assert_raise(Phidgets::Error::NotAttached) {rfid.led_on?}
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_set_led_on
|
40
|
+
rfid = Phidgets::RFID.new
|
41
|
+
assert_raise(Phidgets::Error::NotAttached) {rfid.led_on = true}
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_get_last_tag
|
45
|
+
rfid = Phidgets::RFID.new
|
46
|
+
assert_raise(Phidgets::Error::NotAttached) {rfid.last_tag}
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_get_tag_status
|
50
|
+
rfid = Phidgets::RFID.new
|
51
|
+
assert_raise(Phidgets::Error::NotAttached) {rfid.tag_status}
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_write
|
55
|
+
rfid = Phidgets::RFID.new
|
56
|
+
assert_raise(Phidgets::Error::NotAttached) {rfid.write 'new_tag', Phidgets::RFID::PROTOCOL_EM4100, false}
|
57
|
+
end
|
58
|
+
|
59
|
+
unless RUBY_VERSION < '1.9.0'
|
60
|
+
def test_set_on_tag
|
61
|
+
rfid = Phidgets::RFID.new
|
62
|
+
assert_nothing_raised {rfid.on_tag {puts 'hello'}}
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_set_on_tag_lost
|
66
|
+
rfid = Phidgets::RFID.new
|
67
|
+
assert_nothing_raised {rfid.on_tag_lost {puts 'goodbye'}}
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_set_on_output_change
|
71
|
+
rfid = Phidgets::RFID.new
|
72
|
+
assert_nothing_raised {rfid.on_output_change {puts 'hello'}}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
data/test/test_servo.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestPhidgetsServo < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_create
|
6
|
+
assert_nothing_raised {Phidgets::Servo.new}
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_get_motor_count
|
10
|
+
servo = Phidgets::Servo.new
|
11
|
+
assert_raise(Phidgets::Error::NotAttached) {servo.motor_count}
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_get_position
|
15
|
+
servo = Phidgets::Servo.new
|
16
|
+
assert_raise(Phidgets::Error::NotAttached) {servo.position 1}
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_get_position_min
|
20
|
+
servo = Phidgets::Servo.new
|
21
|
+
assert_raise(Phidgets::Error::NotAttached) {servo.position_min 1}
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_get_position_max
|
25
|
+
servo = Phidgets::Servo.new
|
26
|
+
assert_raise(Phidgets::Error::NotAttached) {servo.position_max 1}
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_set_position
|
30
|
+
servo = Phidgets::Servo.new
|
31
|
+
assert_raise(Phidgets::Error::NotAttached) {servo.set_position 1, 2.14}
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_get_engaged
|
35
|
+
servo = Phidgets::Servo.new
|
36
|
+
assert_raise(Phidgets::Error::NotAttached) {servo.engaged? 1}
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_set_engaged
|
40
|
+
servo = Phidgets::Servo.new
|
41
|
+
assert_raise(Phidgets::Error::NotAttached) {servo.set_engaged 1, true}
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_get_servo_type
|
45
|
+
servo = Phidgets::Servo.new
|
46
|
+
assert_raise(Phidgets::Error::NotAttached) {servo.servo_type 1}
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_set_servo_type
|
50
|
+
servo = Phidgets::Servo.new
|
51
|
+
assert_raise(Phidgets::Error::NotAttached) {servo.set_servo_type 1, Phidgets::Servo::TOWERPRO_MG90}
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_set_servo_parameters
|
55
|
+
servo = Phidgets::Servo.new
|
56
|
+
assert_raise(Phidgets::Error::NotAttached) {servo.set_servo_parameters 1, 0.1, 1.5, 98.5}
|
57
|
+
end
|
58
|
+
|
59
|
+
unless RUBY_VERSION < '1.9.0'
|
60
|
+
def test_set_on_position_change
|
61
|
+
servo = Phidgets::Servo.new
|
62
|
+
assert_nothing_raised {servo.on_position_change {puts 'hello'}}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestPhidgetsSpatial < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_create
|
6
|
+
assert_nothing_raised {Phidgets::Spatial.new}
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_get_acceleration_axis_count
|
10
|
+
spatial = Phidgets::Spatial.new
|
11
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.acceleration_axis_count}
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_get_gyro_axis_count
|
15
|
+
spatial = Phidgets::Spatial.new
|
16
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.gyro_axis_count}
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_get_compass_axis_count
|
20
|
+
spatial = Phidgets::Spatial.new
|
21
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.compass_axis_count}
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_get_acceleration
|
25
|
+
spatial = Phidgets::Spatial.new
|
26
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.acceleration 1}
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_get_acceleration_min
|
30
|
+
spatial = Phidgets::Spatial.new
|
31
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.acceleration_min 1}
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_get_acceleration_max
|
35
|
+
spatial = Phidgets::Spatial.new
|
36
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.acceleration_max 1}
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_get_angular_rate
|
40
|
+
spatial = Phidgets::Spatial.new
|
41
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.angular_rate 1}
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_get_angular_rate_min
|
45
|
+
spatial = Phidgets::Spatial.new
|
46
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.angular_rate_min 1}
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_get_angular_rate_max
|
50
|
+
spatial = Phidgets::Spatial.new
|
51
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.angular_rate_max 1}
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_get_magnetic_field
|
55
|
+
spatial = Phidgets::Spatial.new
|
56
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.magnetic_field 1}
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_get_magnetic_field_min
|
60
|
+
spatial = Phidgets::Spatial.new
|
61
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.magnetic_field_min 1}
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_get_magnetic_field_max
|
65
|
+
spatial = Phidgets::Spatial.new
|
66
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.magnetic_field_max 1}
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_get_data_rate
|
70
|
+
spatial = Phidgets::Spatial.new
|
71
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.data_rate}
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_get_data_rate_min
|
75
|
+
spatial = Phidgets::Spatial.new
|
76
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.data_rate_min}
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_get_data_rate_max
|
80
|
+
spatial = Phidgets::Spatial.new
|
81
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.data_rate_max}
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_set_data_rate
|
85
|
+
spatial = Phidgets::Spatial.new
|
86
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.data_rate = 1000}
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_zero_gyro
|
90
|
+
spatial = Phidgets::Spatial.new
|
91
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.zero_gyro}
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_set_compass_correction_parameters
|
95
|
+
spatial = Phidgets::Spatial.new
|
96
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.set_compass_correction_parameters 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3}
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_reset_compass_correction_parameters
|
100
|
+
spatial = Phidgets::Spatial.new
|
101
|
+
assert_raise(Phidgets::Error::NotAttached) {spatial.reset_compass_correction_parameters}
|
102
|
+
end
|
103
|
+
|
104
|
+
unless RUBY_VERSION < '1.9.0'
|
105
|
+
def test_set_on_spatial_data
|
106
|
+
spatial = Phidgets::Spatial.new
|
107
|
+
assert_nothing_raised {spatial.on_spatial_data {puts 'hello'}}
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
@@ -0,0 +1,163 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestPhidgetsStepper < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_create
|
6
|
+
assert_nothing_raised {Phidgets::Stepper.new}
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_get_input_count
|
10
|
+
stepper = Phidgets::Stepper.new
|
11
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.input_count}
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_get_input_state
|
15
|
+
stepper = Phidgets::Stepper.new
|
16
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.input_state 1}
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_get_motor_count
|
20
|
+
stepper = Phidgets::Stepper.new
|
21
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.motor_count}
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_get_acceleration
|
25
|
+
stepper = Phidgets::Stepper.new
|
26
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.acceleration 1}
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_get_acceleration_min
|
30
|
+
stepper = Phidgets::Stepper.new
|
31
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.acceleration_min 1}
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_get_acceleration_max
|
35
|
+
stepper = Phidgets::Stepper.new
|
36
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.acceleration_max 1}
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_set_acceleration
|
40
|
+
stepper = Phidgets::Stepper.new
|
41
|
+
# ?? assert_raise(Phidgets::Error::NotAttached) {stepper.set_acceleration 1, 0.14}
|
42
|
+
assert_raise(Phidgets::Error::OutOfBounds) {stepper.set_acceleration 1, 0.14}
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_get_velocity_limit
|
46
|
+
stepper = Phidgets::Stepper.new
|
47
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.velocity_limit 1}
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_set_velocity_limit
|
51
|
+
stepper = Phidgets::Stepper.new
|
52
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.set_velocity_limit 1, 2.14}
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_get_velocity
|
56
|
+
stepper = Phidgets::Stepper.new
|
57
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.velocity 1}
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_get_velocity_min
|
61
|
+
stepper = Phidgets::Stepper.new
|
62
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.velocity_min 1}
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_get_velocity_max
|
66
|
+
stepper = Phidgets::Stepper.new
|
67
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.velocity_max 1}
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_get_target_position
|
71
|
+
stepper = Phidgets::Stepper.new
|
72
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.target_position 1}
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_set_target_position
|
76
|
+
stepper = Phidgets::Stepper.new
|
77
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.set_target_position 1, 500}
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_get_current_position
|
81
|
+
stepper = Phidgets::Stepper.new
|
82
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.current_position 1}
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_set_current_position
|
86
|
+
stepper = Phidgets::Stepper.new
|
87
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.set_current_position 1, 500}
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_get_position_min
|
91
|
+
stepper = Phidgets::Stepper.new
|
92
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.position_min 1}
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_get_position_max
|
96
|
+
stepper = Phidgets::Stepper.new
|
97
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.position_max 1}
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_get_current_limit
|
101
|
+
stepper = Phidgets::Stepper.new
|
102
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.current_limit 1}
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_set_current_limit
|
106
|
+
stepper = Phidgets::Stepper.new
|
107
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.set_current_limit 1, 10.7}
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_get_current
|
111
|
+
stepper = Phidgets::Stepper.new
|
112
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.current 1}
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_get_current_min
|
116
|
+
stepper = Phidgets::Stepper.new
|
117
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.current_min 1}
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_get_current_max
|
121
|
+
stepper = Phidgets::Stepper.new
|
122
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.current_max 1}
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_get_engaged
|
126
|
+
stepper = Phidgets::Stepper.new
|
127
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.engaged? 1}
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_set_engaged
|
131
|
+
stepper = Phidgets::Stepper.new
|
132
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.set_engaged 1, true}
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_get_stopped
|
136
|
+
stepper = Phidgets::Stepper.new
|
137
|
+
assert_raise(Phidgets::Error::NotAttached) {stepper.stopped? 1}
|
138
|
+
end
|
139
|
+
|
140
|
+
unless RUBY_VERSION < '1.9.0'
|
141
|
+
def test_set_on_input_change
|
142
|
+
stepper = Phidgets::Stepper.new
|
143
|
+
assert_nothing_raised {stepper.on_input_change {puts 'hello'}}
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_set_on_velocity_change
|
147
|
+
stepper = Phidgets::Stepper.new
|
148
|
+
assert_nothing_raised {stepper.on_velocity_change {puts 'hello'}}
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_set_on_position_change
|
152
|
+
stepper = Phidgets::Stepper.new
|
153
|
+
assert_nothing_raised {stepper.on_position_change {puts 'hello'}}
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_set_on_current_change
|
157
|
+
stepper = Phidgets::Stepper.new
|
158
|
+
assert_nothing_raised {stepper.on_current_change {puts 'hello'}}
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
|