Class: Phidgets::CurrentInput

Inherits:
Common
  • Object
show all
Defined in:
lib/phidgets/current_input.rb,
ext/phidgets/phidgets_current_input.c

Instance Method Summary collapse

Methods inherited from Common

#close, #getAttached, #getChannel, #getChannelClass, #getChannelClassName, #getChannelName, #getChannelSubclass, #getDeviceChannelCount, #getDeviceClass, #getDeviceClassName, #getDeviceID, #getDeviceLabel, #getDeviceName, #getDeviceSKU, #getDeviceSerialNumber, #getDeviceVersion, #getHubPort, #getHubPortCount, #getIsChannel, #getIsHubPortDevice, #getIsLocal, #getIsRemote, #getServerHostname, #getServerName, #getServerPeerName, #getServerUniqueName, #open, #openWaitForAttachment, #setChannel, #setDeviceLabel, #setDeviceSerialNumber, #setHubPort, #setIsHubPortDevice, #setIsLocal, #setIsRemote, #setOnAttachHandler, #setOnDetachHandler, #setOnErrorHandler, #setOnPropertyChangeHandler, #setServerName, #writeDeviceLabel

Constructor Details

#newObject

Creates a Phidget CurrentInput object.



7
8
9
10
11
# File 'ext/phidgets/phidgets_current_input.c', line 7

VALUE ph_current_input_init(VALUE self) {
  ph_data_t *ph = get_ph_data(self);
  ph_raise(PhidgetCurrentInput_create((PhidgetCurrentInputHandle *)(&(ph->handle))));
  return self;
}

Instance Method Details

#getCurrentObject Also known as: current

The most recent current value that the channel has reported. This value will always be between MinCurrent and MaxCurrent.



13
14
15
# File 'ext/phidgets/phidgets_current_input.c', line 13

VALUE ph_current_input_get_current(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetCurrentInput_getCurrent);
}

#getCurrentChangeTriggerObject Also known as: current_change_trigger

The channel will not issue a CurrentChange event until the current value has changed by the amount specified by the CurrentChangeTrigger. Setting the CurrentChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering.



25
26
27
# File 'ext/phidgets/phidgets_current_input.c', line 25

VALUE ph_current_input_get_current_change_trigger(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetCurrentInput_getCurrentChangeTrigger);
}

#getDataIntervalObject Also known as: data_interval

The DataInterval is the time that must elapse before the channel will fire another CurrentChange event. The data interval is bounded by MinDataInterval and MaxDataInterval. The timing between CurrentChange events can also affected by the CurrentChangeTrigger.



42
43
44
# File 'ext/phidgets/phidgets_current_input.c', line 42

VALUE ph_current_input_get_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetCurrentInput_getDataInterval);
}

#getMaxCurrentObject Also known as: max_current

The maximum value the CurrentChange event will report.



21
22
23
# File 'ext/phidgets/phidgets_current_input.c', line 21

VALUE ph_current_input_get_max_current(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetCurrentInput_getMaxCurrent);
}

#getMaxCurrentChangeTriggerObject Also known as: max_current_change_trigger

The maximum value that CurrentChangeTrigger can be set to.



38
39
40
# File 'ext/phidgets/phidgets_current_input.c', line 38

VALUE ph_current_input_get_max_current_change_trigger(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetCurrentInput_getMaxCurrentChangeTrigger);
}

#getMaxDataIntervalObject Also known as: max_data_interval

The maximum value that DataInterval can be set to.



55
56
57
# File 'ext/phidgets/phidgets_current_input.c', line 55

VALUE ph_current_input_get_max_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetCurrentInput_getMaxDataInterval);
}

#getMinCurrentObject Also known as: min_current

The minimum value the CurrentChange event will report.



17
18
19
# File 'ext/phidgets/phidgets_current_input.c', line 17

VALUE ph_current_input_get_min_current(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetCurrentInput_getMinCurrent);
}

#getMinCurrentChangeTriggerObject Also known as: min_current_change_trigger

The minimum value that CurrentChangeTrigger can be set to.



34
35
36
# File 'ext/phidgets/phidgets_current_input.c', line 34

VALUE ph_current_input_get_min_current_change_trigger(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetCurrentInput_getMinCurrentChangeTrigger);
}

#getMinDataIntervalObject Also known as: min_data_interval

The minimum value that DataInterval can be set to.



51
52
53
# File 'ext/phidgets/phidgets_current_input.c', line 51

VALUE ph_current_input_get_min_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetCurrentInput_getMinDataInterval);
}

#getPowerSupplyObject Also known as: power_supply

Choose the power supply voltage. Set this to the voltage specified in the attached sensor’s data sheet to power it. Set to POWER_SUPPLY_OFF to turn off the supply to save power.



59
60
61
# File 'ext/phidgets/phidgets_current_input.c', line 59

VALUE ph_current_input_get_power_supply(VALUE self) {
  return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetCurrentInput_getPowerSupply);
}

#setCurrentChangeTrigger(trigger) ⇒ Object Also known as: current_change_trigger=

The channel will not issue a CurrentChange event until the current value has changed by the amount specified by the CurrentChangeTrigger. Setting the CurrentChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering.



29
30
31
32
# File 'ext/phidgets/phidgets_current_input.c', line 29

VALUE ph_current_input_set_current_change_trigger(VALUE self, VALUE trigger) {
  ph_raise(PhidgetCurrentInput_setCurrentChangeTrigger((PhidgetCurrentInputHandle)get_ph_handle(self), NUM2DBL(trigger)));
  return Qnil;
}

#setDataInterval(interval) ⇒ Object Also known as: data_interval=

The DataInterval is the time that must elapse before the channel will fire another CurrentChange event. The data interval is bounded by MinDataInterval and MaxDataInterval. The timing between CurrentChange events can also affected by the CurrentChangeTrigger.



46
47
48
49
# File 'ext/phidgets/phidgets_current_input.c', line 46

VALUE ph_current_input_set_data_interval(VALUE self, VALUE interval) {
  ph_raise(PhidgetCurrentInput_setDataInterval((PhidgetCurrentInputHandle)get_ph_handle(self), NUM2UINT(interval)));
  return Qnil;
}

#setOnCurrentChangeHandler(cb_proc = nil, &cb_block) ⇒ Object Also known as: on_current_change

call-seq:

setOnCurrentChangeHandler(proc=nil, &block)

Assigns a handler that will be called when the CurrentChange event occurs.



11
12
13
14
15
# File 'lib/phidgets/current_input.rb', line 11

def setOnCurrentChangeHandler(cb_proc = nil, &cb_block)
  @on_current_change_thread.kill if defined? @on_current_change_thread and @on_current_change_thread.alive?
  callback = cb_proc || cb_block
  @on_current_change_thread = Thread.new {ext_setOnCurrentChangeHandler(callback)}
end

#setPowerSupply(power_supply) ⇒ Object Also known as: power_supply=

Choose the power supply voltage. Set this to the voltage specified in the attached sensor’s data sheet to power it. Set to POWER_SUPPLY_OFF to turn off the supply to save power.



63
64
65
66
# File 'ext/phidgets/phidgets_current_input.c', line 63

VALUE ph_current_input_set_power_supply(VALUE self, VALUE power_supply) {
  ph_raise(PhidgetCurrentInput_setPowerSupply((PhidgetCurrentInputHandle)get_ph_handle(self), NUM2INT(power_supply)));
  return Qnil;
}