Class: Phidgets::VoltageRatioInput

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

Constant Summary collapse

SENSOR_TYPE_VOLTAGERATIO =
INT2NUM(SENSOR_TYPE_VOLTAGERATIO)
SENSOR_TYPE_1101_SHARP_2D120X =
INT2NUM(SENSOR_TYPE_1101_SHARP_2D120X)
SENSOR_TYPE_1101_SHARP_2Y0A21 =
INT2NUM(SENSOR_TYPE_1101_SHARP_2Y0A21)
SENSOR_TYPE_1101_SHARP_2Y0A02 =
INT2NUM(SENSOR_TYPE_1101_SHARP_2Y0A02)
SENSOR_TYPE_1102 =
INT2NUM(SENSOR_TYPE_1102)
SENSOR_TYPE_1103 =
INT2NUM(SENSOR_TYPE_1103)
SENSOR_TYPE_1104 =
INT2NUM(SENSOR_TYPE_1104)
SENSOR_TYPE_1105 =
INT2NUM(SENSOR_TYPE_1105)
SENSOR_TYPE_1106 =
INT2NUM(SENSOR_TYPE_1106)
SENSOR_TYPE_1107 =
INT2NUM(SENSOR_TYPE_1107)
SENSOR_TYPE_1108 =
INT2NUM(SENSOR_TYPE_1108)
SENSOR_TYPE_1109 =
INT2NUM(SENSOR_TYPE_1109)
SENSOR_TYPE_1110 =
INT2NUM(SENSOR_TYPE_1110)
SENSOR_TYPE_1111 =
INT2NUM(SENSOR_TYPE_1111)
SENSOR_TYPE_1112 =
INT2NUM(SENSOR_TYPE_1112)
SENSOR_TYPE_1113 =
INT2NUM(SENSOR_TYPE_1113)
SENSOR_TYPE_1115 =
INT2NUM(SENSOR_TYPE_1115)
SENSOR_TYPE_1116 =
INT2NUM(SENSOR_TYPE_1116)
SENSOR_TYPE_1118_AC =
INT2NUM(SENSOR_TYPE_1118_AC)
SENSOR_TYPE_1118_DC =
INT2NUM(SENSOR_TYPE_1118_DC)
SENSOR_TYPE_1119_AC =
INT2NUM(SENSOR_TYPE_1119_AC)
SENSOR_TYPE_1119_DC =
INT2NUM(SENSOR_TYPE_1119_DC)
SENSOR_TYPE_1120 =
INT2NUM(SENSOR_TYPE_1120)
SENSOR_TYPE_1121 =
INT2NUM(SENSOR_TYPE_1121)
SENSOR_TYPE_1122_AC =
INT2NUM(SENSOR_TYPE_1122_AC)
SENSOR_TYPE_1122_DC =
INT2NUM(SENSOR_TYPE_1122_DC)
SENSOR_TYPE_1124 =
INT2NUM(SENSOR_TYPE_1124)
SENSOR_TYPE_1125_HUMIDITY =
INT2NUM(SENSOR_TYPE_1125_HUMIDITY)
SENSOR_TYPE_1125_TEMPERATURE =
INT2NUM(SENSOR_TYPE_1125_TEMPERATURE)
SENSOR_TYPE_1126 =
INT2NUM(SENSOR_TYPE_1126)
SENSOR_TYPE_1128 =
INT2NUM(SENSOR_TYPE_1128)
SENSOR_TYPE_1129 =
INT2NUM(SENSOR_TYPE_1129)
SENSOR_TYPE_1131 =
INT2NUM(SENSOR_TYPE_1131)
SENSOR_TYPE_1134 =
INT2NUM(SENSOR_TYPE_1134)
SENSOR_TYPE_1136 =
INT2NUM(SENSOR_TYPE_1136)
SENSOR_TYPE_1137 =
INT2NUM(SENSOR_TYPE_1137)
SENSOR_TYPE_1138 =
INT2NUM(SENSOR_TYPE_1138)
SENSOR_TYPE_1139 =
INT2NUM(SENSOR_TYPE_1139)
SENSOR_TYPE_1140 =
INT2NUM(SENSOR_TYPE_1140)
SENSOR_TYPE_1141 =
INT2NUM(SENSOR_TYPE_1141)
SENSOR_TYPE_1146 =
INT2NUM(SENSOR_TYPE_1146)
SENSOR_TYPE_3120 =
INT2NUM(SENSOR_TYPE_3120)
SENSOR_TYPE_3121 =
INT2NUM(SENSOR_TYPE_3121)
SENSOR_TYPE_3122 =
INT2NUM(SENSOR_TYPE_3122)
SENSOR_TYPE_3123 =
INT2NUM(SENSOR_TYPE_3123)
SENSOR_TYPE_3130 =
INT2NUM(SENSOR_TYPE_3130)
SENSOR_TYPE_3520 =
INT2NUM(SENSOR_TYPE_3520)
SENSOR_TYPE_3521 =
INT2NUM(SENSOR_TYPE_3521)
SENSOR_TYPE_3522 =
INT2NUM(SENSOR_TYPE_3522)
BRIDGE_GAIN_1 =
INT2NUM(BRIDGE_GAIN_1)
BRIDGE_GAIN_2 =
INT2NUM(BRIDGE_GAIN_2)
BRIDGE_GAIN_4 =
INT2NUM(BRIDGE_GAIN_4)
BRIDGE_GAIN_8 =
INT2NUM(BRIDGE_GAIN_8)
BRIDGE_GAIN_16 =
INT2NUM(BRIDGE_GAIN_16)
BRIDGE_GAIN_32 =
INT2NUM(BRIDGE_GAIN_32)
BRIDGE_GAIN_64 =
INT2NUM(BRIDGE_GAIN_64)
BRIDGE_GAIN_128 =
INT2NUM(BRIDGE_GAIN_128)

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_ratio_input.c', line 8

