Class: Phidgets::InterfaceKit::InterfaceKitOutputs

Inherits:
Object
  • Object
show all
Defined in:
lib/phidgets-ffi/interface_kit.rb

Overview

This class represents an digital output for a PhidgetInterfaceKit. All the properties of an digital output are stored and modified in this class.

Constant Summary collapse

Klass =
Phidgets::FFI::CPhidgetInterfaceKit

Instance Method Summary collapse

Instance Method Details

#indexInteger

Returns index of the digital output, or raises an error.

Returns:

  • (Integer)

    returns index of the digital output, or raises an error.



166
167
168
# File 'lib/phidgets-ffi/interface_kit.rb', line 166

def index 
	@index
end

#inspectObject

Displays data for the digital output



161
162
163
# File 'lib/phidgets-ffi/interface_kit.rb', line 161

def inspect
  "#<#{self.class} @index=#{index}, @state=#{state}>"
end

#offBoolean Also known as: off?

Returns true if the state is off.

Returns:

  • (Boolean)

    returns true if the state is off.



193
194
195
# File 'lib/phidgets-ffi/interface_kit.rb', line 193

def off
  !on
end

#onBoolean Also known as: on?

Returns true if the state is true.

Returns:

  • (Boolean)

    returns true if the state is true.



187
188
189
# File 'lib/phidgets-ffi/interface_kit.rb', line 187

def on
  state == true
end

#stateBoolean

Returns state of the digital output, or raises an error.

Returns:

  • (Boolean)

    returns state of the digital output, or raises an error.



180
181
182
183
184
# File 'lib/phidgets-ffi/interface_kit.rb', line 180

def state
  ptr = ::FFI::MemoryPointer.new(:int)
  Klass.getOutputState(@handle, @index, ptr)
  (ptr.get_int(0) == 0) ? false : true
end

#state=(new_state) ⇒ Boolean

Sets the state of the digital output, or raises an error.

Parameters:

  • new_state (Boolean)

    new state

Returns:

  • (Boolean)

    sets the state of the digital output, or raises an error.



173
174
175
176
177
# File 'lib/phidgets-ffi/interface_kit.rb', line 173

def state=(new_state)
  tmp = new_state ? 1 : 0
  Klass.setOutputState(@handle, @index, tmp)
  new_state
end