phidgets 0.1.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/History.txt +3 -0
  3. data/README.rdoc +32 -43
  4. data/Rakefile +4 -2
  5. data/bin/phidget +18 -72
  6. data/ext/phidgets/extconf.rb +5 -8
  7. data/ext/phidgets/phidgets.c +708 -173
  8. data/ext/phidgets/phidgets.h +54 -35
  9. data/ext/phidgets/phidgets_accelerometer.c +193 -109
  10. data/ext/phidgets/phidgets_bldc_motor.c +529 -0
  11. data/ext/phidgets/phidgets_capacitive_touch.c +302 -0
  12. data/ext/phidgets/phidgets_common.c +570 -315
  13. data/ext/phidgets/phidgets_current_input.c +229 -0
  14. data/ext/phidgets/phidgets_dc_motor.c +562 -0
  15. data/ext/phidgets/phidgets_dictionary.c +154 -213
  16. data/ext/phidgets/phidgets_digital_input.c +127 -0
  17. data/ext/phidgets/phidgets_digital_output.c +288 -0
  18. data/ext/phidgets/phidgets_distance_sensor.c +295 -0
  19. data/ext/phidgets/phidgets_encoder.c +211 -192
  20. data/ext/phidgets/phidgets_frequency_counter.c +310 -177
  21. data/ext/phidgets/phidgets_gps.c +226 -164
  22. data/ext/phidgets/phidgets_gyroscope.c +195 -0
  23. data/ext/phidgets/phidgets_hub.c +39 -0
  24. data/ext/phidgets/phidgets_humidity_sensor.c +200 -0
  25. data/ext/phidgets/phidgets_ir.c +211 -171
  26. data/ext/phidgets/phidgets_lcd.c +512 -0
  27. data/ext/phidgets/phidgets_light_sensor.c +200 -0
  28. data/ext/phidgets/phidgets_log.c +263 -0
  29. data/ext/phidgets/phidgets_magnetometer.c +279 -0
  30. data/ext/phidgets/phidgets_manager.c +86 -297
  31. data/ext/phidgets/phidgets_motor_position_controller.c +787 -0
  32. data/ext/phidgets/phidgets_phsensor.c +200 -152
  33. data/ext/phidgets/phidgets_power_guard.c +144 -0
  34. data/ext/phidgets/phidgets_pressure_sensor.c +200 -0
  35. data/ext/phidgets/phidgets_rc_servo.c +672 -0
  36. data/ext/phidgets/phidgets_resistance_input.c +227 -0
  37. data/ext/phidgets/phidgets_rfid.c +107 -221
  38. data/ext/phidgets/phidgets_sound_sensor.c +284 -0
  39. data/ext/phidgets/phidgets_spatial.c +124 -318
  40. data/ext/phidgets/phidgets_stepper.c +457 -430
  41. data/ext/phidgets/phidgets_temp_sensor.c +223 -228
  42. data/ext/phidgets/phidgets_voltage_input.c +428 -0
  43. data/ext/phidgets/phidgets_voltage_output.c +167 -0
  44. data/ext/phidgets/phidgets_voltage_ratio_input.c +435 -0
  45. data/lib/phidgets.rb +21 -14
  46. data/lib/phidgets/accelerometer.rb +11 -15
  47. data/lib/phidgets/bldc_motor.rb +45 -0
  48. data/lib/phidgets/capacitive_touch.rb +33 -0
  49. data/lib/phidgets/common.rb +40 -69
  50. data/lib/phidgets/current_input.rb +21 -0
  51. data/lib/phidgets/dc_motor.rb +45 -0
  52. data/lib/phidgets/dictionary.rb +30 -39
  53. data/lib/phidgets/digital_input.rb +21 -0
  54. data/lib/phidgets/digital_output.rb +56 -0
  55. data/lib/phidgets/distance_sensor.rb +33 -0
  56. data/lib/phidgets/encoder.rb +1 -29
  57. data/lib/phidgets/frequency_counter.rb +23 -14
  58. data/lib/phidgets/gps.rb +34 -26
  59. data/lib/phidgets/gyroscope.rb +21 -0
  60. data/lib/phidgets/humidity_sensor.rb +21 -0
  61. data/lib/phidgets/ir.rb +34 -39
  62. data/lib/phidgets/light_sensor.rb +21 -0
  63. data/lib/phidgets/magnetometer.rb +21 -0
  64. data/lib/phidgets/manager.rb +18 -66
  65. data/lib/phidgets/motor_position_controller.rb +45 -0
  66. data/lib/phidgets/ph_sensor.rb +2 -6
  67. data/lib/phidgets/pressure_sensor.rb +21 -0
  68. data/lib/phidgets/rc_servo.rb +58 -0
  69. data/lib/phidgets/resistance_input.rb +21 -0
  70. data/lib/phidgets/rfid.rb +22 -38
  71. data/lib/phidgets/sound_sensor.rb +21 -0
  72. data/lib/phidgets/spatial.rb +11 -15
  73. data/lib/phidgets/stepper.rb +48 -50
  74. data/lib/phidgets/temperature_sensor.rb +11 -15
  75. data/lib/phidgets/version.rb +5 -0
  76. data/lib/phidgets/voltage_input.rb +34 -0
  77. data/lib/phidgets/voltage_output.rb +23 -0
  78. data/lib/phidgets/voltage_ratio_input.rb +34 -0
  79. data/phidgets.gemspec +3 -22
  80. data/test/test_accelerometer.rb +42 -23
  81. data/test/test_bldc_motor.rb +134 -0
  82. data/test/test_capacitive_touch.rb +82 -0
  83. data/test/test_common.rb +125 -108
  84. data/test/test_current_input.rb +62 -0
  85. data/test/test_dc_motor.rb +146 -0
  86. data/test/test_dictionary.rb +22 -54
  87. data/test/test_digital_input.rb +30 -0
  88. data/test/test_digital_output.rb +70 -0
  89. data/test/test_distance_sensor.rb +76 -0
  90. data/test/test_encoder.rb +45 -38
  91. data/test/test_frequency_counter.rb +71 -36
  92. data/test/test_gps.rb +29 -38
  93. data/test/test_gyroscope.rb +54 -0
  94. data/test/test_helper.rb +0 -1
  95. data/test/test_hub.rb +14 -0
  96. data/test/test_humidity_sensor.rb +58 -0
  97. data/test/test_ir.rb +34 -34
  98. data/test/test_lcd.rb +146 -0
  99. data/test/test_light_sensor.rb +58 -0
  100. data/test/test_magnetometer.rb +78 -0
  101. data/test/test_manager.rb +10 -79
  102. data/test/test_motor_control.rb +146 -108
  103. data/test/test_phidgets.rb +2 -14
  104. data/test/test_phsensor.rb +46 -34
  105. data/test/test_power_guard.rb +42 -0
  106. data/test/test_pressure_sensor.rb +58 -0
  107. data/test/test_rc_servo.rb +174 -0
  108. data/test/test_resistance_input.rb +66 -0
  109. data/test/test_rfid.rb +15 -54
  110. data/test/test_sound_sensor.rb +78 -0
  111. data/test/test_spatial.rb +19 -85
  112. data/test/test_stepper.rb +89 -98
  113. data/test/test_temp_sensor.rb +42 -47
  114. data/test/test_voltage_input.rb +102 -0
  115. data/test/test_voltage_output.rb +46 -0
  116. data/test/test_voltage_ratio_input.rb +102 -0
  117. metadata +72 -89
  118. data/ext/phidgets/phidgets_advanced_servo.c +0 -567
  119. data/ext/phidgets/phidgets_analog.c +0 -139
  120. data/ext/phidgets/phidgets_bridge.c +0 -263
  121. data/ext/phidgets/phidgets_interface_kit.c +0 -340
  122. data/ext/phidgets/phidgets_led.c +0 -178
  123. data/ext/phidgets/phidgets_motor_control.c +0 -642
  124. data/ext/phidgets/phidgets_servo.c +0 -276
  125. data/ext/phidgets/phidgets_text_lcd.c +0 -381
  126. data/ext/phidgets/phidgets_text_led.c +0 -107
  127. data/ext/phidgets/phidgets_weight_sensor.c +0 -113
  128. data/lib/phidgets/advanced_servo.rb +0 -49
  129. data/lib/phidgets/analog.rb +0 -8
  130. data/lib/phidgets/bridge.rb +0 -25
  131. data/lib/phidgets/interfacekit.rb +0 -49
  132. data/lib/phidgets/led.rb +0 -8
  133. data/lib/phidgets/motor_control.rb +0 -110
  134. data/lib/phidgets/servo.rb +0 -23
  135. data/lib/phidgets/text_lcd.rb +0 -8
  136. data/lib/phidgets/text_led.rb +0 -8
  137. data/lib/phidgets/weight_sensor.rb +0 -25
  138. data/test/test_advanced_servo.rb +0 -152
  139. data/test/test_analog.rb +0 -45
  140. data/test/test_bridge.rb +0 -77
  141. data/test/test_interfacekit.rb +0 -97
  142. data/test/test_led.rb +0 -55
  143. data/test/test_servo.rb +0 -67
  144. data/test/test_text_lcd.rb +0 -115
  145. data/test/test_text_led.rb +0 -35
  146. data/test/test_weight_sensor.rb +0 -32