VALUE ph_voltage_ratio_input_init(VALUE self) {
  ph_data_t *ph = get_ph_data(self);
  ph_raise(PhidgetVoltageRatioInput_create((PhidgetVoltageRatioInputHandle *)(&(ph->handle))));
  return self;
}

Instance Method Details

#getBridgeEnabledObject Also known as: bridge_enabled?

Enable power to and data from the input by setting BridgeEnabled to true.



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

VALUE ph_voltage_ratio_input_get_bridge_enabled(VALUE self) {
  return ph_get_bool(get_ph_handle(self), (phidget_get_bool_func)PhidgetVoltageRatioInput_getBridgeEnabled);
}

#getBridgeGainObject Also known as: bridge_gain

Choose a BridgeGain that best suits your application. For more information about the range and accuracy of each BridgeGain to decide which best suits your application, see your device’s User Guide.



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

VALUE ph_voltage_ratio_input_get_bridge_gain(VALUE self) {
  return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetVoltageRatioInput_getBridgeGain);
}

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



32
33
34
# File 'ext/phidgets/phidgets_voltage_ratio_input.c', line 32

VALUE ph_voltage_ratio_input_get_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetVoltageRatioInput_getDataInterval);
}

#getMaxDataIntervalObject Also known as: max_data_interval

The maximum value that DataInterval can be set to.



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

VALUE ph_voltage_ratio_input_get_max_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetVoltageRatioInput_getMaxDataInterval);
}

#getMaxVoltageRatioObject Also known as: max_voltage_ratio

The maximum value the VoltageRatioChange event will report.



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

VALUE ph_voltage_ratio_input_get_max_voltage_ratio(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageRatioInput_getMaxVoltageRatio);
}

#getMaxVoltageRatioChangeTriggerObject Also known as: max_voltage_ratio_change_trigger

The maximum value that VoltageRatioChangeTrigger can be set to.



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

VALUE ph_voltage_ratio_input_get_max_voltage_ratio_change_trigger(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageRatioInput_getMaxVoltageRatioChangeTrigger);
}

#getMinDataIntervalObject Also known as: min_data_interval

The minimum value that DataInterval can be set to.



41
42
43
# File 'ext/phidgets/phidgets_voltage_ratio_input.c', line 41

VALUE ph_voltage_ratio_input_get_min_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetVoltageRatioInput_getMinDataInterval);
}

#getMinVoltageRatioObject Also known as: min_voltage_ratio

The minimum value the VoltageRatioChange event will report.



85
86
87
# File 'ext/phidgets/phidgets_voltage_ratio_input.c', line 85

VALUE ph_voltage_ratio_input_get_min_voltage_ratio(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageRatioInput_getMinVoltageRatio);
}

#getMinVoltageRatioChangeTriggerObject Also known as: min_voltage_ratio_change_trigger

The minimum value that VoltageRatioChangeTrigger can be set to.



102
103
104
# File 'ext/phidgets/phidgets_voltage_ratio_input.c', line 102

VALUE ph_voltage_ratio_input_get_min_voltage_ratio_change_trigger(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageRatioInput_getMinVoltageRatioChangeTrigger);
}

#getSensorTypeObject Also known as: sensor_type

We sell a variety of analog sensors that do not have their own API, they simply output a voltage that can be converted to a digital value using a specific formula. 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.



