00001 00002 /* 00003 * Copyright 2006 Phidgets Inc. All rights reserved. 00004 */ 00005 00006 package com.phidgets; 00007 import java.util.Iterator; 00008 import java.util.LinkedList; 00009 import com.phidgets.event.*; 00022 public final class TemperatureSensorPhidget extends Phidget 00023 { 00024 public TemperatureSensorPhidget () throws PhidgetException 00025 { 00026 super (create ()); 00027 } 00028 private static native long create () throws PhidgetException; 00029 00033 public static final int PHIDGET_TEMPERATURE_SENSOR_K_TYPE = 1; 00037 public static final int PHIDGET_TEMPERATURE_SENSOR_J_TYPE = 2; 00041 public static final int PHIDGET_TEMPERATURE_SENSOR_E_TYPE = 3; 00045 public static final int PHIDGET_TEMPERATURE_SENSOR_T_TYPE = 4; 00046 00051 public native int getTemperatureInputCount () throws PhidgetException; 00056 public native int getSensorCount () throws PhidgetException; 00066 public native double getTemperature (int index) throws PhidgetException; 00074 public native double getTemperatureMax (int index) throws PhidgetException; 00082 public native double getTemperatureMin (int index) throws PhidgetException; 00091 public native double getAmbientTemperature () throws PhidgetException; 00098 public native double getAmbientTemperatureMax () throws PhidgetException; 00105 public native double getAmbientTemperatureMin () throws PhidgetException; 00115 public native double getPotential (int index) throws PhidgetException; 00123 public native double getPotentialMax (int index) throws PhidgetException; 00131 public native double getPotentialMin (int index) throws PhidgetException; 00140 public native void setTemperatureChangeTrigger (int index, double newVal) throws PhidgetException; 00149 public native double getTemperatureChangeTrigger (int index) throws PhidgetException; 00160 public native int getThermocoupleType (int index) throws PhidgetException; 00176 public native void setThermocoupleType (int index, int type) throws PhidgetException; 00177 00178 private final void enableDeviceSpecificEvents (boolean b) 00179 { 00180 enableTemperatureChangeEvents (b && temperatureChangeListeners.size () > 0); 00181 } 00190 public final void addTemperatureChangeListener (TemperatureChangeListener l) 00191 { 00192 synchronized (temperatureChangeListeners) 00193 { 00194 temperatureChangeListeners.add (l); 00195 enableTemperatureChangeEvents (true); 00196 }} private LinkedList temperatureChangeListeners = new LinkedList (); 00197 private long nativeTemperatureChangeHandler = 0; 00198 public final void removeTemperatureChangeListener (TemperatureChangeListener l) 00199 { 00200 synchronized (temperatureChangeListeners) 00201 { 00202 temperatureChangeListeners.remove (l); 00203 enableTemperatureChangeEvents (temperatureChangeListeners.size () > 0); 00204 }} private void fireTemperatureChange (TemperatureChangeEvent e) 00205 { 00206 synchronized (temperatureChangeListeners) 00207 { 00208 for (Iterator it = temperatureChangeListeners.iterator (); it.hasNext ();) 00209 ((TemperatureChangeListener) it.next ()).temperatureChanged (e); 00210 } 00211 } 00212 private native void enableTemperatureChangeEvents (boolean b); 00213 }