From 0b624384cd52be20e61284551d832b499d7b7707 Mon Sep 17 00:00:00 2001 From: Jonathan McCrohan Date: Sat, 14 Apr 2012 12:56:48 +0100 Subject: Imported Upstream version 2.1.8.20120216 --- Java/com/phidgets/PHSensorPhidget.java | 136 +++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 Java/com/phidgets/PHSensorPhidget.java (limited to 'Java/com/phidgets/PHSensorPhidget.java') diff --git a/Java/com/phidgets/PHSensorPhidget.java b/Java/com/phidgets/PHSensorPhidget.java new file mode 100644 index 0000000..dc9ecf6 --- /dev/null +++ b/Java/com/phidgets/PHSensorPhidget.java @@ -0,0 +1,136 @@ + +/* + * Copyright 2006 Phidgets Inc. All rights reserved. + */ + +package com.phidgets; +import java.util.Iterator; +import java.util.LinkedList; +import com.phidgets.event.*; +/** + * This class represents a Phidget PH Sensor. All methods + * to read pH data from the PH Sensor are implemented in this class. + *

+ * The Phidget PH Sensor provides one standard pH sensor input. + * + * @author Phidgets Inc. + */ +public final class PHSensorPhidget extends Phidget +{ + public PHSensorPhidget () throws PhidgetException + { + super (create ()); + } + private static native long create () throws PhidgetException; + /** + * Returns the measured pH. This value can range from between {@link #getPHMin getPHMin} and {@link #getPHMax getPHMax}, but + * some of this range is likely outside of the valid range of most pH sensors. For example, when there is no pH sensor + * attached, the board will often report an (invalid) pH of 15, which while technically within a valid pH range, is unlikely to be seen. + * @return the current pH + * @throws PhidgetException If this Phidget is not opened and attached. + * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached. + */ + public native double getPH () throws PhidgetException; + /** + * Returns the maximum pH that will be returned by the pH sensor input. + * @return Maximum pH + * @throws PhidgetException If this Phidget is not opened and attached. + * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached. + */ + public native double getPHMax () throws PhidgetException; + /** + * Returns the minimum pH that will be returned by the pH sensor input. + * @return Minimum pH + * @throws PhidgetException If this Phidget is not opened and attached. + * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached. + */ + public native double getPHMin () throws PhidgetException; + /** + * Returns the Potential, in millivolts. This returns the actual voltage potential measured by the A/D. + * This value will always be between {@link #getPotentialMin getPotentialMin} and {@link #getPotentialMax getPotentialMax}. + * This is the value that is internally used to calculate pH in the library. + * @return the current potential + * @throws PhidgetException If this Phidget is not opened and attached. + * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached. + */ + public native double getPotential () throws PhidgetException; + /** + * Returns the maximum potential that will be returned by the pH sensor input. + * @return Maximum potential in millivolts + * @throws PhidgetException If this Phidget is not opened and attached. + * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached. + */ + public native double getPotentialMax () throws PhidgetException; + /** + * Returns the minimum potential that will be returned by the pH sensor input. + * @return Minimum potential in millivolts + * @throws PhidgetException If this Phidget is not opened and attached. + * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached. + */ + public native double getPotentialMin () throws PhidgetException; + /** + * Sets the probe temperature in degrees celcius. + * This value is used while calculating the pH. The default value in the libary is 20 degrees celcius. If the temperature + * of the liquid being measured is not 20 degrees, then it should be measued and set for maximum accuracy. + *

+ * Note: All that this does is set a value in the library that is used for calculating ph. This does not set anything + * in the hardware itself. + * + * @param newVal temperature + * @throws PhidgetException If this Phidget is not opened and attached. + * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached. + */ + public native void setTemperature (double newVal) throws PhidgetException; + /** + * Sets the change trigger. + * This is how much the pH much change between successive PHChangeEvents. By default this value is set to 0.05 + * @param newVal Trigger + * @throws PhidgetException If this Phidget is not opened and attached. + * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached. + */ + public native void setPHChangeTrigger (double newVal) throws PhidgetException; + /** + * Returns the change trigger. + * This is how much the pH much change between successive PHChangeEvents. By default this value is set to 0.05 + * @return Trigger + * @throws PhidgetException If this Phidget is not opened and attached. + * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached. + */ + public native double getPHChangeTrigger () throws PhidgetException; + + private final void enableDeviceSpecificEvents (boolean b) + { + enablePHChangeEvents (b && phChangeListeners.size () > 0); + } + /** + * Adds a pH change listener. The pH change handler is a method that will be called when the pH + * has changed by at least the {@link #getPHChangeTrigger() Trigger} that has been set. + *

+ * There is no limit on the number of pH change handlers that can be registered for a particular Phidget. + * + * @param l An implemetation of the {@link com.phidgets.event.PHChangeListener PHChangeListener} interface + */ + public final void addPHChangeListener (PHChangeListener l) + { + synchronized (phChangeListeners) + { + phChangeListeners.add (l); + enablePHChangeEvents (true); + }} private LinkedList phChangeListeners = new LinkedList (); + private long nativePHChangeHandler = 0; + public final void removePHChangeListener (PHChangeListener l) + { + synchronized (phChangeListeners) + { + phChangeListeners.remove (l); + enablePHChangeEvents (phChangeListeners.size () > 0); + }} private void firePHChange (PHChangeEvent e) + { + synchronized (phChangeListeners) + { + for (Iterator it = phChangeListeners.iterator (); it.hasNext ();) + ((PHChangeListener) it.next ()).phChanged (e); + } + } + private native void enablePHChangeEvents (boolean b); +} -- cgit v1.2.3 ='nohover-highlight'> new util 'hash' for associative arrays new plugin 'cpuinfo' 2004-01-13[lcd4linux @ 2004-01-13 08:18:07 by reinelt]reinelt12-154/+469 timer queues added liblcd4linux deactivated turing transformation to new layout 2004-01-12[lcd4linux @ 2004-01-12 03:51:01 by reinelt]reinelt5-15/+44 evaluating the 'Variables' section in the config file 2004-01-11[lcd4linux @ 2004-01-11 18:26:02 by reinelt]reinelt10-79/+158 further widget and layout processing 2004-01-11[lcd4linux @ 2004-01-11 09:26:15 by reinelt]reinelt4-19/+67 layout starts to exist... 2004-01-10[lcd4linux @ 2004-01-10 20:22:33 by reinelt]reinelt13-210/+554 added new function 'cfg_list()' (not finished yet) added layout.c (will replace processor.c someday) added widget_text.c (will be the first and most important widget) modified lcd4linux.c so that old-style configs should work, too 2004-01-10[lcd4linux @ 2004-01-10 17:45:26 by reinelt]reinelt2-5/+15 changed initialization order so cfg() gets initialized before plugins. This way a plugin's init() can use cfg_get(). Thanks to Xavier for reporting this one! 2004-01-10[lcd4linux @ 2004-01-10 17:36:56 by reinelt]reinelt4-10/+207 I2C Sensors plugin from Xavier added 2004-01-10[lcd4linux @ 2004-01-10 17:34:40 by reinelt]reinelt3-176/+138 further matrixOrbital changes widgets initialized 2004-01-10[lcd4linux @ 2004-01-10 10:20:22 by reinelt]reinelt2-14/+605 new MatrixOrbital changes 2004-01-09[lcd4linux @ 2004-01-09 17:03:06 by reinelt]reinelt10-51/+420 initiated transfer to new driver architecture new file 'drv.c' will someday replace 'display.c' new file 'drv_MatrixOrbital.c' will replace 'MatrixOrbital.c' due to this 'soft' transfer lcd4linux should stay usable during the switch (at least I hope so) 2004-01-09[lcd4linux @ 2004-01-09 04:16:06 by reinelt]reinelt28-193/+332 added 'section' argument to cfg_get(), but NULLed it on all calls by now. 2004-01-08[lcd4linux @ 2004-01-08 06:00:28 by reinelt]reinelt1-8/+14 allowed '.' in key names allowed empty group keys (not only "group anything {", but "anything {") 2004-01-08[lcd4linux @ 2004-01-08 05:28:12 by reinelt]reinelt3-42/+198 Luk Claes added to AUTHORS cfg: group handling ('{}') added 2004-01-07[lcd4linux @ 2004-01-07 10:15:41 by reinelt]reinelt4-184/+436 small glitch in evaluator fixed made config table sorted and access with bsearch(), which should be much faster 2004-01-06[lcd4linux @ 2004-01-06 23:01:37 by reinelt]reinelt3-4/+7 more copyright issues 2004-01-06[lcd4linux @ 2004-01-06 22:33:13 by reinelt]reinelt14-472/+542 Copyright statements cleaned up 2004-01-06[lcd4linux @ 2004-01-06 21:14:51 by reinelt]reinelt4-14/+7 more debianizing 2004-01-06[lcd4linux @ 2004-01-06 18:22:41 by reinelt]reinelt1-3/+13 debian updates 2004-01-06[lcd4linux @ 2004-01-06 17:56:43 by reinelt]reinelt3-1000/+2045 autotools update 2004-01-06[lcd4linux @ 2004-01-06 17:37:00 by reinelt]reinelt1-0/+20 2004-01-06[lcd4linux @ 2004-01-06 17:33:45 by reinelt]reinelt6-28/+298 Evaluator: functions with variable argument lists Evaluator: plugin_sample.c and README.Plugins added 2004-01-06[lcd4linux @ 2004-01-06 15:19:12 by reinelt]reinelt2-104/+136 Evaluator rearrangements... 2004-01-05[lcd4linux @ 2004-01-05 11:57:38 by reinelt]reinelt7-8/+168 added %y tokens to make the Evaluator useable 2004-01-02[lcd4linux @ 2004-01-02 14:20:15 by reinelt]reinelt10-0/+201 debianization added 2004-01-02[lcd4linux @ 2004-01-02 14:18:54 by reinelt]reinelt2-0/+101 Changelog, TODO updated 2003-12-19[lcd4linux @ 2003-12-19 06:27:33 by reinelt]reinelt4-8/+119 added XMMS plugin from Markus Keil