Class: Phidgets::VoltageInput

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

Constant Summary collapse

SENSOR_TYPE_VOLTAGE =
INT2NUM(SENSOR_TYPE_VOLTAGE)
SENSOR_TYPE_1114 =
INT2NUM(SENSOR_TYPE_1114)
SENSOR_TYPE_1117 =
INT2NUM(SENSOR_TYPE_1117)
SENSOR_TYPE_1123 =
INT2NUM(SENSOR_TYPE_1123)
SENSOR_TYPE_1127 =
INT2NUM(SENSOR_TYPE_1127)
SENSOR_TYPE_1130_PH =
INT2NUM(SENSOR_TYPE_1130_PH)
SENSOR_TYPE_1130_ORP =
INT2NUM(SENSOR_TYPE_1130_ORP)
SENSOR_TYPE_1132 =
INT2NUM(SENSOR_TYPE_1132)
SENSOR_TYPE_1133 =
INT2NUM(SENSOR_TYPE_1133)
SENSOR_TYPE_1135 =
INT2NUM(SENSOR_TYPE_1135)
SENSOR_TYPE_1142 =
INT2NUM(SENSOR_TYPE_1142)
SENSOR_TYPE_1143 =
INT2NUM(SENSOR_TYPE_1143)
SENSOR_TYPE_3500 =
INT2NUM(SENSOR_TYPE_3500)
SENSOR_TYPE_3501 =
INT2NUM(SENSOR_TYPE_3501)
SENSOR_TYPE_3502 =
INT2NUM(SENSOR_TYPE_3502)
SENSOR_TYPE_3503 =
INT2NUM(SENSOR_TYPE_3503)
SENSOR_TYPE_3507 =
INT2NUM(SENSOR_TYPE_3507)
SENSOR_TYPE_3508 =
INT2NUM(SENSOR_TYPE_3508)
SENSOR_TYPE_3509 =
INT2NUM(SENSOR_TYPE_3509)
SENSOR_TYPE_3510 =
INT2NUM(SENSOR_TYPE_3510)
SENSOR_TYPE_3511 =
INT2NUM(SENSOR_TYPE_3511)
SENSOR_TYPE_3512 =
INT2NUM(SENSOR_TYPE_3512)
SENSOR_TYPE_3513 =
INT2NUM(SENSOR_TYPE_3513)
SENSOR_TYPE_3514 =
INT2NUM(SENSOR_TYPE_3514)
SENSOR_TYPE_3515 =
INT2NUM(SENSOR_TYPE_3515)
SENSOR_TYPE_3516 =
INT2NUM(SENSOR_TYPE_3516)
SENSOR_TYPE_3517 =
INT2NUM(SENSOR_TYPE_3517)
SENSOR_TYPE_3518 =
INT2NUM(SENSOR_TYPE_3518)
SENSOR_TYPE_3519 =
INT2NUM(SENSOR_TYPE_3519)
SENSOR_TYPE_3584 =
INT2NUM(SENSOR_TYPE_3584)
SENSOR_TYPE_3585 =
INT2NUM(SENSOR_TYPE_3585)
SENSOR_TYPE_3586 =
INT2NUM(SENSOR_TYPE_3586)
SENSOR_TYPE_3587 =
INT2NUM(SENSOR_TYPE_3587)
SENSOR_TYPE_3588 =
INT2NUM(SENSOR_TYPE_3588)
SENSOR_TYPE_3589 =
INT2NUM(SENSOR_TYPE_3589)
VOLTAGE_RANGE_10mV =
INT2NUM(VOLTAGE_RANGE_10mV)
VOLTAGE_RANGE_40mV =
INT2NUM(VOLTAGE_RANGE_40mV)
VOLTAGE_RANGE_200mV =
INT2NUM(VOLTAGE_RANGE_200mV)
VOLTAGE_RANGE_312_5mV =
INT2NUM(VOLTAGE_RANGE_312_5mV)
VOLTAGE_RANGE_400mV =
INT2NUM(VOLTAGE_RANGE_400mV)
VOLTAGE_RANGE_1000mV =
INT2NUM(VOLTAGE_RANGE_1000mV)
VOLTAGE_RANGE_2V =
INT2NUM(VOLTAGE_RANGE_2V)
VOLTAGE_RANGE_5V =
INT2NUM(VOLTAGE_RANGE_5V)
VOLTAGE_RANGE_15V =
INT2NUM(VOLTAGE_RANGE_15V)
VOLTAGE_RANGE_40V =
INT2NUM(VOLTAGE_RANGE_40V)
VOLTAGE_RANGE_AUTO =
INT2NUM(VOLTAGE_RANGE_AUTO)

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 VoltageInput object.



8
9
10
11
12
# File 'ext/phidgets/phidgets_voltage_input.c', line 8