@@ -1,27 +1,117 @@
1
1
 
2
2
  #include "phidgets.h"
3
3
 
4
+ #define TEMP_SENSOR_TEMPERATURE_CHANGE_CALLBACK 0
4
5
 
5
- VALUE ph_temp_init(VALUE self);
6
- VALUE ph_temp_get_temperature_input_count(VALUE self);
7
- VALUE ph_temp_get_temperature(VALUE self, VALUE index);
8
- VALUE ph_temp_get_temperature_min(VALUE self, VALUE index);
9
- VALUE ph_temp_get_temperature_max(VALUE self, VALUE index);
10
- VALUE ph_temp_get_temperature_change_trigger(VALUE self, VALUE index);
11
- VALUE ph_temp_set_temperature_change_trigger(VALUE self, VALUE index, VALUE temperature);
12
- VALUE ph_temp_get_potential(VALUE self, VALUE index);
13
- VALUE ph_temp_get_potential_min(VALUE self, VALUE index);
14
- VALUE ph_temp_get_potential_max(VALUE self, VALUE index);
15
- VALUE ph_temp_get_ambient_temperature(VALUE self);
16
- VALUE ph_temp_get_ambient_temperature_min(VALUE self);
17
- VALUE ph_temp_get_ambient_temperature_max(VALUE self);
18
- VALUE ph_temp_get_thermocouple_type(VALUE self, VALUE index);
19
- VALUE ph_temp_set_thermocouple_type(VALUE self, VALUE index, VALUE thermocouple);
20
-
21
- #ifdef PH_CALLBACK
22
- VALUE ph_temp_set_on_temperature_change_handler(VALUE self, VALUE handler);
23
- int ph_temp_on_temperature_change(CPhidgetTemperatureSensorHandle phid, void *userPtr, int index, double temperature);
24
- #endif
6
+
7
+ VALUE ph_temp_init(VALUE self) {
8
+ ph_data_t *ph = get_ph_data(self);
9
+ ph_raise(PhidgetTemperatureSensor_create((PhidgetTemperatureSensorHandle *)(&(ph->handle))));
10
+ return self;
11
+ }
12
+
13
+ VALUE ph_temp_get_data_interval(VALUE self) {
14
+ return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetTemperatureSensor_getDataInterval);
15
+ }
16
+
17
+ VALUE ph_temp_set_data_interval(VALUE self, VALUE interval) {
18
+ ph_raise(PhidgetTemperatureSensor_setDataInterval((PhidgetTemperatureSensorHandle)get_ph_handle(self), NUM2UINT(interval)));
19
+ return Qnil;
20
+ }
21
+
22
+ VALUE ph_temp_get_min_data_interval(VALUE self) {
23
+ return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetTemperatureSensor_getMinDataInterval);
24
+ }
25
+
26
+ VALUE ph_temp_get_max_data_interval(VALUE self) {
27
+ return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetTemperatureSensor_getMaxDataInterval);
28
+ }
29
+
30
+ VALUE ph_temp_get_rtd_type(VALUE self) {
31
+ return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetTemperatureSensor_getRTDType);
32
+ }
33
+
34
+ VALUE ph_temp_set_rtd_type(VALUE self, VALUE rtd_type) {
35
+ ph_raise(PhidgetTemperatureSensor_setRTDType((PhidgetTemperatureSensorHandle)get_ph_handle(self), NUM2INT(rtd_type)));
36
+ return Qnil;
37
+ }
38
+
39
+ VALUE ph_temp_get_rtd_wire_setup(VALUE self) {
40
+ return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetTemperatureSensor_getRTDWireSetup);
41
+ }
42
+
43
+ VALUE ph_temp_set_rtd_wire_setup(VALUE self, VALUE wire_setup) {
44
+ ph_raise(PhidgetTemperatureSensor_setRTDWireSetup((PhidgetTemperatureSensorHandle)get_ph_handle(self), NUM2INT(wire_setup)));
45
+ return Qnil;
46
+ }
47
+
48
+ VALUE ph_temp_get_temperature(VALUE self) {
49
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetTemperatureSensor_getTemperature);
50
+ }
51
+
52
+ VALUE ph_temp_get_min_temperature(VALUE self) {
53
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetTemperatureSensor_getMinTemperature);
54
+ }
55
+
56
+ VALUE ph_temp_get_max_temperature(VALUE self) {
57
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetTemperatureSensor_getMaxTemperature);
58
+ }
59
+
60
+ VALUE ph_temp_get_temperature_change_trigger(VALUE self) {
61
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetTemperatureSensor_getTemperatureChangeTrigger);
62
+ }
63
+
64
+ VALUE ph_temp_set_temperature_change_trigger(VALUE self, VALUE temperature) {
65
+ ph_raise(PhidgetTemperatureSensor_setTemperatureChangeTrigger((PhidgetTemperatureSensorHandle)get_ph_handle(self), NUM2DBL(temperature)));
66
+ return Qnil;
67
+ }
68
+
69
+ VALUE ph_temp_get_min_temperature_change_trigger(VALUE self) {
70
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetTemperatureSensor_getMinTemperatureChangeTrigger);
71
+ }
72
+
73
+ VALUE ph_temp_get_max_temperature_change_trigger(VALUE self) {
74
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetTemperatureSensor_getMaxTemperatureChangeTrigger);
75
+ }
76
+
77
+ VALUE ph_temp_get_thermocouple_type(VALUE self) {
78
+ return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetTemperatureSensor_getThermocoupleType);
79
+ }
80
+
81
+ VALUE ph_temp_set_thermocouple_type(VALUE self, VALUE type) {
82
+ ph_raise(PhidgetTemperatureSensor_setThermocoupleType((PhidgetTemperatureSensorHandle)get_ph_handle(self), (PhidgetTemperatureSensor_ThermocoupleType)NUM2INT(type)));
83
+ return Qnil;
84
+ }
85
+
86
+
87
+ void CCONV ph_temp_on_temperature_change(PhidgetTemperatureSensorHandle phid, void *userPtr, double temperature) {
88
+ ph_callback_data_t *callback_data = ((ph_callback_data_t *)userPtr);
89
+ while(sem_wait(&callback_data->handler_ready)!=0) {};
90
+ callback_data->arg1 = DBL2NUM(temperature);
91
+ callback_data->arg2 = Qnil;
92
+ callback_data->arg3 = Qnil;
93
+ callback_data->arg4 = Qnil;
94
+ sem_post(&callback_data->callback_called);
95
+ }
96
+
97
+
98
+ VALUE ph_temp_set_on_temperature_change_handler(VALUE self, VALUE handler) {
99
+ ph_data_t *ph = get_ph_data(self);
100
+ ph_callback_data_t *callback_data = &ph->dev_callbacks[TEMP_SENSOR_TEMPERATURE_CHANGE_CALLBACK];
101
+ if( TYPE(handler) == T_NIL ) {
102
+ callback_data->callback = T_NIL;
103
+ callback_data->exit = true;
104
+ ph_raise(PhidgetTemperatureSensor_setOnTemperatureChangeHandler((PhidgetTemperatureSensorHandle)ph->handle, NULL, (void *)NULL));
105
+ sem_post(&callback_data->callback_called);
106
+ } else {
107
+ callback_data->exit = false;
108
+ callback_data->phidget = self;
109
+ callback_data->callback = handler;
110
+ ph_raise(PhidgetTemperatureSensor_setOnTemperatureChangeHandler((PhidgetTemperatureSensorHandle)ph->handle, ph_temp_on_temperature_change, (void *)callback_data));
111
+ ph_callback_thread(callback_data);
112
+ }
113
+ return Qnil;
114
+ }
25
115
 
