Class: Phidgets::Manager

Inherits:
Common
  • Object
show all
Defined in:
lib/phidgets/manager.rb

Constant Summary collapse

@@create =
nil
@@open =
nil
@@close =
nil
@@delete =
nil
@@getdevices =
nil

Instance Method Summary collapse

Methods inherited from Common

#getDeviceClass, #getDeviceID, #getDeviceLabel, #getDeviceName, #getDeviceStatus, #getDeviceType, #getDeviceVersion, #getErrorDescription, #getLibraryVersion, #getSerialNumber, #getServerAddress, #getServerID, #getServerStatus, #openRemote, #openRemoteIP, #setDeviceLabel, setLibName, #setOnConnectHandler, #setOnDisconnectHandler, #setOnErrorHandler, #waitForAttachment

Constructor Details

#initializeManager

Returns a new instance of Manager.



11
12
13
14
15
16
17
18
19
# File 'lib/phidgets/manager.rb', line 11

def initialize
  super()

  @manhandle = DL.malloc(DL.sizeof('P'))

  create
  open

end

Instance Method Details

#closeObject



31
32
33
# File 'lib/phidgets/manager.rb', line 31

def close
  call_IX(@@close, 'CPhidgetManager_close', 'IP', @manhandle)
end

#createObject



21
22
23
24
25
# File 'lib/phidgets/manager.rb', line 21

def create
  @@create = sym('CPhidgetManager_create', 'Ip') if @@create == nil
  r, rs = @@create.call(@manhandle.ref)
  raise Phidgets::Exception.new(r) if r != 0
end

#deleteObject



35
36
37
# File 'lib/phidgets/manager.rb', line 35

def delete
  call_IX(@@delete, 'CPhidgetManager_delete', 'IP', @manhandle)
end

#get_attached_devicesObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/phidgets/manager.rb', line 47

def get_attached_devices

  @devices = DL.malloc(DL.sizeof('P'))
  @numDevices = DL.malloc(DL.sizeof('I'))

  puts "|-   # -|-              Type              -|- Serial No. -|-  Version -|\n"
  puts "|-------|----------------------------------|--------------|------------|\n"
  @@getdevices = sym('CPhidgetManager_getAttachedDevices', 'IPPP') if @@getdevices == nil
  r, rs = @@getdevices.call(@manhandle, @devices.ref, @numDevices.ref)
  raise Phidgets::Exception.new(r) if r != 0
  @numDevices.free = nil
  puts "Num Devices: #{@numDevices.to_i}"

end

#openObject



27
28
29
# File 'lib/phidgets/manager.rb', line 27

def open
  call_IX(@@open, 'CPhidgetManager_open', 'IP', @manhandle)
end

#setOnAttachHandler(callback, data) ⇒ Object



43
44
45
# File 'lib/phidgets/manager.rb', line 43

def setOnAttachHandler(callback, data)
  call_IXXX(@@attach_handler, 'CPhidgetManager_set_OnAttach_Handler', 'IPPP', @handle, createCallback(callback), DL::PtrData.new(data.object_id))
end

#setOnDetachHandler(callback, data) ⇒ Object



39
40
41
# File 'lib/phidgets/manager.rb', line 39

def setOnDetachHandler(callback, data)
  call_IXXX(@@detach_handler, 'CPhidgetManager_set_OnDetach_Handler', 'IPPP', @handle, createCallback(callback), DL::PtrData.new(data.object_id))
end