VALUE ph_voltage_input_init(VALUE self) {
  ph_data_t *ph = get_ph_data(self);
  ph_raise(PhidgetVoltageInput_create((PhidgetVoltageInputHandle *)(&(ph->handle))));
  return self;
}

Instance Method Details

#getDataIntervalObject Also known as: data_interval

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



14
15
16
# File 'ext/phidgets/phidgets_voltage_input.c', line 14

VALUE ph_voltage_input_get_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetVoltageInput_getDataInterval);
}

#getMaxDataIntervalObject Also known as: max_data_interval

The maximum value that DataInterval can be set to.



27
28
29
# File 'ext/phidgets/phidgets_voltage_input.c', line 27

VALUE ph_voltage_input_get_max_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetVoltageInput_getMaxDataInterval);
}

#getMaxVoltageObject Also known as: max_voltage

The maximum value the VoltageChange event will report.



80
81
82
# File 'ext/phidgets/phidgets_voltage_input.c', line 80

VALUE ph_voltage_input_get_max_voltage(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageInput_getMaxVoltage);
}

#getMaxVoltageChangeTriggerObject Also known as: max_voltage_change_trigger

The maximum value that VoltageChangeTrigger can be set to.



97
98
99
# File 'ext/phidgets/phidgets_voltage_input.c', line 97

VALUE ph_voltage_input_get_max_voltage_change_trigger(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageInput_getMaxVoltageChangeTrigger);
}

#getMinDataIntervalObject Also known as: min_data_interval

The minimum value that DataInterval can be set to.



23
24
25
# File 'ext/phidgets/phidgets_voltage_input.c', line 23

VALUE ph_voltage_input_get_min_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetVoltageInput_getMinDataInterval);
}

#getMinVoltageObject Also known as: min_voltage

The minimum value the VoltageChange event will report.



76
77
78
# File 'ext/phidgets/phidgets_voltage_input.c', line 76

VALUE ph_voltage_input_get_min_voltage(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageInput_getMinVoltage);
}

#getMinVoltageChangeTriggerObject Also known as: min_voltage_change_trigger

The minimum value that VoltageChangeTrigger can be set to.



93
94
95
# File 'ext/phidgets/phidgets_voltage_input.c', line 93

VALUE ph_voltage_input_get_min_voltage_change_trigger(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageInput_getMinVoltageChangeTrigger);
}

#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.



31
32
33
# File 'ext/phidgets/phidgets_voltage_input.c', line 31

VALUE ph_voltage_input_get_power_supply(VALUE self) {
  return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetVoltageInput_getPowerSupply);
}

#getSensorTypeObject Also known as: sensor_type

By matching the SensorType to your analog sensor, the correct formula will automatically be applied to data when you get the SensorValue or subscribe to the SensorChange event. The SensorChange event has its own change trigger associated with it: SensorValueChangeTrigger. Any data from getting the SensorValue or subscribing to the SensorChange event will have a SensorUnit associated with it. Note: Unlike other properties such as DeviceSerialNumber or Channel, SensorType is set after the device is opened, not before.



40
41
42
# File 'ext/phidgets/phidgets_voltage_input.c', line 40

VALUE ph_voltage_input_get_sensor_type(VALUE self) {
  return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetVoltageInput_getSensorType);
}

#getSensorUnitObject Also known as: sensor_unit

The unit of measurement that applies to the sensor values of the SensorType that has been selected. Helps keep track of the type of information being calculated from the voltage input.



49
50
51
52
53
54
55
56
57
# File 'ext/phidgets/phidgets_voltage_input.c', line 49

VALUE ph_voltage_input_get_sensor_unit(VALUE self) {
  VALUE unit_info = rb_hash_new();
  Phidget_UnitInfo sensorUnit;
  ph_raise(PhidgetVoltageInput_getSensorUnit((PhidgetVoltageInputHandle)get_ph_handle(self), &sensorUnit));
  rb_hash_aset(unit_info, rb_str_new2("unit"), INT2NUM(sensorUnit.unit));
  rb_hash_aset(unit_info, rb_str_new2("name"), rb_str_new2(sensorUnit.name));
  rb_hash_aset(unit_info, rb_str_new2("symbol"), rb_str_new2(sensorUnit.symbol));
  return unit_info;
}

#getSensorValueObject Also known as: sensor_value

The most recent sensor value that the channel has reported. Use SensorUnit to get the measurement units that are associated with the SensorValue.



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

VALUE ph_voltage_input_get_sensor_value(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageInput_getSensorValue);
}

#getSensorValueChangeTriggerObject Also known as: sensor_value_change_trigger

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



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

VALUE ph_voltage_input_get_sensor_value_change_trigger(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageInput_getSensorValueChangeTrigger);
}

#getVoltageObject Also known as: voltage

The most recent voltage value that the channel has reported. This value will always be between MinVoltage and MaxVoltage.



72
73
74
# File 'ext/phidgets/phidgets_voltage_input.c', line 72

