Class: PhidgetsNative::Device

Inherits:
Object
  • Object
show all
Defined in:
ext/phidgets_native/device_ruby.c,
ext/phidgets_native/device_ruby.c

Overview

This class is the base class from which all phidget devices will inherit. Basic functionality related to the management of any device can be found in here. These methods are all available to all phidgets.

Direct Known Subclasses

Analog, Bridge, FrequencyCounter, GPS, IR, LED, RFID, Servo, TemperatureSensor

Instance Method Summary collapse

Constructor Details

#new(serial_number) ⇒ Object

All phidget objects are created from the device serial number. Serial numbers are required to be Fixnums (aka “unsigned integers”).

Instance Method Details

#closenil

This method will unregister the phidget event handlers, and free up all API resources associated with the phidget. This is an optional, but useful way to remove the object’s overhead before the GC kicks in and actually frees the resource.

Returns:

  • (nil)

#device_classString

Returns a string indicating the “class” of the device. This string comes directly from the CPhidget_getDeviceClass function.

Returns:

  • (String)

#device_idString

Returns a string indicating the “identifier” of the device. Seemingly, this is the product name and part number. This string comes directly from the CPhidget_getDeviceID function.

Returns:

  • (String)

#is_attached?Boolean

Returns true if the device is connected, false if otherwise.

Returns:

  • (Boolean)

#labelString

Returns a string which contains the device label. This string comes directly from the CPhidget_getDeviceLabel function.

Returns:

  • (String)

#nameString

Returns a string indicating the “name” of the device. This seems to be just the product name. This string comes directly from the CPhidget_getDeviceName function.

Returns:

  • (String)

#serial_numberFixNum

Returns a string which contains the device’s serial number. This string comes from what was provided in the object initializer

Returns:

  • (FixNum)

#typeString

Returns a string indicating the “type” of the device. This doesn’t appear to differ much from the device_closs. This string comes directly from the CPhidget_getDeviceType function.

Returns:

  • (String)

#versionFixNum

Returns an FixNum containing the device firmware version. This number comes from the CPhidget_getDeviceVersion function.

Returns:

  • (FixNum)

#wait_for_attachment(timeout) ⇒ FixNum

Call CPhidget_waitForAttachment to execute wait_for_attachment. Given a timeout, this method will pause execution until this device is attached, or timeout milliseconds expires. The method returns the provided timeout parameter.

Returns:

  • (FixNum)