Class: Phidgets::FrequencyCounter
- Inherits:
-
Object
- Object
- Phidgets::FrequencyCounter
- Includes:
- Common
- Defined in:
- lib/phidgets-ffi/frequency_counter.rb
Overview
This class represents a PhidgetFrequencyCounter.
Defined Under Namespace
Classes: FrequencyCounterInputs
Constant Summary collapse
- Klass =
Phidgets::FFI::CPhidgetFrequencyCounter
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
The attributes of a PhidgetFrequencyCounter.
-
#inputs ⇒ FrequencyCounterInputs
readonly
Collection of frequency counter inputs.
Instance Method Summary collapse
-
#on_count(obj = nil, &block) ⇒ Boolean
Sets an count handler callback function.
Methods included from Common
#attached?, #attached_to_server?, attributes, #close, #detached?, #detached_to_server?, device_class, #device_class, device_id, #id, #initialize, #label, #label=, #name, #on_attach, #on_detach, #on_error, #on_server_connect, #on_server_disconnect, #on_sleep, #on_wake, #serial_number, #server_address, server_address, #server_id, server_id, server_status, #type, #version, #wait_for_attachment
Instance Attribute Details
#attributes ⇒ Object (readonly)
The attributes of a PhidgetFrequencyCounter
16 17 18 |
# File 'lib/phidgets-ffi/frequency_counter.rb', line 16 def attributes @attributes end |
#inputs ⇒ FrequencyCounterInputs (readonly)
Collection of frequency counter inputs
11 12 13 |
# File 'lib/phidgets-ffi/frequency_counter.rb', line 11 def inputs @inputs end |
Instance Method Details
#on_count(obj = nil, &block) ⇒ Boolean
Sets an count handler callback function. This is called when ticks are counted on an frequency counter input, or when the timeout expires
As this runs in it’s own thread, be sure that all errors are properly handled or the thread will halt and not fire any more.
32 33 34 35 36 37 38 |
# File 'lib/phidgets-ffi/frequency_counter.rb', line 32 def on_count(obj=nil, &block) @on_count_obj = obj @on_count = Proc.new { |device, obj_ptr, index, time, counts| yield self, @inputs[index], time, counts, object_for(obj_ptr) } Klass.set_OnCount_Handler(@handle, @on_count, pointer_for(obj)) end |