Class: Phidgets::FrequencyCounter
- Defined in:
- lib/phidgets/frequency_counter.rb,
ext/phidgets/phidgets_frequency_counter.c
Constant Summary collapse
- FILTER_TYPE_ZERO_CROSSING =
INT2NUM(FILTER_TYPE_ZERO_CROSSING)
- FILTER_TYPE_LOGIC_LEVEL =
INT2NUM(FILTER_TYPE_LOGIC_LEVEL)
Instance Method Summary collapse
-
#getCount ⇒ Object
(also: #count)
The most recent count value the channel has reported.
-
#getDataInterval ⇒ Object
(also: #data_interval)
The DataInterval is the time that must elapse before the channel will fire another CountChange/FrequencyChange event.
-
#getEnabled ⇒ Boolean
(also: #enabled?)
Enables or disables the channel.
-
#getFilterType ⇒ Object
(also: #filter_type)
Determines the signal type that the channel responds to.
-
#getFrequency ⇒ Object
(also: #frequency)
The most recent frequency value that the channel has reported.
-
#getFrequencyCutoff ⇒ Object
(also: #frequency_cutoff)
The frequency at which zero hertz is assumed.
-
#getInputMode ⇒ Object
(also: #input_mode)
The input polarity mode for your channel.
-
#getMaxDataInterval ⇒ Object
(also: #max_data_interval)
The maximum value that DataInterval can be set to.
-
#getMaxFrequency ⇒ Object
(also: #max_frequency)
The maximum value the FrequencyChange event will report.
-
#getMaxFrequencyCutoff ⇒ Object
(also: #max_frequency_cutoff)
The maximum value that FrequencyCutoff can be set to.
-
#getMinDataInterval ⇒ Object
(also: #min_data_interval)
The minimum value that DataInterval can be set to.
-
#getMinFrequencyCutoff ⇒ Object
(also: #min_frequency_cutoff)
The minimum value that FrequencyCutoff can be set to.
-
#getPowerSupply ⇒ Object
(also: #power_supply)
Choose the power supply voltage.
-
#getTimeElapsed ⇒ Time
(also: #time_elapsed)
The amount of time the frequency counter has been enabled for.
-
#new ⇒ Object
constructor
Creates a Phidget FrequencyCounter object.
-
#reset ⇒ Object
Resets the Count and TimeElapsed.
-
#setDataInterval(interval) ⇒ Object
(also: #data_interval=)
The DataInterval is the time that must elapse before the channel will fire another CountChange/FrequencyChange event.
-
#setEnabled(state) ⇒ Object
(also: #enabled=)
Enables or disables the channel.
-
#setFilterType(filter_type) ⇒ Object
(also: #filter_type=)
Determines the signal type that the channel responds to.
-
#setFrequencyCutoff(cutoff) ⇒ Object
(also: #frequency_cutoff=)
The frequency at which zero hertz is assumed.
-
#setInputMode(mode) ⇒ Object
(also: #input_mode=)
The input polarity mode for your channel.
-
#setOnCountChangeHandler(cb_proc = nil, &cb_block) ⇒ Object
(also: #on_count_change)
call-seq: setOnCountChangeHandler(proc=nil, &block).
-
#setOnFrequencyChangeHandler(cb_proc = nil, &cb_block) ⇒ Object
(also: #on_frequency_change)
call-seq: setOnFrequencyChangeHandler(proc=nil, &block).
-
#setPowerSupply(power_supply) ⇒ Object
(also: #power_supply=)
Choose the power supply voltage.
Methods inherited from Common
#close, #getAttached, #getChannel, #getChannelClass, #getChannelClassName, #getChannelName, #getChannelSubclass, #getDeviceChannelCount, #getDeviceClass, #getDeviceClassName, #getDeviceID, #getDeviceLabel, #getDeviceName, #getDeviceSKU, #getDeviceSerialNumber, #getDeviceVersion, #getHubPort, #getHubPortCount, #getIsChannel, #getIsHubPortDevice, #getIsLocal, #getIsRemote, #getServerHostname, #getServerName, #getServerPeerName, #getServerUniqueName, #open, #openWaitForAttachment, #setChannel, #setDeviceLabel, #setDeviceSerialNumber, #setHubPort, #setIsHubPortDevice, #setIsLocal, #setIsRemote, #setOnAttachHandler, #setOnDetachHandler, #setOnErrorHandler, #setOnPropertyChangeHandler, #setServerName, #writeDeviceLabel
Constructor Details
#new ⇒ Object
Creates a Phidget FrequencyCounter object.
9 10 11 12 13 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 9
VALUE ph_freq_init(VALUE self) {
ph_data_t *ph = get_ph_data(self);
ph_raise(PhidgetFrequencyCounter_create((PhidgetFrequencyCounterHandle *)(&(ph->handle))));
return self;
}
|
Instance Method Details
#getCount ⇒ Object Also known as: count
The most recent count value the channel has reported. The count represents the total number of pulses since the the channel was opened, or last reset.
15 16 17 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 15
VALUE ph_freq_get_count(VALUE self) {
return ph_get_uint64(get_ph_handle(self), (phidget_get_uint64_func)PhidgetFrequencyCounter_getCount);
}
|
#getDataInterval ⇒ Object Also known as: data_interval
The DataInterval is the time that must elapse before the channel will fire another CountChange/FrequencyChange event. The data interval is bounded by MinDataInterval and MaxDataInterval.
28 29 30 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 28
VALUE ph_freq_get_data_interval(VALUE self) {
return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetFrequencyCounter_getDataInterval);
}
|
#getEnabled ⇒ Boolean Also known as: enabled?
Enables or disables the channel. 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.
19 20 21 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 19
VALUE ph_freq_get_enabled(VALUE self) {
return ph_get_bool(get_ph_handle(self), (phidget_get_bool_func)PhidgetFrequencyCounter_getEnabled);
}
|
#getFilterType ⇒ Object Also known as: filter_type
Determines the signal type that the channel responds to. The filter type is chosen based on the type of input signal. See the PhidgetFrequencyCounter_FilterType entry under Enumerations for more information.
45 46 47 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 45
VALUE ph_freq_get_filter_type(VALUE self) {
return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetFrequencyCounter_getFilterType);
}
|
#getFrequency ⇒ Object Also known as: frequency
The most recent frequency value that the channel has reported. This value will always be between 0 Hz and MaxFrequency.
54 55 56 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 54
VALUE ph_freq_get_frequency(VALUE self) {
return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetFrequencyCounter_getFrequency);
}
|
#getFrequencyCutoff ⇒ Object Also known as: frequency_cutoff
The frequency at which zero hertz is assumed. This means any frequency at or below the FrequencyCutoff value will be reported as 0 Hz. 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.
62 63 64 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 62
VALUE ph_freq_get_frequency_cutoff(VALUE self) {
return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetFrequencyCounter_getFrequencyCutoff);
}
|
#getInputMode ⇒ Object Also known as: input_mode
The input polarity mode for your channel. See your device’s User Guide for more information about what value to chooose for the InputMode.
79 80 81 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 79
VALUE ph_freq_get_input_mode(VALUE self) {
return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetFrequencyCounter_getInputMode);
}
|
#getMaxDataInterval ⇒ Object Also known as: max_data_interval
The maximum value that DataInterval can be set to.
41 42 43 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 41
VALUE ph_freq_get_max_data_interval(VALUE self) {
return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetFrequencyCounter_getMaxDataInterval);
}
|
#getMaxFrequency ⇒ Object Also known as: max_frequency
The maximum value the FrequencyChange event will report.
58 59 60 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 58
VALUE ph_freq_get_max_frequency(VALUE self) {
return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetFrequencyCounter_getMaxFrequency);
}
|
#getMaxFrequencyCutoff ⇒ Object Also known as: max_frequency_cutoff
The maximum value that FrequencyCutoff can be set to.
75 76 77 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 75
VALUE ph_freq_get_max_frequency_cutoff(VALUE self) {
return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetFrequencyCounter_getMaxFrequencyCutoff);
}
|
#getMinDataInterval ⇒ Object Also known as: min_data_interval
The minimum value that DataInterval can be set to.
37 38 39 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 37
VALUE ph_freq_get_min_data_interval(VALUE self) {
return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetFrequencyCounter_getMinDataInterval);
}
|
#getMinFrequencyCutoff ⇒ Object Also known as: min_frequency_cutoff
The minimum value that FrequencyCutoff can be set to.
71 72 73 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 71
VALUE ph_freq_get_min_frequency_cutoff(VALUE self) {
return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetFrequencyCounter_getMinFrequencyCutoff);
}
|
#getPowerSupply ⇒ Object Also known as: power_supply
Choose the power supply voltage. Set this to the voltage specified in the attached sensor’s data sheet to power it. Set to POWER_SUPPLY_OFF to turn off the supply to save power.
88 89 90 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 88
VALUE ph_freq_get_power_supply(VALUE self) {
return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetFrequencyCounter_getPowerSupply);
}
|
#getTimeElapsed ⇒ Time Also known as: time_elapsed
The amount of time the frequency counter has been enabled for. This property complements Count, the total number of pulses detected since the channel was opened, or last reset.
102 103 104 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 102
VALUE ph_freq_get_time_elapsed(VALUE self) {
return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetFrequencyCounter_getTimeElapsed);
}
|
#reset ⇒ Object
Resets the Count and TimeElapsed. For best results, reset should be called when the channel is disabled.
97 98 99 100 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 97
VALUE ph_freq_reset(VALUE self) {
ph_raise(PhidgetFrequencyCounter_reset((PhidgetFrequencyCounterHandle)get_ph_handle(self)));
return Qnil;
}
|
#setDataInterval(interval) ⇒ Object Also known as: data_interval=
The DataInterval is the time that must elapse before the channel will fire another CountChange/FrequencyChange event. The data interval is bounded by MinDataInterval and MaxDataInterval.
32 33 34 35 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 32
VALUE ph_freq_set_data_interval(VALUE self, VALUE interval) {
ph_raise(PhidgetFrequencyCounter_setDataInterval((PhidgetFrequencyCounterHandle)get_ph_handle(self), NUM2UINT(interval)));
return Qnil;
}
|
#setEnabled(state) ⇒ Object Also known as: enabled=
Enables or disables the channel. 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.
23 24 25 26 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 23
VALUE ph_freq_set_enabled(VALUE self, VALUE state) {
ph_raise(PhidgetFrequencyCounter_setEnabled((PhidgetFrequencyCounterHandle)get_ph_handle(self), TYPE(state) == T_TRUE ? PTRUE : PFALSE));
return Qnil;
}
|
#setFilterType(filter_type) ⇒ Object Also known as: filter_type=
Determines the signal type that the channel responds to. The filter type is chosen based on the type of input signal. See the PhidgetFrequencyCounter_FilterType entry under Enumerations for more information.
49 50 51 52 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 49
VALUE ph_freq_set_filter_type(VALUE self, VALUE filter) {
ph_raise(PhidgetFrequencyCounter_setFilterType((PhidgetFrequencyCounterHandle)get_ph_handle(self), NUM2INT(filter)));
return Qnil;
}
|
#setFrequencyCutoff(cutoff) ⇒ Object Also known as: frequency_cutoff=
The frequency at which zero hertz is assumed. This means any frequency at or below the FrequencyCutoff value will be reported as 0 Hz. 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.
66 67 68 69 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 66
VALUE ph_freq_set_frequency_cutoff(VALUE self, VALUE cutoff) {
ph_raise(PhidgetFrequencyCounter_setFrequencyCutoff((PhidgetFrequencyCounterHandle)get_ph_handle(self), NUM2DBL(cutoff)));
return Qnil;
}
|
#setInputMode(mode) ⇒ Object Also known as: input_mode=
The input polarity mode for your channel. See your device’s User Guide for more information about what value to chooose for the InputMode.
83 84 85 86 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 83
VALUE ph_freq_set_input_mode(VALUE self, VALUE mode) {
ph_raise(PhidgetFrequencyCounter_setInputMode((PhidgetFrequencyCounterHandle)get_ph_handle(self), NUM2INT(mode)));
return Qnil;
}
|
#setOnCountChangeHandler(cb_proc = nil, &cb_block) ⇒ Object Also known as: on_count_change
call-seq:
setOnCountChangeHandler(proc=nil, &block)
Assigns a handler that will be called when the CountChange event occurs.
11 12 13 14 15 |
# File 'lib/phidgets/frequency_counter.rb', line 11 def setOnCountChangeHandler(cb_proc = nil, &cb_block) @on_count_change_thread.kill if defined? @on_count_change_thread and @on_count_change_thread.alive? callback = cb_proc || cb_block @on_count_change_thread = Thread.new {ext_setOnCountChangeHandler(callback)} end |
#setOnFrequencyChangeHandler(cb_proc = nil, &cb_block) ⇒ Object Also known as: on_frequency_change
call-seq:
setOnFrequencyChangeHandler(proc=nil, &block)
Assigns a handler that will be called when the CountChange event occurs.
24 25 26 27 28 |
# File 'lib/phidgets/frequency_counter.rb', line 24 def setOnFrequencyChangeHandler(cb_proc = nil, &cb_block) @on_frequency_change_thread.kill if defined? @on_frequency_change_thread and @on_frequency_change_thread.alive? callback = cb_proc || cb_block @on_frequency_change_thread = Thread.new {ext_setOnFrequencyChangeHandler(callback)} end |
#setPowerSupply(power_supply) ⇒ Object Also known as: power_supply=
Choose the power supply voltage. Set this to the voltage specified in the attached sensor’s data sheet to power it. Set to POWER_SUPPLY_OFF to turn off the supply to save power.
92 93 94 95 |
# File 'ext/phidgets/phidgets_frequency_counter.c', line 92
VALUE ph_freq_set_power_supply(VALUE self, VALUE power_supply) {
ph_raise(PhidgetFrequencyCounter_setPowerSupply((PhidgetFrequencyCounterHandle)get_ph_handle(self), NUM2INT(power_supply)));
return Qnil;
}
|