26
116
 
27
117
  void Init_temperature_sensor() {
@@ -29,10 +119,15 @@ void Init_temperature_sensor() {
29
119
  VALUE ph_common = rb_const_get(ph_module, rb_intern("Common"));
30
120
  VALUE ph_temp = rb_define_class_under(ph_module, "TemperatureSensor", ph_common);
31
121
 
32
- rb_define_const(ph_temp, "K_TYPE", INT2FIX(PHIDGET_TEMPERATURE_SENSOR_K_TYPE));
33
- rb_define_const(ph_temp, "J_TYPE", INT2FIX(PHIDGET_TEMPERATURE_SENSOR_J_TYPE));
34
- rb_define_const(ph_temp, "E_TYPE", INT2FIX(PHIDGET_TEMPERATURE_SENSOR_E_TYPE));
35
- rb_define_const(ph_temp, "T_TYPE", INT2FIX(PHIDGET_TEMPERATURE_SENSOR_T_TYPE));
122
+ rb_define_const(ph_temp, "RTD_TYPE_PT100_3850", INT2NUM(RTD_TYPE_PT100_3850));
123
+ rb_define_const(ph_temp, "RTD_TYPE_PT1000_3850", INT2NUM(RTD_TYPE_PT1000_3850));
124
+ rb_define_const(ph_temp, "RTD_TYPE_PT100_3920", INT2NUM(RTD_TYPE_PT100_3920));
125
+ rb_define_const(ph_temp, "RTD_TYPE_PT1000_3920", INT2NUM(RTD_TYPE_PT1000_3920));
126
+
127
+ rb_define_const(ph_temp, "THERMOCOUPLE_TYPE_K", INT2NUM(THERMOCOUPLE_TYPE_K));
128
+ rb_define_const(ph_temp, "THERMOCOUPLE_TYPE_J", INT2NUM(THERMOCOUPLE_TYPE_J));
129
+ rb_define_const(ph_temp, "THERMOCOUPLE_TYPE_E", INT2NUM(THERMOCOUPLE_TYPE_E));
130
+ rb_define_const(ph_temp, "THERMOCOUPLE_TYPE_T", INT2NUM(THERMOCOUPLE_TYPE_T));
36
131
 
37
132
  /* Document-method: new
38
133
  * call-seq: new
@@ -41,255 +136,155 @@ void Init_temperature_sensor() {
41
136
  */
42
137
  rb_define_method(ph_temp, "initialize", ph_temp_init, 0);
43
138
 
44
- /* Document-method: getTemperatureInputCount
45
- * call-seq: getTemperatureInputCount -> count
139
+ /* Document-method: getDataInterval
140
+ * call-seq: getDataInterval -> interval
46
141
  *
47
- * Gets the number of thermocouple inputs supported by this board.
142
+ * The DataInterval is the time that must elapse before the channel will fire another TemperatureChange event.
143
+ * The data interval is bounded by MinDataInterval and MaxDataInterval.
144
+ * The timing between TemperatureChange events can also affected by the TemperatureChangeTrigger.
48
145
  */
49
- rb_define_method(ph_temp, "getTemperatureInputCount", ph_temp_get_temperature_input_count, 0);
146
+ rb_define_method(ph_temp, "getDataInterval", ph_temp_get_data_interval, 0);
147
+ rb_define_alias(ph_temp, "data_interval", "getDataInterval");
50
148
 
51
- /* Document-method: getTemperature
52
- * call-seq: getTemperature(index) -> temperature
149
+ /* Document-method: setDataInterval
150
+ * call-seq: setDataInterval(interval)
53
151
  *
54
- * Gets the temperature measured by a thermocouple input.
152
+ * The DataInterval is the time that must elapse before the channel will fire another TemperatureChange event.
153
+ * The data interval is bounded by MinDataInterval and MaxDataInterval.
154
+ * The timing between TemperatureChange events can also affected by the TemperatureChangeTrigger.
55
155
  */
56
- rb_define_method(ph_temp, "getTemperature", ph_temp_get_temperature, 1);
156
+ rb_define_method(ph_temp, "setDataInterval", ph_temp_set_data_interval, 1);
157
+ rb_define_alias(ph_temp, "data_interval=", "setDataInterval");
57
158
 
58
- /* Document-method: getTemperatureMin
59
- * call-seq: getTemperatureMin(index) -> temperature
159
+ /* Document-method: getMinDataInterval
160
+ * call-seq: getMinDataInterval -> interval
60
161
  *
61
- * Gets the minimum temperature that can be measured by a thermocouple input. This depends on the type
62
- * of thermocouple attached, as well as the ambient temperature.
162
+ * The minimum value that DataInterval can be set to.
63
163
  */
64
- rb_define_method(ph_temp, "getTemperatureMin", ph_temp_get_temperature_min, 1);
164
+ rb_define_method(ph_temp, "getMinDataInterval", ph_temp_get_min_data_interval, 0);
165
+ rb_define_alias(ph_temp, "min_data_interval", "getMinDataInterval");
65
166
 
66
- /* Document-method: getTemperatureMax
67
- * call-seq: getTemperatureMax(index) -> temperature
167
+ /* Document-method: getMaxDataInterval
168
+ * call-seq: getMaxDataInterval -> interval
68
169
  *
69
- * Gets the maximum temperature that can be measured by a thermocouple input. This depends on the type
70
- * of thermocouple attached, as well as the ambient temperature.
170
+ * The maximum value that DataInterval can be set to.
71
171
  */
72
- rb_define_method(ph_temp, "getTemperatureMax", ph_temp_get_temperature_max, 1);
172
+ rb_define_method(ph_temp, "getMaxDataInterval", ph_temp_get_max_data_interval, 0);
173
+ rb_define_alias(ph_temp, "max_data_interval", "getMaxDataInterval");
73
174
 
74
- /* Document-method: getTemperatureChangeTrigger
75
- * call-seq: getTemperatureChangeTrigger(index) -> trigger
175
+ /* Document-method: getRTDType
176
+ * call-seq: getRTDType -> rtd_type
76
177
  *
77
- * Gets the change trigger for a thermocouple input.
178
+ * The RTDType must correspond to the RTD type you are using in your application.
179
+ * If you are unsure which RTDType to use, visit your device's User Guide for more information.
78
180
  */
79
- rb_define_method(ph_temp, "getTemperatureChangeTrigger", ph_temp_get_temperature_change_trigger, 1);
181
+ rb_define_method(ph_temp, "getRTDType", ph_temp_get_rtd_type, 0);
182
+ rb_define_alias(ph_temp, "rtd_type", "getRTDType");
80
183
 
81
- /* Document-method: setTemperatureChangeTrigger
82
- * call-seq: setTemperatureChangeTrigger(index, trigger)
184
+ /* Document-method: setRTDType
185
+ * call-seq: setRTDType(rtd_type)
83
186
  *
84
- * Sets the change trigger for a thermocouple input.
187
+ * The RTDType must correspond to the RTD type you are using in your application.
188
+ * If you are unsure which RTDType to use, visit your device's User Guide for more information.
85
189
  */
86
- rb_define_method(ph_temp, "setTemperatureChangeTrigger", ph_temp_set_temperature_change_trigger, 2);
190
+ rb_define_method(ph_temp, "setRTDType", ph_temp_set_rtd_type, 1);
191
+ rb_define_alias(ph_temp, "rtd_type=", "setRTDType");
87
192
 
88
- /* Document-method: getPotential
89
- * call-seq: getPotential(index) -> potential
193
+ /* Document-method: getRTDWireSetup
194
+ * call-seq: getRTDWireSetup -> wire_setup
90
195
  *
91
- * Gets the currently sensed potential for a thermocouple input.
196
+ * The RTDWireSetup must correspond to the wire configuration you are using in your application.
197
+ * If you are unsure which RTDWireSetup to use, visit your device's User Guide for more information.
92
198
  */
93
- rb_define_method(ph_temp, "getPotential", ph_temp_get_potential, 1);
199
+ rb_define_method(ph_temp, "getRTDWireSetup", ph_temp_get_rtd_wire_setup, 0);
200
+ rb_define_alias(ph_temp, "rtd_wire_setup", "getRTDWireSetup");
94
201
 
95
- /* Document-method: getPotentialMin
96
- * call-seq: getPotentialMin(index) -> potential
202
+ /* Document-method: setRTDWireSetup
203
+ * call-seq: setRTDWireSetup(wire_setup)
97
204
  *
98
- * Gets the minimum potential that a thermocouple input can measure.
205
+ * The RTDWireSetup must correspond to the wire configuration you are using in your application.
206
+ * If you are unsure which RTDWireSetup to use, visit your device's User Guide for more information.
99
207
  */
100
- rb_define_method(ph_temp, "getPotentialMin", ph_temp_get_potential_min, 1);
208
+ rb_define_method(ph_temp, "setRTDWireSetup", ph_temp_set_rtd_wire_setup, 1);
209
+ rb_define_alias(ph_temp, "rtd_wire_setup=", "setRTDWireSetup");
101
210
 
102
- /* Document-method: getPotentialMax
103
- * call-seq: getPotentialMax(index) -> potential
211
+ /* Document-method: getTemperature
212
+ * call-seq: getTemperature -> temperature
104
213
  *
105
- * Gets the maximum potential that a thermocouple input can measure.
214
+ * The most recent temperature value that the channel has reported.
215
+ * This value will always be between MinTemperature and MaxTemperature.
106
216
  */
107
- rb_define_method(ph_temp, "getPotentialMax", ph_temp_get_potential_max, 1);
217
+ rb_define_method(ph_temp, "getTemperature", ph_temp_get_temperature, 0);
218
+ rb_define_alias(ph_temp, "temperature", "getTemperature");
108
219
 
109
- /* Document-method: getAmbientTemperature
110
- * call-seq: getAmbientTemperature -> temperature
220
+ /* Document-method: getMinTemperature
221
+ * call-seq: getMinTemperature -> temperature
111
222
  *
112
- * Gets the ambient (board) temperature.
223
+ * The minimum value the TemperatureChange event will report.
113
224
  */
114
- rb_define_method(ph_temp, "getAmbientTemperature", ph_temp_get_ambient_temperature, 0);
225
+ rb_define_method(ph_temp, "getMinTemperature", ph_temp_get_min_temperature, 0);
226
+ rb_define_alias(ph_temp, "min_temperature", "getMinTemperature");
115
227
 
116
- /* Document-method: getAmbientTemperatureMin
117
- * call-seq: getAmbientTemperatureMin -> temperature
228
+ /* Document-method: getMaxTemperature
229
+ * call-seq: getMaxTemperature -> temperature
118
230
  *
119
- * Gets the minimum temperature that the ambient onboard temperature sensor can measure.
231
+ * The maximum value the TemperatureChange event will report.
120
232
  */
121
- rb_define_method(ph_temp, "getAmbientTemperatureMin", ph_temp_get_ambient_temperature_min, 0);
233
+ rb_define_method(ph_temp, "getMaxTemperature", ph_temp_get_max_temperature, 0);
234
+ rb_define_alias(ph_temp, "max_temperature", "getMaxTemperature");
122
235
 
123
- /* Document-method: getAmbientTemperatureMax
124
- * call-seq: getAmbientTemperatureMax -> temperature
236
+ /* Document-method: getTemperatureChangeTrigger
237
+ * call-seq: getTemperatureChangeTrigger -> trigger
125
238
  *
126
- * Gets the maximum temperature that the ambient onboard temperature sensor can measure.
239
+ * The channel will not issue a TemperatureChange event until the temperature value has changed by the amount specified by the TemperatureChangeTrigger.
240
+ * Setting the TemperatureChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering.
127
241
  */
128
- rb_define_method(ph_temp, "getAmbientTemperatureMax", ph_temp_get_ambient_temperature_max, 0);
242
+ rb_define_method(ph_temp, "getTemperatureChangeTrigger", ph_temp_get_temperature_change_trigger, 0);
243
+ rb_define_alias(ph_temp, "temperature_change_trigger", "getTemperatureChangeTrigger");
129
244
 
130
- /* Document-method: getThermocoupleType
131
- * call-seq: getThermocoupleType(index) -> type
245
+ /* Document-method: setTemperatureChangeTrigger
246
+ * call-seq: setTemperatureChangeTrigger(trigger)
132
247
  *
133
- * Gets the type of thermocouple set to be at a thermocouple input. By default this is K-Type.
248
+ * The channel will not issue a TemperatureChange event until the temperature value has changed by the amount specified by the TemperatureChangeTrigger.
249
+ * Setting the TemperatureChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering.
134
250
  */
135
- rb_define_method(ph_temp, "getThermocoupleType", ph_temp_get_thermocouple_type, 1);
251
+ rb_define_method(ph_temp, "setTemperatureChangeTrigger", ph_temp_set_temperature_change_trigger, 1);
252
+ rb_define_alias(ph_temp, "temperature_change_trigger=", "setTemperatureChangeTrigger");
136
253
 
137
- /* Document-method: setThermocoupleType
138
- * call-seq: setThermocoupleType(index, type)
254
+ /* Document-method: getMinTemperatureChangeTrigger
255
+ * call-seq: getMinTemperatureChangeTrigger -> trigger
139
256
  *
140
- * Sets the type of thermocouple plugged into a thermocouple input. By default this is K-Type.
257
+ * The minimum value that TemperatureChangeTrigger can be set to.
141
258
  */
142
- rb_define_method(ph_temp, "setThermocoupleType", ph_temp_set_thermocouple_type, 2);
259
+ rb_define_method(ph_temp, "getMinTemperatureChangeTrigger", ph_temp_get_min_temperature_change_trigger, 0);
260
+ rb_define_alias(ph_temp, "min_temperature_change_trigger", "getMinTemperatureChangeTrigger");
143
261
 
144
- #ifdef PH_CALLBACK
145
- rb_define_private_method(ph_temp, "ext_setOnTemperatureChangeHandler", ph_temp_set_on_temperature_change_handler, 1);
146
- #endif
262
+ /* Document-method: getMaxTemperatureChangeTrigger
263
+ * call-seq: getMaxTemperatureChangeTrigger -> trigger
264
+ *
265
+ * The maximum value that TemperatureChangeTrigger can be set to.
266
+ */
267
+ rb_define_method(ph_temp, "getMaxTemperatureChangeTrigger", ph_temp_get_max_temperature_change_trigger, 0);
268
+ rb_define_alias(ph_temp, "max_temperature_change_trigger", "getMaxTemperatureChangeTrigger");
147
269
 
148
- rb_define_alias(ph_temp, "temperature_input_count", "getTemperatureInputCount");
149
- rb_define_alias(ph_temp, "temperature", "getTemperature");
150
- rb_define_alias(ph_temp, "temperature_min", "getTemperatureMin");
151
- rb_define_alias(ph_temp, "temperature_max", "getTemperatureMax");
152
- rb_define_alias(ph_temp, "temperature_change_trigger", "getTemperatureChangeTrigger");
153
- rb_define_alias(ph_temp, "set_temperature_change_trigger", "setTemperatureChangeTrigger");
154
- rb_define_alias(ph_temp, "potential", "getPotential");
155
- rb_define_alias(ph_temp, "potential_min", "getPotentialMin");
156
- rb_define_alias(ph_temp, "potential_max", "getPotentialMax");
157
- rb_define_alias(ph_temp, "ambient_temperature", "getAmbientTemperature");
158
- rb_define_alias(ph_temp, "ambient_temperature_min", "getAmbientTemperatureMin");
159
- rb_define_alias(ph_temp, "ambient_temperature_max", "getAmbientTemperatureMax");
270
+ /* Document-method: getThermocoupleType
271
+ * call-seq: getThermocoupleType -> type
272
+ *
273
+ * The ThermocoupleType must correspond to the thermocouple type you are using in your application.
274
+ * If you are unsure which ThermocoupleType to use, visit the Thermocouple Primer for more information.
275
+ */
276
+ rb_define_method(ph_temp, "getThermocoupleType", ph_temp_get_thermocouple_type, 0);
160
277
  rb_define_alias(ph_temp, "thermocouple_type", "getThermocoupleType");
161
- rb_define_alias(ph_temp, "set_thermocouple_type", "setThermocoupleType");
162
- }
163
-
164
-
165
-
166
- VALUE ph_temp_init(VALUE self) {
167
- ph_data_t *ph = get_ph_data(self);
168
- ph_raise(CPhidgetTemperatureSensor_create((CPhidgetTemperatureSensorHandle *)(&(ph->handle))));
169
- return self;
170
- }
171
-
172
- VALUE ph_temp_get_temperature_input_count(VALUE self) {
173
- CPhidgetTemperatureSensorHandle handle = (CPhidgetTemperatureSensorHandle)get_ph_handle(self);
174
- int count;
175
- ph_raise(CPhidgetTemperatureSensor_getTemperatureInputCount(handle, &count));
176
- return INT2FIX(count);
177
- }
178
-
179
- VALUE ph_temp_get_temperature(VALUE self, VALUE index) {
180
- CPhidgetTemperatureSensorHandle handle = (CPhidgetTemperatureSensorHandle)get_ph_handle(self);
181
- double temperature;
182
- ph_raise(CPhidgetTemperatureSensor_getTemperature(handle, FIX2INT(index), &temperature));
183
- return rb_float_new(temperature);
184
- }
185
-
186
- VALUE ph_temp_get_temperature_min(VALUE self, VALUE index) {
187
- CPhidgetTemperatureSensorHandle handle = (CPhidgetTemperatureSensorHandle)get_ph_handle(self);
188
- double temperature;
189
- ph_raise(CPhidgetTemperatureSensor_getTemperatureMin(handle, FIX2INT(index), &temperature));
190
- return rb_float_new(temperature);
191
- }
192
-
193
- VALUE ph_temp_get_temperature_max(VALUE self, VALUE index) {
194
- CPhidgetTemperatureSensorHandle handle = (CPhidgetTemperatureSensorHandle)get_ph_handle(self);
195
- double temperature;
196
- ph_raise(CPhidgetTemperatureSensor_getTemperatureMax(handle, FIX2INT(index), &temperature));
197
- return rb_float_new(temperature);
198
- }
199
-
200
- VALUE ph_temp_get_temperature_change_trigger(VALUE self, VALUE index) {
201
- CPhidgetTemperatureSensorHandle handle = (CPhidgetTemperatureSensorHandle)get_ph_handle(self);
202
- double temperature;
203
- ph_raise(CPhidgetTemperatureSensor_getTemperatureChangeTrigger(handle, FIX2INT(index), &temperature));
204
- return rb_float_new(temperature);
205
- }
206
-
207
- VALUE ph_temp_set_temperature_change_trigger(VALUE self, VALUE index, VALUE temperature) {
208
- CPhidgetTemperatureSensorHandle handle = (CPhidgetTemperatureSensorHandle)get_ph_handle(self);
209
- ph_raise(CPhidgetTemperatureSensor_setTemperatureChangeTrigger(handle, FIX2INT(index), NUM2DBL(temperature)));
210
- return Qnil;
211
- }
212
-
213
- VALUE ph_temp_get_potential(VALUE self, VALUE index) {
214
- CPhidgetTemperatureSensorHandle handle = (CPhidgetTemperatureSensorHandle)get_ph_handle(self);
215
- double potential;
216
- ph_raise(CPhidgetTemperatureSensor_getPotential(handle, FIX2INT(index), &potential));
217
- return rb_float_new(potential);
218
- }
219
-
220
- VALUE ph_temp_get_potential_min(VALUE self, VALUE index) {
221
- CPhidgetTemperatureSensorHandle handle = (CPhidgetTemperatureSensorHandle)get_ph_handle(self);
222
- double potential;
223
- ph_raise(CPhidgetTemperatureSensor_getPotentialMin(handle, FIX2INT(index), &potential));
224
- return rb_float_new(potential);
225
- }
226
-
227
- VALUE ph_temp_get_potential_max(VALUE self, VALUE index) {
228
- CPhidgetTemperatureSensorHandle handle = (CPhidgetTemperatureSensorHandle)get_ph_handle(self);
229
- double potential;
230
- ph_raise(CPhidgetTemperatureSensor_getPotentialMax(handle, FIX2INT(index), &potential));
231
- return rb_float_new(potential);
232
- }
233
-
234
- VALUE ph_temp_get_ambient_temperature(VALUE self) {
235
- CPhidgetTemperatureSensorHandle handle = (CPhidgetTemperatureSensorHandle)get_ph_handle(self);
236
- double temperature;
237
- ph_raise(CPhidgetTemperatureSensor_getAmbientTemperature(handle, &temperature));
238
- return rb_float_new(temperature);
239
- }
240
-
241
- VALUE ph_temp_get_ambient_temperature_min(VALUE self) {
242
- CPhidgetTemperatureSensorHandle handle = (CPhidgetTemperatureSensorHandle)get_ph_handle(self);
243
- double temperature;
244
- ph_raise(CPhidgetTemperatureSensor_getAmbientTemperatureMin(handle, &temperature));
245
- return rb_float_new(temperature);
246
- }
247
-
248
- VALUE ph_temp_get_ambient_temperature_max(VALUE self) {
249
- CPhidgetTemperatureSensorHandle handle = (CPhidgetTemperatureSensorHandle)get_ph_handle(self);
250
- double temperature;
251
- ph_raise(CPhidgetTemperatureSensor_getAmbientTemperatureMax(handle, &temperature));
252
- return rb_float_new(temperature);
253
- }
254
-
255
- VALUE ph_temp_get_thermocouple_type(VALUE self, VALUE index) {
256
- CPhidgetTemperatureSensorHandle handle = (CPhidgetTemperatureSensorHandle)get_ph_handle(self);
257
- CPhidgetTemperatureSensor_ThermocoupleType type;
258
- ph_raise(CPhidgetTemperatureSensor_getThermocoupleType(handle, FIX2INT(index), &type));
259
- return INT2FIX(type);
260
- }
261
-
262
- VALUE ph_temp_set_thermocouple_type(VALUE self, VALUE index, VALUE type) {
263
- CPhidgetTemperatureSensorHandle handle = (CPhidgetTemperatureSensorHandle)get_ph_handle(self);
264
- ph_raise(CPhidgetTemperatureSensor_setThermocoupleType(handle, FIX2INT(index), (CPhidgetTemperatureSensor_ThermocoupleType)FIX2INT(type)));
265
- return Qnil;
266
- }
267
-
268
-
269
- #ifdef PH_CALLBACK
270
- VALUE ph_temp_set_on_temperature_change_handler(VALUE self, VALUE handler) {
271
- ph_data_t *ph = get_ph_data(self);
272
- ph_callback_data_t *callback_data = &ph->dev_callback_1;
273
- if( TYPE(handler) == T_NIL ) {
274
- callback_data->exit = true;
275
- ph_raise(CPhidgetTemperatureSensor_set_OnTemperatureChange_Handler((CPhidgetTemperatureSensorHandle)ph->handle, NULL, (void *)NULL));
276
- } else {
277
- callback_data->called = false;
278
- callback_data->exit = false;
279
- callback_data->phidget = self;
280
- callback_data->callback = handler;
281
- ph_raise(CPhidgetTemperatureSensor_set_OnTemperatureChange_Handler((CPhidgetTemperatureSensorHandle)ph->handle, ph_temp_on_temperature_change, (void *)callback_data));
282
- ph_callback_thread(callback_data);
283
- }
284
- return Qnil;
285
- }
286
278
 
279
+ /* Document-method: setThermocoupleType
280
+ * call-seq: setThermocoupleType(type)
281
+ *
282
+ * The ThermocoupleType must correspond to the thermocouple type you are using in your application.
283
+ * If you are unsure which ThermocoupleType to use, visit the Thermocouple Primer for more information.
284
+ */
285
+ rb_define_method(ph_temp, "setThermocoupleType", ph_temp_set_thermocouple_type, 1);
286
+ rb_define_alias(ph_temp, "thermocouple_type=", "setThermocoupleType");
287
287
 
288
- int ph_temp_on_temperature_change(CPhidgetTemperatureSensorHandle phid, void *userPtr, int index, double temperature) {
289
- ph_callback_data_t *callback_data = ((ph_callback_data_t *)userPtr);
290
- callback_data->called = true;
291
- return EPHIDGET_OK;
288
+ rb_define_private_method(ph_temp, "ext_setOnTemperatureChangeHandler", ph_temp_set_on_temperature_change_handler, 1);
292
289
  }
293
290
 
294
- #endif
295
-