Class: Phidgets::HumiditySensor

Inherits:
Common
  • Object
show all
Defined in:
lib/phidgets/humidity_sensor.rb,
ext/phidgets/phidgets_humidity_sensor.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 HumiditySensor object.



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

VALUE ph_humidity_init(VALUE self) {
  ph_data_t *ph = get_ph_data(self);
  ph_raise(PhidgetHumiditySensor_create((PhidgetHumiditySensorHandle *)(&(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 HumidityChange event. The data interval is bounded by MinDataInterval and MaxDataInterval. The timing between HumidityChange events can also affected by the HumidityChangeTrigger.



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

VALUE ph_humidity_get_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetHumiditySensor_getDataInterval);
}

#getHumidityObject Also known as: humidity

The most recent humidity value that the channel has reported. This value will always be between MinHumidity and MaxHumidity.



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

VALUE ph_humidity_get_humidity(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetHumiditySensor_getHumidity);
}

#getHumidityChangeTriggerObject Also known as: humidity_change_trigger

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



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

VALUE ph_humidity_get_humidity_change_trigger(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetHumiditySensor_getHumidityChangeTrigger);
}

#getMaxDataIntervalObject Also known as: max_data_interval

The maximum value that DataInterval can be set to.



26
27
28
# File 'ext/phidgets/phidgets_humidity_sensor.c', line 26

VALUE ph_humidity_get_max_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetHumiditySensor_getMaxDataInterval);
}

#getMaxHumidityObject Also known as: max_humidity

The maximum value that the HumidityChange event will report.



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

VALUE ph_humidity_get_max_humidity(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetHumiditySensor_getMaxHumidity);
}

#getMaxHumidityChangeTriggerObject Also known as: max_humidity_change_trigger

The maximum value that HumidityChangeTrigger can be set to.



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

VALUE ph_humidity_get_max_humidity_change_trigger(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetHumiditySensor_getMaxHumidityChangeTrigger);
}

#getMinDataIntervalObject Also known as: min_data_interval

The minimum value that DataInterval can be set to.



22
23
24
# File 'ext/phidgets/phidgets_humidity_sensor.c', line 22

VALUE ph_humidity_get_min_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetHumiditySensor_getMinDataInterval);
}

#getMinHumidityObject Also known as: min_humidity

The minimum value that the HumidityChange event will report.



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

VALUE ph_humidity_get_min_humidity(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetHumiditySensor_getMinHumidity);
}

#getMinHumidityChangeTriggerObject Also known as: min_humidity_change_trigger

The minimum value that HumidityChangeTrigger can be set to.



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

VALUE ph_humidity_get_min_humidity_change_trigger(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetHumiditySensor_getMinHumidityChangeTrigger);
}

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

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



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

VALUE ph_humidity_set_data_interval(VALUE self, VALUE interval) {
  ph_raise(PhidgetHumiditySensor_setDataInterval((PhidgetHumiditySensorHandle)get_ph_handle(self), NUM2UINT(interval)));
  return Qnil;
}

#setHumidityChangeTrigger(change_trigger) ⇒ Object Also known as: humidity_change_trigger=

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



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

VALUE ph_humidity_set_humidity_change_trigger(VALUE self, VALUE change_trigger) {
  ph_raise(PhidgetHumiditySensor_setHumidityChangeTrigger((PhidgetHumiditySensorHandle)get_ph_handle(self), NUM2DBL(change_trigger)));
  return Qnil;
}

#setOnHumidityChangeHandler(cb_proc = nil, &cb_block) ⇒ Object Also known as: on_humidity_change

call-seq:

setOnHumidityChangeHandler(proc=nil, &block)

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



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

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