49
50
51
# File 'ext/phidgets/phidgets_voltage_ratio_input.c', line 49

VALUE ph_voltage_ratio_input_get_sensor_type(VALUE self) {
  return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetVoltageRatioInput_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 ratio input.



58
59
60
61
62
63
64
65
66
# File 'ext/phidgets/phidgets_voltage_ratio_input.c', line 58

VALUE ph_voltage_ratio_input_get_sensor_unit(VALUE self) {
  VALUE unit_info = rb_hash_new();
  Phidget_UnitInfo sensorUnit;
  ph_raise(PhidgetVoltageRatioInput_getSensorUnit((PhidgetVoltageRatioInputHandle)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.



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

VALUE ph_voltage_ratio_input_get_sensor_value(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageRatioInput_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.



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

VALUE ph_voltage_ratio_input_get_sensor_value_change_trigger(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageRatioInput_getSensorValueChangeTrigger);
}

#getVoltageRatioObject Also known as: voltage_ratio

The most recent voltage ratio value that the channel has reported. This value will always be between MinVoltageRatio and MaxVoltageRatio.



81
82
83
# File 'ext/phidgets/phidgets_voltage_ratio_input.c', line 81

VALUE ph_voltage_ratio_input_get_voltage_ratio(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageRatioInput_getVoltageRatio);
}

#getVoltageRatioChangeTriggerObject Also known as: voltage_ratio_change_trigger

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



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

VALUE ph_voltage_ratio_input_get_voltage_ratio_change_trigger(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageRatioInput_getVoltageRatioChangeTrigger);
}

#setBridgeEnabled(bridge_enabled) ⇒ Object Also known as: bridge_enabled=

Enable power to and data from the input by setting BridgeEnabled to true.



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

VALUE ph_voltage_ratio_input_set_bridge_enabled(VALUE self, VALUE enabled) {
  ph_raise(PhidgetVoltageRatioInput_setBridgeEnabled((PhidgetVoltageRatioInputHandle)get_ph_handle(self), TYPE(enabled) == T_TRUE ? PTRUE : PFALSE));
  return Qnil;
}

#setBridgeGain(bridge_gain) ⇒ Object Also known as: bridge_gain=

Choose a BridgeGain that best suits your application. For more information about the range and accuracy of each BridgeGain to decide which best suits your application, see your device’s User Guide.



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

VALUE ph_voltage_ratio_input_set_bridge_gain(VALUE self, VALUE bridge_gain) {
  ph_raise(PhidgetVoltageRatioInput_setBridgeGain((PhidgetVoltageRatioInputHandle)get_ph_handle(self), NUM2INT(bridge_gain)));
  return Qnil;
}

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



36
37
38
39
# File 'ext/phidgets/phidgets_voltage_ratio_input.c', line 36

VALUE ph_voltage_ratio_input_set_data_interval(VALUE self, VALUE interval) {
  ph_raise(PhidgetVoltageRatioInput_setDataInterval((PhidgetVoltageRatioInputHandle)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_ratio_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

#setOnVoltageRatioChangeHandler(cb_proc = nil, &cb_block) ⇒ Object Also known as: on_voltage_ratio_change

call-seq:

setOnVoltageRatioChangeHandler(proc=nil, &block)

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



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

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

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

We sell a variety of analog sensors that do not have their own API, they simply output a voltage that can be converted to a digital value using a specific formula. 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.



53
54
55
56
# File 'ext/phidgets/phidgets_voltage_ratio_input.c', line 53

VALUE ph_voltage_ratio_input_set_sensor_type(VALUE self, VALUE sensor_type) {
  ph_raise(PhidgetVoltageRatioInput_setSensorType((PhidgetVoltageRatioInputHandle)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.



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

VALUE ph_voltage_ratio_input_set_sensor_value_change_trigger(VALUE self, VALUE trigger) {
  ph_raise(PhidgetVoltageRatioInput_setSensorValueChangeTrigger((PhidgetVoltageRatioInputHandle)get_ph_handle(self), NUM2DBL(trigger)));
  return Qnil;
}

#setVoltageRatioChangeTrigger(trigger) ⇒ Object Also known as: voltage_ratio_change_trigger=

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



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

VALUE ph_voltage_ratio_input_set_voltage_ratio_change_trigger(VALUE self, VALUE trigger) {
  ph_raise(PhidgetVoltageRatioInput_setVoltageRatioChangeTrigger((PhidgetVoltageRatioInputHandle)get_ph_handle(self), NUM2DBL(trigger)));
  return Qnil;
}