VALUE ph_voltage_input_get_voltage(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageInput_getVoltage);
}

#getVoltageChangeTriggerObject Also known as: voltage_change_trigger

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



84
85
86
# File 'ext/phidgets/phidgets_voltage_input.c', line 84

VALUE ph_voltage_input_get_voltage_change_trigger(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageInput_getVoltageChangeTrigger);
}

#getVoltageRangeObject Also known as: voltage_range

The voltage range you choose should allow you to measure the full range of your input signal. A larger VoltageRange equates to less resolution. If a Saturation event occurs, increase the voltage range.



101
102
103
# File 'ext/phidgets/phidgets_voltage_input.c', line 101

VALUE ph_voltage_input_get_voltage_range(VALUE self) {
  return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetVoltageInput_getVoltageRange);
}

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

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



18
19
20
21
# File 'ext/phidgets/phidgets_voltage_input.c', line 18

VALUE ph_voltage_input_set_data_interval(VALUE self, VALUE interval) {
  ph_raise(PhidgetVoltageInput_setDataInterval((PhidgetVoltageInputHandle)get_ph_handle(self), NUM2UINT(interval)));
  return Qnil;
}

#setOnSensorChangeHandler(cb_proc = nil, &cb_block) ⇒ Object Also known as: on_sensor_change

call-seq:

setOnSensorChangeHandler(proc=nil, &block)

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



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

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

#setOnVoltageChangeHandler(cb_proc = nil, &cb_block) ⇒ Object Also known as: on_voltage_change

call-seq:

setOnVoltageChangeHandler(proc=nil, &block)

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



24
25
26
27
28
# File 'lib/phidgets/voltage_input.rb', line 24

def setOnVoltageChangeHandler(cb_proc = nil, &cb_block)
  @on_voltage_change_thread.kill if defined? @on_voltage_change_thread and @on_voltage_change_thread.alive?
  callback = cb_proc || cb_block
  @on_voltage_change_thread = Thread.new {ext_setOnVoltageChangeHandler(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.



35
36
37
38
# File 'ext/phidgets/phidgets_voltage_input.c', line 35

VALUE ph_voltage_input_set_power_supply(VALUE self, VALUE power_supply) {
  ph_raise(PhidgetVoltageInput_setPowerSupply((PhidgetVoltageInputHandle)get_ph_handle(self), NUM2INT(power_supply)));
  return Qnil;
}

#setSensorType(sensor_type) ⇒ Object Also known as: sensor_type=

By matching the SensorType to your analog sensor, the correct formula will automatically be applied to data when you get the SensorValue or subscribe to the SensorChange event. The SensorChange event has its own change trigger associated with it: SensorValueChangeTrigger. Any data from getting the SensorValue or subscribing to the SensorChange event will have a SensorUnit associated with it. Note: Unlike other properties such as DeviceSerialNumber or Channel, SensorType is set after the device is opened, not before.



44
45
46
47
# File 'ext/phidgets/phidgets_voltage_input.c', line 44

VALUE ph_voltage_input_set_sensor_type(VALUE self, VALUE sensor_type) {
  ph_raise(PhidgetVoltageInput_setSensorType((PhidgetVoltageInputHandle)get_ph_handle(self), NUM2INT(sensor_type)));
  return Qnil;
}

#setSensorValueChangeTrigger(trigger) ⇒ Object Also known as: sensor_value_change_trigger=

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



67
68
69
70
# File 'ext/phidgets/phidgets_voltage_input.c', line 67

VALUE ph_voltage_input_set_sensor_value_change_trigger(VALUE self, VALUE trigger) {
  ph_raise(PhidgetVoltageInput_setSensorValueChangeTrigger((PhidgetVoltageInputHandle)get_ph_handle(self), NUM2DBL(trigger)));
  return Qnil;
}

#setVoltageChangeTrigger(trigger) ⇒ Object Also known as: voltage_change_trigger=

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



88
89
90
91
# File 'ext/phidgets/phidgets_voltage_input.c', line 88

VALUE ph_voltage_input_set_voltage_change_trigger(VALUE self, VALUE trigger) {
  ph_raise(PhidgetVoltageInput_setVoltageChangeTrigger((PhidgetVoltageInputHandle)get_ph_handle(self), NUM2DBL(trigger)));
  return Qnil;
}

#setVoltageRange(voltage_range) ⇒ Object Also known as: voltage_range=

The voltage range you choose should allow you to measure the full range of your input signal. A larger VoltageRange equates to less resolution. If a Saturation event occurs, increase the voltage range.



105
106
107
108
# File 'ext/phidgets/phidgets_voltage_input.c', line 105

VALUE ph_voltage_input_set_voltage_range(VALUE self, VALUE voltage_range) {
  ph_raise(PhidgetVoltageInput_setVoltageRange((PhidgetVoltageInputHandle)get_ph_handle(self), NUM2INT(voltage_range)));
  return Qnil;
}