Class: Phidgets::Manager
- Inherits:
-
Object
- Object
- Phidgets::Manager
- Defined in:
- lib/phidgets/manager.rb,
ext/phidgets/phidgets_manager.c
Instance Method Summary collapse
-
#close ⇒ Object
Closes a Phidget Manager that has been opened.
-
#new ⇒ Object
constructor
Creates a Phidget Manager object.
-
#open ⇒ Object
Opens the Phidget Manager.
-
#setOnAttachHandler(cb_proc = nil, &cb_block) ⇒ Object
(also: #on_attach)
call-seq: setOnAttachHandler(proc=nil, &block).
-
#setOnDetachHandler(cb_proc = nil, &cb_block) ⇒ Object
(also: #on_detach)
call-seq: setOnDetachHandler(proc=nil, &block).
Constructor Details
#new ⇒ Object
Creates a Phidget Manager object.
32 33 34 35 36 |
# File 'ext/phidgets/phidgets_manager.c', line 32
VALUE ph_manager_init(VALUE self) {
ph_data_t *ph = get_ph_data(self);
ph_raise(PhidgetManager_create((PhidgetManagerHandle *)(&(ph->handle))));
return self;
}
|
Instance Method Details
#close ⇒ Object
Closes a Phidget Manager that has been opened. PhidgetManage#close will release the Phidget Manager, and should be called prior to delete.
43 44 45 46 |
# File 'ext/phidgets/phidgets_manager.c', line 43
VALUE ph_manager_close(VALUE self) {
ph_raise(PhidgetManager_close((PhidgetManagerHandle)get_ph_handle(self)));
return Qnil;
}
|
#open ⇒ Object
Opens the Phidget Manager. Be sure to register Attach and Detach event handlers for the Manager before opening it, to ensure you program doesn’t miss the events reported for devices already connected to your system.
38 39 40 41 |
# File 'ext/phidgets/phidgets_manager.c', line 38
VALUE ph_manager_open(VALUE self) {
ph_raise(PhidgetManager_open((PhidgetManagerHandle)get_ph_handle(self)));
return Qnil;
}
|
#setOnAttachHandler(cb_proc = nil, &cb_block) ⇒ Object Also known as: on_attach
call-seq:
setOnAttachHandler(proc=nil, &block)
Assigns a handler that will be called when the Attach event occurs.
10 11 12 13 14 |
# File 'lib/phidgets/manager.rb', line 10 def setOnAttachHandler(cb_proc = nil, &cb_block) @on_attach_thread.kill if defined? @on_attach_thread and @on_attach_thread.alive? callback = cb_proc || cb_block @on_attach_thread = Thread.new {ext_setOnAttachHandler(callback)} end |
#setOnDetachHandler(cb_proc = nil, &cb_block) ⇒ Object Also known as: on_detach
call-seq:
setOnDetachHandler(proc=nil, &block)
Assigns a handler that will be called when the Detach event occurs.
21 22 23 24 25 |
# File 'lib/phidgets/manager.rb', line 21 def setOnDetachHandler(cb_proc = nil, &cb_block) @on_detach_thread.kill if defined? @on_detach_thread and @on_detach_thread.alive? callback = cb_proc || cb_block @on_detach_thread = Thread.new {ext_setOnDetachHandler(callback)} end |