Class: Phidgets::Analog::AnalogOutputs
- Inherits:
-
Object
- Object
- Phidgets::Analog::AnalogOutputs
- Defined in:
- lib/phidgets-ffi/analog.rb
Overview
This class represents an analog output for a PhidgetAnalog. All the properties of an output are stored and modified in this class.
Constant Summary collapse
- Klass =
Phidgets::FFI::CPhidgetAnalog
Instance Method Summary collapse
-
#enabled ⇒ Boolean
Returns the enabled state of an output, or raises an error.
-
#enabled=(new_state) ⇒ Boolean
Sets the enabled state of an output, or raises an error.
-
#index ⇒ Integer
Returns the index of an output, or raises an error.
-
#inspect ⇒ Object
Displays data for the analog output.
-
#voltage ⇒ Float
Returns the voltage of an output, in V, or raises an error.
-
#voltage=(new_voltage) ⇒ Float
Sets the voltage of an output, in V, or raises an error.
-
#voltage_max ⇒ Float
Returns the maximum supported output voltage, or raises an error.
-
#voltage_min ⇒ Float
Returns the minimum supported output voltage, or raises an error.
Instance Method Details
#enabled ⇒ Boolean
Returns the enabled state of an output, or raises an error.
64 65 66 67 68 |
# File 'lib/phidgets-ffi/analog.rb', line 64 def enabled ptr = ::FFI::MemoryPointer.new(:int) Klass.getEnabled(@handle, @index, ptr) (ptr.get_int(0) == 0) ? false : true end |
#enabled=(new_state) ⇒ Boolean
Sets the enabled state of an output, or raises an error.
73 74 75 76 77 |
# File 'lib/phidgets-ffi/analog.rb', line 73 def enabled=(new_state) tmp = new_state ? 1 : 0 Klass.setEnabled(@handle, @index, tmp) new_state end |
#index ⇒ Integer
Returns the index of an output, or raises an error.
58 59 60 |
# File 'lib/phidgets-ffi/analog.rb', line 58 def index @index end |
#inspect ⇒ Object
Displays data for the analog output
53 54 55 |
# File 'lib/phidgets-ffi/analog.rb', line 53 def inspect "#<#{self.class} @index=#{index}, @enabled=#{enabled}, @voltage=#{voltage}, @voltage_min=#{voltage_min}, @voltage_max=#{voltage_max}>" end |
#voltage ⇒ Float
Returns the voltage of an output, in V, or raises an error.
80 81 82 83 84 |
# File 'lib/phidgets-ffi/analog.rb', line 80 def voltage ptr = ::FFI::MemoryPointer.new(:double) Klass.getVoltage(@handle, @index, ptr) ptr.get_double(0) end |
#voltage=(new_voltage) ⇒ Float
Sets the voltage of an output, in V, or raises an error.
89 90 91 92 |
# File 'lib/phidgets-ffi/analog.rb', line 89 def voltage=(new_voltage) Klass.setVoltage(@handle, @index, new_voltage.to_f) new_voltage end |
#voltage_max ⇒ Float
Returns the maximum supported output voltage, or raises an error.
102 103 104 105 106 |
# File 'lib/phidgets-ffi/analog.rb', line 102 def voltage_max ptr = ::FFI::MemoryPointer.new(:double) Klass.getVoltageMax(@handle, @index, ptr) ptr.get_double(0) end |
#voltage_min ⇒ Float
Returns the minimum supported output voltage, or raises an error.
95 96 97 98 99 |
# File 'lib/phidgets-ffi/analog.rb', line 95 def voltage_min ptr = ::FFI::MemoryPointer.new(:double) Klass.getVoltageMin(@handle, @index, ptr) ptr.get_double(0) end |