phidgets 0.1.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +3 -0
- data/README.rdoc +32 -43
- data/Rakefile +4 -2
- data/bin/phidget +18 -72
- data/ext/phidgets/extconf.rb +5 -8
- data/ext/phidgets/phidgets.c +708 -173
- data/ext/phidgets/phidgets.h +54 -35
- data/ext/phidgets/phidgets_accelerometer.c +193 -109
- data/ext/phidgets/phidgets_bldc_motor.c +529 -0
- data/ext/phidgets/phidgets_capacitive_touch.c +302 -0
- data/ext/phidgets/phidgets_common.c +570 -315
- data/ext/phidgets/phidgets_current_input.c +229 -0
- data/ext/phidgets/phidgets_dc_motor.c +562 -0
- data/ext/phidgets/phidgets_dictionary.c +154 -213
- data/ext/phidgets/phidgets_digital_input.c +127 -0
- data/ext/phidgets/phidgets_digital_output.c +288 -0
- data/ext/phidgets/phidgets_distance_sensor.c +295 -0
- data/ext/phidgets/phidgets_encoder.c +211 -192
- data/ext/phidgets/phidgets_frequency_counter.c +310 -177
- data/ext/phidgets/phidgets_gps.c +226 -164
- data/ext/phidgets/phidgets_gyroscope.c +195 -0
- data/ext/phidgets/phidgets_hub.c +39 -0
- data/ext/phidgets/phidgets_humidity_sensor.c +200 -0
- data/ext/phidgets/phidgets_ir.c +211 -171
- data/ext/phidgets/phidgets_lcd.c +512 -0
- data/ext/phidgets/phidgets_light_sensor.c +200 -0
- data/ext/phidgets/phidgets_log.c +263 -0
- data/ext/phidgets/phidgets_magnetometer.c +279 -0
- data/ext/phidgets/phidgets_manager.c +86 -297
- data/ext/phidgets/phidgets_motor_position_controller.c +787 -0
- data/ext/phidgets/phidgets_phsensor.c +200 -152
- data/ext/phidgets/phidgets_power_guard.c +144 -0
- data/ext/phidgets/phidgets_pressure_sensor.c +200 -0
- data/ext/phidgets/phidgets_rc_servo.c +672 -0
- data/ext/phidgets/phidgets_resistance_input.c +227 -0
- data/ext/phidgets/phidgets_rfid.c +107 -221
- data/ext/phidgets/phidgets_sound_sensor.c +284 -0
- data/ext/phidgets/phidgets_spatial.c +124 -318
- data/ext/phidgets/phidgets_stepper.c +457 -430
- data/ext/phidgets/phidgets_temp_sensor.c +223 -228
- data/ext/phidgets/phidgets_voltage_input.c +428 -0
- data/ext/phidgets/phidgets_voltage_output.c +167 -0
- data/ext/phidgets/phidgets_voltage_ratio_input.c +435 -0
- data/lib/phidgets.rb +21 -14
- data/lib/phidgets/accelerometer.rb +11 -15
- data/lib/phidgets/bldc_motor.rb +45 -0
- data/lib/phidgets/capacitive_touch.rb +33 -0
- data/lib/phidgets/common.rb +40 -69
- data/lib/phidgets/current_input.rb +21 -0
- data/lib/phidgets/dc_motor.rb +45 -0
- data/lib/phidgets/dictionary.rb +30 -39
- data/lib/phidgets/digital_input.rb +21 -0
- data/lib/phidgets/digital_output.rb +56 -0
- data/lib/phidgets/distance_sensor.rb +33 -0
- data/lib/phidgets/encoder.rb +1 -29
- data/lib/phidgets/frequency_counter.rb +23 -14
- data/lib/phidgets/gps.rb +34 -26
- data/lib/phidgets/gyroscope.rb +21 -0
- data/lib/phidgets/humidity_sensor.rb +21 -0
- data/lib/phidgets/ir.rb +34 -39
- data/lib/phidgets/light_sensor.rb +21 -0
- data/lib/phidgets/magnetometer.rb +21 -0
- data/lib/phidgets/manager.rb +18 -66
- data/lib/phidgets/motor_position_controller.rb +45 -0
- data/lib/phidgets/ph_sensor.rb +2 -6
- data/lib/phidgets/pressure_sensor.rb +21 -0
- data/lib/phidgets/rc_servo.rb +58 -0
- data/lib/phidgets/resistance_input.rb +21 -0
- data/lib/phidgets/rfid.rb +22 -38
- data/lib/phidgets/sound_sensor.rb +21 -0
- data/lib/phidgets/spatial.rb +11 -15
- data/lib/phidgets/stepper.rb +48 -50
- data/lib/phidgets/temperature_sensor.rb +11 -15
- data/lib/phidgets/version.rb +5 -0
- data/lib/phidgets/voltage_input.rb +34 -0
- data/lib/phidgets/voltage_output.rb +23 -0
- data/lib/phidgets/voltage_ratio_input.rb +34 -0
- data/phidgets.gemspec +3 -22
- data/test/test_accelerometer.rb +42 -23
- data/test/test_bldc_motor.rb +134 -0
- data/test/test_capacitive_touch.rb +82 -0
- data/test/test_common.rb +125 -108
- data/test/test_current_input.rb +62 -0
- data/test/test_dc_motor.rb +146 -0
- data/test/test_dictionary.rb +22 -54
- data/test/test_digital_input.rb +30 -0
- data/test/test_digital_output.rb +70 -0
- data/test/test_distance_sensor.rb +76 -0
- data/test/test_encoder.rb +45 -38
- data/test/test_frequency_counter.rb +71 -36
- data/test/test_gps.rb +29 -38
- data/test/test_gyroscope.rb +54 -0
- data/test/test_helper.rb +0 -1
- data/test/test_hub.rb +14 -0
- data/test/test_humidity_sensor.rb +58 -0
- data/test/test_ir.rb +34 -34
- data/test/test_lcd.rb +146 -0
- data/test/test_light_sensor.rb +58 -0
- data/test/test_magnetometer.rb +78 -0
- data/test/test_manager.rb +10 -79
- data/test/test_motor_control.rb +146 -108
- data/test/test_phidgets.rb +2 -14
- data/test/test_phsensor.rb +46 -34
- data/test/test_power_guard.rb +42 -0
- data/test/test_pressure_sensor.rb +58 -0
- data/test/test_rc_servo.rb +174 -0
- data/test/test_resistance_input.rb +66 -0
- data/test/test_rfid.rb +15 -54
- data/test/test_sound_sensor.rb +78 -0
- data/test/test_spatial.rb +19 -85
- data/test/test_stepper.rb +89 -98
- data/test/test_temp_sensor.rb +42 -47
- data/test/test_voltage_input.rb +102 -0
- data/test/test_voltage_output.rb +46 -0
- data/test/test_voltage_ratio_input.rb +102 -0
- metadata +72 -89
- data/ext/phidgets/phidgets_advanced_servo.c +0 -567
- data/ext/phidgets/phidgets_analog.c +0 -139
- data/ext/phidgets/phidgets_bridge.c +0 -263
- data/ext/phidgets/phidgets_interface_kit.c +0 -340
- data/ext/phidgets/phidgets_led.c +0 -178
- data/ext/phidgets/phidgets_motor_control.c +0 -642
- data/ext/phidgets/phidgets_servo.c +0 -276
- data/ext/phidgets/phidgets_text_lcd.c +0 -381
- data/ext/phidgets/phidgets_text_led.c +0 -107
- data/ext/phidgets/phidgets_weight_sensor.c +0 -113
- data/lib/phidgets/advanced_servo.rb +0 -49
- data/lib/phidgets/analog.rb +0 -8
- data/lib/phidgets/bridge.rb +0 -25
- data/lib/phidgets/interfacekit.rb +0 -49
- data/lib/phidgets/led.rb +0 -8
- data/lib/phidgets/motor_control.rb +0 -110
- data/lib/phidgets/servo.rb +0 -23
- data/lib/phidgets/text_lcd.rb +0 -8
- data/lib/phidgets/text_led.rb +0 -8
- data/lib/phidgets/weight_sensor.rb +0 -25
- data/test/test_advanced_servo.rb +0 -152
- data/test/test_analog.rb +0 -45
- data/test/test_bridge.rb +0 -77
- data/test/test_interfacekit.rb +0 -97
- data/test/test_led.rb +0 -55
- data/test/test_servo.rb +0 -67
- data/test/test_text_lcd.rb +0 -115
- data/test/test_text_led.rb +0 -35
- data/test/test_weight_sensor.rb +0 -32
@@ -1,24 +1,167 @@
|
|
1
1
|
|
2
2
|
#include "phidgets.h"
|
3
3
|
|
4
|
+
#define FREQ_COUNTER_COUNT_CHANGE_CALLBACK 0
|
5
|
+
#define FREQ_COUNTER_FREQUENCY_CHANGE_CALLBACK 1
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
VALUE
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
VALUE
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
7
|
+
|
8
|
+
|
9
|
+
VALUE ph_freq_init(VALUE self) {
|
10
|
+
ph_data_t *ph = get_ph_data(self);
|
11
|
+
ph_raise(PhidgetFrequencyCounter_create((PhidgetFrequencyCounterHandle *)(&(ph->handle))));
|
12
|
+
return self;
|
13
|
+
}
|
14
|
+
|
15
|
+
VALUE ph_freq_get_count(VALUE self) {
|
16
|
+
return ph_get_uint64(get_ph_handle(self), (phidget_get_uint64_func)PhidgetFrequencyCounter_getCount);
|
17
|
+
}
|
18
|
+
|
19
|
+
VALUE ph_freq_get_enabled(VALUE self) {
|
20
|
+
return ph_get_bool(get_ph_handle(self), (phidget_get_bool_func)PhidgetFrequencyCounter_getEnabled);
|
21
|
+
}
|
22
|
+
|
23
|
+
VALUE ph_freq_set_enabled(VALUE self, VALUE state) {
|
24
|
+
ph_raise(PhidgetFrequencyCounter_setEnabled((PhidgetFrequencyCounterHandle)get_ph_handle(self), TYPE(state) == T_TRUE ? PTRUE : PFALSE));
|
25
|
+
return Qnil;
|
26
|
+
}
|
27
|
+
|
28
|
+
VALUE ph_freq_get_data_interval(VALUE self) {
|
29
|
+
return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetFrequencyCounter_getDataInterval);
|
30
|
+
}
|
31
|
+
|
32
|
+
VALUE ph_freq_set_data_interval(VALUE self, VALUE interval) {
|
33
|
+
ph_raise(PhidgetFrequencyCounter_setDataInterval((PhidgetFrequencyCounterHandle)get_ph_handle(self), NUM2UINT(interval)));
|
34
|
+
return Qnil;
|
35
|
+
}
|
36
|
+
|
37
|
+
VALUE ph_freq_get_min_data_interval(VALUE self) {
|
38
|
+
return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetFrequencyCounter_getMinDataInterval);
|
39
|
+
}
|
40
|
+
|
41
|
+
VALUE ph_freq_get_max_data_interval(VALUE self) {
|
42
|
+
return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetFrequencyCounter_getMaxDataInterval);
|
43
|
+
}
|
44
|
+
|
45
|
+
VALUE ph_freq_get_filter_type(VALUE self) {
|
46
|
+
return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetFrequencyCounter_getFilterType);
|
47
|
+
}
|
48
|
+
|
49
|
+
VALUE ph_freq_set_filter_type(VALUE self, VALUE filter) {
|
50
|
+
ph_raise(PhidgetFrequencyCounter_setFilterType((PhidgetFrequencyCounterHandle)get_ph_handle(self), NUM2INT(filter)));
|
51
|
+
return Qnil;
|
52
|
+
}
|
53
|
+
|
54
|
+
VALUE ph_freq_get_frequency(VALUE self) {
|
55
|
+
return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetFrequencyCounter_getFrequency);
|
56
|
+
}
|
57
|
+
|
58
|
+
VALUE ph_freq_get_max_frequency(VALUE self) {
|
59
|
+
return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetFrequencyCounter_getMaxFrequency);
|
60
|
+
}
|
61
|
+
|
62
|
+
VALUE ph_freq_get_frequency_cutoff(VALUE self) {
|
63
|
+
return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetFrequencyCounter_getFrequencyCutoff);
|
64
|
+
}
|
65
|
+
|
66
|
+
VALUE ph_freq_set_frequency_cutoff(VALUE self, VALUE cutoff) {
|
67
|
+
ph_raise(PhidgetFrequencyCounter_setFrequencyCutoff((PhidgetFrequencyCounterHandle)get_ph_handle(self), NUM2DBL(cutoff)));
|
68
|
+
return Qnil;
|
69
|
+
}
|
70
|
+
|
71
|
+
VALUE ph_freq_get_min_frequency_cutoff(VALUE self) {
|
72
|
+
return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetFrequencyCounter_getMinFrequencyCutoff);
|
73
|
+
}
|
74
|
+
|
75
|
+
VALUE ph_freq_get_max_frequency_cutoff(VALUE self) {
|
76
|
+
return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetFrequencyCounter_getMaxFrequencyCutoff);
|
77
|
+
}
|
78
|
+
|
79
|
+
VALUE ph_freq_get_input_mode(VALUE self) {
|
80
|
+
return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetFrequencyCounter_getInputMode);
|
81
|
+
}
|
82
|
+
|
83
|
+
VALUE ph_freq_set_input_mode(VALUE self, VALUE mode) {
|
84
|
+
ph_raise(PhidgetFrequencyCounter_setInputMode((PhidgetFrequencyCounterHandle)get_ph_handle(self), NUM2INT(mode)));
|
85
|
+
return Qnil;
|
86
|
+
}
|
87
|
+
|
88
|
+
VALUE ph_freq_get_power_supply(VALUE self) {
|
89
|
+
return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetFrequencyCounter_getPowerSupply);
|
90
|
+
}
|
91
|
+
|
92
|
+
VALUE ph_freq_set_power_supply(VALUE self, VALUE power_supply) {
|
93
|
+
ph_raise(PhidgetFrequencyCounter_setPowerSupply((PhidgetFrequencyCounterHandle)get_ph_handle(self), NUM2INT(power_supply)));
|
94
|
+
return Qnil;
|
95
|
+
}
|
96
|
+
|
97
|
+
VALUE ph_freq_reset(VALUE self) {
|
98
|
+
ph_raise(PhidgetFrequencyCounter_reset((PhidgetFrequencyCounterHandle)get_ph_handle(self)));
|
99
|
+
return Qnil;
|
100
|
+
}
|
101
|
+
|
102
|
+
VALUE ph_freq_get_time_elapsed(VALUE self) {
|
103
|
+
return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetFrequencyCounter_getTimeElapsed);
|
104
|
+
}
|
105
|
+
|
106
|
+
|
107
|
+
void CCONV ph_freq_on_count_change(PhidgetFrequencyCounterHandle phid, void *userPtr, uint64_t counts, double timeChange) {
|
108
|
+
ph_callback_data_t *callback_data = ((ph_callback_data_t *)userPtr);
|
109
|
+
while(sem_wait(&callback_data->handler_ready)!=0) {};
|
110
|
+
callback_data->arg1 = ULL2NUM(counts);
|
111
|
+
callback_data->arg2 = DBL2NUM(timeChange);
|
112
|
+
callback_data->arg3 = Qnil;
|
113
|
+
callback_data->arg4 = Qnil;
|
114
|
+
sem_post(&callback_data->callback_called);
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
VALUE ph_freq_set_on_count_change_handler(VALUE self, VALUE handler) {
|
119
|
+
ph_data_t *ph = get_ph_data(self);
|
120
|
+
ph_callback_data_t *callback_data = &ph->dev_callbacks[FREQ_COUNTER_COUNT_CHANGE_CALLBACK];
|
121
|
+
if( TYPE(handler) == T_NIL ) {
|
122
|
+
callback_data->callback = T_NIL;
|
123
|
+
callback_data->exit = true;
|
124
|
+
ph_raise(PhidgetFrequencyCounter_setOnCountChangeHandler((PhidgetFrequencyCounterHandle)ph->handle, NULL, (void *)NULL));
|
125
|
+
sem_post(&callback_data->callback_called);
|
126
|
+
} else {
|
127
|
+
callback_data->exit = false;
|
128
|
+
callback_data->phidget = self;
|
129
|
+
callback_data->callback = handler;
|
130
|
+
ph_raise(PhidgetFrequencyCounter_setOnCountChangeHandler((PhidgetFrequencyCounterHandle)ph->handle, ph_freq_on_count_change, (void *)callback_data));
|
131
|
+
ph_callback_thread(callback_data);
|
132
|
+
}
|
133
|
+
return Qnil;
|
134
|
+
}
|
135
|
+
|
136
|
+
|
137
|
+
void CCONV ph_freq_on_frequency_change(PhidgetFrequencyCounterHandle phid, void *userPtr, double frequency) {
|
138
|
+
ph_callback_data_t *callback_data = ((ph_callback_data_t *)userPtr);
|
139
|
+
while(sem_wait(&callback_data->handler_ready)!=0) {};
|
140
|
+
callback_data->arg1 = DBL2NUM(frequency);
|
141
|
+
callback_data->arg2 = Qnil;
|
142
|
+
callback_data->arg3 = Qnil;
|
143
|
+
callback_data->arg4 = Qnil;
|
144
|
+
sem_post(&callback_data->callback_called);
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
VALUE ph_freq_set_on_frequency_change_handler(VALUE self, VALUE handler) {
|
149
|
+
ph_data_t *ph = get_ph_data(self);
|
150
|
+
ph_callback_data_t *callback_data = &ph->dev_callbacks[FREQ_COUNTER_FREQUENCY_CHANGE_CALLBACK];
|
151
|
+
if( TYPE(handler) == T_NIL ) {
|
152
|
+
callback_data->callback = T_NIL;
|
153
|
+
callback_data->exit = true;
|
154
|
+
ph_raise(PhidgetFrequencyCounter_setOnFrequencyChangeHandler((PhidgetFrequencyCounterHandle)ph->handle, NULL, (void *)NULL));
|
155
|
+
sem_post(&callback_data->callback_called);
|
156
|
+
} else {
|
157
|
+
callback_data->exit = false;
|
158
|
+
callback_data->phidget = self;
|
159
|
+
callback_data->callback = handler;
|
160
|
+
ph_raise(PhidgetFrequencyCounter_setOnFrequencyChangeHandler((PhidgetFrequencyCounterHandle)ph->handle, ph_freq_on_frequency_change, (void *)callback_data));
|
161
|
+
ph_callback_thread(callback_data);
|
162
|
+
}
|
163
|
+
return Qnil;
|
164
|
+
}
|
22
165
|
|
23
166
|
|
24
167
|
void Init_frequency_counter() {
|
@@ -26,9 +169,10 @@ void Init_frequency_counter() {
|
|
26
169
|
VALUE ph_common = rb_const_get(ph_module, rb_intern("Common"));
|
27
170
|
VALUE ph_freq = rb_define_class_under(ph_module, "FrequencyCounter", ph_common);
|
28
171
|
|
29
|
-
|
30
|
-
rb_define_const(ph_freq, "
|
31
|
-
rb_define_const(ph_freq, "
|
172
|
+
|
173
|
+
rb_define_const(ph_freq, "FILTER_TYPE_ZERO_CROSSING", INT2NUM(FILTER_TYPE_ZERO_CROSSING));
|
174
|
+
rb_define_const(ph_freq, "FILTER_TYPE_LOGIC_LEVEL", INT2NUM(FILTER_TYPE_LOGIC_LEVEL));
|
175
|
+
|
32
176
|
|
33
177
|
/* Document-method: new
|
34
178
|
* call-seq: new
|
@@ -37,205 +181,194 @@ void Init_frequency_counter() {
|
|
37
181
|
*/
|
38
182
|
rb_define_method(ph_freq, "initialize", ph_freq_init, 0);
|
39
183
|
|
40
|
-
/* Document-method:
|
41
|
-
* call-seq:
|
184
|
+
/* Document-method: getCount
|
185
|
+
* call-seq: getCount -> count
|
42
186
|
*
|
43
|
-
*
|
187
|
+
* The most recent count value the channel has reported.
|
188
|
+
* The count represents the total number of pulses since the the channel was opened, or last reset.
|
44
189
|
*/
|
45
|
-
rb_define_method(ph_freq, "
|
190
|
+
rb_define_method(ph_freq, "getCount", ph_freq_get_count, 0);
|
191
|
+
rb_define_alias(ph_freq, "count", "getCount");
|
46
192
|
|
47
|
-
/* Document-method:
|
48
|
-
* call-seq:
|
193
|
+
/* Document-method: getEnabled
|
194
|
+
* call-seq: getEnabled -> true or false
|
49
195
|
*
|
50
|
-
*
|
196
|
+
* Enables or disables the channel.
|
197
|
+
* When a channel is disabled, it will not longer register counts, therefore the TimeElapsed and Count will not be updated until the channel is re-enabled.
|
51
198
|
*/
|
52
|
-
rb_define_method(ph_freq, "
|
199
|
+
rb_define_method(ph_freq, "getEnabled", ph_freq_get_enabled, 0);
|
200
|
+
rb_define_alias(ph_freq, "enabled?", "getEnabled");
|
53
201
|
|
54
|
-
/* Document-method:
|
55
|
-
* call-seq:
|
202
|
+
/* Document-method: setEnabled
|
203
|
+
* call-seq: setEnabled(state)
|
56
204
|
*
|
57
|
-
*
|
205
|
+
* Enables or disables the channel.
|
206
|
+
* When a channel is disabled, it will not longer register counts, therefore the TimeElapsed and Count will not be updated until the channel is re-enabled.
|
58
207
|
*/
|
59
|
-
rb_define_method(ph_freq, "
|
208
|
+
rb_define_method(ph_freq, "setEnabled", ph_freq_set_enabled, 1);
|
209
|
+
rb_define_alias(ph_freq, "enabled=", "setEnabled");
|
60
210
|
|
61
|
-
/* Document-method:
|
62
|
-
* call-seq:
|
211
|
+
/* Document-method: getDataInterval
|
212
|
+
* call-seq: getDataInterval -> interval
|
63
213
|
*
|
64
|
-
*
|
214
|
+
* The DataInterval is the time that must elapse before the channel will fire another CountChange/FrequencyChange event.
|
215
|
+
* The data interval is bounded by MinDataInterval and MaxDataInterval.
|
65
216
|
*/
|
66
|
-
rb_define_method(ph_freq, "
|
217
|
+
rb_define_method(ph_freq, "getDataInterval", ph_freq_get_data_interval, 0);
|
218
|
+
rb_define_alias(ph_freq, "data_interval", "getDataInterval");
|
67
219
|
|
68
|
-
/* Document-method:
|
69
|
-
* call-seq:
|
220
|
+
/* Document-method: setDataInterval
|
221
|
+
* call-seq: setDataInterval(interval)
|
70
222
|
*
|
71
|
-
*
|
223
|
+
* The DataInterval is the time that must elapse before the channel will fire another CountChange/FrequencyChange event.
|
224
|
+
* The data interval is bounded by MinDataInterval and MaxDataInterval.
|
72
225
|
*/
|
73
|
-
rb_define_method(ph_freq, "
|
226
|
+
rb_define_method(ph_freq, "setDataInterval", ph_freq_set_data_interval, 1);
|
227
|
+
rb_define_alias(ph_freq, "data_interval=", "setDataInterval");
|
74
228
|
|
75
|
-
/* Document-method:
|
76
|
-
* call-seq:
|
229
|
+
/* Document-method: getMinDataInterval
|
230
|
+
* call-seq: getMinDataInterval -> interval
|
77
231
|
*
|
78
|
-
*
|
232
|
+
* The minimum value that DataInterval can be set to.
|
79
233
|
*/
|
80
|
-
rb_define_method(ph_freq, "
|
234
|
+
rb_define_method(ph_freq, "getMinDataInterval", ph_freq_get_min_data_interval, 0);
|
235
|
+
rb_define_alias(ph_freq, "min_data_interval", "getMinDataInterval");
|
81
236
|
|
82
|
-
/* Document-method:
|
83
|
-
* call-seq:
|
237
|
+
/* Document-method: getMaxDataInterval
|
238
|
+
* call-seq: getMaxDataInterval -> interval
|
84
239
|
*
|
85
|
-
*
|
240
|
+
* The maximum value that DataInterval can be set to.
|
86
241
|
*/
|
87
|
-
rb_define_method(ph_freq, "
|
242
|
+
rb_define_method(ph_freq, "getMaxDataInterval", ph_freq_get_max_data_interval, 0);
|
243
|
+
rb_define_alias(ph_freq, "max_data_interval", "getMaxDataInterval");
|
88
244
|
|
89
|
-
/* Document-method:
|
90
|
-
* call-seq:
|
245
|
+
/* Document-method: getFilterType
|
246
|
+
* call-seq: getFilterType -> filter_type
|
91
247
|
*
|
92
|
-
*
|
248
|
+
* Determines the signal type that the channel responds to.
|
249
|
+
* The filter type is chosen based on the type of input signal. See the PhidgetFrequencyCounter_FilterType entry under Enumerations for more information.
|
93
250
|
*/
|
94
|
-
rb_define_method(ph_freq, "
|
251
|
+
rb_define_method(ph_freq, "getFilterType", ph_freq_get_filter_type, 0);
|
252
|
+
rb_define_alias(ph_freq, "filter_type", "getFilterType");
|
95
253
|
|
96
|
-
/* Document-method:
|
97
|
-
* call-seq:
|
254
|
+
/* Document-method: setFilterType
|
255
|
+
* call-seq: setFilterType(filter_type)
|
98
256
|
*
|
99
|
-
*
|
257
|
+
* Determines the signal type that the channel responds to.
|
258
|
+
* The filter type is chosen based on the type of input signal. See the PhidgetFrequencyCounter_FilterType entry under Enumerations for more information.
|
100
259
|
*/
|
101
|
-
rb_define_method(ph_freq, "
|
260
|
+
rb_define_method(ph_freq, "setFilterType", ph_freq_set_filter_type, 1);
|
261
|
+
rb_define_alias(ph_freq, "filter_type=", "setFilterType");
|
102
262
|
|
103
|
-
/* Document-method:
|
104
|
-
* call-seq:
|
263
|
+
/* Document-method: getFrequency
|
264
|
+
* call-seq: getFrequency -> frequency
|
105
265
|
*
|
106
|
-
*
|
266
|
+
* The most recent frequency value that the channel has reported.
|
267
|
+
* This value will always be between 0 Hz and MaxFrequency.
|
107
268
|
*/
|
108
|
-
rb_define_method(ph_freq, "
|
269
|
+
rb_define_method(ph_freq, "getFrequency", ph_freq_get_frequency, 0);
|
270
|
+
rb_define_alias(ph_freq, "frequency", "getFrequency");
|
109
271
|
|
110
|
-
/* Document-method:
|
111
|
-
* call-seq:
|
272
|
+
/* Document-method: getMaxFrequency
|
273
|
+
* call-seq: getMaxFrequency -> frequency
|
112
274
|
*
|
113
|
-
*
|
275
|
+
* The maximum value the FrequencyChange event will report.
|
114
276
|
*/
|
115
|
-
rb_define_method(ph_freq, "
|
116
|
-
|
117
|
-
#ifdef PH_CALLBACK
|
118
|
-
rb_define_private_method(ph_freq, "ext_setOnCountHandler", ph_freq_set_on_count_handler, 1);
|
119
|
-
#endif
|
277
|
+
rb_define_method(ph_freq, "getMaxFrequency", ph_freq_get_max_frequency, 0);
|
278
|
+
rb_define_alias(ph_freq, "max_frequency", "getMaxFrequency");
|
120
279
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
rb_define_alias(ph_freq, "
|
130
|
-
rb_define_alias(ph_freq, "set_filter", "setFilter");
|
131
|
-
}
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
VALUE ph_freq_init(VALUE self) {
|
136
|
-
ph_data_t *ph = get_ph_data(self);
|
137
|
-
ph_raise(CPhidgetFrequencyCounter_create((CPhidgetFrequencyCounterHandle *)(&(ph->handle))));
|
138
|
-
return self;
|
139
|
-
}
|
140
|
-
|
141
|
-
VALUE ph_freq_get_frequency_input_count(VALUE self) {
|
142
|
-
CPhidgetFrequencyCounterHandle handle = (CPhidgetFrequencyCounterHandle)get_ph_handle(self);
|
143
|
-
int count;
|
144
|
-
ph_raise(CPhidgetFrequencyCounter_getFrequencyInputCount(handle, &count));
|
145
|
-
return INT2FIX(count);
|
146
|
-
}
|
147
|
-
|
148
|
-
VALUE ph_freq_reset(VALUE self, VALUE index) {
|
149
|
-
CPhidgetFrequencyCounterHandle handle = (CPhidgetFrequencyCounterHandle)get_ph_handle(self);
|
150
|
-
ph_raise(CPhidgetFrequencyCounter_reset(handle, FIX2INT(index)));
|
151
|
-
return Qnil;
|
152
|
-
}
|
153
|
-
|
154
|
-
VALUE ph_freq_get_frequency(VALUE self, VALUE index) {
|
155
|
-
CPhidgetFrequencyCounterHandle handle = (CPhidgetFrequencyCounterHandle)get_ph_handle(self);
|
156
|
-
double freq;
|
157
|
-
ph_raise(CPhidgetFrequencyCounter_getFrequency(handle, FIX2INT(index), &freq));
|
158
|
-
return rb_float_new(freq);
|
159
|
-
}
|
160
|
-
|
161
|
-
VALUE ph_freq_get_total_time(VALUE self, VALUE index) {
|
162
|
-
CPhidgetFrequencyCounterHandle handle = (CPhidgetFrequencyCounterHandle)get_ph_handle(self);
|
163
|
-
__int64 time;
|
164
|
-
ph_raise(CPhidgetFrequencyCounter_getTotalTime(handle, FIX2INT(index), &time));
|
165
|
-
return INT2NUM(time);
|
166
|
-
}
|
167
|
-
|
168
|
-
VALUE ph_freq_get_total_count(VALUE self, VALUE index) {
|
169
|
-
CPhidgetFrequencyCounterHandle handle = (CPhidgetFrequencyCounterHandle)get_ph_handle(self);
|
170
|
-
__int64 count;
|
171
|
-
ph_raise(CPhidgetFrequencyCounter_getTotalCount(handle, FIX2INT(index), &count));
|
172
|
-
return INT2NUM(count);
|
173
|
-
}
|
280
|
+
/* Document-method: getFrequencyCutoff
|
281
|
+
* call-seq: getFrequencyCutoff -> cutoff
|
282
|
+
*
|
283
|
+
* The frequency at which zero hertz is assumed.
|
284
|
+
* This means any frequency at or below the FrequencyCutoff value will be reported as 0 Hz.
|
285
|
+
* This property is stored locally, so other users who have this Phidget open over a network connection won't see the effects of your selected cutoff.
|
286
|
+
*/
|
287
|
+
rb_define_method(ph_freq, "getFrequencyCutoff", ph_freq_get_frequency_cutoff, 0);
|
288
|
+
rb_define_alias(ph_freq, "frequency_cutoff", "getFrequencyCutoff");
|
174
289
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
290
|
+
/* Document-method: setFrequencyCutoff
|
291
|
+
* call-seq: setFrequencyCutoff(cutoff)
|
292
|
+
*
|
293
|
+
* The frequency at which zero hertz is assumed.
|
294
|
+
* This means any frequency at or below the FrequencyCutoff value will be reported as 0 Hz.
|
295
|
+
* This property is stored locally, so other users who have this Phidget open over a network connection won't see the effects of your selected cutoff.
|
296
|
+
*/
|
297
|
+
rb_define_method(ph_freq, "setFrequencyCutoff", ph_freq_set_frequency_cutoff, 1);
|
298
|
+
rb_define_alias(ph_freq, "frequency_cutoff=", "setFrequencyCutoff");
|
181
299
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
300
|
+
/* Document-method: getMinFrequencyCutoff
|
301
|
+
* call-seq: getMinFrequencyCutoff -> cutoff
|
302
|
+
*
|
303
|
+
* The minimum value that FrequencyCutoff can be set to.
|
304
|
+
*/
|
305
|
+
rb_define_method(ph_freq, "getMinFrequencyCutoff", ph_freq_get_min_frequency_cutoff, 0);
|
306
|
+
rb_define_alias(ph_freq, "min_frequency_cutoff", "getMinFrequencyCutoff");
|
187
307
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
308
|
+
/* Document-method: getMaxFrequencyCutoff
|
309
|
+
* call-seq: getMaxFrequencyCutoff -> cutoff
|
310
|
+
*
|
311
|
+
* The maximum value that FrequencyCutoff can be set to.
|
312
|
+
*/
|
313
|
+
rb_define_method(ph_freq, "getMaxFrequencyCutoff", ph_freq_get_max_frequency_cutoff, 0);
|
314
|
+
rb_define_alias(ph_freq, "max_frequency_cutoff", "getMaxFrequencyCutoff");
|
194
315
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
316
|
+
/* Document-method: getInputMode
|
317
|
+
* call-seq: getInputMode -> mode
|
318
|
+
*
|
319
|
+
* The input polarity mode for your channel.
|
320
|
+
* See your device's User Guide for more information about what value to chooose for the InputMode.
|
321
|
+
*/
|
322
|
+
rb_define_method(ph_freq, "getInputMode", ph_freq_get_input_mode, 0);
|
323
|
+
rb_define_alias(ph_freq, "input_mode", "getInputMode");
|
200
324
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
325
|
+
/* Document-method: setInputMode
|
326
|
+
* call-seq: setInputMode(mode)
|
327
|
+
*
|
328
|
+
* The input polarity mode for your channel.
|
329
|
+
* See your device's User Guide for more information about what value to chooose for the InputMode.
|
330
|
+
*/
|
331
|
+
rb_define_method(ph_freq, "setInputMode", ph_freq_set_input_mode, 1);
|
332
|
+
rb_define_alias(ph_freq, "input_mode=", "setInputMode");
|
207
333
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
334
|
+
/* Document-method: getPowerSupply
|
335
|
+
* call-seq: getPowerSupply -> power_supply
|
336
|
+
*
|
337
|
+
* Choose the power supply voltage.
|
338
|
+
* Set this to the voltage specified in the attached sensor's data sheet to power it.
|
339
|
+
* Set to POWER_SUPPLY_OFF to turn off the supply to save power.
|
340
|
+
*/
|
341
|
+
rb_define_method(ph_freq, "getPowerSupply", ph_freq_get_power_supply, 0);
|
342
|
+
rb_define_alias(ph_freq, "power_supply", "getPowerSupply");
|
213
343
|
|
344
|
+
/* Document-method: setPowerSupply
|
345
|
+
* call-seq: setPowerSupply(power_supply)
|
346
|
+
*
|
347
|
+
* Choose the power supply voltage.
|
348
|
+
* Set this to the voltage specified in the attached sensor's data sheet to power it.
|
349
|
+
* Set to POWER_SUPPLY_OFF to turn off the supply to save power.
|
350
|
+
*/
|
351
|
+
rb_define_method(ph_freq, "setPowerSupply", ph_freq_set_power_supply, 1);
|
352
|
+
rb_define_alias(ph_freq, "power_supply=", "setPowerSupply");
|
214
353
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
} else {
|
223
|
-
callback_data->called = false;
|
224
|
-
callback_data->exit = false;
|
225
|
-
callback_data->phidget = self;
|
226
|
-
callback_data->callback = handler;
|
227
|
-
ph_raise(CPhidgetFrequencyCounter_set_OnCount_Handler((CPhidgetFrequencyCounterHandle)ph->handle, ph_freq_on_count, (void *)callback_data));
|
228
|
-
ph_callback_thread(callback_data);
|
229
|
-
}
|
230
|
-
return Qnil;
|
231
|
-
}
|
354
|
+
/* Document-method: reset
|
355
|
+
* call-seq: reset
|
356
|
+
*
|
357
|
+
* Resets the Count and TimeElapsed.
|
358
|
+
* For best results, reset should be called when the channel is disabled.
|
359
|
+
*/
|
360
|
+
rb_define_method(ph_freq, "reset", ph_freq_reset, 0);
|
232
361
|
|
362
|
+
/* Document-method: getTimeElapsed
|
363
|
+
* call-seq: getTimeElapsed -> time
|
364
|
+
*
|
365
|
+
* The amount of time the frequency counter has been enabled for.
|
366
|
+
* This property complements Count, the total number of pulses detected since the channel was opened, or last reset.
|
367
|
+
*/
|
368
|
+
rb_define_method(ph_freq, "getTimeElapsed", ph_freq_get_time_elapsed, 0);
|
369
|
+
rb_define_alias(ph_freq, "time_elapsed", "getTimeElapsed");
|
233
370
|
|
234
|
-
|
235
|
-
|
236
|
-
callback_data->called = true;
|
237
|
-
return EPHIDGET_OK;
|
371
|
+
rb_define_private_method(ph_freq, "ext_setOnCountChangeHandler", ph_freq_set_on_count_change_handler, 1);
|
372
|
+
rb_define_private_method(ph_freq, "ext_setOnFrequencyChangeHandler", ph_freq_set_on_frequency_change_handler, 1);
|
238
373
|
}
|
239
374
|
|
240
|
-
#endif
|
241
|
-
|