aboutsummaryrefslogtreecommitdiffstats
path: root/Java
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2012-04-14 12:56:48 +0100
committerJonathan McCrohan <jmccrohan@gmail.com>2012-04-14 12:56:48 +0100
commit0b624384cd52be20e61284551d832b499d7b7707 (patch)
tree6f95a4bbef47abc9720b96c0722e8f632aef228a /Java
downloadlibphidget21-0b624384cd52be20e61284551d832b499d7b7707.tar.gz
Imported Upstream version 2.1.8.20120216upstream/2.1.8.20120216
Diffstat (limited to 'Java')
-rw-r--r--Java/com/phidgets/AccelerometerPhidget.java116
-rw-r--r--Java/com/phidgets/AdvancedServoPhidget.java492
-rw-r--r--Java/com/phidgets/AnalogPhidget.java78
-rw-r--r--Java/com/phidgets/BridgePhidget.java202
-rw-r--r--Java/com/phidgets/Dictionary.java348
-rw-r--r--Java/com/phidgets/DictionaryKeyListener.java184
-rw-r--r--Java/com/phidgets/EncoderPhidget.java173
-rw-r--r--Java/com/phidgets/FrequencyCounterPhidget.java171
-rw-r--r--Java/com/phidgets/GPSPhidget.java151
-rw-r--r--Java/com/phidgets/IRCode.java93
-rw-r--r--Java/com/phidgets/IRCodeInfo.java360
-rw-r--r--Java/com/phidgets/IRLearnedCode.java51
-rw-r--r--Java/com/phidgets/IRPhidget.java239
-rw-r--r--Java/com/phidgets/InterfaceKitPhidget.java346
-rw-r--r--Java/com/phidgets/LEDPhidget.java141
-rw-r--r--Java/com/phidgets/Manager.java408
-rw-r--r--Java/com/phidgets/MotorControlPhidget.java497
-rw-r--r--Java/com/phidgets/PHSensorPhidget.java136
-rw-r--r--Java/com/phidgets/Phidget.java1000
-rw-r--r--Java/com/phidgets/PhidgetException.java337
-rw-r--r--Java/com/phidgets/RFIDPhidget.java197
-rw-r--r--Java/com/phidgets/ServoPhidget.java286
-rw-r--r--Java/com/phidgets/SpatialEventData.java101
-rw-r--r--Java/com/phidgets/SpatialPhidget.java205
-rw-r--r--Java/com/phidgets/StepperPhidget.java422
-rw-r--r--Java/com/phidgets/TemperatureSensorPhidget.java213
-rw-r--r--Java/com/phidgets/TextLCDPhidget.java278
-rw-r--r--Java/com/phidgets/TextLEDPhidget.java68
-rw-r--r--Java/com/phidgets/WeightSensorPhidget.java89
-rw-r--r--Java/com/phidgets/event/AccelerationChangeEvent.java69
-rw-r--r--Java/com/phidgets/event/AccelerationChangeListener.java20
-rw-r--r--Java/com/phidgets/event/AttachEvent.java46
-rw-r--r--Java/com/phidgets/event/AttachListener.java20
-rw-r--r--Java/com/phidgets/event/BackEMFUpdateEvent.java70
-rw-r--r--Java/com/phidgets/event/BackEMFUpdateListener.java21
-rw-r--r--Java/com/phidgets/event/BridgeDataEvent.java69
-rw-r--r--Java/com/phidgets/event/BridgeDataListener.java20
-rw-r--r--Java/com/phidgets/event/CodeEvent.java73
-rw-r--r--Java/com/phidgets/event/CodeListener.java21
-rw-r--r--Java/com/phidgets/event/CurrentChangeEvent.java69
-rw-r--r--Java/com/phidgets/event/CurrentChangeListener.java21
-rw-r--r--Java/com/phidgets/event/CurrentUpdateEvent.java70
-rw-r--r--Java/com/phidgets/event/CurrentUpdateListener.java20
-rw-r--r--Java/com/phidgets/event/DetachEvent.java46
-rw-r--r--Java/com/phidgets/event/DetachListener.java20
-rw-r--r--Java/com/phidgets/event/EncoderPositionChangeEvent.java84
-rw-r--r--Java/com/phidgets/event/EncoderPositionChangeListener.java20
-rw-r--r--Java/com/phidgets/event/EncoderPositionUpdateEvent.java73
-rw-r--r--Java/com/phidgets/event/EncoderPositionUpdateListener.java20
-rw-r--r--Java/com/phidgets/event/ErrorEvent.java59
-rw-r--r--Java/com/phidgets/event/ErrorListener.java21
-rw-r--r--Java/com/phidgets/event/FrequencyCounterCountEvent.java81
-rw-r--r--Java/com/phidgets/event/FrequencyCounterCountListener.java20
-rw-r--r--Java/com/phidgets/event/GPSPositionChangeEvent.java80
-rw-r--r--Java/com/phidgets/event/GPSPositionChangeListener.java20
-rw-r--r--Java/com/phidgets/event/GPSPositionFixStatusChangeEvent.java58
-rw-r--r--Java/com/phidgets/event/GPSPositionFixStatusChangeListener.java20
-rw-r--r--Java/com/phidgets/event/InputChangeEvent.java69
-rw-r--r--Java/com/phidgets/event/InputChangeListener.java21
-rw-r--r--Java/com/phidgets/event/KeyChangeEvent.java63
-rw-r--r--Java/com/phidgets/event/KeyChangeListener.java21
-rw-r--r--Java/com/phidgets/event/KeyRemovalEvent.java61
-rw-r--r--Java/com/phidgets/event/KeyRemovalListener.java21
-rw-r--r--Java/com/phidgets/event/LearnEvent.java60
-rw-r--r--Java/com/phidgets/event/LearnListener.java21
-rw-r--r--Java/com/phidgets/event/MotorVelocityChangeEvent.java69
-rw-r--r--Java/com/phidgets/event/MotorVelocityChangeListener.java20
-rw-r--r--Java/com/phidgets/event/OutputChangeEvent.java69
-rw-r--r--Java/com/phidgets/event/OutputChangeListener.java21
-rw-r--r--Java/com/phidgets/event/PHChangeEvent.java58
-rw-r--r--Java/com/phidgets/event/PHChangeListener.java20
-rw-r--r--Java/com/phidgets/event/RawDataEvent.java70
-rw-r--r--Java/com/phidgets/event/RawDataListener.java21
-rw-r--r--Java/com/phidgets/event/SensorChangeEvent.java69
-rw-r--r--Java/com/phidgets/event/SensorChangeListener.java19
-rw-r--r--Java/com/phidgets/event/SensorUpdateEvent.java70
-rw-r--r--Java/com/phidgets/event/SensorUpdateListener.java19
-rw-r--r--Java/com/phidgets/event/ServerConnectEvent.java48
-rw-r--r--Java/com/phidgets/event/ServerConnectListener.java20
-rw-r--r--Java/com/phidgets/event/ServerDisconnectEvent.java48
-rw-r--r--Java/com/phidgets/event/ServerDisconnectListener.java20
-rw-r--r--Java/com/phidgets/event/ServoPositionChangeEvent.java70
-rw-r--r--Java/com/phidgets/event/ServoPositionChangeListener.java21
-rw-r--r--Java/com/phidgets/event/ServoVelocityChangeEvent.java69
-rw-r--r--Java/com/phidgets/event/ServoVelocityChangeListener.java20
-rw-r--r--Java/com/phidgets/event/SpatialDataEvent.java60
-rw-r--r--Java/com/phidgets/event/SpatialDataListener.java21
-rw-r--r--Java/com/phidgets/event/StepperPositionChangeEvent.java70
-rw-r--r--Java/com/phidgets/event/StepperPositionChangeListener.java21
-rw-r--r--Java/com/phidgets/event/StepperVelocityChangeEvent.java69
-rw-r--r--Java/com/phidgets/event/StepperVelocityChangeListener.java20
-rw-r--r--Java/com/phidgets/event/TagGainEvent.java59
-rw-r--r--Java/com/phidgets/event/TagGainListener.java21
-rw-r--r--Java/com/phidgets/event/TagLossEvent.java59
-rw-r--r--Java/com/phidgets/event/TagLossListener.java21
-rw-r--r--Java/com/phidgets/event/TemperatureChangeEvent.java70
-rw-r--r--Java/com/phidgets/event/TemperatureChangeListener.java20
-rw-r--r--Java/com/phidgets/event/WeightChangeEvent.java58
-rw-r--r--Java/com/phidgets/event/WeightChangeListener.java20
-rw-r--r--Java/com/phidgets/macros/BridgePhidget.jm171
-rw-r--r--Java/com_phidgets_AccelerometerPhidget.c21
-rw-r--r--Java/com_phidgets_AccelerometerPhidget.h221
-rw-r--r--Java/com_phidgets_AdvancedServoPhidget.c66
-rw-r--r--Java/com_phidgets_AdvancedServoPhidget.h439
-rw-r--r--Java/com_phidgets_AnalogPhidget.c17
-rw-r--r--Java/com_phidgets_AnalogPhidget.h221
-rw-r--r--Java/com_phidgets_BridgePhidget.c40
-rw-r--r--Java/com_phidgets_BridgePhidget.h283
-rw-r--r--Java/com_phidgets_Dictionary.c334
-rw-r--r--Java/com_phidgets_Dictionary.h133
-rw-r--r--Java/com_phidgets_DictionaryKeyListener.c132
-rw-r--r--Java/com_phidgets_DictionaryKeyListener.h21
-rw-r--r--Java/com_phidgets_EncoderPhidget.c31
-rw-r--r--Java/com_phidgets_EncoderPhidget.h261
-rw-r--r--Java/com_phidgets_FrequencyCounterPhidget.c49
-rw-r--r--Java/com_phidgets_FrequencyCounterPhidget.h267
-rw-r--r--Java/com_phidgets_GPSPhidget.c101
-rw-r--r--Java/com_phidgets_GPSPhidget.h237
-rw-r--r--Java/com_phidgets_IRPhidget.c777
-rw-r--r--Java/com_phidgets_IRPhidget.h239
-rw-r--r--Java/com_phidgets_InterfaceKitPhidget.c36
-rw-r--r--Java/com_phidgets_InterfaceKitPhidget.h317
-rw-r--r--Java/com_phidgets_LEDPhidget.c38
-rw-r--r--Java/com_phidgets_LEDPhidget.h237
-rw-r--r--Java/com_phidgets_Manager.c392
-rw-r--r--Java/com_phidgets_Manager.h133
-rw-r--r--Java/com_phidgets_MotorControlPhidget.c75
-rw-r--r--Java/com_phidgets_MotorControlPhidget.h437
-rw-r--r--Java/com_phidgets_PHSensorPhidget.c24
-rw-r--r--Java/com_phidgets_PHSensorPhidget.h245
-rw-r--r--Java/com_phidgets_Phidget.c630
-rw-r--r--Java/com_phidgets_Phidget.h405
-rw-r--r--Java/com_phidgets_RFIDPhidget.c104
-rw-r--r--Java/com_phidgets_RFIDPhidget.h261
-rw-r--r--Java/com_phidgets_ServoPhidget.c47
-rw-r--r--Java/com_phidgets_ServoPhidget.h319
-rw-r--r--Java/com_phidgets_SpatialPhidget.c166
-rw-r--r--Java/com_phidgets_SpatialPhidget.h325
-rw-r--r--Java/com_phidgets_StepperPhidget.c53
-rw-r--r--Java/com_phidgets_StepperPhidget.h405
-rw-r--r--Java/com_phidgets_TemperatureSensorPhidget.c42
-rw-r--r--Java/com_phidgets_TemperatureSensorPhidget.h301
-rw-r--r--Java/com_phidgets_TextLCDPhidget.c97
-rw-r--r--Java/com_phidgets_TextLCDPhidget.h359
-rw-r--r--Java/com_phidgets_TextLEDPhidget.c29
-rw-r--r--Java/com_phidgets_TextLEDPhidget.h205
-rw-r--r--Java/com_phidgets_WeightSensorPhidget.c18
-rw-r--r--Java/com_phidgets_WeightSensorPhidget.h197
-rw-r--r--Java/phidget_jni.c156
-rw-r--r--Java/phidget_jni.h322
150 files changed, 20816 insertions, 0 deletions
diff --git a/Java/com/phidgets/AccelerometerPhidget.java b/Java/com/phidgets/AccelerometerPhidget.java
new file mode 100644
index 0000000..c0c82ae
--- /dev/null
+++ b/Java/com/phidgets/AccelerometerPhidget.java
@@ -0,0 +1,116 @@
+
+/*
+ * 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 Accelerometer. All methods to read
+ * acceleration data from an Accelerometer are implemented in this class.
+ <p>
+ The Phidget Accelerometer provides 2 or 3 axes of acceleration data, at anywhere from 2g to 10g
+ sensitivity, depending on the specific revision. See your hardware documetation for more information.
+ They can measure both static (gravity) and dynamic acceleration.
+
+ * @author Phidgets Inc.
+ */
+public final class AccelerometerPhidget extends Phidget
+{
+ public AccelerometerPhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+
+ /**
+ * Returns the number of accelerometer axes. Currently all accelerometers provide two or three axes of acceleration - x, y, (and z).
+ * @return number of axes of acceleration
+ */
+ public native int getAxisCount () throws PhidgetException;
+ /**
+ * Returns the acceleration of a particular axis. This value is returned in g's, where one g of acceleration is
+ * equal to gravity. This means that at a standstill each axis will measure between -1.0 and 1.0 g's depending on
+ * orientation.
+ * <P>
+ * This value will always be between {@link #getAccelerationMin getAccelerationMin} and {@link #getAccelerationMax getAccelerationMax}.
+ * <p>
+ * Index 0 is the x-axis, 1 is the y-axis, and 2 is the z-axis (where available).
+ *
+ * @param index index of the axis
+ * @return acceleration of the selected axis
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getAcceleration (int index) throws PhidgetException;
+ /**
+ * Returns the maximum acceleration value that this axis will report. This will be set to just higher then the maximum
+ * acceleration that this axis can measure. If the acceleration is equal to this maximum, assume that that axis is saturated
+ * beyond what it can measure.
+ * @return maximum acceleration
+ */
+ public native double getAccelerationMax (int index) throws PhidgetException;
+ /**
+ * Returns the minimum acceleration value that this axis will report. This will be set to just lower then the minimum
+ * acceleration that this axis can measure. If the acceleration is equal to this minimum, assume that that axis is saturated
+ * beyond what it can measure.
+ * @return minimum acceleration
+ */
+ public native double getAccelerationMin (int index) throws PhidgetException;
+ /**
+ * Sets the change trigger for an Axis. This value is in g's and is by default set to 0.
+ * This is the difference in acceleration that must appear between succesive calls to the
+ * OnAccelerationChange event handler.
+ * @param index index of the axis
+ * @param newVal the new change trigger for this axis
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setAccelerationChangeTrigger (int index, double newVal) throws PhidgetException;
+ /**
+ * Returns the change trigger for an Axis. This value is in g's and is by default set to 0.
+ * @param index index of the axis
+ * @return change trigger of the selected axis
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getAccelerationChangeTrigger (int index) throws PhidgetException;
+
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ enableAccelerationChangeEvents (b && accelerationChangeListeners.size () > 0);
+ }
+ /**
+ * Adds an acceleration change listener. The acceleration change handler is a method that will be called when the acceleration
+ * of an axis has changed by at least the {@link #getAccelerationChangeTrigger(int) Trigger} that has been set for that axis.
+ * <p>
+ * There is no limit on the number of acceleration change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.AccelerationChangeListener AccelerationChangeListener} interface
+ */
+ public final void addAccelerationChangeListener (AccelerationChangeListener l)
+ {
+ synchronized (accelerationChangeListeners)
+ {
+ accelerationChangeListeners.add (l);
+ enableAccelerationChangeEvents (true);
+ }} private LinkedList accelerationChangeListeners = new LinkedList ();
+ private long nativeAccelerationChangeHandler = 0;
+ public final void removeAccelerationChangeListener (AccelerationChangeListener l)
+ {
+ synchronized (accelerationChangeListeners)
+ {
+ accelerationChangeListeners.remove (l);
+ enableAccelerationChangeEvents (accelerationChangeListeners.size () > 0);
+ }} private void fireAccelerationChange (AccelerationChangeEvent e)
+ {
+ synchronized (accelerationChangeListeners)
+ {
+ for (Iterator it = accelerationChangeListeners.iterator (); it.hasNext ();)
+ ((AccelerationChangeListener) it.next ()).accelerationChanged (e);
+ }
+ }
+ private native void enableAccelerationChangeEvents (boolean b);
+}
diff --git a/Java/com/phidgets/AdvancedServoPhidget.java b/Java/com/phidgets/AdvancedServoPhidget.java
new file mode 100644
index 0000000..1aa485a
--- /dev/null
+++ b/Java/com/phidgets/AdvancedServoPhidget.java
@@ -0,0 +1,492 @@
+
+/*
+ * 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 Advanced Servo Controller. All methods
+ * to to control a motor controller and read back motor data are implemented in this class.
+ * <p>
+ * The Phidget Advanced Servo Controller is able to control 1 or more servo motors. Motos acceleration
+ * and Velocity are controllable. The number of servos that can be controlled depends on the
+ * version of the controller.
+ *
+ * @author Phidgets Inc.
+ */
+public final class AdvancedServoPhidget extends Phidget
+{
+ public AdvancedServoPhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+
+ /**
+ * Default - This is what the servo API been historically used, originally based on the Futaba FP-S148. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_DEFAULT = 1;
+ /**
+ * Raw us mode - all position, velocity, acceleration functions are specified in microseconds rather then degrees. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_RAW_us_MODE = 2;
+ /**
+ * HiTec HS-322HD Standard Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_HS322HD = 3;
+ /**
+ * HiTec HS-5245MG Digital Mini Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_HS5245MG = 4;
+ /**
+ * HiTec HS-805BB Mega Quarter Scale Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_805BB = 5;
+ /**
+ * HiTec HS-422 Standard Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_HS422 = 6;
+ /**
+ * Tower Pro MG90 Micro Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_TOWERPRO_MG90 = 7;
+ /**
+ * HiTec HSR-1425CR Continuous Rotation Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_HSR1425CR = 8;
+ /**
+ * HiTec HS-785HB Sail Winch Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_HS785HB = 9;
+ /**
+ * HiTec HS-485HB Deluxe Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_HS485HB = 10;
+ /**
+ * HiTec HS-645MG Ultra Torque Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_HS645MG = 11;
+ /**
+ * HiTec HS-815BB Mega Sail Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_815BB = 12;
+ /**
+ * Firgelli L12 Linear Actuator 30mm 50:1. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_FIRGELLI_L12_30_50_06_R = 13;
+ /**
+ * Firgelli L12 Linear Actuator 50mm 100:1. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_FIRGELLI_L12_50_100_06_R = 14;
+ /**
+ * Firgelli L12 Linear Actuator 50mm 210:1. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_FIRGELLI_L12_50_210_06_R = 15;
+ /**
+ * Firgelli L12 Linear Actuator 100mm 50:1. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_FIRGELLI_L12_100_50_06_R = 16;
+ /**
+ * Firgelli L12 Linear Actuator 100mm 100:1. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_FIRGELLI_L12_100_100_06_R = 17;
+ /**
+ * SpringRC SM-S2313M Micro Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_SPRINGRC_SM_S2313M = 18;
+ /**
+ * SpringRC SM-S3317M Small Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_SPRINGRC_SM_S3317M = 19;
+ /**
+ * SpringRC SM-S3317SR Small Continuous Rotation Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_SPRINGRC_SM_S3317SR = 20;
+ /**
+ * SpringRC SM-S4303R Standard Continuous Rotation Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_SPRINGRC_SM_S4303R = 21;
+ /**
+ * SpringRC SM-S4315M High Torque Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_SPRINGRC_SM_S4315M = 22;
+ /**
+ * SpringRC SM-S4315R High Torque Continuous Rotation Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_SPRINGRC_SM_S4315R = 23;
+ /**
+ * SpringRC SM-S4505B Standard Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_SPRINGRC_SM_S4505B = 24;
+ /**
+ * User Defined servo parameters. This is used with {@link #getServoType getServoType}
+ */
+ public static final int PHIDGET_SERVO_USER_DEFINED = 25;
+
+ /**
+ * Returns the number of servo motors supported by this Phidget. This does not neccesarily correspond
+ * to the number of motors actually attached to the board.
+ * @return number of supported motors
+ * @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 int getMotorCount () throws PhidgetException;
+ /**
+ * Returns the maximum acceleration that a motor will accept, or return.
+ * <p>This value is in degrees per second squared.
+ * @param index Index of the motor
+ * @return Maximum acceleration
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getAccelerationMax (int index) throws PhidgetException;
+ /**
+ * Returns the minimum acceleration that a motor will accept, or return.
+ * <p>This value is in degrees per second squared.
+ * @param index Index of the motor
+ * @return Minimum acceleration
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getAccelerationMin (int index) throws PhidgetException;
+ /**
+ * Returns the maximum velocity that a servo motor will accept, or return.
+ * <p>This value is in degrees per second.
+ * @param index Index of the motor
+ * @return Maximum velocity
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getVelocityMax (int index) throws PhidgetException;
+ /**
+ * Returns the minimum velocity that a servo motor will accept, or return.
+ * <p>This value is in degrees per second.
+ * @param index Index of the motor
+ * @return Minimum velocity
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getVelocityMin (int index) throws PhidgetException;
+ /**
+ * Returns the maximum position that a servo motor will accept, or return.
+ * <p>This value is in degrees.
+ * @param index Index of the motor
+ * @return Maximum position
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getPositionMax (int index) throws PhidgetException;
+ /**
+ * Sets the maximum position that a servo motor will accept, or return. This is for limiting the range of motion of the servo
+ * controller. The Maximum cannot be extended beyond it's original value.
+ * <p>This value is in degrees.
+ * @param index Index of the motor
+ * @param position Maximum position
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setPositionMax (int index, double position) throws PhidgetException;
+ /**
+ * Returns the minimum position that a servo motor will accept, or return.
+ * <p>This value uses the same units as
+ * <p>This value is in degrees.
+ * @param index Index of the motor
+ * @return Minimum position
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getPositionMin (int index) throws PhidgetException;
+ /**
+ * Sets the minimum position that a servo motor will accept, or return. This is for limiting the range of motion of the servo
+ * controller. The Minimum cannot be extended beyond it's original value.
+ * <p>This value is in degrees.
+ * @param index Index of the motor
+ * @param position Minimum position
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setPositionMin (int index, double position) throws PhidgetException;
+ /**
+ * Returns a motor's acceleration. The valid range is between {@link #getAccelerationMin getAccelerationMin}
+ * and {@link #getAccelerationMax getAccelerationMax}, and refers to how fast the Servo Controller will change the speed of a motor.
+ * <p>This value is in degrees per second squared.
+ * @param index index of motor
+ * @return acceleration of motor
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is invalid, or if the acceleration is unknown.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getAcceleration (int index) throws PhidgetException;
+ /**
+ * Sets a motor's acceleration.
+ * The valid range is between {@link #getAccelerationMin getAccelerationMin} and {@link #getAccelerationMax getAccelerationMax}.
+ * This controls how fast the motor changes speed.
+ * <p>This value is in degrees per second squared.
+ * @param index index of the motor
+ * @param acceleration requested acceleration for that motor
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index or acceleration are invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setAcceleration (int index, double acceleration) throws PhidgetException;
+ /**
+ * Returns a motor's velocity limit. This is the maximum velocity that the motor will turn at.
+ * The valid range is between {@link #getVelocityMin getVelocityMin} and {@link #getVelocityMax getVelocityMax},
+ * with 0 being stopped.
+ * <p>This value is in degrees per second.
+ * @param index index of the motor
+ * @return current speed of the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is invalid, or if the velocity in unknown.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getVelocityLimit (int index) throws PhidgetException;
+ /**
+ * Sets a motor's velocity limit. This is the maximum velocity that the motor will turn at.
+ * The valid range is between {@link #getVelocityMin getVelocityMin} and {@link #getVelocityMax getVelocityMax},
+ * with 0 being stopped.
+ * <p>This value is in degrees per second.
+ * @param index index of the motor
+ * @param velocity requested velocity for the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index or velocity are invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setVelocityLimit (int index, double velocity) throws PhidgetException;
+ /**
+ * Returns a motor's current velocity. The valid range is between {@link #getVelocityMin getVelocityMin} and {@link #getVelocityMax getVelocityMax},
+ * with 0 being stopped.
+ * <p>This value is in degrees per second.
+ * @param index index of the motor
+ * @return current speed of the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is invalid, or if the velocity in unknown.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getVelocity (int index) throws PhidgetException;
+ /**
+ * Returns a motor's current position. This is the actual position that the motor is at right now.
+ * The valid range is between {@link #getPositionMin getPositionMin} and {@link #getPositionMax getPositionMax}.
+ * <p>This value is in degrees.
+ * @param index index of the motor
+ * @return current position of the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is invalid, or if the position in unknown.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getPosition (int index) throws PhidgetException;
+ /**
+ * Sets a motor's target position. Use this is set the target position for the servo.
+ * If the servo is {@link #setEngaged engaged} it will start moving towards this target position.
+ * The valid range is between {@link #getPositionMin getPositionMin} and {@link #getPositionMax getPositionMax}.
+ * <p>This value is in degrees.
+ * @param index index of the motor
+ * @param position target position of the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index or position are invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setPosition (int index, double position) throws PhidgetException;
+ /**
+ * Returns the engaged state of a motor.
+ *
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getEngaged (int index) throws PhidgetException;
+ /**
+ * Engage or disengage a motor.
+ * <p>
+ * This engages or disengages the servo motor. The motors are by default disengaged when the servo controller is plugged in.
+ * When the servo is disengaged, position, velocity, etc. can all be set, but the motor will not start moving until it is engaged.
+ * If position is read when a motor is disengaged, it will throw an exception.
+ * <p>
+ * This corresponds to a PCM of 0 being sent to the servo.
+ *
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setEngaged (int index, boolean state) throws PhidgetException;
+ /**
+ * Returns the speed ramping state of a motor.
+ *
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getSpeedRampingOn (int index) throws PhidgetException;
+ /**
+ * Sets the speed ramping state.
+ * <p>
+ * Disable speed ramping to disable velocity and acceleration control. With speed ramping disabled, the servo will be sent to
+ * the desired position immediately upon recieving the command. This is how the regular Phidget Servo Controller works.
+ * <p>
+ * This is turned on by default.
+ *
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setSpeedRampingOn (int index, boolean state) throws PhidgetException;
+ /**
+ * Returns a motor's current usage. The valid range depends on the servo controller.
+ * This value is in Amps.
+ * @param index index of the motor
+ * @return current usage of the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is invalid, or if the value is unknown.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getCurrent (int index) throws PhidgetException;
+ /**
+ * Returns the stopped state of a motor. Use this to determine if the motor is moving and/or up to date with the latest commands you have sent.
+ * If this is true, the motor is guaranteed to be stopped and to have processed every command issued. Generally, this would
+ * be polled after a target position is set to wait until that position is reached.
+ *
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getStopped (int index) throws PhidgetException;
+ /**
+ * Returns the servo type for an index.
+ * The possible values for type are {@link #PHIDGET_SERVO_DEFAULT PHIDGET_SERVO_DEFAULT},
+ * {@link #PHIDGET_SERVO_RAW_us_MODE PHIDGET_SERVO_RAW_us_MODE}, {@link #PHIDGET_SERVO_HITEC_HS322HD PHIDGET_SERVO_HITEC_HS322HD},
+ * {@link #PHIDGET_SERVO_HITEC_HS5245MG PHIDGET_SERVO_HITEC_HS5245MG}, {@link #PHIDGET_SERVO_HITEC_805BB PHIDGET_SERVO_HITEC_805BB},
+ * {@link #PHIDGET_SERVO_HITEC_HS422 PHIDGET_SERVO_HITEC_HS422}, etc.
+ * @param index Input
+ * @return Servo Type
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getServoType (int index) throws PhidgetException;
+ /**
+ * Sets the servo type for an index.
+ * <p>
+ * This constrains the PCM to the valid range of the servo, and sets the degrees-to-PCM ratio to match the actual servo rotation.
+ * Velocity is also constrained to the maximum speed attainable by the servo.
+ * <p>
+ * The possible values for type are {@link #PHIDGET_SERVO_DEFAULT PHIDGET_SERVO_DEFAULT},
+ * {@link #PHIDGET_SERVO_RAW_us_MODE PHIDGET_SERVO_RAW_us_MODE}, {@link #PHIDGET_SERVO_HITEC_HS322HD PHIDGET_SERVO_HITEC_HS322HD},
+ * {@link #PHIDGET_SERVO_HITEC_HS5245MG PHIDGET_SERVO_HITEC_HS5245MG}, {@link #PHIDGET_SERVO_HITEC_805BB PHIDGET_SERVO_HITEC_805BB},
+ * {@link #PHIDGET_SERVO_HITEC_HS422 PHIDGET_SERVO_HITEC_HS422}, etc.
+ * <p>
+ * Support for other servo types can be achieved by using {@link #setServoParameters setServoParameters}.
+ * <p>
+ * The default setting is {@link #PHIDGET_SERVO_DEFAULT PHIDGET_SERVO_DEFAULT}, which is used for historical (backwards compatibility) reasons.
+ * @param index Input
+ * @param type Servo Type
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setServoType (int index, int type) throws PhidgetException;
+ /**
+ * Sets the servo parameters for a custom servo definition.
+ * <p>
+ * This constrains the PCM to the valid range of the servo, and sets the degrees-to-PCM ratio to match the actual servo rotation.
+ * Velocity is also constrained to the maximum speed attainable by the servo.
+ * <p>
+ * @param index Servo Index
+ * @param minUs Minimum PCM supported in microseconds
+ * @param maxUs Maximum PCM supported in microseconds
+ * @param degrees Degrees of rotation represented by the given PCM range
+ * @param velocityMax Maximum supported velocity of the servo in degrees/second
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setServoParameters (int index, double minUs, double maxUs, double degrees, double velocityMax) throws PhidgetException;
+
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ enableServoPositionChangeEvents (b && servoPositionChangeListeners.size () > 0);
+ enableServoVelocityChangeEvents (b && servoVelocityChangeListeners.size () > 0);
+ enableCurrentChangeEvents (b && currentChangeListeners.size () > 0);
+ }
+ /**
+ * Adds a position change listener. The position change handler is a method that will be called when the servo
+ * position has changed.
+ * <p>
+ * There is no limit on the number of position change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.ServoPositionChangeListener ServoPositionChangeListener} interface
+ */
+ public final void addServoPositionChangeListener (ServoPositionChangeListener l)
+ {
+ synchronized (servoPositionChangeListeners)
+ {
+ servoPositionChangeListeners.add (l);
+ enableServoPositionChangeEvents (true);
+ }} private LinkedList servoPositionChangeListeners = new LinkedList ();
+ private long nativeServoPositionChangeHandler = 0;
+ public final void removeServoPositionChangeListener (ServoPositionChangeListener l)
+ {
+ synchronized (servoPositionChangeListeners)
+ {
+ servoPositionChangeListeners.remove (l);
+ enableServoPositionChangeEvents (servoPositionChangeListeners.size () > 0);
+ }} private void fireServoPositionChange (ServoPositionChangeEvent e)
+ {
+ synchronized (servoPositionChangeListeners)
+ {
+ for (Iterator it = servoPositionChangeListeners.iterator (); it.hasNext ();)
+ ((ServoPositionChangeListener) it.next ()).servoPositionChanged (e);
+ }
+ }
+ private native void enableServoPositionChangeEvents (boolean b);
+ /**
+ * Adds a velocity change listener. The velocity change handler is a method that will be called when the servo
+ * velocity has changed.
+ * <p>
+ * There is no limit on the number of velocity change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.ServoVelocityChangeListener ServoVelocityChangeListener} interface
+ */
+ public final void addServoVelocityChangeListener (ServoVelocityChangeListener l)
+ {
+ synchronized (servoVelocityChangeListeners)
+ {
+ servoVelocityChangeListeners.add (l);
+ enableServoVelocityChangeEvents (true);
+ }} private LinkedList servoVelocityChangeListeners = new LinkedList ();
+ private long nativeServoVelocityChangeHandler = 0;
+ public final void removeServoVelocityChangeListener (ServoVelocityChangeListener l)
+ {
+ synchronized (servoVelocityChangeListeners)
+ {
+ servoVelocityChangeListeners.remove (l);
+ enableServoVelocityChangeEvents (servoVelocityChangeListeners.size () > 0);
+ }} private void fireServoVelocityChange (ServoVelocityChangeEvent e)
+ {
+ synchronized (servoVelocityChangeListeners)
+ {
+ for (Iterator it = servoVelocityChangeListeners.iterator (); it.hasNext ();)
+ ((ServoVelocityChangeListener) it.next ()).servoVelocityChanged (e);
+ }
+ }
+ private native void enableServoVelocityChangeEvents (boolean b);
+ /**
+ * Adds a current change listener. The current change handler is a method that will be called when the servo
+ * current has changed.
+ * <p>
+ * There is no limit on the number of current change handlers that can be registered for a particular Phidget.
+ * <p>
+ * Note that not all stepper controllers support current sensing.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.CurrentChangeListener CurrentChangeListener} interface
+ */
+ public final void addCurrentChangeListener (CurrentChangeListener l)
+ {
+ synchronized (currentChangeListeners)
+ {
+ currentChangeListeners.add (l);
+ enableCurrentChangeEvents (true);
+ }} private LinkedList currentChangeListeners = new LinkedList ();
+ private long nativeCurrentChangeHandler = 0;
+ public final void removeCurrentChangeListener (CurrentChangeListener l)
+ {
+ synchronized (currentChangeListeners)
+ {
+ currentChangeListeners.remove (l);
+ enableCurrentChangeEvents (currentChangeListeners.size () > 0);
+ }} private void fireCurrentChange (CurrentChangeEvent e)
+ {
+ synchronized (currentChangeListeners)
+ {
+ for (Iterator it = currentChangeListeners.iterator (); it.hasNext ();)
+ ((CurrentChangeListener) it.next ()).currentChanged (e);
+ }
+ }
+ private native void enableCurrentChangeEvents (boolean b);
+}
diff --git a/Java/com/phidgets/AnalogPhidget.java b/Java/com/phidgets/AnalogPhidget.java
new file mode 100644
index 0000000..b8f4c0a
--- /dev/null
+++ b/Java/com/phidgets/AnalogPhidget.java
@@ -0,0 +1,78 @@
+
+/*
+ * Copyright 2011 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 Analog. All methods
+ * to manipulate the Phidget Analog are implemented in this class.
+ *
+ * @author Phidgets Inc.
+ */
+public final class AnalogPhidget extends Phidget
+{
+ public AnalogPhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+
+ /**
+ * Returns the number of analog outputs.
+ * @return Number of analog outputs
+ */
+ public native int getOutputCount () throws PhidgetException;
+ /**
+ * Returns the current voltage output setting for an analog output, in Volts. The range is between {@link #getVoltageMin(int) getVoltageMin} and {@link #getVoltageMax(int) getVoltageMax}.
+ * @param index index of the analog output
+ * @return current voltage for an analog output, in Volts
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getVoltage (int index) throws PhidgetException;
+ /**
+ * Sets the current voltage setting for an analog output, in Volts. The range is between {@link #getVoltageMin(int) getVoltageMin} and {@link #getVoltageMax(int) getVoltageMax}.
+ * @param index index of the analog output
+ * @param current new voltage for an analog output, in Volts
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setVoltage (int index, double current) throws PhidgetException;
+ /**
+ * Gets the minimum supported voltage for an output, in Volts.
+ * @param index index of the analog output
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getVoltageMin (int index) throws PhidgetException;
+ /**
+ * Gets the maximum supported voltage for an output, in Volts.
+ * @param index index of the analog output
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getVoltageMax (int index) throws PhidgetException;
+ /**
+ * Returns the enabled state for an analog output. When enabled, the output drives at the set Voltage, up to 20mA. When disabled, the output is tied to ground via a 4K pull-down.
+ * @param index index of the analog output
+ * @return enabled state for an output
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getEnabled (int index) throws PhidgetException;
+ /**
+ * Sets the enabled state for a an analog output. When enabled, the output drives at the set Voltage, up to 20mA. When disabled, the output is tied to ground via a 4K pull-down.
+ * @param index index of the analog output
+ * @param state new state of the analog output
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setEnabled (int index, boolean state) throws PhidgetException;
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ }
+}
diff --git a/Java/com/phidgets/BridgePhidget.java b/Java/com/phidgets/BridgePhidget.java
new file mode 100644
index 0000000..55f0b65
--- /dev/null
+++ b/Java/com/phidgets/BridgePhidget.java
@@ -0,0 +1,202 @@
+
+/*
+ * Copyright 2011 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 Bridge. All methods
+ * to manipulate the Phidget Bridge are implemented in this class.
+ * <p>
+ *
+ * @author Phidgets Inc.
+ */
+public final class BridgePhidget extends Phidget
+{
+ public BridgePhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+ /**
+ * 1 Gain. This is used with {@link #getGain(int) getGain} and {@link #setGain(int, int) setGain}
+ */
+ public static final int PHIDGET_BRIDGE_GAIN_1 = 1;
+ /**
+ * 8 Gain. This is used with {@link #getGain(int) getGain} and {@link #setGain(int, int) setGain}
+ */
+ public static final int PHIDGET_BRIDGE_GAIN_8 = 2;
+ /**
+ * 16 Gain. This is used with {@link #getGain(int) getGain} and {@link #setGain(int, int) setGain}
+ */
+ public static final int PHIDGET_BRIDGE_GAIN_16 = 3;
+ /**
+ * 32 Gain. This is used with {@link #getGain(int) getGain} and {@link #setGain(int, int) setGain}
+ */
+ public static final int PHIDGET_BRIDGE_GAIN_32 = 4;
+ /**
+ * 64 Gain. This is used with {@link #getGain(int) getGain} and {@link #setGain(int, int) setGain}
+ */
+ public static final int PHIDGET_BRIDGE_GAIN_64 = 5;
+ /**
+ * 128 Gain. This is used with {@link #getGain(int) getGain} and {@link #setGain(int, int) setGain}
+ */
+ public static final int PHIDGET_BRIDGE_GAIN_128 = 6;
+ /**
+ * Unknown Gain. This is used with {@link #getGain(int) getGain} and {@link #setGain(int, int) setGain}
+ */
+ public static final int PHIDGET_BRIDGE_GAIN_UNKNOWN = 7;
+ /**
+ * Returns the number of bridges.
+ * @return Number of bridges
+ */
+ public native int getInputCount () throws PhidgetException;
+ /**
+ * Returns the value of the selected input, in mV/V. If the input is not enabled, an EPHIDGET_UNKNOWNVAL exception will be thrown. If the bridge is saturated
+ *, this will be equal to BridgeMax or BridgeMin and an error event will be fired - in this case, gain should be reduced if possible.
+ * @param index Index of the bridge
+ * @return bridge value
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getBridgeValue (int index) throws PhidgetException;
+ /**
+ * Returns the minimum value that the selected bridge can measure, in mV/V. This value will depend on the selected gain. At a gain of 1, BridgeMin == -1000 mV/V.
+ * @param index Index of the bridge
+ * @return minimum value
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getBridgeMin (int index) throws PhidgetException;
+ /**
+ * Returns the maximum value that the selected bridge can measure, in mV/V. This value will depend on the selected gain. At a gain of 1, BridgeMin == 1000 mV/V.
+ * @param index Index of the bridge
+ * @return maximum value
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getBridgeMax (int index) throws PhidgetException;
+ /**
+ * Returns the enabled state of the specified bridge. This applies power between +5v and Ground, and starts measuring the differential on the +/- pins. By default, all bridges are
+ * disabled, and need to be explicitly enabled on startup.
+ * @param index Index of the bridge
+ * @return state of the specified bridge
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getEnabled (int index) throws PhidgetException;
+ /**
+ * Sets the enabled state of the specified bridge. This applies power between +5v and Ground, and starts measuring the differential on the +/- pins. By default, all bridges are
+ * disabled, and need to be explicitly enabled on startup.
+ * @param index Index of the bridge
+ * @param state new state of the specified bridge
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setEnabled (int index, boolean state) throws PhidgetException;
+ /**
+ * Returns the gain for the selected bridge. Note that increasing the gains will reduce the measurable
+ * voltage difference by the gain factor, with +-1000 mV/V being the maximum, with no gain.
+ * The possible values for gain are {@link #PHIDGET_BRIDGE_GAIN_1 PHIDGET_BRIDGE_GAIN_1},
+ * {@link #PHIDGET_BRIDGE_GAIN_8 PHIDGET_BRIDGE_GAIN_8}, {@link #PHIDGET_BRIDGE_GAIN_16 PHIDGET_BRIDGE_GAIN_16},
+ * {@link #PHIDGET_BRIDGE_GAIN_32 PHIDGET_BRIDGE_GAIN_32}, {@link #PHIDGET_BRIDGE_GAIN_64 PHIDGET_BRIDGE_GAIN_64},
+ * {@link #PHIDGET_BRIDGE_GAIN_128 PHIDGET_BRIDGE_GAIN_128}, {@link #PHIDGET_BRIDGE_GAIN_UNKNOWN PHIDGET_BRIDGE_GAIN_UNKNOWN}
+ * <p>
+ * @param index Index of the bridge
+ * @return gain
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getGain (int index) throws PhidgetException;
+ /**
+ * Sets the gain for the selected bridge. Note that increasing the gains will reduce the measurable
+ * voltage difference by the gain factor, with +-1000 mV/V being the maximum, with no gain.
+ * <p>
+ * The possible values for gain are {@link #PHIDGET_BRIDGE_GAIN_1 PHIDGET_BRIDGE_GAIN_1},
+ * {@link #PHIDGET_BRIDGE_GAIN_8 PHIDGET_BRIDGE_GAIN_8}, {@link #PHIDGET_BRIDGE_GAIN_16 PHIDGET_BRIDGE_GAIN_16},
+ * {@link #PHIDGET_BRIDGE_GAIN_32 PHIDGET_BRIDGE_GAIN_32}, {@link #PHIDGET_BRIDGE_GAIN_64 PHIDGET_BRIDGE_GAIN_64},
+ * {@link #PHIDGET_BRIDGE_GAIN_128 PHIDGET_BRIDGE_GAIN_128}, {@link #PHIDGET_BRIDGE_GAIN_UNKNOWN PHIDGET_BRIDGE_GAIN_UNKNOWN}
+ * <p>
+ * @param index Index of the bridge
+ * @param gain new gain
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setGain (int index, int gain) throws PhidgetException;
+ /**
+ * Returns the data rate, in ms. Data rate applies to all 4 bridges simultaneously. Setting a slower data rate will reduce
+ * noise at the cost of sample time. Also note that each bridge is being sampled only 1/4 of the time - this is okay for very stable signals,
+ * but for changing signals, it is best to set a higher sampling rate and do averaging in the software.
+ * <p>
+ * Data rate must be a multiple of 8ms. Trying to set something between multiplies of 8 will cause an EPHIDGET_INVALIDARG exception.
+ * <p>
+ * @return Data Rate
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getDataRate () throws PhidgetException;
+ /**
+ * Sets the data rate, in ms. Data rate applies to all 4 bridges simultaneously. Setting a slower data rate will reduce
+ * noise at the cost of sample time. Also note that each bridge is being sampled only 1/4 of the time - this is okay for very stable signals,
+ * but for changing signals, it is best to set a higher sampling rate and do averaging in the software.
+ * <p>
+ * Data rate must be a multiple of 8ms. Trying to set something between multiplies of 8 will cause an EPHIDGET_INVALIDARG exception.
+ * <p>
+ * @param rate new data rate
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the data rate is out of range
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setDataRate (int rate) throws PhidgetException;
+ /**
+ * Gets the minimum supported data rate, in ms.
+ * @return minimum supported data rate
+ * @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 int getDataRateMin () throws PhidgetException;
+ /**
+ * Gets the maximum supported data rate, in ms.
+ * @return maximum supported data rate
+ * @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 int getDataRateMax () throws PhidgetException;
+
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ enableBridgeDataEvents (b && bridgeDataListeners.size () > 0);
+ }
+ /**
+ * Adds a bridge data listener. The bridge data handler is a method that will be called at the specified data rate, for each enabled bridge. Value is the bridgeValue, in mV/V.
+ * <p>
+ * There is no limit on the number of bridge data handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.BridgeDataListener BridgeDataListener} interface
+ */
+ public final void addBridgeDataListener (BridgeDataListener l)
+ {
+ synchronized (bridgeDataListeners)
+ {
+ bridgeDataListeners.add (l);
+ enableBridgeDataEvents (true);
+ }} private LinkedList bridgeDataListeners = new LinkedList ();
+ private long nativeBridgeDataHandler = 0;
+ public final void removeBridgeDataListener (BridgeDataListener l)
+ {
+ synchronized (bridgeDataListeners)
+ {
+ bridgeDataListeners.remove (l);
+ enableBridgeDataEvents (bridgeDataListeners.size () > 0);
+ }} private void fireBridgeData (BridgeDataEvent e)
+ {
+ synchronized (bridgeDataListeners)
+ {
+ for (Iterator it = bridgeDataListeners.iterator (); it.hasNext ();)
+ ((BridgeDataListener) it.next ()).bridgeData (e);
+ }
+ }
+ private native void enableBridgeDataEvents (boolean b);
+}
diff --git a/Java/com/phidgets/Dictionary.java b/Java/com/phidgets/Dictionary.java
new file mode 100644
index 0000000..0afde5e
--- /dev/null
+++ b/Java/com/phidgets/Dictionary.java
@@ -0,0 +1,348 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets;
+
+import com.phidgets.event.*;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Vector;
+
+/**
+ * This class represents the Phidget Dictionary.
+ * <p>
+ * The Phidget Dictionary is a service provided by the Phidget Webservice.
+ * The Webservice maintains a centralized dictionary of key-value pairs that can be accessed and changed from any number of clients.
+ * <p>
+ * Note that the Webservice uses this dictionary to control access to Phidgets through the openRemote and openRemoteIP interfaces,
+ * and as such, you should never add or modify a key that starts with /PSK/ or /PCK/, unless you want to explicitly modify Phidget
+ * specific data -- and this is highly discouraged, as it's very easy to break things. Listening to these keys is fine if so desired.
+ * <p>
+ * The intended use for the dictionary is as a central repository for communication and persistent storage of data between several
+ * client applications. As an example - a higher level interface exposed by one application -- which controls the Phidgets, for
+ * others to access -- rather then every client talking directly to the Phidgets themselves.
+ * <p>
+ * The dictionary makes use of extended regular expressions for key matching.
+ *
+ * @author Phidgets Inc.
+ */
+public class Dictionary
+{
+ static
+ {
+ try
+ {
+ System.loadLibrary("phidget21");
+ }
+ catch(UnsatisfiedLinkError ex)
+ {
+ String os = System.getProperty("os.name");
+ if(os.startsWith("Linux"))
+ {
+ throw new ExceptionInInitializerError(ex.getMessage()
+ +"\nCould not locate the Phidget C library (libphidget21.so)."
+ +"\nMake sure it is installed, and add it's path to LD_LIBRARY_PATH.");
+ }
+ else if(os.startsWith("Windows"))
+ {
+ throw new ExceptionInInitializerError(ex.getMessage()
+ +"\nCould not locate the Phidget C library."
+ +"\nThe Windows Phidget21 MSI must be installed.");
+ }
+ else if(os.startsWith("Mac"))
+ {
+ throw new ExceptionInInitializerError(ex.getMessage()
+ +"\nCould not locate the Phidget C library."
+ +"\nThe Mac Phidget21 DMG must be installed.");
+ }
+ else
+ {
+ throw new ExceptionInInitializerError(ex.getMessage()
+ +"\nCould not locate the Phidget C library.");
+ }
+ }
+ }
+
+ public long handle = 0;
+ /**
+ * The default constructor. Creating a Phidget Dictionary object will initialize the
+ * dictionary handle internally, but {@link #open(String, int) open} still needs to be called
+ * to actually work with it.
+ */
+ public Dictionary() throws PhidgetException
+ {
+ handle = create();
+ }
+ private final native long create() throws PhidgetException;
+
+ private final native void nativeClose() throws PhidgetException;
+ private final native void nativeDelete() throws PhidgetException;
+ private final native void nativeOpenRemote(String serverID, String pass) throws PhidgetException;
+ private final native void nativeOpenRemoteIP(String ipAddress, int port, String pass) throws PhidgetException;
+ private final native void nativeAddKey(String key, String val, int persistent) throws PhidgetException;
+ private final native void nativeRemoveKey(String keyPattern) throws PhidgetException;
+ private final native String nativeGetKey(String key) throws PhidgetException;
+
+
+ /**
+ * Returns the Address of a Phidget Webservice when this Dictionary was opened as remote. This may be an IP Address or a hostname.
+ *
+ * @return Server Address
+ * @throws PhidgetException if this Dictionary was not opened.
+ */
+ public final native String getServerAddress() throws PhidgetException;
+ /**
+ * Returns the Server ID of a Phidget Webservice when this Dictionary was opened as remote. This is an arbitrary server identifier,
+ * independant of IP address and Port.
+ *
+ * @return Server ID
+ * @throws PhidgetException if this Dictionary was not opened.
+ */
+ public final native String getServerID() throws PhidgetException;
+ /**
+ * Returns the Port of a Phidget Webservice when this Dictionary was opened as remote.
+ *
+ * @return Server Port
+ * @throws PhidgetException if this Dictionary was not opened.
+ */
+ public final native int getServerPort() throws PhidgetException;
+ /**
+ * Returns the attached status of this Dictionary.
+ *
+ * @return Status
+ * @throws PhidgetException If this Dictionary is not opened.
+ */
+ public final native boolean isAttached() throws PhidgetException;
+
+ /**
+ * Returns the network attached status for remotely opened Phidgets. This method returns True or False, depending on whether a connection to the
+ * Phidget WebService is open - or not. If this is false for a remote Phidget then the connection is not active - either because a connection
+ * has not yet been established, or because the connection was terminated.
+ *
+ * @return Status
+ * @throws PhidgetException If this Phidget is not opened.
+ */
+ public final native boolean isAttachedToServer() throws PhidgetException;
+
+ /**
+ * Adds a new key to the Dictionary, or modifies the value of an existing key.
+ * <p>
+ * The key can only contain numbers, letters, "/", ".", "-", "_", and must begin with a letter, "_" or "/".
+ * <p>
+ * The value can contain any value.
+ * <p>
+ * The key will stay in the dictionary until explicitly removed.
+ *
+ *
+ */
+ public final void add(String key, String val) throws PhidgetException
+ {
+ nativeAddKey(key, val, 1);
+ }
+
+ /**
+ * Adds a new key to the Dictionary, or modifies the value of an existing key.
+ * <p>
+ * The key can only contain numbers, letters, "/", ".", "-", "_", and must begin with a letter, "_" or "/".
+ * <p>
+ * The value can contain any value.
+ * <p>
+ * The persistent value controls whether a key will stay in the dictionary after the client that created it disconnects.
+ * If persistent == 0, the key is removed when the connection closes. Otherwise the key remains in the dictionary until
+ * it is explicitly removed.
+ *
+ */
+ public final void add(String key, String val, boolean persistent) throws PhidgetException
+ {
+ if (persistent) nativeAddKey(key, val, 1);
+ else nativeAddKey(key, val, 0);
+ }
+ /**
+ * Removes a key, or set of keys, from the Dictionary.
+ * <p>
+ * The key name is a regular expressions pattern, and so care must be taken to only have it match the specific keys you want to remove.
+ */
+ public final void remove(String pattern) throws PhidgetException
+ {
+ nativeRemoveKey(pattern);
+ }
+
+ /**
+ * Gets the value for a key.
+ */
+ public final String get(String key) throws PhidgetException
+ {
+ return nativeGetKey(key);
+ }
+
+ /**
+ * Open this Dictionary remotely and securely, using an IP Address.
+ * <p>
+ * This method is the same as {@link #open(String, int) open(String ipAddress, int port)}, except that it specifies a password.
+ * This password can be set as a parameter when starting the Phidget Webservice.
+ */
+ public final void open(String ipAddress, int port, String password) throws PhidgetException
+ {
+ enableEvents(true);
+ nativeOpenRemoteIP(ipAddress, port, password);
+ }
+ /**
+ * Open this Dictionary remotely using an IP Address.
+ * <p>
+ * This version of open is network based, and relies on the Phidget Webservice running at the specified Address and Port
+ * before open is called.
+ * <p>
+ * @param ipAddress IP Address or hostname of the Phidget Webservice
+ * @param port Port of the Phidget Webservice
+ * @throws PhidgetException if the Phidget Webservice cannot be contacted
+ */
+ public final void open(String ipAddress, int port) throws PhidgetException
+ {
+ enableEvents(true);
+ nativeOpenRemoteIP(ipAddress, port, "");
+ }
+ /**
+ * Open this Dictionary remotely and securely, using a Server ID.
+ * <p>
+ * This method is the same as {@link #open(String) open(String serverID)}, except that it specifies a password.
+ * This password can be set as a parameter when starting the Phidget Webservice.
+ */
+ public final void open(String serverID, String password) throws PhidgetException
+ {
+ enableEvents(true);
+ nativeOpenRemote(serverID, password);
+ }
+ /**
+ * Open this Dictionary remotely using a Server ID.
+ * <p>
+ * This version of open is network based.
+ *
+ * @param serverID ServerID of the Phidget Webservice
+ */
+ public final void open(String serverID) throws PhidgetException
+ {
+ enableEvents(true);
+ nativeOpenRemote(serverID, "");
+ }
+ /**
+ * Closes this Dictionary.
+ * This will shut down all threads dealing with this Dictionary and you won't recieve any more events.
+ *
+ * @throws PhidgetException If this Dictionary is not opened.
+ */
+ public final void close() throws PhidgetException
+ {
+ enableEvents(false);
+ nativeClose();
+ }
+
+ private void enableEvents(boolean b)
+ {
+ enableServerConnectEvents(b && serverConnectListeners.size() > 0);
+ enableServerDisconnectEvents(b && serverDisconnectListeners.size() > 0);
+ }
+
+ private LinkedList serverConnectListeners = new LinkedList();
+ private long nativeServerConnectHandler = 0;
+
+ /**
+ * Adds an serverConnect listener. The serverConnect handler is a method that will be called when a connection to a server is made
+ * <p>
+ * There is no limit on the number of serverConnect handlers that can be registered for a particular Manager.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.ServerConnectListener ServerConnectListener} interface
+ */
+ public final void addServerConnectListener(ServerConnectListener l)
+ {
+ synchronized (serverConnectListeners)
+ {
+ serverConnectListeners.add(l);
+ enableServerConnectEvents(true);
+ }
+ }
+
+ /**
+ * Removes an serverConnect listener. This will remove a previously added serverConnect listener.
+ */
+ public final void removeServerConnectListener(ServerConnectListener l)
+ {
+ synchronized (serverConnectListeners)
+ {
+ serverConnectListeners.remove(l);
+ enableServerConnectEvents(serverConnectListeners.size() > 0);
+ }
+ }
+ private void fireServerConnect(ServerConnectEvent e)
+ {
+ synchronized (serverConnectListeners)
+ {
+ for (Iterator it = serverConnectListeners.iterator();
+ it.hasNext(); )
+ ((ServerConnectListener)it.next()).serverConnected(e);
+ }
+ }
+ private native void enableServerConnectEvents(boolean b);
+
+
+ private LinkedList serverDisconnectListeners = new LinkedList();
+ private long nativeServerDisconnectHandler = 0;
+
+ /**
+ * Adds an serverDisconnect listener. The serverDisconnect handler is a method that will be called when a connection to a server is terminated.
+ * <p>
+ * There is no limit on the number of serverDisconnect handlers that can be registered for a particular Manager.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.ServerDisconnectListener ServerDisconnectListener} interface
+ */
+ public final void addServerDisconnectListener(ServerDisconnectListener l)
+ {
+ synchronized (serverDisconnectListeners)
+ {
+ serverDisconnectListeners.add(l);
+ enableServerDisconnectEvents(true);
+ }
+ }
+
+ /**
+ * Removes an serverDisconnect listener. This will remove a previously added serverDisconnect listener.
+ */
+ public final void removeServerDisconnectListener(ServerDisconnectListener l)
+ {
+ synchronized (serverDisconnectListeners)
+ {
+ serverDisconnectListeners.remove(l);
+ enableServerDisconnectEvents(serverDisconnectListeners.size() > 0);
+ }
+ }
+ private void fireServerDisconnect(ServerDisconnectEvent e)
+ {
+ synchronized (serverDisconnectListeners)
+ {
+ for (Iterator it = serverDisconnectListeners.iterator();
+ it.hasNext(); )
+ ((ServerDisconnectListener)it.next()).serverDisconnected(e);
+ }
+ }
+ private native void enableServerDisconnectEvents(boolean b);
+
+ /**
+ * Return a Sring describing this dictionary.
+ */
+ public String toString()
+ {
+ return "PhidgetDictionary: ";
+ }
+
+ protected void finalize() {
+ try
+ {
+ close();
+ nativeDelete();
+ handle = 0;
+ } catch (Exception e) {
+ ;
+ }
+ }
+}
diff --git a/Java/com/phidgets/DictionaryKeyListener.java b/Java/com/phidgets/DictionaryKeyListener.java
new file mode 100644
index 0000000..db09a90
--- /dev/null
+++ b/Java/com/phidgets/DictionaryKeyListener.java
@@ -0,0 +1,184 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets;
+
+import com.phidgets.event.*;
+
+import com.phidgets.Dictionary;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+/**
+ * This class represents a key listener.
+ * <p>
+ * This key listener is used, along with the Dictionary object, to set up listener for specific keys, or groups of keys.
+ * Events are available for key add or change, and for key removal.
+ */
+public class DictionaryKeyListener
+{
+ private String pattern;
+ Dictionary dict;
+
+ static
+ {
+ try
+ {
+ System.loadLibrary("phidget21");
+ }
+ catch(UnsatisfiedLinkError ex)
+ {
+ String os = System.getProperty("os.name");
+ if(os.startsWith("Linux"))
+ {
+ throw new ExceptionInInitializerError(ex.getMessage()
+ +"\nCould not locate the Phidget C library."
+ +"\nMake sure to compile with 'make jni' and install with 'make install'.");
+ }
+ else if(os.startsWith("Windows"))
+ {
+ throw new ExceptionInInitializerError(ex.getMessage()
+ +"\nCould not locate the Phidget C library."
+ +"\nThe Windows Phidget21 MSI must be installed.");
+ }
+ else if(os.startsWith("Mac"))
+ {
+ throw new ExceptionInInitializerError(ex.getMessage()
+ +"\nCould not locate the Phidget C library."
+ +"\nThe Mac Phidget21 DMG must be installed.");
+ }
+ else
+ {
+ throw new ExceptionInInitializerError(ex.getMessage()
+ +"\nCould not locate the Phidget C library.");
+ }
+ }
+ }
+
+ private long handle = 0;
+ private long nativeHandler = 0;
+ public long listenerhandle = 0;
+
+ /**
+ * Start this key listener. This method should not be called until the coresponding dictionary is connected.
+ */
+ public void start() throws PhidgetException
+ {
+ this.handle = dict.handle;
+ if (handle == 0)
+ throw (new PhidgetException(5, "Dictionary is not attached - call open first"));
+ listenerhandle = enableDictionaryKeyEvents((keyChangeListeners.size() > 0) || (keyRemovalListeners.size() > 0), pattern);
+ }
+
+ /**
+ * Stop this key listener.
+ */
+ public void stop()
+ {
+ listenerhandle = enableDictionaryKeyEvents(false, pattern);
+ }
+
+ /**
+ * Returns the Dictionary object that this listener is listening on.
+ */
+ public Dictionary getDictionary()
+ {
+ return dict;
+ }
+
+ /**
+ * Creates a new key listener, for a specific pattern, on a specific dictionary object.
+ * The pattern is a regular expression.
+ */
+ public DictionaryKeyListener(Dictionary dict, String pattern)
+ {
+ this.pattern = pattern;
+ this.dict = dict;
+ this.handle = dict.handle;
+ }
+
+ private LinkedList keyChangeListeners = new LinkedList();
+ private long nativeKeyChangeHandler = 0;
+
+ /**
+ * Add a new listener for key change events. This also applies for key add events..
+ */
+ public final void addKeyChangeListener(KeyChangeListener l)
+ {
+ synchronized (keyChangeListeners)
+ {
+ keyChangeListeners.add(l);
+ //enableDictionaryKeyEvents(true, pattern);
+ }
+ }
+ /**
+ * Removes a key change listener.
+ */
+ public final void removeKeyChangeListener(KeyChangeListener l)
+ {
+ synchronized (keyChangeListeners)
+ {
+ keyChangeListeners.remove(l);
+ //enableDictionaryKeyEvents(keyChangeListeners.size() > 0, pattern);
+ }
+ }
+ private void fireKeyChange(KeyChangeEvent e)
+ {
+ synchronized (keyChangeListeners)
+ {
+ for (Iterator it = keyChangeListeners.iterator();
+ it.hasNext(); )
+ ((KeyChangeListener)it.next()).keyChanged(e);
+ }
+ }
+ private native long enableDictionaryKeyEvents(boolean b, String pattern);
+
+ private LinkedList keyRemovalListeners = new LinkedList();
+ private long nativeKeyRemovalHandler = 0;
+
+ /**
+ * Add a new listener for key removal events.
+ */
+ public final void addKeyRemovalListener(KeyRemovalListener l)
+ {
+ synchronized (keyRemovalListeners)
+ {
+ keyRemovalListeners.add(l);
+ //enableDictionaryKeyEvents(true, pattern);
+ }
+ }
+ /**
+ * removes a key removal listener.
+ */
+ public final void removeKeyRemovalListener(KeyRemovalListener l)
+ {
+ synchronized (keyRemovalListeners)
+ {
+ keyRemovalListeners.remove(l);
+ //enableDictionaryKeyEvents(keyRemovalListeners.size() > 0, pattern);
+ }
+ }
+ private void fireKeyRemoval(KeyRemovalEvent e)
+ {
+ synchronized (keyRemovalListeners)
+ {
+ for (Iterator it = keyRemovalListeners.iterator();
+ it.hasNext(); )
+ ((KeyRemovalListener)it.next()).keyRemoved(e);
+ }
+ }
+
+ /**
+ * Return a Sring describing this dictionary key listener.
+ */
+ public String toString()
+ {
+ return dict.toString() + "Dictionary Key Listener ("+pattern+"): ";
+ }
+
+ protected void finalize()
+ {
+ listenerhandle = enableDictionaryKeyEvents(false, pattern);
+ }
+}
diff --git a/Java/com/phidgets/EncoderPhidget.java b/Java/com/phidgets/EncoderPhidget.java
new file mode 100644
index 0000000..1543bd3
--- /dev/null
+++ b/Java/com/phidgets/EncoderPhidget.java
@@ -0,0 +1,173 @@
+
+/*
+ * 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 Encoder. All methods
+ * to read encoder data from an encoder are implemented in this class.
+ <p>
+ Phidget Encoder boards generally support 1 or more encoders with 0 or more digital inputs.
+ Both high speed optical and low speed mechanical encoders are supported with this API.
+ *
+ * @author Phidgets Inc.
+ */
+public final class EncoderPhidget extends Phidget
+{
+ public EncoderPhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+ /**
+ * Returns number of encoders. All current encoder boards support one encoder.
+ * @return number of encoders
+ * @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 int getEncoderCount () throws PhidgetException;
+ /**
+ * Returns number of digital inputs. On the mechanical encoder this refers to the pushbutton. The
+ high speed encoder does not have any digital inputs.
+ * @return number of inputs
+ * @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 int getInputCount () throws PhidgetException;
+ /**
+ * Returns the position of an encoder. This is an absolute position as calcutated since the encoder was plugged in.
+ This value can be reset to anything using {@link #setEncoderPosition(int, int) setEncoderPosition}.
+ * @param index index of the encoder
+ * @return position of the encoder
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getPosition (int index) throws PhidgetException;
+ /**
+ * Returns the last index position of an encoder. This is the position of the last index pulse. Not all encoders support index.
+ * @param index index of the encoder
+ * @return last index position of the encoder
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is out of range, of if index is not supported.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getIndexPosition (int index) throws PhidgetException;
+ /**
+ * @deprecated Replaced by
+ * {@link #getPosition}
+ */
+ public native int getEncoderPosition (int index) throws PhidgetException;
+ /**
+ * Sets the position of a specific encoder. This resets the internal position count for an encoder. This call in no way actually
+ sends information to the device, as an absolute position is maintained only in the library. After this call, position changes
+ from the encoder will use the new value to calculate absolute position as reported by {@link #getEncoderPosition}.
+ * @param index index of the encoder
+ * @param position new position for this encoder.
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setPosition (int index, int position) throws PhidgetException;
+ /**
+ * @deprecated Replaced by
+ * {@link #setPosition}
+ */
+ public native void setEncoderPosition (int index, int position) throws PhidgetException;
+ /**
+ * Returns the state of a digital input. On the mechanical encoder this refers to the pushbutton. The
+ high speed encoder does not have any digital inputs. A value of true means that the input is active(the button is pushed).
+ * @param index index of the input
+ * @return state of the input
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getInputState (int index) throws PhidgetException;
+ /**
+ * Returns the enabled state of an encoder. True indicated activated, False deactivated, which is the default.
+ * @param index index of the encoder
+ * @return state of the encoder
+ * @throws PhidgetException If this Phidget is not opened and attached, the index is out of range, or enable is not supported.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getEnabled (int index) throws PhidgetException;
+ /**
+ * Sets the enabled state of an encoder. True indicated activated, False deactivated, which is the default.
+ * @param index index of the encoder
+ * @param state desired state
+ * @throws PhidgetException If this Phidget is not opened and attached, the index is out of range, or enable is not supported.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setEnabled (int index, boolean state) throws PhidgetException;
+
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ enableEncoderPositionChangeEvents (b && encoderPositionChangeListeners.size () > 0);
+ enableInputChangeEvents (b && inputChangeListeners.size () > 0);
+ }
+ /**
+ * Adds a position change listener. The position change handler is a method that will be called when the position of an
+ encoder changes. The position change event provides data about how many ticks have occured, and how much time has
+ passed since the last position change event, but does not contain an absolute position. This can be obtained from
+ {@link #getEncoderPosition}.
+ * <p>
+ * There is no limit on the number of position change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.EncoderPositionChangeListener EncoderPositionChangeListener} interface
+ */
+ public final void addEncoderPositionChangeListener (EncoderPositionChangeListener l)
+ {
+ synchronized (encoderPositionChangeListeners)
+ {
+ encoderPositionChangeListeners.add (l);
+ enableEncoderPositionChangeEvents (true);
+ }} private LinkedList encoderPositionChangeListeners = new LinkedList ();
+ private long nativeEncoderPositionChangeHandler = 0;
+ public final void removeEncoderPositionChangeListener (EncoderPositionChangeListener l)
+ {
+ synchronized (encoderPositionChangeListeners)
+ {
+ encoderPositionChangeListeners.remove (l);
+ enableEncoderPositionChangeEvents (encoderPositionChangeListeners.size () > 0);
+ }} private void fireEncoderPositionChange (EncoderPositionChangeEvent e)
+ {
+ synchronized (encoderPositionChangeListeners)
+ {
+ for (Iterator it = encoderPositionChangeListeners.iterator (); it.hasNext ();)
+ ((EncoderPositionChangeListener) it.next ()).encoderPositionChanged (e);
+ }
+ }
+ private native void enableEncoderPositionChangeEvents (boolean b);
+ /**
+ * Adds an input change listener. The input change handler is a method that will be called when an input on this
+ * Encoder board has changed.
+ * <p>
+ * There is no limit on the number of input change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.InputChangeListener InputChangeListener} interface
+ */
+ public final void addInputChangeListener (InputChangeListener l)
+ {
+ synchronized (inputChangeListeners)
+ {
+ inputChangeListeners.add (l);
+ enableInputChangeEvents (true);
+ }} private LinkedList inputChangeListeners = new LinkedList ();
+ private long nativeInputChangeHandler = 0;
+ public final void removeInputChangeListener (InputChangeListener l)
+ {
+ synchronized (inputChangeListeners)
+ {
+ inputChangeListeners.remove (l);
+ enableInputChangeEvents (inputChangeListeners.size () > 0);
+ }} private void fireInputChange (InputChangeEvent e)
+ {
+ synchronized (inputChangeListeners)
+ {
+ for (Iterator it = inputChangeListeners.iterator (); it.hasNext ();)
+ ((InputChangeListener) it.next ()).inputChanged (e);
+ }
+ }
+ private native void enableInputChangeEvents (boolean b);
+}
diff --git a/Java/com/phidgets/FrequencyCounterPhidget.java b/Java/com/phidgets/FrequencyCounterPhidget.java
new file mode 100644
index 0000000..b6b138e
--- /dev/null
+++ b/Java/com/phidgets/FrequencyCounterPhidget.java
@@ -0,0 +1,171 @@
+
+/*
+ * Copyright 2011 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 Frequency Counter. All methods
+ * to read manipulate the Phidget Frequency Counter are implemented in this class.
+ * <p>
+ *
+ * @author Phidgets Inc.
+ */
+public final class FrequencyCounterPhidget extends Phidget
+{
+ public FrequencyCounterPhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+ /**
+ * Zero-Crossing Filter Type. This is used with {@link #getFilter(int) getFilter} and {@link #setFilter(int, int) setFilter}
+ */
+ public static final int PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_ZERO_CROSSING = 1;
+ /**
+ * Logic-Level Filter Type. This is used with {@link #getFilter(int) getFilter} and {@link #setFilter(int, int) setFilter}
+ */
+ public static final int PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_LOGIC_LEVEL = 2;
+ /**
+ * Unknown Filter Type. This is used with {@link #getFilter(int) getFilter} and {@link #setFilter(int, int) setFilter}
+ */
+ public static final int PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_UNKNOWN = 3;
+ /**
+ * Returns the number of channels.
+ * @return Number of inputs
+ */
+ public native int getFrequencyInputCount () throws PhidgetException;
+ /**
+ * Returns the last calcualted frequency on the specified channel, in Hz. This function will return 0 if the {@link #getTimeout(int) getTimeout} value elapses without detecting a signal.
+ * Frequency is recalculated up to 31.25 times a second, depending on the pulse rate.
+ * @param index Index of the channel
+ * @return frequency of the channel
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getFrequency (int index) throws PhidgetException;
+ /**
+ * Returns the total number of pulses detected on the specified channel since the Phidget was opened, or since the last reset.
+ * @param index Index of the channel
+ * @return total number of pulses
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native long getTotalCount (int index) throws PhidgetException;
+ /**
+ * Returns the total elapsed tiem since Phidget was opened, or since the last reset, in microseconds. This time corresponds to the {@link #getTotalCount(int) getTotalCount} property.
+ * @param index Index of the channel
+ * @return total time, in microseconds
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native long getTotalTime (int index) throws PhidgetException;
+ /**
+ * Returns the timeout value, in microseconds. This value is used to set the time to wait without detecting a signal before reporting 0 Hz. The valid range is 0.1 - 100 seconds(100,000 - 100,000,000 microseconds).
+ * 0.1 timeout represents the lowest frequency that will be measurable.
+ * @param index Index of the channel
+ * @return timeout value
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getTimeout (int index) throws PhidgetException;
+ /**
+ * Sets the timeout value, in microseconds. This value is used to set the time to wait without detecting a signal before reporting 0 Hz. The valid range is 0.1 - 100 seconds(100,000 - 100,000,000 microseconds).
+ * 0.1 timeout represents the lowest frequency that will be measurable.
+ * @param index Index of the channel
+ * @param timeout new timeout value
+ * @throws PhidgetException If this Phidget is not opened and attached, the index is out of range or the the timeout value is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setTimeout (int index, int timeout) throws PhidgetException;
+ /**
+ * Returns the enabled state on the specified channel. When the channel is disabled, it will no longer register counts. TotalTime and TotalCount properties will not be incremented until
+ * the channel is re-enabled.
+ * @param index Index of the channel
+ * @return state
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getEnabled (int index) throws PhidgetException;
+ /**
+ * Gets the enabled state on the specified channel. When the channel is disabled, it will no longer register counts. TotalTime and TotalCount properties will not be incremented until
+ * the channel is re-enabled.
+ * @param index Index of the channel
+ * @param state new enabled state
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setEnabled (int index, boolean state) throws PhidgetException;
+ /**
+ * Gets the channel filter mode. This controls the type of signal that the Frequency Counter will respond to - either a zero-centered or a logic-level signal.
+ * <p>
+ * The possible values for type are {@link #PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_ZERO_CROSSING PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_ZERO_CROSSING},
+ * {@link #PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_LOGIC_LEVEL PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_LOGIC_LEVEL}, {@link #PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_UNKNOWN PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_UNKNOWN}
+ * <p>
+ * @param index Index of the channel
+ * @return filter type
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getFilter (int index) throws PhidgetException;
+ /**
+ * Sets the channel filter mode. This controls the type of signal that the Frequency Counter will respond to - either a zero-centered or a logic-level signal.
+ * <p>
+ * The possible values for type are {@link #PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_ZERO_CROSSING PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_ZERO_CROSSING},
+ * {@link #PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_LOGIC_LEVEL PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_LOGIC_LEVEL}, {@link #PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_UNKNOWN PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_UNKNOWN}
+ * <p>
+ * @param index Index of the channel
+ * @param type new filter type
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setFilter (int index, int type) throws PhidgetException;
+ /**
+ * Resets the {@link #getTotalCount(int) getTotalCount} and {@link #getTotalTime(int) getTotalTime} counters to 0 for the specified channel. For best performance, this should be called when the channel is disabled.
+ * @param index Index of the channel
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void reset (int index) throws PhidgetException;
+
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ enableFrequencyCounterCountEvents (b && frequencyCounterCountListeners.size () > 0);
+ }
+ /**
+ * Adds a count listener. The count handler is a method that will be called whenever some counts have been detected.
+ * This event will fire up to 31.25 times a second, depending on the pulse rate. The time is in microseconds and represents the amount
+ * of time in which the number of counts occured. This event can be used to calculate frequency independently of the phidget21 library frequency implementation.
+ * This event will fire with a count of 0 once, after the Timeout time has elapsed with no counts for a channel, to indicate 0 Hz.
+ * <p>
+ * There is no limit on the number of count handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.FrequencyCounterCountListener FrequencyCounterCountListener} interface
+ */
+ public final void addFrequencyCounterCountListener (FrequencyCounterCountListener l)
+ {
+ synchronized (frequencyCounterCountListeners)
+ {
+ frequencyCounterCountListeners.add (l);
+ enableFrequencyCounterCountEvents (true);
+ }} private LinkedList frequencyCounterCountListeners = new LinkedList ();
+ private long nativeFrequencyCounterCountHandler = 0;
+ public final void removeFrequencyCounterCountListener (FrequencyCounterCountListener l)
+ {
+ synchronized (frequencyCounterCountListeners)
+ {
+ frequencyCounterCountListeners.remove (l);
+ enableFrequencyCounterCountEvents (frequencyCounterCountListeners.size () > 0);
+ }} private void fireFrequencyCounterCount (FrequencyCounterCountEvent e)
+ {
+ synchronized (frequencyCounterCountListeners)
+ {
+ for (Iterator it = frequencyCounterCountListeners.iterator (); it.hasNext ();)
+ ((FrequencyCounterCountListener) it.next ()).frequencyCounterCounted (e);
+ }
+ }
+ private native void enableFrequencyCounterCountEvents (boolean b);
+}
diff --git a/Java/com/phidgets/GPSPhidget.java b/Java/com/phidgets/GPSPhidget.java
new file mode 100644
index 0000000..dde1400
--- /dev/null
+++ b/Java/com/phidgets/GPSPhidget.java
@@ -0,0 +1,151 @@
+
+/*
+ * Copyright 2011 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets;
+import java.util.Iterator;
+import java.util.LinkedList;
+import com.phidgets.event.*;
+import java.util.Calendar;
+ /**
+ * This class represents a Phidget GPS. All methods
+ * to manipulate the Phidget GPS are implemented in this class.
+ * <p>
+ *
+ * @author Phidgets Inc.
+ */
+public final class GPSPhidget extends Phidget
+{
+ public GPSPhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+
+ /**
+ * Returns the current latitude, in signed degrees format.
+ * @return Current latitude, in signed degrees format.
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the GPS is not plugged into the board.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ * If the latitude is not available, an EPHIDGET_UNKNOWNVAL exception is thrown.
+ */
+ public native double getLatitude () throws PhidgetException;
+ /**
+ * Returns the current longitude, in signed degrees format.
+ * @return Current longitude, in signed degrees format.
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the GPS is not plugged into the board.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ * If the longitude is not available, an EPHIDGET_UNKNOWNVAL exception is thrown.
+ */
+ public native double getLongitude () throws PhidgetException;
+ /**
+ * Returns the current altitude, in meters.
+ * @return Current altitude, in meters.
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the GPS is not plugged into the board.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ * If the altitude is not available, an EPHIDGET_UNKNOWNVAL exception is thrown.
+ */
+ public native double getAltitude () throws PhidgetException;
+ /**
+ * Returns the current heading, in degrees - compass bearing format. Heading is only accurate if the GPS is moving, and it represents
+ * a heading over time, and not the actual direction the PhidgetGPS is pointing.
+ * exception is thrown.
+ * @return Heading in degrees(compass bearing format).
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the GPS is not plugged into the board.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ * If the heading is not available, an EPHIDGET_UNKNOWNVAL.
+ */
+ public native double getHeading () throws PhidgetException;
+ /**
+ * Returns the current velocity, in km/h. Velocity is only accurate if the PhidgetGPS is moving.
+ * @return Velocity in km/h.
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the GPS is not plugged into the board.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ * If the velocity is not available, an EPHIDGET_UNKNOWNVAL exception is thrown.
+ */
+ public native double getVelocity () throws PhidgetException;
+ /**
+ * Returns the current GPS date and time, in UTC. The time is updated 10 times a second and is accurate to within at least 500ms when {@link #getPositionFixStatus getPositionFixStatus} is true.
+ * @return Current GPS date and time.
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the GPS is not plugged into the board.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ * If the date or time are not available, an EPHIDGET_UNKNOWNVAL exception is thrown.
+ */
+ public native Calendar getDateAndTime () throws PhidgetException;
+ /**
+ * Returns the current position fix status. If true, all of the above properties will be available. Time and date may or may not be available, but they can only be trusted
+ * as accurate when the PositionFixStatus is true.
+ * @return Current position fix status.
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the GPS is not plugged into the board.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ * If false, the {@link #getHeading getHeading} / {@link #getVelocity getVelocity} will throw an EPHIDGET_UNKNOWN exception.
+ */
+ public native boolean getPositionFixStatus () throws PhidgetException;
+
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ enableGPSPositionFixStatusChangeEvents (b && gpsPositionFixStatusChangeListeners.size () > 0);
+ enableGPSPositionChangeEvents (b && gpsPositionChangeListeners.size () > 0);
+ }
+ /**
+ * Adds a position fix status change listener. The position fix status change handler is a method that will be called when the position fix status changes.
+ * <p>
+ * There is no limit on the number of position fix status change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.GPSPositionFixStatusChangeListener GPSPositionFixStatusChangeListener} interface
+ */
+ public final void addGPSPositionFixStatusChangeListener (GPSPositionFixStatusChangeListener l)
+ {
+ synchronized (gpsPositionFixStatusChangeListeners)
+ {
+ gpsPositionFixStatusChangeListeners.add (l);
+ enableGPSPositionFixStatusChangeEvents (true);
+ }} private LinkedList gpsPositionFixStatusChangeListeners = new LinkedList ();
+ private long nativeGPSPositionFixStatusChangeHandler = 0;
+ public final void removeGPSPositionFixStatusChangeListener (GPSPositionFixStatusChangeListener l)
+ {
+ synchronized (gpsPositionFixStatusChangeListeners)
+ {
+ gpsPositionFixStatusChangeListeners.remove (l);
+ enableGPSPositionFixStatusChangeEvents (gpsPositionFixStatusChangeListeners.size () > 0);
+ }} private void fireGPSPositionFixStatusChange (GPSPositionFixStatusChangeEvent e)
+ {
+ synchronized (gpsPositionFixStatusChangeListeners)
+ {
+ for (Iterator it = gpsPositionFixStatusChangeListeners.iterator (); it.hasNext ();)
+ ((GPSPositionFixStatusChangeListener) it.next ()).gpsPositionFixStatusChanged (e);
+ }
+ }
+ private native void enableGPSPositionFixStatusChangeEvents (boolean b);
+ /**
+ * Adds a position change listener. The position change handler is a method that will be called when the position changes.
+ * <p>
+ * There is no limit on the number of position change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.GPSPositionChangeListener GPSPositionChangeListener} interface
+ */
+ public final void addGPSPositionChangeListener (GPSPositionChangeListener l)
+ {
+ synchronized (gpsPositionChangeListeners)
+ {
+ gpsPositionChangeListeners.add (l);
+ enableGPSPositionChangeEvents (true);
+ }} private LinkedList gpsPositionChangeListeners = new LinkedList ();
+ private long nativeGPSPositionChangeHandler = 0;
+ public final void removeGPSPositionChangeListener (GPSPositionChangeListener l)
+ {
+ synchronized (gpsPositionChangeListeners)
+ {
+ gpsPositionChangeListeners.remove (l);
+ enableGPSPositionChangeEvents (gpsPositionChangeListeners.size () > 0);
+ }} private void fireGPSPositionChange (GPSPositionChangeEvent e)
+ {
+ synchronized (gpsPositionChangeListeners)
+ {
+ for (Iterator it = gpsPositionChangeListeners.iterator (); it.hasNext ();)
+ ((GPSPositionChangeListener) it.next ()).gpsPositionChanged (e);
+ }
+ }
+ private native void enableGPSPositionChangeEvents (boolean b);
+}
diff --git a/Java/com/phidgets/IRCode.java b/Java/com/phidgets/IRCode.java
new file mode 100644
index 0000000..51b014c
--- /dev/null
+++ b/Java/com/phidgets/IRCode.java
@@ -0,0 +1,93 @@
+
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets;
+/**
+ * This class represents an IR Code.
+ *
+ * @author Phidget Inc.
+ */
+public final class IRCode
+{
+ private short[] data;
+ /**
+ * IR code data. This is MSB first, right justified. This is really an (unsigned) Byte array,
+ * so values range from 0-255. We have to use shorts because Java doesn't support unsigned types.
+ */
+ public short[] getData()
+ {
+ return data;
+ }
+ private int bitCount;
+ /**
+ * Data bits. This is important because many codes use a number of bits that doesn't line up with byte (8-bit) borders.
+ */
+ public int getBitCount()
+ {
+ return bitCount;
+ }
+
+ /**
+ * Creates a new IR Code from a string.
+ * @param code the IR code
+ * @param bitCount the code length in bits.
+ */
+ public IRCode(String code, int bitCount)
+ {
+ this.data = HexToData(code);
+ this.bitCount = bitCount;
+ }
+
+ /**
+ * Creates a new IR Code from a data array.
+ * @param data the IR code data
+ * @param bitCount the code length in bits.
+ */
+ public IRCode(short[] data, int bitCount)
+ {
+ int length = (bitCount / 8) + ((bitCount % 8 > 0) ? 1 : 0);
+
+ this.data = new short[length];
+ for (int i = 0; i < length; i++)
+ this.data[i] = data[i];
+
+ this.bitCount = bitCount;
+ }
+
+ private short[] HexToData(String hexString)
+ {
+ if (hexString == null)
+ return null;
+
+ if (hexString.startsWith("0x")){
+ hexString = hexString.substring(2);
+ }
+
+ if (hexString.length() % 2 == 1)
+ hexString = '0' + hexString; // Up to you whether to pad the first or last byte
+
+ short[] data = new short[hexString.length() / 2];
+
+ for (int i = 0; i < data.length; i++){
+ data[i] = (short) Integer.parseInt(hexString.substring(i * 2, (i * 2) + 2), 16);
+ }
+
+ return data;
+ }
+ private char[] hexlookup = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
+ /**
+ * String representation of the IR code.
+ */
+ public String toString()
+ {
+ String out = "";
+ for(int i=0;i<data.length;i++)
+ {
+ out = out + (hexlookup[data[i] / 16]);
+ out = out + (hexlookup[data[i] % 16]);
+ }
+ return out;
+ }
+}
diff --git a/Java/com/phidgets/IRCodeInfo.java b/Java/com/phidgets/IRCodeInfo.java
new file mode 100644
index 0000000..8c67b10
--- /dev/null
+++ b/Java/com/phidgets/IRCodeInfo.java
@@ -0,0 +1,360 @@
+
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets;
+/**
+ * This class represents IR Code Properties needed for transmit.
+ *
+ * @author Phidget Inc.
+ */
+public final class IRCodeInfo
+{
+ /**
+ * Unknown encoding. This is used with {@link #getEncoding getEncoding}
+ */
+ public static final int ENCODING_UNKNOWN = 1;
+ /**
+ * Space encoding. This is used with {@link #getEncoding getEncoding}
+ */
+ public static final int ENCODING_SPACE = 2;
+ /**
+ * Pulse encoding. This is used with {@link #getEncoding getEncoding}
+ */
+ public static final int ENCODING_PULSE = 3;
+ /**
+ * BiPhase encoding. This is used with {@link #getEncoding getEncoding}
+ */
+ public static final int ENCODING_BIPHASE = 4;
+ /**
+ * RC5 encoding. This is used with {@link #getEncoding getEncoding}
+ */
+ public static final int ENCODING_RC5 = 5;
+ /**
+ * RC6 encoding. This is used with {@link #getEncoding getEncoding}
+ */
+ public static final int ENCODING_RC6 = 6;
+
+ /**
+ * Unknown length. This is used with {@link #getLength getLength}
+ */
+ public static final int LENGTH_UNKNOWN = 1;
+ /**
+ * Constant length. This is used with {@link #getLength getLength}
+ */
+ public static final int LENGTH_CONSTANT = 2;
+ /**
+ * Variable length. This is used with {@link #getLength getLength}
+ */
+ public static final int LENGTH_VARIABLE = 3;
+
+ private int encoding=ENCODING_UNKNOWN, length=LENGTH_UNKNOWN, bitCount=0, gap=0, trail=0, minRepeat=1, carrierFrequency=38000, dutyCycle=33;
+ private int[] header=null, one=new int[] {0,0}, zero=new int[] {0,0}, repeat=null;
+ private IRCode toggleMask=null;
+
+ /**
+ * Creates a new IR Code Info object.
+ * @param bitCount the bit count
+ */
+ public IRCodeInfo(int bitCount) throws PhidgetException
+ {
+ this.bitCount = bitCount;
+ }
+
+ /**
+ * Creates a new IR Code Info object.
+ * @param encoding the encoding - one of {@link #ENCODING_SPACE ENCODING_SPACE},
+ * {@link #ENCODING_PULSE ENCODING_PULSE}, {@link #ENCODING_BIPHASE ENCODING_BIPHASE},
+ * {@link #ENCODING_RC5 ENCODING_RC5} or {@link #ENCODING_RC6 ENCODING_RC6}
+ * @param bitCount the bit count
+ */
+ public IRCodeInfo(int encoding, int bitCount) throws PhidgetException
+ {
+ this.encoding = encoding;
+ this.bitCount = bitCount;
+ }
+
+ /**
+ * Creates a new IR Code Info object.
+ * @param encoding the encoding - one of {@link #ENCODING_SPACE ENCODING_SPACE},
+ * {@link #ENCODING_PULSE ENCODING_PULSE}, {@link #ENCODING_BIPHASE ENCODING_BIPHASE},
+ * {@link #ENCODING_RC5 ENCODING_RC5} or {@link #ENCODING_RC6 ENCODING_RC6}
+ * @param bitCount the bit count
+ * @param header the header (pulse,space)
+ * @param zero the zero (pulse, space)
+ * @param one the one (pulse, space)
+ * @param trail the trailing pulse
+ * @param gap the trailing gap
+ */
+ public IRCodeInfo(int encoding, int bitCount, int[] header, int[] zero, int[] one, int trail, int gap) throws PhidgetException
+ {
+ this.encoding = encoding;
+ this.bitCount = bitCount;
+
+ if(header != null)
+ {
+ if(header.length != 2)
+ throw new PhidgetException(PhidgetException.EPHIDGET_INVALIDARG, "header must have 2 elements");
+ this.header = new int[] { header[0], header[1] };
+ }
+
+ if(zero==null || zero.length != 2)
+ throw new PhidgetException(PhidgetException.EPHIDGET_INVALIDARG, "zero must have 2 elements");
+ this.zero = new int[] { zero[0], zero[1] };
+
+ if(one==null || one.length != 2)
+ throw new PhidgetException(PhidgetException.EPHIDGET_INVALIDARG, "one must have 2 elements");
+ this.one = new int[] { one[0], one[1] };
+
+ this.trail = trail;
+ this.gap = gap;
+ }
+
+ /**
+ * Creates a new IR Code Info object.
+ * @param encoding the encoding - one of {@link #ENCODING_SPACE ENCODING_SPACE},
+ * {@link #ENCODING_PULSE ENCODING_PULSE}, {@link #ENCODING_BIPHASE ENCODING_BIPHASE},
+ * {@link #ENCODING_RC5 ENCODING_RC5} or {@link #ENCODING_RC6 ENCODING_RC6}
+ * @param bitCount the bit count
+ * @param header the header (pulse,space)
+ * @param zero the zero (pulse, space)
+ * @param one the one (pulse, space)
+ * @param trail the trailing pulse
+ * @param gap the trailing gap
+ * @param repeat the special repeat code
+ */
+ public IRCodeInfo(int encoding, int bitCount, int[] header, int[] zero, int[] one, int trail, int gap, int[] repeat) throws PhidgetException
+ {
+ this.encoding = encoding;
+ this.bitCount = bitCount;
+
+ if(header != null)
+ {
+ if(header.length != 2)
+ throw new PhidgetException(PhidgetException.EPHIDGET_INVALIDARG, "header must have 2 elements");
+ this.header = new int[] { header[0], header[1] };
+ }
+
+ if(zero==null || zero.length != 2)
+ throw new PhidgetException(PhidgetException.EPHIDGET_INVALIDARG, "zero must have 2 elements");
+ this.zero = new int[] { zero[0], zero[1] };
+
+ if(one==null || one.length != 2)
+ throw new PhidgetException(PhidgetException.EPHIDGET_INVALIDARG, "one must have 2 elements");
+ this.one = new int[] { one[0], one[1] };
+
+ this.trail = trail;
+ this.gap = gap;
+
+ if(repeat != null)
+ {
+ this.repeat = new int[repeat.length];
+ for(int i=0; i<repeat.length; i++)
+ this.repeat[i] = repeat[i];
+ }
+ }
+
+ /**
+ * Creates a new IR Code Info object.
+ * @param encoding the encoding - one of {@link #ENCODING_SPACE ENCODING_SPACE},
+ * {@link #ENCODING_PULSE ENCODING_PULSE}, {@link #ENCODING_BIPHASE ENCODING_BIPHASE},
+ * {@link #ENCODING_RC5 ENCODING_RC5} or {@link #ENCODING_RC6 ENCODING_RC6}
+ * @param bitCount the bit count
+ * @param header the header (pulse,space)
+ * @param zero the zero (pulse, space)
+ * @param one the one (pulse, space)
+ * @param trail the trailing pulse
+ * @param gap the trailing gap
+ * @param repeat the special repeat code
+ * @param minRepeat the minimum number of times to repeat the code
+ * @param toggleMask the bits to toggle when minRepeat is > 1
+ * @param length the length style - one of {@link #LENGTH_CONSTANT LENGTH_CONSTANT} or {@link #LENGTH_VARIABLE LENGTH_VARIABLE}
+ * @param carrierFrequency the carrier frequency in kHz
+ * @param dutyCycle the duty cycle in percent
+ */
+ public IRCodeInfo(
+ int encoding,
+ int bitCount,
+ int[] header,
+ int[] zero,
+ int[] one,
+ int trail,
+ int gap,
+ int[] repeat,
+ int minRepeat,
+ IRCode toggleMask,
+ int length,
+ int carrierFrequency,
+ int dutyCycle) throws PhidgetException
+ {
+ this.encoding = encoding;
+ this.bitCount = bitCount;
+
+ if(header != null)
+ {
+ if(header.length != 2)
+ throw new PhidgetException(PhidgetException.EPHIDGET_INVALIDARG, "header must have 2 elements");
+ this.header = new int[] { header[0], header[1] };
+ }
+
+ if(zero==null || zero.length != 2)
+ throw new PhidgetException(PhidgetException.EPHIDGET_INVALIDARG, "zero must have 2 elements");
+ this.zero = new int[] { zero[0], zero[1] };
+
+ if(one==null || one.length != 2)
+ throw new PhidgetException(PhidgetException.EPHIDGET_INVALIDARG, "one must have 2 elements");
+ this.one = new int[] { one[0], one[1] };
+
+ this.trail = trail;
+ this.gap = gap;
+
+ if(repeat != null)
+ {
+ this.repeat = new int[repeat.length];
+ for(int i=0; i<repeat.length; i++)
+ this.repeat[i] = repeat[i];
+ }
+
+ this.minRepeat = minRepeat;
+
+ if(toggleMask != null)
+ toggleMask = new IRCode(toggleMask.getData(), toggleMask.getBitCount());
+
+ this.length = length;
+ this.carrierFrequency = carrierFrequency;
+ this.dutyCycle = dutyCycle;
+ }
+
+ /**
+ * Returns the encoding.
+ * @return encoding
+ */
+ public int getEncoding()
+ {
+ return encoding;
+ }
+ /**
+ * Returns the length style.
+ * @return length style
+ */
+ public int getLength()
+ {
+ return length;
+ }
+ /**
+ * Returns the bit count.
+ * @return bit count
+ */
+ public int getBitCount()
+ {
+ return bitCount;
+ }
+ /**
+ * Returns the gap.
+ * @return gap
+ */
+ public int getGap()
+ {
+ return gap;
+ }
+ /**
+ * Returns the trail.
+ * @return trail
+ */
+ public int getTrail()
+ {
+ return trail;
+ }
+ /**
+ * Returns the min repeat.
+ * @return min repeat
+ */
+ public int getMinRepeat()
+ {
+ return minRepeat;
+ }
+ /**
+ * Returns the carrier frequency.
+ * @return carrier frequency
+ */
+ public int getCarrierFrequency()
+ {
+ return carrierFrequency;
+ }
+ /**
+ * Returns the duty cycle.
+ * @return duty cycle
+ */
+ public int getDutyCycle()
+ {
+ return dutyCycle;
+ }
+ /**
+ * Returns the header.
+ * @return header
+ */
+ public int[] getHeader()
+ {
+ return header;
+ }
+ /**
+ * Returns the zero.
+ * @return zero
+ */
+ public int[] getZero()
+ {
+ return zero;
+ }
+ /**
+ * Returns the one.
+ * @return one
+ */
+ public int[] getOne()
+ {
+ return one;
+ }
+ /**
+ * Returns the repeat code.
+ * @return repeat code
+ */
+ public int[] getRepeat()
+ {
+ return repeat;
+ }
+ /**
+ * Returns the toggle mask.
+ * @return toggle mask
+ */
+ public IRCode getToggleMask()
+ {
+ return toggleMask;
+ }
+
+
+ public String toString()
+ {
+ String out = "";
+ out = out + " Encoding: " + encoding + "\n";
+ out = out + " Zero: " + zero[0] + ", " + zero[1] + "\n";
+ out = out + " One: " + one[0] + ", " + one[1] + "\n";
+ if (header != null)
+ {
+ if (header[0] != 0)
+ out = out + " Header: " + header[0] + ", " + header[1] + "\n";
+ }
+
+ if (trail != 0)
+ out = out + " Trail: " + trail + "\n";
+ if (gap != 0)
+ out = out + " Gap: " + gap + "\n";
+ if (repeat != null)
+ {
+ out = out + " Repeat: ";
+ for(int i=0;i<repeat.length;i++)
+ out = out + repeat[i] + ", ";
+ out = out + "\n";
+ }
+ return out;
+ }
+}
diff --git a/Java/com/phidgets/IRLearnedCode.java b/Java/com/phidgets/IRLearnedCode.java
new file mode 100644
index 0000000..4949d07
--- /dev/null
+++ b/Java/com/phidgets/IRLearnedCode.java
@@ -0,0 +1,51 @@
+
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets;
+/**
+ * This class represents an IR Learned Code. This is used in the Learn event.
+ *
+ * @author Phidget Inc.
+ */
+public final class IRLearnedCode
+{
+ private IRCode code;
+ private IRCodeInfo codeInfo;
+
+ /**
+ * Creates a new IR Learned Code. This is used in the Learn event.
+ * @param code the IR code
+ * @param codeInfo the code parameters
+ */
+ public IRLearnedCode(IRCode code, IRCodeInfo codeInfo)
+ {
+ this.code=code;
+ this.codeInfo=codeInfo;
+ }
+
+ /**
+ * Returns the code.
+ * @return code
+ */
+ public IRCode getCode()
+ {
+ return code;
+ }
+
+ /**
+ * Returns the code parameters.
+ * @return code parameters
+ */
+ public IRCodeInfo getCodeInfo()
+ {
+ return codeInfo;
+ }
+
+ public String toString()
+ {
+ return code.toString() + " (" + code.getBitCount() + "-bit)\n" + codeInfo.toString();
+ }
+}
+
diff --git a/Java/com/phidgets/IRPhidget.java b/Java/com/phidgets/IRPhidget.java
new file mode 100644
index 0000000..8418d74
--- /dev/null
+++ b/Java/com/phidgets/IRPhidget.java
@@ -0,0 +1,239 @@
+
+/*
+ * Copyright 2010 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 IR. All methods
+ * to send and receive IR data are implemented in this class.
+ * <p>
+ * The Phidget IR Receiver-Transmitter can send and receive Consumer-IR signals. Ability to learn and re-transmit codes,
+ * as well as low-level access to raw data, is provided.
+ *
+ * @author Phidgets Inc.
+ */
+public final class IRPhidget extends Phidget
+{
+ public IRPhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+
+ /**
+ * Represents a long space (greater then 327,670 microseconds) in raw data.
+ * This can be considered a period of no IR activity. This is used with {@link #readRaw readRaw}
+ */
+ public static final int RAWDATA_LONGSPACE = 0x7fffffff;
+
+ /**
+ * Transmits a code.
+ * @param code the code to transmit
+ * @param codeInfo the code specification
+ * @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 transmit (IRCode code, IRCodeInfo codeInfo) throws PhidgetException;
+ /**
+ * Transmits a repeat. This needs to be called within the gap time of a transmit to be meaningful.
+ * @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 transmitRepeat () throws PhidgetException;
+ /**
+ * Transmits raw data.
+ * @param data data in microseconds, must start and end with a pulse
+ * @param offset offset in the data array to start transmitting
+ * @param count number of elements of data to transmit
+ * @param gap gap size in microseconds
+ * @param carrierFrequency carrier frequency in kHz
+ * @param dutyCycle duty cycle in percent
+ * @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 transmitRaw (int[]data, int offset, int count, int gap, int carrierFrequency, int dutyCycle) throws PhidgetException;
+ /**
+ * Transmits raw data.
+ * @param data data in microseconds, must start and end with a pulse
+ * @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 final void transmitRaw (int[]data) throws PhidgetException
+ {
+ transmitRaw (data, 0, data.length, 0, 0, 0);
+ }
+ /**
+ * Transmits raw data.
+ * @param data data in microseconds, must start and end with a pulse
+ * @param gap gap size in microseconds
+ * @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 final void transmitRaw (int[]data, int gap) throws PhidgetException
+ {
+ transmitRaw (data, 0, data.length, gap, 0, 0);
+ }
+ /**
+ * Transmits raw data.
+ * @param data data in microseconds, must start and end with a pulse
+ * @param offset offset in the data array to start transmitting
+ * @param count number of elements of data to transmit
+ * @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 final void transmitRaw (int[]data, int offset, int count) throws PhidgetException
+ {
+ transmitRaw (data, offset, count, 0, 0, 0);
+ }
+ /**
+ * Transmits raw data.
+ * @param data data in microseconds, must start and end with a pulse
+ * @param offset offset in the data array to start transmitting
+ * @param count number of elements of data to transmit
+ * @param gap gap size in microseconds
+ * @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 final void transmitRaw (int[]data, int offset, int count, int gap) throws PhidgetException
+ {
+ transmitRaw (data, offset, count, gap, 0, 0);
+ }
+ /**
+ * Reads raw data. Use {@link #RAWDATA_LONGSPACE RAWDATA_LONGSPACE} to detect gaps in IR data.
+ * @param buffer array into which data will be read.
+ * @param offset offset in data to start writing
+ * @param count maximum ammount of data to read
+ * @return ammount of data read
+ * @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 int readRaw (int[]buffer, int offset, int count) throws PhidgetException;
+ /**
+ * Reads raw data. Use {@link #RAWDATA_LONGSPACE RAWDATA_LONGSPACE} to detect gaps in IR data.
+ * @param buffer array into which data will be read.
+ * @return ammount of data read
+ * @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 final int readRaw (int[]buffer) throws PhidgetException
+ {
+ return readRaw (buffer, 0, buffer.length);
+ }
+ /**
+ * Returns the last recieved code. This is updated right after the code event returns.
+ * @return last code
+ * @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 IRCode getLastCode () throws PhidgetException;
+ /**
+ * Returns the last learned code. This is updated right after the learn event returns.
+ * @return last learned code
+ * @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 IRLearnedCode getLastLearnedCode () throws PhidgetException;
+
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ enableCodeEvents (b && codeListeners.size () > 0);
+ enableLearnEvents (b && learnListeners.size () > 0);
+ enableRawDataEvents (b && rawDataListeners.size () > 0);
+ }
+ /**
+ * Adds a code listener. The code handler is a method that will be called when a new code is
+ seen by the reader. The event is fired on each code, including repetitions.
+ * <p>
+ * There is no limit on the number of code handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.CodeListener CodeListener} interface
+ */
+ public final void addCodeListener (CodeListener l)
+ {
+ synchronized (codeListeners)
+ {
+ codeListeners.add (l);
+ enableCodeEvents (true);
+ }} private LinkedList codeListeners = new LinkedList ();
+ private long nativeCodeHandler = 0;
+ public final void removeCodeListener (CodeListener l)
+ {
+ synchronized (codeListeners)
+ {
+ codeListeners.remove (l);
+ enableCodeEvents (codeListeners.size () > 0);
+ }} private void fireCode (CodeEvent e)
+ {
+ synchronized (codeListeners)
+ {
+ for (Iterator it = codeListeners.iterator (); it.hasNext ();)
+ ((CodeListener) it.next ()).code (e);
+ }
+ }
+ private native void enableCodeEvents (boolean b);
+ /**
+ * Adds a code learn listener. The learn handler is a method that will be called when a new code is
+ learned by the reader. This requires that the code be repeated several times.
+ * <p>
+ * There is no limit on the number of learn handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.LearnListener LearnListener} interface
+ */
+ public final void addLearnListener (LearnListener l)
+ {
+ synchronized (learnListeners)
+ {
+ learnListeners.add (l);
+ enableLearnEvents (true);
+ }} private LinkedList learnListeners = new LinkedList ();
+ private long nativeLearnHandler = 0;
+ public final void removeLearnListener (LearnListener l)
+ {
+ synchronized (learnListeners)
+ {
+ learnListeners.remove (l);
+ enableLearnEvents (learnListeners.size () > 0);
+ }} private void fireLearn (LearnEvent e)
+ {
+ synchronized (learnListeners)
+ {
+ for (Iterator it = learnListeners.iterator (); it.hasNext ();)
+ ((LearnListener) it.next ()).learn (e);
+ }
+ }
+ private native void enableLearnEvents (boolean b);
+ /**
+ * Adds a rawData listener. The rawData handler is a method that will be called when a raw IR data is recieved.
+ * <p>
+ * There is no limit on the number of rawData handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.RawDataListener RawDataListener} interface
+ */
+ public final void addRawDataListener (RawDataListener l)
+ {
+ synchronized (rawDataListeners)
+ {
+ rawDataListeners.add (l);
+ enableRawDataEvents (true);
+ }} private LinkedList rawDataListeners = new LinkedList ();
+ private long nativeRawDataHandler = 0;
+ public final void removeRawDataListener (RawDataListener l)
+ {
+ synchronized (rawDataListeners)
+ {
+ rawDataListeners.remove (l);
+ enableRawDataEvents (rawDataListeners.size () > 0);
+ }} private void fireRawData (RawDataEvent e)
+ {
+ synchronized (rawDataListeners)
+ {
+ for (Iterator it = rawDataListeners.iterator (); it.hasNext ();)
+ ((RawDataListener) it.next ()).rawData (e);
+ }
+ }
+ private native void enableRawDataEvents (boolean b);
+}
diff --git a/Java/com/phidgets/InterfaceKitPhidget.java b/Java/com/phidgets/InterfaceKitPhidget.java
new file mode 100644
index 0000000..d7aed29
--- /dev/null
+++ b/Java/com/phidgets/InterfaceKitPhidget.java
@@ -0,0 +1,346 @@
+/*
+ * 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 Interface Kit. All methods
+ * to read and write data to and from an Interface Kit are implemented in this class.
+ * <p>
+ * There are many types of Interface Kits, but each is simply a collection of 0 or more
+ * digital inputs, digital outpus and analog sensors. Inputs can be read and outputs can be set,
+ * and event handlers can be set for each of these.
+ * <p>
+ * See your hardware documentation for more information on the I/O specific to your Phidget.
+ *
+ * @author Phidgets Inc.
+ */
+public final class InterfaceKitPhidget extends Phidget
+{
+ /**
+ * Class Constructor. Calling this opens a connection to the phidget21 C library creates
+ * an internal handle for this Phidget, ready to call open on.
+ *
+ * @throws PhidgetException If there was a problem connecting to phidget21 or creating
+ * the internal handle.
+ */
+ public InterfaceKitPhidget() throws PhidgetException {
+ super(create());
+ }
+
+ private static native long create() throws PhidgetException;
+
+ /**
+ * Returns the number of digital outputs on this Interface Kit. Not all interface kits
+ * have the same number of digital outputs, and some don't have any digital outputs at all.
+ *
+ * @return Number of digital outputs
+ * @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 int getOutputCount() throws PhidgetException;
+
+ /**
+ * Returns the number of ditigal inputs on this Interface Kit. Not all interface kits
+ * have the same number of digital inputs, and some don't have any digital inputs at all.
+ *
+ * @return Number of digital inputs
+ * @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 int getInputCount() throws PhidgetException;
+
+ /**
+ * Returns the number of analog inputs on the Interface Kit. Not all interface kits
+ * have the same number of analog inputs, and some don't have any analog inputs at all.
+ *
+ * @return Number of analog inputs
+ * @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 int getSensorCount() throws PhidgetException;
+
+ /**
+ * Returns the minimum data rate for a sensor, in milliseconds.
+ *
+ * @param index Index of the input
+ * @return minimum data rate
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getDataRateMin(int index) throws PhidgetException;
+
+ /**
+ * Returns the maximum data rate for a sensor, in milliseconds.
+ *
+ * @param index Index of the input
+ * @return maximum data rate
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getDataRateMax(int index) throws PhidgetException;
+
+ /**
+ * Returns the state of a digital input. Digital inputs read True where they are activated and false
+ * when they are in their default state.
+ * <p>
+ * Be sure to check {@link #getInputCount() getInputCount} first if you are unsure as to the number of inputs, so as not to
+ * set an Index that is out of range.
+ *
+ * @param index Index of the input
+ * @return State of the input
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getInputState(int index) throws PhidgetException;
+
+ /**
+ * Returns the state of a digital output. Depending on the Phidget, this value may be either the value that you last
+ * wrote out to the Phidget, or the value that the Phidget last returned. This is because some Phidgets return their output state
+ * and others do not. This means that with some devices, reading the output
+ * state of a pin directly after setting it, may not return the value that you just set.
+ * <p>
+ * Be sure to check {@link #getOutputCount() getOutputCount} first if you are unsure as to the number of outputs, so as not to
+ * attempt to get an Index that is out of range.
+ *
+ * @param index Index of the output
+ * @return State of the output
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getOutputState(int index) throws PhidgetException;
+
+ /**
+ * Returns the value of a analog input.
+ * The analog inputs are where analog sensors are attached on the InterfaceKit 8/8/8.
+ * On the Linear and Circular touch sensor Phidgets, analog input 0 represents position
+ * on the slider.
+ * <p>
+ * The valid range is 0-1000. In the case of a sensor, this value can be converted to an actual
+ * sensor value using the formulas provided here: http://www.phidgets.com/documentation/Sensors.pdf
+ *
+ * @param index Index of the sensor
+ * @return Sensor value
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getSensorValue(int index) throws PhidgetException;
+
+ /**
+ * Returns the raw value of a analog input. This is a more accurate version of {@link #getSensorValue(int) getSensorValue}.
+ * The valid range is 0-4095. Note however that the analog outputs on the Interface Kit 8/8/8 are only 10-bit values
+ * and this value represents an oversampling to 12-bit.
+ *
+ * @param index Index of the sensor
+ * @return Sensor value
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getSensorRawValue(int index) throws PhidgetException;
+
+ /**
+ * Returns the change trigger for an analog input. This is the ammount that an inputs must change
+ * between successive SensorChangeEvents. This is based on the 0-1000 range provided by getSensorValue.
+ * This value is by default set to 10 for most Interface Kits with analog inputs.
+ *
+ * @param index Index of the sensor
+ * @return Trigger value
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getSensorChangeTrigger(int index)
+ throws PhidgetException;
+
+ /**
+ * Returns the data rate for a sensor, in milliseconds.
+ *
+ * @param index Index of the sensor
+ * @return data rate
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getDataRate(int index)
+ throws PhidgetException;
+
+ /**
+ * Gets the ratiometric state for the analog sensors
+ *
+ * @return state State
+ * @throws PhidgetException If this Phidget is not opened and attached, or if this phidget does not support ratiometric.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getRatiometric()
+ throws PhidgetException;
+
+ /**
+ * Sets the state of a digital output. Setting this to true will activate the output, False is the default state.
+ *
+ * @param index Index of the output
+ * @param newVal State to set the output to
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setOutputState(int index, boolean newVal)
+ throws PhidgetException;
+
+ /**
+ * Sets the change trigger for an analog input. This is the ammount that an inputs must change
+ * between successive SensorChangeEvents. This is based on the 0-1000 range provided by getSensorValue.
+ * This value is by default set to 10 for most Interface Kits with analog inputs.
+ *
+ * @param index Input
+ * @param newVal Value
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setSensorChangeTrigger(int index, int newVal)
+ throws PhidgetException;
+
+ /**
+ * Sets the data rate of a sensor, in milliseconds.
+ *
+ * @param index Input
+ * @param newVal data rate
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setDataRate(int index, int newVal)
+ throws PhidgetException;
+
+ /**
+ * Sets the ratiometric state for the analog inputs. The default is for ratiometric to be set on and this
+ * is appropriate for most sensors.
+ *
+ * @param state State
+ * @throws PhidgetException If this Phidget is not opened and attached, or if this Phidget does not support ratiometric
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setRatiometric(boolean state)
+ throws PhidgetException;
+
+ private final void enableDeviceSpecificEvents(boolean b) {
+ enableInputChangeEvents(b && inputChangeListeners.size() > 0);
+ enableOutputChangeEvents(b && outputChangeListeners.size() > 0);
+ enableSensorChangeEvents(b && sensorChangeListeners.size() > 0);
+ }
+
+ private LinkedList inputChangeListeners = new LinkedList();
+ private long nativeInputChangeHandler = 0;
+
+ /**
+ * Adds an input change listener. The input change handler is a method that will be called when an input on this
+ * Interface Kit has changed.
+ * <p>
+ * There is no limit on the number of input change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.InputChangeListener InputChangeListener} interface
+ */
+ public final void addInputChangeListener(InputChangeListener l) {
+ synchronized (inputChangeListeners) {
+ inputChangeListeners.add(l);
+ enableInputChangeEvents(true);
+ }
+ }
+
+ /**
+ * Removes an input change listener. This will remove a previously added input change listener.
+ */
+ public final void removeInputChangeListener(InputChangeListener l) {
+ synchronized (inputChangeListeners) {
+ inputChangeListeners.remove(l);
+ enableInputChangeEvents(inputChangeListeners.size() >
+ 0);
+ }
+ }
+ private void fireInputChange(InputChangeEvent e) {
+ synchronized (inputChangeListeners) {
+ for (Iterator it = inputChangeListeners.iterator();
+ it.hasNext(); )
+ ((InputChangeListener)it.next()).inputChanged(
+ e);
+ }
+ }
+ private native void enableInputChangeEvents(boolean b);
+
+ private LinkedList outputChangeListeners = new LinkedList();
+ private long nativeOutputChangeHandler = 0;
+
+ /**
+ * Adds an output change listener. The output change handler is a method that will be called when an output on this
+ * Interface Kit has changed.
+ * <p>
+ * There is no limit on the number of output change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.OutputChangeListener OutputChangeListener} interface
+ */
+ public final void addOutputChangeListener(OutputChangeListener l) {
+ synchronized (outputChangeListeners) {
+ outputChangeListeners.add(l);
+ enableOutputChangeEvents(true);
+ }
+ }
+
+ /**
+ * Removes an output change listener. This will remove a previously added output change listener.
+ */
+ public final void removeOutputChangeListener(OutputChangeListener l) {
+ synchronized (outputChangeListeners) {
+ outputChangeListeners.remove(l);
+ enableOutputChangeEvents(outputChangeListeners.size()
+ > 0);
+ }
+ }
+ private void fireOutputChange(OutputChangeEvent e) {
+ synchronized (outputChangeListeners) {
+ for (Iterator it = outputChangeListeners.iterator();
+ it.hasNext(); )
+ ((OutputChangeListener)it.next())
+ .outputChanged(e);
+ }
+ }
+ private native void enableOutputChangeEvents(boolean b);
+
+ private LinkedList sensorChangeListeners = new LinkedList();
+ private long nativeSensorChangeHandler = 0;
+
+ /**
+ * Adds a sensor change listener. The sensor change handler is a method that will be called when a sensor on this
+ * Interface Kit has changed by at least the {@link #getSensorChangeTrigger(int) Trigger} that has been set for this sensor.
+ * <p>
+ * There is no limit on the number of sensor change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.SensorChangeListener SensorChangeListener} interface
+ */
+ public final void addSensorChangeListener(SensorChangeListener l) {
+ synchronized (sensorChangeListeners) {
+ sensorChangeListeners.add(l);
+ enableSensorChangeEvents(true);
+ }
+ }
+
+ /**
+ * Removes a sensor change listener. This will remove a previously added sensor change listener.
+ */
+ public final void removeSensorChangeListener(SensorChangeListener l) {
+ synchronized (sensorChangeListeners) {
+ sensorChangeListeners.remove(l);
+ enableSensorChangeEvents(sensorChangeListeners.size()
+ > 0);
+ }
+ }
+ private void fireSensorChange(SensorChangeEvent e) {
+ synchronized (sensorChangeListeners) {
+ for (Iterator it = sensorChangeListeners.iterator();
+ it.hasNext(); )
+ ((SensorChangeListener)it.next())
+ .sensorChanged(e);
+ }
+ }
+ private native void enableSensorChangeEvents(boolean b);
+}
diff --git a/Java/com/phidgets/LEDPhidget.java b/Java/com/phidgets/LEDPhidget.java
new file mode 100644
index 0000000..77a37e2
--- /dev/null
+++ b/Java/com/phidgets/LEDPhidget.java
@@ -0,0 +1,141 @@
+
+/*
+ * 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 LED. All methods
+ * to control a Phidget LED are implemented in this class.
+ <p>
+ The Phidget LED is a board that is meant for driving LEDs. Currently, the
+ only available version drives 64 LEDs, but other versions may become available
+ so this number is not absolute.
+ <p>
+ LEDs can be controlled individually, at brightness levels from 0-100.
+ *
+ * @author Phidgets Inc.
+ */
+public final class LEDPhidget extends Phidget
+{
+ public LEDPhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+
+ /**
+ * 20mA current limit. This is used with {@link #getCurrentLimit getCurrentLimit} and {@link #setCurrentLimit setCurrentLimit}
+ */
+ public static final int PHIDGET_LED_CURRENT_LIMIT_20mA = 1;
+ /**
+ * 40mA current limit. This is used with {@link #getCurrentLimit getCurrentLimit} and {@link #setCurrentLimit setCurrentLimit}
+ */
+ public static final int PHIDGET_LED_CURRENT_LIMIT_40mA = 2;
+ /**
+ * 60mA current limit. This is used with {@link #getCurrentLimit getCurrentLimit} and {@link #setCurrentLimit setCurrentLimit}
+ */
+ public static final int PHIDGET_LED_CURRENT_LIMIT_60mA = 3;
+ /**
+ * 80mA current limit. This is used with {@link #getCurrentLimit getCurrentLimit} and {@link #setCurrentLimit setCurrentLimit}
+ */
+ public static final int PHIDGET_LED_CURRENT_LIMIT_80mA = 4;
+
+ /**
+ * 1.7V Voltage output. This is used with {@link #getVoltage getVoltage} and {@link #setVoltage setVoltage}
+ */
+ public static final int PHIDGET_LED_VOLTAGE_1_7V = 1;
+ /**
+ * 2.75V Voltage output. This is used with {@link #getVoltage getVoltage} and {@link #setVoltage setVoltage}
+ */
+ public static final int PHIDGET_LED_VOLTAGE_2_75V = 2;
+ /**
+ * 3.9V Voltage output. This is used with {@link #getVoltage getVoltage} and {@link #setVoltage setVoltage}
+ */
+ public static final int PHIDGET_LED_VOLTAGE_3_9V = 3;
+ /**
+ * 5.0V Voltage output. This is used with {@link #getVoltage getVoltage} and {@link #setVoltage setVoltage}
+ */
+ public static final int PHIDGET_LED_VOLTAGE_5_0V = 4;
+
+ /**
+ * Returns the current limit for the all outputs. This is only supported by some PhidgetLEDs - see the product manual.
+ * The possible values for type are {@link #PHIDGET_LED_CURRENT_LIMIT_20mA PHIDGET_LED_CURRENT_LIMIT_20mA},
+ * {@link #PHIDGET_LED_CURRENT_LIMIT_40mA PHIDGET_LED_CURRENT_LIMIT_40mA}, {@link #PHIDGET_LED_CURRENT_LIMIT_60mA PHIDGET_LED_CURRENT_LIMIT_60mA} and
+ * {@link #PHIDGET_LED_CURRENT_LIMIT_80mA PHIDGET_LED_CURRENT_LIMIT_80mA}
+ * @return Current Limit
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is out of range, or if unsupported by this board.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getCurrentLimit () throws PhidgetException;
+ /**
+ * Sets the current limit for all outputs. This is only supported by some PhidgetLEDs - see the product manual.
+ * <p>
+ * The possible values for type are {@link #PHIDGET_LED_CURRENT_LIMIT_20mA PHIDGET_LED_CURRENT_LIMIT_20mA},
+ * {@link #PHIDGET_LED_CURRENT_LIMIT_40mA PHIDGET_LED_CURRENT_LIMIT_40mA}, {@link #PHIDGET_LED_CURRENT_LIMIT_60mA PHIDGET_LED_CURRENT_LIMIT_60mA} and
+ * {@link #PHIDGET_LED_CURRENT_LIMIT_80mA PHIDGET_LED_CURRENT_LIMIT_80mA}
+ * <p>
+ * By default, currentLimit is set to {@link #PHIDGET_LED_CURRENT_LIMIT_20mA PHIDGET_LED_CURRENT_LIMIT_20mA}.
+ * @param currentLimit Current Limit
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is out of range, or if unsupported by this board.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setCurrentLimit (int currentLimit) throws PhidgetException;
+
+ /**
+ * Returns the voltage output for the all outputs. This is only supported by some PhidgetLEDs - see the product manual.
+ * The possible values for type are {@link #PHIDGET_LED_VOLTAGE_1_7V PHIDGET_LED_VOLTAGE_1_7V},
+ * {@link #PHIDGET_LED_VOLTAGE_2_75V PHIDGET_LED_VOLTAGE_2_75V}, {@link #PHIDGET_LED_VOLTAGE_3_9V PHIDGET_LED_VOLTAGE_3_9V} and
+ * {@link #PHIDGET_LED_VOLTAGE_5_0V PHIDGET_LED_VOLTAGE_5_0V}
+ * @return Voltage
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is out of range, or if unsupported by this board.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getVoltage () throws PhidgetException;
+ /**
+ * Sets the voltage output for all outputs. This is only supported by some PhidgetLEDs - see the product manual.
+ * <p>
+ * The possible values for type are {@link #PHIDGET_LED_VOLTAGE_1_7V PHIDGET_LED_VOLTAGE_1_7V},
+ * {@link #PHIDGET_LED_VOLTAGE_2_75V PHIDGET_LED_VOLTAGE_2_75V}, {@link #PHIDGET_LED_VOLTAGE_3_9V PHIDGET_LED_VOLTAGE_3_9V} and
+ * {@link #PHIDGET_LED_VOLTAGE_5_0V PHIDGET_LED_VOLTAGE_5_0V}
+ * <p>
+ * By default, voltage is set to {@link #PHIDGET_LED_VOLTAGE_2_75V PHIDGET_LED_VOLTAGE_2_75V}.
+ * @param voltage Voltage
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is out of range, or if unsupported by this board.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setVoltage (int voltage) throws PhidgetException;
+
+ /**
+ * Returns the number of LEDs that this board can drive. This may not correspond to the actual number
+ of LEDs attached.
+ * @return number of LEDs
+ * @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 int getLEDCount () throws PhidgetException;
+ /**
+ * Returns the brightness value of an LED. This value ranges from 0-100.
+ * @param index LED
+ * @return brightness
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getDiscreteLED (int index) throws PhidgetException;
+ /**
+ * Sets the brightness of an LED.
+ * Valid values are 0-100, with 0 being off and 100 being the brightest. This 0-100 value is converted internally to a
+ 6-bit value (0-63) so only 64 levels of brightness are actually possible.
+ * @param index index of the LED
+ * @param brightness desired brightness of this LED
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index of brightness value are out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setDiscreteLED (int index, int brightness) throws PhidgetException;
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ }
+}
diff --git a/Java/com/phidgets/Manager.java b/Java/com/phidgets/Manager.java
new file mode 100644
index 0000000..7e7cafb
--- /dev/null
+++ b/Java/com/phidgets/Manager.java
@@ -0,0 +1,408 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets;
+
+import com.phidgets.event.*;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Vector;
+
+/**
+ * <p>
+ * This class represents a Phidget Manager.
+ * The Phidget manager is a way to keep track of attached phidgets, it will send
+ * Attach and Detach events as Phidgets are added and removed fromt the system.
+ * <p>
+ * The Phidget manager deals in base Phidget objects. These objects are not actually connected to
+ * opened Phidgets but can be used to get serial number, name, version, etc.
+ *
+ * @author Phidgets Inc.
+ */
+public class Manager
+{
+ private Vector phidgets;
+
+ static
+ {
+ try
+ {
+ System.loadLibrary("phidget21");
+ }
+ catch(UnsatisfiedLinkError ex)
+ {
+ String os = System.getProperty("os.name");
+ if(os.startsWith("Linux"))
+ {
+ throw new ExceptionInInitializerError(ex.getMessage()
+ +"\nCould not locate the Phidget C library (libphidget21.so)."
+ +"\nMake sure it is installed, and add it's path to LD_LIBRARY_PATH.");
+ }
+ else if(os.startsWith("Windows"))
+ {
+ throw new ExceptionInInitializerError(ex.getMessage()
+ +"\nCould not locate the Phidget C library."
+ +"\nThe Windows Phidget21 MSI must be installed.");
+ }
+ else if(os.startsWith("Mac"))
+ {
+ throw new ExceptionInInitializerError(ex.getMessage()
+ +"\nCould not locate the Phidget C library."
+ +"\nThe Mac Phidget21 DMG must be installed.");
+ }
+ else
+ {
+ throw new ExceptionInInitializerError(ex.getMessage()
+ +"\nCould not locate the Phidget C library.");
+ }
+ }
+ }
+
+ private long handle = 0;
+ /**
+ * The default constructor. Creating a Phidget Manager object will initialize the
+ * attach and detach handlers internally, but {@link #open() open} still needs to be called
+ * to actually recieve event notifications.
+ */
+ public Manager() throws PhidgetException
+ {
+ handle = create();
+ phidgets = new Vector();
+ addAttachListener(new AttachListener()
+ {
+ public void attached(AttachEvent ae)
+ {
+ phidgets.add(ae.getSource());
+ }
+ });
+ addDetachListener(new DetachListener()
+ {
+ public void detached(DetachEvent ae)
+ {
+ phidgets.remove(ae.getSource());
+ }
+ });
+ }
+ private final native long create() throws PhidgetException;
+
+ /**
+ * Returns the Address of a Phidget Webservice when this Manager was opened as remote. This may be an IP Address or a hostname.
+ *
+ * @return Server Address
+ * @throws PhidgetException if this Manager was not opened.
+ */
+ public final native String getServerAddress() throws PhidgetException;
+ /**
+ * Returns the Server ID of a Phidget Webservice when this Manager was opened as remote. This is an arbitrary server identifier,
+ * independant of IP address and Port.
+ *
+ * @return Server ID
+ * @throws PhidgetException if this Manager was not opened.
+ */
+ public final native String getServerID() throws PhidgetException;
+ /**
+ * Returns the Port of a Phidget Webservice when this Manager was opened as remote.
+ *
+ * @return Server Port
+ * @throws PhidgetException if this Manager was not opened.
+ */
+ public final native int getServerPort() throws PhidgetException;
+ /**
+ * Returns the attached status of this Manager.
+ *
+ * @return Status
+ * @throws PhidgetException If this Manager is not opened.
+ */
+ public final native boolean isAttached() throws PhidgetException;
+
+ /**
+ * Returns the network attached status for remotely opened Phidgets. This method returns True or False, depending on whether a connection to the
+ * Phidget WebService is open - or not. If this is false for a remote Phidget then the connection is not active - either because a connection
+ * has not yet been established, or because the connection was terminated.
+ *
+ * @return Status
+ * @throws PhidgetException If this Phidget is not opened.
+ */
+ public final native boolean isAttachedToServer() throws PhidgetException;
+
+ private final native void nativeClose() throws PhidgetException;
+ private final native void nativeDelete() throws PhidgetException;
+ private final native void nativeOpen() throws PhidgetException;
+ private final native void nativeOpenRemote(String serverID, String pass) throws PhidgetException;
+ private final native void nativeOpenRemoteIP(String ipAddress, int port, String pass) throws PhidgetException;
+
+ /**
+ * Starts the PhidgetManager. This method starts the phidget manager running in the base Phidget21 C library.
+ * If attach and detach listeners are to be used, they should be registered before start is called so
+ * that no events are missed. Once start is called, the Phidget Manager will be active until {@link #close() close} is called.
+ */
+ public final void open() throws PhidgetException {
+ enableEvents(true);
+ nativeOpen();
+ }
+ /**
+ * Open this Manager remotely and securely, using an IP Address.
+ * <p>
+ * This method is the same as {@link #open(String, int) open(String ipAddress, int port)}, except that it specifies a password.
+ * This password can be set as a parameter when starting the Phidget Webservice.
+ */
+ public final void open(String ipAddress, int port, String password) throws PhidgetException
+ {
+ enableEvents(true);
+ nativeOpenRemoteIP(ipAddress, port, password);
+ }
+ /**
+ * Open this Manager remotely using an IP Address.
+ * <p>
+ * This version of open is network based.
+ * <p>
+ * @param ipAddress IP Address or hostname of the Phidget Webservice
+ * @param port Port of the Phidget Webservice
+ * @throws PhidgetException if the Phidget Webservice cannot be contacted
+ */
+ public final void open(String ipAddress, int port) throws PhidgetException
+ {
+ enableEvents(true);
+ nativeOpenRemoteIP(ipAddress, port, "");
+ }
+ /**
+ * Open this Manager remotely and securely, using a Server ID.
+ * <p>
+ * This method is the same as {@link #open(String) open(String serverID)}, except that it specifies a password.
+ * This password can be set as a parameter when starting the Phidget Webservice.
+ */
+ public final void open(String serverID, String password) throws PhidgetException
+ {
+ enableEvents(true);
+ nativeOpenRemote(serverID, password);
+ }
+ /**
+ * Open this Manager remotely using a Server ID.
+ * <p>
+ * This version of open is network based.
+ * <p>
+ * ServerID can be NULL to get a listing of all Phidgets on all Servers
+ *
+ * @param serverID ServerID of the Phidget Webservice
+ */
+ public final void open(String serverID) throws PhidgetException
+ {
+ enableEvents(true);
+ nativeOpenRemote(serverID, "");
+ }
+
+ /**
+ * Shuts down the Phidget Manager. This method should be called to close down the Phidget Manager.
+ * Events will no longer be recieved. This method gets calledd automatically when the class is
+ * destroyed so calling it is not required.
+ */
+ public final void close() throws PhidgetException {
+ enableEvents(false);
+ nativeClose();
+ }
+
+ private void enableEvents(boolean b)
+ {
+ enableManagerAttachEvents(b && attachListeners.size() > 0);
+ enableManagerDetachEvents(b && detachListeners.size() > 0);
+ enableServerConnectEvents(b && serverConnectListeners.size() > 0);
+ enableServerDisconnectEvents(b && serverDisconnectListeners.size() > 0);
+ }
+
+ private LinkedList attachListeners = new LinkedList();
+ private long nativeAttachHandler = 0;
+
+ /**
+ * Adds an attach listener. The attach handler is a method that will be called when a Phidget is phisically attached
+ * to the system, and has gone through its initalization, and so is ready to be used.
+ * <p>
+ * There is no limit on the number of attach handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.AttachListener AttachListener} interface
+ */
+ public final void addAttachListener(AttachListener l) {
+ synchronized (attachListeners) {
+ attachListeners.add(l);
+ enableManagerAttachEvents(true);
+ }
+ }
+
+ /**
+ * Removes an attach listener. This will remove a previously added attach listener.
+ */
+ public final void removeAttachListener(AttachListener l) {
+ synchronized (attachListeners) {
+ attachListeners.remove(l);
+ enableManagerAttachEvents(attachListeners.size() > 0);
+ }
+ }
+ private void fireAttach(AttachEvent e) {
+ synchronized (attachListeners) {
+ for (Iterator it = attachListeners.iterator();
+ it.hasNext(); )
+ ((AttachListener)it.next()).attached(e);
+ }
+ }
+ private native void enableManagerAttachEvents(boolean b);
+
+ private LinkedList detachListeners = new LinkedList();
+ private long nativeDetachHandler = 0;
+
+ /**
+ * Adds a detach listener. The detach handler is a method that will be called when a Phidget is phisically detached
+ * from the system, and is no longer available.
+ * <p>
+ * There is no limit on the number of detach handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.DetachListener DetachListener} interface
+ */
+ public final void addDetachListener(DetachListener l) {
+ synchronized (detachListeners) {
+ detachListeners.add(l);
+ enableManagerDetachEvents(true);
+ }
+ }
+
+ /**
+ * Removes a detach listener. This will remove a previously added detach listener.
+ */
+ public final void removeDetachListener(DetachListener l) {
+ synchronized (detachListeners) {
+ detachListeners.remove(l);
+ enableManagerDetachEvents(detachListeners.size() > 0);
+ }
+ }
+ private void fireDetach(DetachEvent e) {
+ synchronized (detachListeners) {
+ for (Iterator it = detachListeners.iterator();
+ it.hasNext(); )
+ ((DetachListener)it.next()).detached(e);
+ }
+ }
+ private native void enableManagerDetachEvents(boolean b);
+
+ private LinkedList serverConnectListeners = new LinkedList();
+ private long nativeServerConnectHandler = 0;
+
+ /**
+ * Adds an serverConnect listener. The serverConnect handler is a method that will be called when a connection to a server is made
+ * <p>
+ * There is no limit on the number of serverConnect handlers that can be registered for a particular Manager.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.ServerConnectListener ServerConnectListener} interface
+ */
+ public final void addServerConnectListener(ServerConnectListener l)
+ {
+ synchronized (serverConnectListeners)
+ {
+ serverConnectListeners.add(l);
+ enableServerConnectEvents(true);
+ }
+ }
+
+ /**
+ * Removes an serverConnect listener. This will remove a previously added serverConnect listener.
+ */
+ public final void removeServerConnectListener(ServerConnectListener l)
+ {
+ synchronized (serverConnectListeners)
+ {
+ serverConnectListeners.remove(l);
+ enableServerConnectEvents(serverConnectListeners.size() > 0);
+ }
+ }
+ private void fireServerConnect(ServerConnectEvent e)
+ {
+ synchronized (serverConnectListeners)
+ {
+ for (Iterator it = serverConnectListeners.iterator();
+ it.hasNext(); )
+ ((ServerConnectListener)it.next()).serverConnected(e);
+ }
+ }
+ private native void enableServerConnectEvents(boolean b);
+
+
+ private LinkedList serverDisconnectListeners = new LinkedList();
+ private long nativeServerDisconnectHandler = 0;
+
+ /**
+ * Adds an serverDisconnect listener. The serverDisconnect handler is a method that will be called when a connection to a server is terminated.
+ * <p>
+ * There is no limit on the number of serverDisconnect handlers that can be registered for a particular Manager.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.ServerDisconnectListener ServerDisconnectListener} interface
+ */
+ public final void addServerDisconnectListener(ServerDisconnectListener l)
+ {
+ synchronized (serverDisconnectListeners)
+ {
+ serverDisconnectListeners.add(l);
+ enableServerDisconnectEvents(true);
+ }
+ }
+
+ /**
+ * Removes an serverDisconnect listener. This will remove a previously added serverDisconnect listener.
+ */
+ public final void removeServerDisconnectListener(ServerDisconnectListener l)
+ {
+ synchronized (serverDisconnectListeners)
+ {
+ serverDisconnectListeners.remove(l);
+ enableServerDisconnectEvents(serverDisconnectListeners.size() > 0);
+ }
+ }
+ private void fireServerDisconnect(ServerDisconnectEvent e)
+ {
+ synchronized (serverDisconnectListeners)
+ {
+ for (Iterator it = serverDisconnectListeners.iterator();
+ it.hasNext(); )
+ ((ServerDisconnectListener)it.next()).serverDisconnected(e);
+ }
+ }
+ private native void enableServerDisconnectEvents(boolean b);
+
+ protected void finalize() throws Throwable
+ {
+ try
+ {
+ close();
+ } catch (Exception e) {
+ ;
+ }
+ try
+ {
+ nativeDelete();
+ }
+ catch (Exception e)
+ {
+ ;
+ }
+ finally{
+ handle = 0;
+ super.finalize();
+ }
+ }
+
+ /**
+ * Return a Sring describing this manager.
+ */
+ public String toString()
+ {
+ return "PhidgetManager: ";
+ }
+
+ /**
+ * Returns a list of Phidgets attached to the host computer. This list is updated right before the attach and detach
+ * events, and so will be up to date within these events.
+ * @return list of attached Phidgets
+ */
+ public Vector getPhidgets()
+ {
+ return phidgets;
+ }
+}
diff --git a/Java/com/phidgets/MotorControlPhidget.java b/Java/com/phidgets/MotorControlPhidget.java
new file mode 100644
index 0000000..8539b98
--- /dev/null
+++ b/Java/com/phidgets/MotorControlPhidget.java
@@ -0,0 +1,497 @@
+
+/*
+ * Copyright 2011 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 Motor Controller. All Methods
+ * to to control a motor controller and read back motor data are implemented in this class.
+ <p>
+ The Motor Control Phidget is able to control 1 or more DC motors.
+ Both speed and acceleration are controllable. Speed is controlled via PWM. The size of the motors
+ that can be driven depends on the motor controller. See your hardware documentation for more information.
+ <p>
+ The motor Controller boards also has 0 or more digital inputs.
+ *
+ * @author Phidgets Inc.
+ */
+public final class MotorControlPhidget extends Phidget
+{
+ public MotorControlPhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+
+ /**
+ * Returns the number of motors supported by this Phidget. This does not neccesarily correspond
+ to the number of motors actually attached to the board.
+ * @return number of supported motors
+ * @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 int getMotorCount () throws PhidgetException;
+ /**
+ * Returns the number of digital inputs. Not all Motor Controllers have digital inputs.
+ * @return number of digital inputs
+ * @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 int getInputCount () throws PhidgetException;
+ /**
+ * Returns the number of encoders. Not all Motor Controllers have encoders.
+ * @return number of encoders
+ * @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 int getEncoderCount () throws PhidgetException;
+ /**
+ * Returns the number of analog inputs. Not all Motor Controllers have analog inputs.
+ * @return number of analog inputs
+ * @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 int getSensorCount () throws PhidgetException;
+ /**
+ * Returns the state of a digital input. True means that the input is activated, and False indicates the default state.
+ * @param index index of the input
+ * @return state of the input
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getInputState (int index) throws PhidgetException;
+ /**
+ * Returns the position of an encoder. This is an absolute position as calcutated since the encoder was plugged in.
+ This value can be reset to anything using {@link #setEncoderPosition(int, int) setEncoderPosition}. Not all Motor Controllers have encoders.
+
+ * @param index index of the encoder
+ * @return position of the encoder
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getEncoderPosition (int index) throws PhidgetException;
+ /**
+ * Sets the position of a specific encoder. This resets the internal position count for an encoder. This call in no way actually
+ sends information to the device, as an absolute position is maintained only in the library. After this call, position changes
+ from the encoder will use the new value to calculate absolute position as reported by {@link #getEncoderPosition}. Not all Motor Controllers have encoders.
+ * @param index index of the encoder
+ * @param position new position for a encoder.
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setEncoderPosition (int index, int position) throws PhidgetException;
+ /**
+ * Returns the value of a sensor. Not all Motor Controllers have analog sensors.
+ * @param index index of the sensor
+ * @return sensor value of the sensor. Range is 0-1000.
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getSensorValue (int index) throws PhidgetException;
+ /**
+ * Returns the raw value of a sensor(12-bit). Not all Motor Controllers have analog sensors.
+ * @param index index of the sensor
+ * @return sensor raw value of the sensor. Range is 0-4096.
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getSensorRawValue (int index) throws PhidgetException;
+ /**
+ * Returns the ratiometric state of a sensor. Not all Motor Controllers have analog sensors.
+ * @return ratiometric state of sensors
+ * @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 boolean getRatiometric () throws PhidgetException;
+ /**
+ * Sets the ratiometric state. This controls the voltage reference used for sampling the analog sensors.
+ * @param ratiometric new ratiometric state of the sensors
+ * @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 setRatiometric (boolean ratiometric) throws PhidgetException;
+ /**
+ * Returns a motor's acceleration. The valid range is between {@link #getAccelerationMin getAccelerationMin} and {@link #getAccelerationMax getAccelerationMax}, and refers to how fast the Motor Controller
+ will change the speed of a motor.
+ * @param index Index of motor
+ * @return acceleration of motor
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getAcceleration (int index) throws PhidgetException;
+ /**
+ * Sets a motor's acceleration.
+ * The valid range is between {@link #getAccelerationMin getAccelerationMin} and {@link #getAccelerationMax getAccelerationMax}. This controls how fast the motor changes speed.
+ * @param index index of the motor
+ * @param acceleration requested acceleration for that motor
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index or acceleration value are invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setAcceleration (int index, double acceleration) throws PhidgetException;
+ /**
+ * Returns the maximum acceleration that a motor will accept, or return.
+ * @param index Index of the motor
+ * @return Maximum acceleration
+ * @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 getAccelerationMax (int index) throws PhidgetException;
+ /**
+ * Returns the minimum acceleration that a motor will accept, or return.
+ * @param index Index of the motor
+ * @return Minimum acceleration
+ * @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 getAccelerationMin (int index) throws PhidgetException;
+ /**
+ * Returns a motor's velocity. The valid range is -100 - 100, with 0 being stopped.
+ * @param index index of the motor
+ * @return current velocity of the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getVelocity (int index) throws PhidgetException;
+ /**
+ * @deprecated Replaced by
+ * {@link #getVelocity}
+ */
+ public native double getSpeed (int index) throws PhidgetException;
+ /**
+ * Sets a motor's velocity.
+ * The valid range is from -100 to 100, with 0 being stopped. -100 and 100 both correspond to full voltage,
+ with the value in between corresponding to different widths of PWM.
+ * @param index index of the motor
+ * @param velocity requested velocity for the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index or speed value are invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setVelocity (int index, double velocity) throws PhidgetException;
+ /**
+ * @deprecated Replaced by
+ * {@link #setVelocity}
+ */
+ public native void setSpeed (int index, double speed) throws PhidgetException;
+ /**
+ * Returns a motor's current usage. The valid range is 0 - 255. Note that this is not supported on all motor controllers.
+ * @param index index of the motor
+ * @return current usage of the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getCurrent (int index) throws PhidgetException;
+ /**
+ * Returns the Back EMF sensing state for a specific motor. Note that this is not supported on all motor controllers.
+ * @param index Index of the motor
+ * @return Back EMF Sensing state for the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getBackEMFSensingState (int index) throws PhidgetException;
+ /**
+ * Sets the Back EMF sensing state for a specific motor. Note that this is not supported on all motor controllers.
+ * @param index Index of the motor
+ * @param bEMFState new Back EMF Sensing State
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setBackEMFSensingState (int index, boolean bEMFState) throws PhidgetException;
+ /**
+ * Sets the Back EMF voltage for a specific motor. Note that this is not supported on all motor controllers.
+ * @param index Index of the motor
+ * @return Back EMF voltage of the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getBackEMF (int index) throws PhidgetException;
+ /**
+ * Sets the supply voltage for the motors. This could be higher than the actual voltage. Note that this is not supported on all motor controllers.
+ * @return Supply voltage of the motor, in volts
+ * @throws PhidgetException If this Phidget is not opened and attached, the index is invalid, or if {@link #setBackEMFSensingState setBackEMFSensingState} is not set.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getSupplyVoltage () throws PhidgetException;
+ /**
+ * Returns the braking value for a specific motor. Note that this is not supported on all motor controllers.
+ * @param index index of the motor
+ * @return Braking value for the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getBraking (int index) throws PhidgetException;
+ /**
+ * Sets the braking value for a specific motor. This is applied when velocity is 0. Default is 0%. Note that this is not supported on all motor controllers. Range is 0-100.
+ * @param index index of the motor
+ * @param braking new braking value for a specific motor
+ * @throws PhidgetException If this Phidget is not opened and attached, the index is invalid, or the brake value is invalid
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setBraking (int index, double braking) throws PhidgetException;
+
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ enableMotorVelocityChangeEvents (b && motorVelocityChangeListeners.size () > 0);
+ enableCurrentChangeEvents (b && currentChangeListeners.size () > 0);
+ enableCurrentUpdateEvents (b && currentUpdateListeners.size () > 0);
+ enableInputChangeEvents (b && inputChangeListeners.size () > 0);
+ enableEncoderPositionChangeEvents (b && encoderPositionChangeListeners.size () > 0);
+ enableEncoderPositionUpdateEvents (b && encoderPositionUpdateListeners.size () > 0);
+ enableBackEMFUpdateEvents (b && backEMFUpdateListeners.size () > 0);
+ enableSensorUpdateEvents (b && sensorUpdateListeners.size () > 0);
+ }
+ /**
+ * Adds a velocity change listener. The velocity change handler is a method that will be called when the velocity
+ of a motor changes. These velocity changes are reported back from the Motor Controller and so correspond to actual motor speeds
+ over time.
+ * <p>
+ * There is no limit on the number of velocity change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.MotorVelocityChangeListener MotorVelocityChangeListener} interface
+ */
+ public final void addMotorVelocityChangeListener (MotorVelocityChangeListener l)
+ {
+ synchronized (motorVelocityChangeListeners)
+ {
+ motorVelocityChangeListeners.add (l);
+ enableMotorVelocityChangeEvents (true);
+ }} private LinkedList motorVelocityChangeListeners = new LinkedList ();
+ private long nativeMotorVelocityChangeHandler = 0;
+ public final void removeMotorVelocityChangeListener (MotorVelocityChangeListener l)
+ {
+ synchronized (motorVelocityChangeListeners)
+ {
+ motorVelocityChangeListeners.remove (l);
+ enableMotorVelocityChangeEvents (motorVelocityChangeListeners.size () > 0);
+ }} private void fireMotorVelocityChange (MotorVelocityChangeEvent e)
+ {
+ synchronized (motorVelocityChangeListeners)
+ {
+ for (Iterator it = motorVelocityChangeListeners.iterator (); it.hasNext ();)
+ ((MotorVelocityChangeListener) it.next ()).motorVelocityChanged (e);
+ }
+ }
+ private native void enableMotorVelocityChangeEvents (boolean b);
+ /**
+ * Adds a current change listener. The current change handler is a method that will be called when the current
+ consumed by a motor changes. Note that this event is not supported with the current motor controller, but
+ will be supported in the future
+ * <p>
+ * There is no limit on the number of current change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.CurrentChangeListener CurrentChangeListener} interface
+ */
+ public final void addCurrentChangeListener (CurrentChangeListener l)
+ {
+ synchronized (currentChangeListeners)
+ {
+ currentChangeListeners.add (l);
+ enableCurrentChangeEvents (true);
+ }} private LinkedList currentChangeListeners = new LinkedList ();
+ private long nativeCurrentChangeHandler = 0;
+ public final void removeCurrentChangeListener (CurrentChangeListener l)
+ {
+ synchronized (currentChangeListeners)
+ {
+ currentChangeListeners.remove (l);
+ enableCurrentChangeEvents (currentChangeListeners.size () > 0);
+ }} private void fireCurrentChange (CurrentChangeEvent e)
+ {
+ synchronized (currentChangeListeners)
+ {
+ for (Iterator it = currentChangeListeners.iterator (); it.hasNext ();)
+ ((CurrentChangeListener) it.next ()).currentChanged (e);
+ }
+ }
+ private native void enableCurrentChangeEvents (boolean b);
+ /**
+ * Adds a current update listener. The current change handler is a method that will be called every 8ms, regardless whether the current
+ consumed by a motor changes. Note that this event is not supported with all motor controllers
+ * <p>
+ * There is no limit on the number of current update handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.CurrentUpdateListener CurrentUpdateListener} interface
+ */
+ public final void addCurrentUpdateListener (CurrentUpdateListener l)
+ {
+ synchronized (currentUpdateListeners)
+ {
+ currentUpdateListeners.add (l);
+ enableCurrentUpdateEvents (true);
+ }} private LinkedList currentUpdateListeners = new LinkedList ();
+ private long nativeCurrentUpdateHandler = 0;
+ public final void removeCurrentUpdateListener (CurrentUpdateListener l)
+ {
+ synchronized (currentUpdateListeners)
+ {
+ currentUpdateListeners.remove (l);
+ enableCurrentUpdateEvents (currentUpdateListeners.size () > 0);
+ }} private void fireCurrentUpdate (CurrentUpdateEvent e)
+ {
+ synchronized (currentUpdateListeners)
+ {
+ for (Iterator it = currentUpdateListeners.iterator (); it.hasNext ();)
+ ((CurrentUpdateListener) it.next ()).currentUpdated (e);
+ }
+ }
+ private native void enableCurrentUpdateEvents (boolean b);
+ /**
+ * Adds an input change listener. The input change handler is a method that will be called when an input on this
+ * Motor Controller board has changed.
+ * <p>
+ * There is no limit on the number of input change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.InputChangeListener InputChangeListener} interface
+ */
+ public final void addInputChangeListener (InputChangeListener l)
+ {
+ synchronized (inputChangeListeners)
+ {
+ inputChangeListeners.add (l);
+ enableInputChangeEvents (true);
+ }} private LinkedList inputChangeListeners = new LinkedList ();
+ private long nativeInputChangeHandler = 0;
+ public final void removeInputChangeListener (InputChangeListener l)
+ {
+ synchronized (inputChangeListeners)
+ {
+ inputChangeListeners.remove (l);
+ enableInputChangeEvents (inputChangeListeners.size () > 0);
+ }} private void fireInputChange (InputChangeEvent e)
+ {
+ synchronized (inputChangeListeners)
+ {
+ for (Iterator it = inputChangeListeners.iterator (); it.hasNext ();)
+ ((InputChangeListener) it.next ()).inputChanged (e);
+ }
+ }
+ private native void enableInputChangeEvents (boolean b);
+ /**
+ * Adds a position change listener. The position change handler is a method that will be called when the position of an
+ encoder changes. The position change event provides data about how many ticks have occured, and how much time has
+ passed since the last position change event, but does not contain an absolute position. This can be obtained from
+ {@link #getEncoderPosition}.
+ * <p>
+ * There is no limit on the number of encoder position change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.EncoderPositionChangeListener EncoderPositionChangeListener} interface
+ */
+ public final void addEncoderPositionChangeListener (EncoderPositionChangeListener l)
+ {
+ synchronized (encoderPositionChangeListeners)
+ {
+ encoderPositionChangeListeners.add (l);
+ enableEncoderPositionChangeEvents (true);
+ }} private LinkedList encoderPositionChangeListeners = new LinkedList ();
+ private long nativeEncoderPositionChangeHandler = 0;
+ public final void removeEncoderPositionChangeListener (EncoderPositionChangeListener l)
+ {
+ synchronized (encoderPositionChangeListeners)
+ {
+ encoderPositionChangeListeners.remove (l);
+ enableEncoderPositionChangeEvents (encoderPositionChangeListeners.size () > 0);
+ }} private void fireEncoderPositionChange (EncoderPositionChangeEvent e)
+ {
+ synchronized (encoderPositionChangeListeners)
+ {
+ for (Iterator it = encoderPositionChangeListeners.iterator (); it.hasNext ();)
+ ((EncoderPositionChangeListener) it.next ()).encoderPositionChanged (e);
+ }
+ }
+ private native void enableEncoderPositionChangeEvents (boolean b);
+ /**
+ * Adds a position update listener. The position update handler is a method that will be called at a constant rate; every 8ms, whether the encoder position has changed or not.
+ * The position update event provides data about how many ticks have occured since the last position update event, but does not contain an absolute position. This can be obtained from
+ *{@link #getEncoderPosition}.
+ * <p>
+ * There is no limit on the number of encoder position update handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.EncoderPositionUpdateListener EncoderPositionUpdateListener} interface
+ */
+ public final void addEncoderPositionUpdateListener (EncoderPositionUpdateListener l)
+ {
+ synchronized (encoderPositionUpdateListeners)
+ {
+ encoderPositionUpdateListeners.add (l);
+ enableEncoderPositionUpdateEvents (true);
+ }} private LinkedList encoderPositionUpdateListeners = new LinkedList ();
+ private long nativeEncoderPositionUpdateHandler = 0;
+ public final void removeEncoderPositionUpdateListener (EncoderPositionUpdateListener l)
+ {
+ synchronized (encoderPositionUpdateListeners)
+ {
+ encoderPositionUpdateListeners.remove (l);
+ enableEncoderPositionUpdateEvents (encoderPositionUpdateListeners.size () > 0);
+ }} private void fireEncoderPositionUpdate (EncoderPositionUpdateEvent e)
+ {
+ synchronized (encoderPositionUpdateListeners)
+ {
+ for (Iterator it = encoderPositionUpdateListeners.iterator (); it.hasNext ();)
+ ((EncoderPositionUpdateListener) it.next ()).encoderPositionUpdated (e);
+ }
+ }
+ private native void enableEncoderPositionUpdateEvents (boolean b);
+ /**
+ * Adds a Back EMF update listener. The Back EMF update handler is a method that will be called at a constant rate; every 8ms, whether the Back EMF value has changed or not.
+ * <p>
+ * There is no limit on the number of Back EMF update handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.BackEMFUpdateListener BackEMFUpdateListener} interface
+ */
+ public final void addBackEMFUpdateListener (BackEMFUpdateListener l)
+ {
+ synchronized (backEMFUpdateListeners)
+ {
+ backEMFUpdateListeners.add (l);
+ enableBackEMFUpdateEvents (true);
+ }} private LinkedList backEMFUpdateListeners = new LinkedList ();
+ private long nativeBackEMFUpdateHandler = 0;
+ public final void removeBackEMFUpdateListener (BackEMFUpdateListener l)
+ {
+ synchronized (backEMFUpdateListeners)
+ {
+ backEMFUpdateListeners.remove (l);
+ enableBackEMFUpdateEvents (backEMFUpdateListeners.size () > 0);
+ }} private void fireBackEMFUpdate (BackEMFUpdateEvent e)
+ {
+ synchronized (backEMFUpdateListeners)
+ {
+ for (Iterator it = backEMFUpdateListeners.iterator (); it.hasNext ();)
+ ((BackEMFUpdateListener) it.next ()).backEMFUpdated (e);
+ }
+ }
+ private native void enableBackEMFUpdateEvents (boolean b);
+ /**
+ * Adds a sensor update listener. The sensor update handler is a method that will be called at a constant rate; every 8ms, whether the sensor value has changed or not.
+ * <p>
+ * There is no limit on the number of sensor update handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.SensorUpdateListener SensorUpdateListener} interface
+ */
+ public final void addSensorUpdateListener (SensorUpdateListener l)
+ {
+ synchronized (sensorUpdateListeners)
+ {
+ sensorUpdateListeners.add (l);
+ enableSensorUpdateEvents (true);
+ }} private LinkedList sensorUpdateListeners = new LinkedList ();
+ private long nativeSensorUpdateHandler = 0;
+ public final void removeSensorUpdateListener (SensorUpdateListener l)
+ {
+ synchronized (sensorUpdateListeners)
+ {
+ sensorUpdateListeners.remove (l);
+ enableSensorUpdateEvents (sensorUpdateListeners.size () > 0);
+ }} private void fireSensorUpdate (SensorUpdateEvent e)
+ {
+ synchronized (sensorUpdateListeners)
+ {
+ for (Iterator it = sensorUpdateListeners.iterator (); it.hasNext ();)
+ ((SensorUpdateListener) it.next ()).sensorUpdated (e);
+ }
+ }
+ private native void enableSensorUpdateEvents (boolean b);
+}
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.
+ * <p>
+ * 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.
+ * <p>
+ * 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.
+ * <p>
+ * 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);
+}
diff --git a/Java/com/phidgets/Phidget.java b/Java/com/phidgets/Phidget.java
new file mode 100644
index 0000000..e2d611c
--- /dev/null
+++ b/Java/com/phidgets/Phidget.java
@@ -0,0 +1,1000 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+package com.phidgets;
+
+import com.phidgets.event.*;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+
+/**
+ * This is the base class from which all Phidget device classes derive.
+ * Don't create phidget devices directly using this class. Use the specific class for the
+ * device that you wish to access.
+ *
+ * @author Phidgets Inc.
+ * @version 2.1.7
+ */
+public class Phidget
+{
+ static
+ {
+ try
+ {
+
+ System.loadLibrary("phidget21");
+
+ }
+ catch(UnsatisfiedLinkError ex)
+ {
+ String os = System.getProperty("os.name");
+ if(os.startsWith("Linux"))
+ {
+ throw new ExceptionInInitializerError(ex.getMessage()
+ +"\nCould not locate the Phidget C library (libphidget21.so)."
+ +"\nMake sure it is installed, and add it's path to LD_LIBRARY_PATH.");
+ }
+ else if(os.startsWith("Windows"))
+ {
+ throw new ExceptionInInitializerError(ex.getMessage()
+ +"\nCould not locate the Phidget C library."
+ +"\nThe Windows Phidget21 MSI must be installed.");
+ }
+ else if(os.startsWith("Mac"))
+ {
+ throw new ExceptionInInitializerError(ex.getMessage()
+ +"\nCould not locate the Phidget C library."
+ +"\nThe Mac Phidget21 DMG must be installed.");
+ }
+ else
+ {
+ throw new ExceptionInInitializerError(ex.getMessage()
+ +"\nCould not locate the Phidget C library.");
+ }
+ }
+
+
+
+ }
+
+ private long handle = 0;
+ boolean managerPhidget = false;
+
+ /**
+ * Class constructor specifying a handle. This constructor is to be used only by subclasses, as the Phidget calss should never need to
+ * be instatiated directly by the user.
+ *
+ * @param handle A native Handle points to the underlying phidget structure in the base phidget21 C library.
+ */
+ public Phidget(long handle) {
+ this.handle = handle;
+ }
+
+ private final long getHandle() {
+ return handle;
+ }
+
+ /**
+ * Returns the library version. This is the library version of the underlying phidget21 C library and not the version of the
+ * JNI wrapper implementation.
+ * <p>
+ * The version is retured at a string which contains the version number and build date.
+ *
+ * @return Library Version
+ */
+ public final static native String getLibraryVersion();
+
+ /**
+ * Critial error messages. This is used with {@link #enableLogging enableLogging} and {@link #log log}
+ * <p>
+ * This is the lowest logging level. Errors at this level are generally non-recoverable and indicate either hardware problems,
+ * library bugs, or other serious issues.
+ * <P>
+ * If logging is enabled at this level, only {@link #PHIDGET_LOG_CRITICAL PHIDGET_LOG_CRITICAL} messages are logged.
+ */
+ public static final int PHIDGET_LOG_CRITICAL = 1;
+ /**
+ * Non-critical error messages. This is used with {@link #enableLogging enableLogging} and {@link #log log}
+ * <P>
+ * Errors at this level are generally automatically recoverable, but may help to track down issues.
+ * <p>
+ * If logging is enabled at this level, {@link #PHIDGET_LOG_ERROR PHIDGET_LOG_ERROR} as well as
+ * {@link #PHIDGET_LOG_CRITICAL PHIDGET_LOG_CRITICAL} messages are logged.
+ */
+ public static final int PHIDGET_LOG_ERROR = 2;
+ /**
+ * Warning messages. This is used with {@link #enableLogging enableLogging} and {@link #log log}
+ * <P>
+ * Warnings are used to log behaviour that is not neccessarily in error, but is nevertheless odd or unexpected.
+ * <p>
+ * If logging is enabled at this level, {@link #PHIDGET_LOG_WARNING PHIDGET_LOG_WARNING} as well as
+ * {@link #PHIDGET_LOG_ERROR PHIDGET_LOG_ERROR} and {@link #PHIDGET_LOG_CRITICAL PHIDGET_LOG_CRITICAL} messages are logged.
+ */
+ public static final int PHIDGET_LOG_WARNING = 3;
+ /**
+ * Debug messages. This is used with {@link #enableLogging enableLogging} and {@link #log log}
+ * <P>
+ * Debug messages are generally used for debugging at Phdigets Inc.
+ * <p>
+ * Note: {@link #PHIDGET_LOG_DEBUG PHIDGET_LOG_DEBUG} messages are only logged in the debug version of the library, regardless of logging level.
+ * Thus, these logs should never be seen outside of Phidgets Inc.
+ * <p>
+ * If logging is enabled at this level, {@link #PHIDGET_LOG_DEBUG PHIDGET_LOG_DEBUG} as well as
+ * {@link #PHIDGET_LOG_WARNING PHIDGET_LOG_WARNING}, {@link #PHIDGET_LOG_ERROR PHIDGET_LOG_ERROR}
+ * and {@link #PHIDGET_LOG_CRITICAL PHIDGET_LOG_CRITICAL} messages are logged.
+ */
+ public static final int PHIDGET_LOG_DEBUG = 4;
+ /**
+ * Informational messages. This is used with {@link #enableLogging enableLogging} and {@link #log log}
+ * <P>
+ * Informational messages track key happenings within phidget21 - mostly to do with threads starting and shutting down, and the
+ * internals of the USB code.
+ * <p>
+ * If logging is enabled at this level, {@link #PHIDGET_LOG_INFO PHIDGET_LOG_INFO} as well as
+ * {@link #PHIDGET_LOG_DEBUG PHIDGET_LOG_DEBUG}, {@link #PHIDGET_LOG_WARNING PHIDGET_LOG_WARNING}, {@link #PHIDGET_LOG_ERROR PHIDGET_LOG_ERROR}
+ * and {@link #PHIDGET_LOG_CRITICAL PHIDGET_LOG_CRITICAL} messages are logged.
+ */
+ public static final int PHIDGET_LOG_INFO = 5;
+ /**
+ * Verbose messages. This is used with {@link #enableLogging enableLogging} and {@link #log log}
+ * <P>
+ * This is the highest logging level. Verbose messages are informational messages that are expected to happen so
+ * frequently that they tend to drown out other log messages.
+ * <p>
+ * If logging is enabled at this level, {@link #PHIDGET_LOG_VERBOSE PHIDGET_LOG_VERBOSE} as well as
+ * {@link #PHIDGET_LOG_INFO PHIDGET_LOG_INFO}, {@link #PHIDGET_LOG_DEBUG PHIDGET_LOG_DEBUG},
+ * {@link #PHIDGET_LOG_WARNING PHIDGET_LOG_WARNING}, {@link #PHIDGET_LOG_ERROR PHIDGET_LOG_ERROR}
+ * and {@link #PHIDGET_LOG_CRITICAL PHIDGET_LOG_CRITICAL} messages are logged.
+ */
+ public static final int PHIDGET_LOG_VERBOSE = 6;
+
+ private final static native void nativeEnableLogging(int level, String file);
+
+ /**
+ * Turns on logging in the native C Library. This is mostly usefull for debugging purposes - when an issue needs to be resolved by
+ * Phidgets Inc. The output is mostly low-level library information, that won't be usefull for most users.
+ * <p>
+ * Logging may be usefull for users trying to debug their own problems, as logs can be inserted by the user using {@link #log log}.
+ * <p>
+ * The level can be one of: {@link #PHIDGET_LOG_VERBOSE PHIDGET_LOG_VERBOSE},
+ * {@link #PHIDGET_LOG_INFO PHIDGET_LOG_INFO}, {@link #PHIDGET_LOG_DEBUG PHIDGET_LOG_DEBUG},
+ * {@link #PHIDGET_LOG_WARNING PHIDGET_LOG_WARNING}, {@link #PHIDGET_LOG_ERROR PHIDGET_LOG_ERROR}
+ * or {@link #PHIDGET_LOG_CRITICAL PHIDGET_LOG_CRITICAL}
+ *
+ * @param level highest level of logging that will be output
+ * @param file file to output log to. specify 'null' to output to the console
+ */
+ public final static void enableLogging(int level, String file)
+ {
+ nativeEnableLogging(level, file);
+ }
+
+ /**
+ * Turns off logging in the native C Library. This only needs to be called if enableLogging was called to turn logging on.
+ * This will turn logging back off.
+ */
+ public final static native void disableLogging();
+
+ private final static native void nativeLog(int level, String id, String log);
+
+ /**
+ * Adds a log entry into the phidget log. This log is enabled by calling {@link #enableLogging(int level, String file) enableLogging}
+ * and this allows the entry of user logs in amongst the phidget library logs.
+ * <p>
+ * The level can be one of: {@link #PHIDGET_LOG_VERBOSE PHIDGET_LOG_VERBOSE},
+ * {@link #PHIDGET_LOG_INFO PHIDGET_LOG_INFO}, {@link #PHIDGET_LOG_DEBUG PHIDGET_LOG_DEBUG},
+ * {@link #PHIDGET_LOG_WARNING PHIDGET_LOG_WARNING}, {@link #PHIDGET_LOG_ERROR PHIDGET_LOG_ERROR}
+ * or {@link #PHIDGET_LOG_CRITICAL PHIDGET_LOG_CRITICAL}
+ * <p>
+ * Note: {@link #PHIDGET_LOG_DEBUG PHIDGET_LOG_DEBUG} should not be used, as these logs are only printed when using the debug library,
+ * which is not generally available.
+ *
+ * @param level level to enter the log at
+ * @param id an arbitrary identifier for this log. This can be NULL. The C library uses this field for source filename and line number
+ * @param log the message to log
+ */
+ public final static void log(int level, String id, String log)
+ {
+ nativeLog(level, id, log);
+ }
+
+ public static final int PHIDID_NOTHING = 1;
+
+ /* These are all current devices */
+ public static final int PHIDID_ACCELEROMETER_3AXIS = 0x07E;
+ public static final int PHIDID_ADVANCEDSERVO_1MOTOR = 0x082;
+ public static final int PHIDID_ANALOG_4OUTPUT = 0x037;
+ public static final int PHIDID_ADVANCEDSERVO_8MOTOR = 0x03A;
+ public static final int PHIDID_BIPOLAR_STEPPER_1MOTOR = 0x07B;
+ public static final int PHIDID_BRIDGE_4INPUT = 0x03B;
+ public static final int PHIDID_ENCODER_1ENCODER_1INPUT = 0x04B;
+ public static final int PHIDID_ENCODER_HS_1ENCODER = 0x080;
+ public static final int PHIDID_ENCODER_HS_4ENCODER_4INPUT = 0x04F;
+ public static final int PHIDID_FREQUENCYCOUNTER_2INPUT = 0x035;
+ public static final int PHIDID_GPS = 0x079;
+ public static final int PHIDID_INTERFACEKIT_0_0_4 = 0x040;
+ public static final int PHIDID_INTERFACEKIT_0_0_8 = 0x081;
+ public static final int PHIDID_INTERFACEKIT_0_16_16 = 0x044;
+ public static final int PHIDID_INTERFACEKIT_8_8_8 = 0x045;
+ public static final int PHIDID_INTERFACEKIT_8_8_8_w_LCD = 0x07D;
+ public static final int PHIDID_IR = 0x04D;
+ public static final int PHIDID_LED_64 = 0x04A;
+ public static final int PHIDID_LED_64_ADV = 0x04C;
+ public static final int PHIDID_LINEAR_TOUCH = 0x076;
+ public static final int PHIDID_MOTORCONTROL_HC_2MOTOR = 0x059;
+ public static final int PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT = 0x058;
+ public static final int PHIDID_MOTORCONTROL_1MOTOR = 0x03E;
+ public static final int PHIDID_PHSENSOR = 0x074;
+ public static final int PHIDID_RFID_2OUTPUT = 0x031;
+ public static final int PHIDID_ROTARY_TOUCH = 0x077;
+ public static final int PHIDID_SERVO_1MOTOR = 0x039;
+ public static final int PHIDID_SPATIAL_ACCEL_3AXIS = 0x07F;
+ public static final int PHIDID_SPATIAL_ACCEL_GYRO_COMPASS = 0x033;
+ public static final int PHIDID_TEMPERATURESENSOR = 0x070;
+ public static final int PHIDID_TEMPERATURESENSOR_4 = 0x032;
+ public static final int PHIDID_TEXTLCD_2x20_w_8_8_8 = 0x17D;
+ public static final int PHIDID_TEXTLCD_ADAPTER = 0x03D;
+ public static final int PHIDID_UNIPOLAR_STEPPER_4MOTOR = 0x07A;
+
+ /* These are all past devices (no longer sold) */
+ public static final int PHIDID_ACCELEROMETER_2AXIS = 0x071;
+ public static final int PHIDID_INTERFACEKIT_0_8_8_w_LCD = 0x053;
+ public static final int PHIDID_INTERFACEKIT_4_8_8 = 4;
+ public static final int PHIDID_RFID = 0x030;
+ public static final int PHIDID_SERVO_1MOTOR_OLD = 2;
+ public static final int PHIDID_SERVO_4MOTOR = 0x038;
+ public static final int PHIDID_SERVO_4MOTOR_OLD = 3;
+ public static final int PHIDID_TEXTLCD_2x20 = 0x052;
+ public static final int PHIDID_TEXTLCD_2x20_w_0_8_8 = 0x153;
+ public static final int PHIDID_TEXTLED_1x8 = 0x049;
+ public static final int PHIDID_TEXTLED_4x8 = 0x048;
+ public static final int PHIDID_WEIGHTSENSOR = 0x072;
+
+
+ /**
+ * Returns the Device ID of this Phidget. This is one of the PHIDID_(...) constants defined above. This uniquely identifies a specific type of Phidget.
+ *
+ * @return Device ID
+ * @throws PhidgetException If this Phidget is not opened and attached. See {@link #open(int) open} for information on determining if a device is attached.
+ */
+ public final native int getDeviceID() throws PhidgetException;
+
+ public static final int PHIDCLASS_NOTHING = 1;
+ public static final int PHIDCLASS_ACCELEROMETER = 2;
+ public static final int PHIDCLASS_ADVANCEDSERVO = 3;
+ public static final int PHIDCLASS_ANALOG = 22;
+ public static final int PHIDCLASS_BRIDGE = 23;
+ public static final int PHIDCLASS_ENCODER = 4;
+ public static final int PHIDCLASS_FREQUENCYCOUNTER = 21;
+ public static final int PHIDCLASS_GPS = 5;
+ public static final int PHIDCLASS_INTERFACEKIT = 7;
+ public static final int PHIDCLASS_LED = 8;
+ public static final int PHIDCLASS_MOTORCONTROL = 9;
+ public static final int PHIDCLASS_PHSENSOR = 10;
+ public static final int PHIDCLASS_RFID = 11;
+ public static final int PHIDCLASS_SERVO = 12;
+ public static final int PHIDCLASS_STEPPER = 13;
+ public static final int PHIDCLASS_TEMPERATURESENSOR = 14;
+ public static final int PHIDCLASS_TEXTLCD = 15;
+ public static final int PHIDCLASS_TEXTLED = 16;
+ public static final int PHIDCLASS_WEIGHTSENSOR = 17;
+
+ /**
+ * Returns the Device Class of this Phidget. This is one of the PHIDCLASS_(...) constants defined above. This represents a class of Phidgets - ie Interface Kit.
+ *
+ * @return Device ID
+ * @throws PhidgetException If this Phidget is not opened and attached. See {@link #open(int) open} for information on determining if a device is attached.
+ */
+ public final native int getDeviceClass() throws PhidgetException;
+
+ /**
+ * Returns the unique serial number of this Phidget. This number is set during manufacturing, and is unique across all Phidgets.
+ * This number can be used in calls to {@link #open(int) open} to specify this specific Phidget to be opened.
+ *
+ * @return Serial Number
+ * @throws PhidgetException If this Phidget is not opened and attached. See {@link #open(int) open} for information on determining if a device is attached.
+ */
+ public final native int getSerialNumber() throws PhidgetException;
+
+ /**
+ * Returns the device version of this Phidget. This number is simply a way of distinguishing between different revisions
+ * of a specific type of Phidget, and is only really of use if you need to troubleshoot device problems with Phidgets Inc.
+ *
+ * @return Version
+ * @throws PhidgetException If this Phidget is not opened and attached. See {@link #open(int) open} for information on determining if a device is attached.
+ */
+ public final native int getDeviceVersion() throws PhidgetException;
+
+ /**
+ * Return the device type of this Phidget. This is a string that describes the device as a class of devices. For example,
+ * all PhidgetInterfaceKit Phidgets will returns the String "PhidgetInterfaceKit".
+ * <p>
+ * This function is mostly usefull if you are using the {@link com.phidgets.Manager Phidget Manager} because it's attach and detach handlers
+ * return {link com.phidgets.phidget phidget} objects, and you can use this method to determine their proper type.
+ *
+ * @return Device Type
+ * @throws PhidgetException If this Phidget is not opened and attached. See {@link #open(int) open} for information on determining if a device is attached.
+ */
+ public final native String getDeviceType() throws PhidgetException;
+
+ /**
+ * Return the name of this Phidget. This is a string that describes the device. For example, a PhidgetInterfaceKit could be described
+ * as "Phidget InterfaceKit 8/8/8", or "Phidget InterfaceKit 0/0/4", among others, depending on the specific device.
+ * <p>
+ * This lets you determine the specific type of a Phidget, within the broader classes of Phidgets, such as PhidgetInterfaceKit, or PhidgetServo
+ *
+ * @return Name
+ * @throws PhidgetException If this Phidget is not opened and attached. See {@link #open(int) open} for information on determining if a device is attached.
+ */
+ public final native String getDeviceName() throws PhidgetException;
+
+ /**
+ * Returns the attached status of this Phidget. This method returns True or False, depending on whether the Phidget is phisically plugged
+ * into the computer, initialized, and ready to use - or not. If a Phidget is not attached, many functions calls will fail with a PhidgetException,
+ * so either checking this function, or using the Attach and Detach events, is recommended, if a device is likely to be attached or
+ * detached during use.
+ *
+ * @return Status
+ * @throws PhidgetException If this Phidget is not opened.
+ */
+ public final native boolean isAttached() throws PhidgetException;
+
+ /**
+ * Returns the network attached status for remotely opened Phidgets. This method returns True or False, depending on whether a connection to the
+ * Phidget WebService is open - or not. If this is false for a remote Phidget then the connection is not active - either because a connection
+ * has not yet been established, or because the connection was terminated.
+ *
+ * @return Status
+ * @throws PhidgetException If this Phidget is not opened.
+ */
+ public final native boolean isAttachedToServer() throws PhidgetException;
+
+ /**
+ * Returns the label associated with this Phidget. This label is a String - up to ten digits - that is stored in the Flash memory
+ * of newer Phidgets. This label can be set programatically (see {@link #setDeviceLabel(String) setDeviceLabel}), and is non-volatile - so it is remembered
+ * even if the Phidget is unplugged.
+ *
+ * @return Label
+ * @throws PhidgetException If this Phidget is not opened and attached, or if this Phidget does not support labels.
+ * See {@link #open(int) open} for determining if a device is attached.
+ */
+ public final native String getDeviceLabel() throws PhidgetException;
+
+ /**
+ * Sets the Label associated with this Phidget. Labels are user defined Strings that persist in a Phidget's Flash.
+ * They are only supported in the newer Phidgets. The maximum length is 10 characters.
+ * <p>
+ * Labels can not currently be set from Windows because of driver incompatibility. Labels can be set from MacOS, Linux and Windows CE.
+ *
+ * @param label Label
+ * @throws PhidgetException If this Phidget is not opened and attached, or if this Phidget does not support labels, or if this is
+ * called from Windows. See {@link #open(int) open} for determining if a device is attached.
+ */
+ public final native void setDeviceLabel(String label) throws PhidgetException;
+
+ /**
+ * Returns the Address of a Phidget Webservice when this Phidget was opened as remote. This may be an IP Address or a hostname.
+ *
+ * @return Server Address
+ * @throws PhidgetException if this Phidget was open opened as a remote Phidget.
+ */
+ public final native String getServerAddress() throws PhidgetException;
+ /**
+ * Returns the Server ID of a Phidget Webservice when this Phidget was opened as remote. This is an arbitrary server identifier,
+ * independant of IP address and Port.
+ *
+ * @return Server ID
+ * @throws PhidgetException if this Phidget was open opened as a remote Phidget.
+ */
+ public final native String getServerID() throws PhidgetException;
+ /**
+ * Returns the Port of a Phidget Webservice when this Phidget was opened as remote.
+ *
+ * @return Server Port
+ * @throws PhidgetException if this Phidget was open opened as a remote Phidget.
+ */
+ public final native int getServerPort() throws PhidgetException;
+
+ private final native void nativeClose() throws PhidgetException;
+ private final native void nativeDelete() throws PhidgetException;
+ private final native void nativeOpen(int serial) throws PhidgetException;
+ private final native void nativeOpenRemote(int serial, String serverID, String pass) throws PhidgetException;
+ private final native void nativeOpenRemoteIP(int serial, String ipAddress, int port, String pass) throws PhidgetException;
+ private final native void nativeOpenLabel(String label) throws PhidgetException;
+ private final native void nativeOpenLabelRemote(String label, String serverID, String pass) throws PhidgetException;
+ private final native void nativeOpenLabelRemoteIP(String label, String ipAddress, int port, String pass) throws PhidgetException;
+
+ /**
+ * Open this Phidget with a specific serial number.
+ * <p>
+ * Open is pervasive. What this means is that you can call open on a device before it is plugged in,
+ * and keep the device opened across device dis- and re-connections.
+ * <p>
+ * Open is Asynchronous. What this means is that open will return immediately --
+ * before the device being opened is actually available, so you need to use either the {@link #addAttachListener(AttachListener l) attach event}
+ * or the {@link #waitForAttachment() waitForAttachment} method to determine if a device
+ * is available before using it.
+ * <p>
+ * This version of open specifies a serial number - The serial number is a unique number assigned to each Phidget
+ * during production and can be used to uniquely identify specific phidgets.
+ * use {@link #openAny() openAny} to open a device without specifying the serial number.
+ *
+ * @param serial Serial Number
+ */
+ public final void open(int serial) throws PhidgetException {
+ enableEvents(true);
+ nativeOpen(serial);
+ }
+
+ /**
+ * Open this Phidget remotely using an IP Address, and a specific serial number.
+ * <p>
+ * This version of open is network based.
+ * <p>
+ * Open is pervasive. What this means is that you can call open on a device before it is plugged in,
+ * and on a server before it is running, and keep the device opened across device, and server dis- and re-connections.
+ * <p>
+ * Open is Asynchronous. What this means is that open will return immediately --
+ * before the device being opened is actually available, so you need to use either the {@link #addAttachListener(AttachListener l) attach event}
+ * or the {@link #waitForAttachment() waitForAttachment} method to determine if a device
+ * is available before using it.
+ * <p>
+ * This version of open specifies a serial number - The serial number is a unique number assigned to each Phidget
+ * during production and can be used to uniquely identify specific phidgets.
+ * use {@link #openAny(String ipAddress, int port) openAny(String ipAddress, int port)} to open a device without specifying the serial number.
+ *
+ * @param serial Serial Number
+ * @param ipAddress IP Address or hostname of the Phidget Webservice
+ * @param port Port of the Phidget Webservice
+ * @throws PhidgetException if the Phidget Webservice cannot be contacted
+ */
+ public final void open(int serial, String ipAddress, int port) throws PhidgetException
+ {
+ open(serial, ipAddress, port, "");
+ }
+ /**
+ * Open this Phidget remotely and securely, using an IP Address, and a specific serial number.
+ * <p>
+ * This method is the same as {@link #open(int, String, int) open(int serial, String ipAddress, int port)}, except that it specifies a password.
+ * This password can be set as a parameter when starting the Phidget Webservice.
+ */
+ public final void open(int serial, String ipAddress, int port, String password) throws PhidgetException
+ {
+ enableEvents(true);
+ nativeOpenRemoteIP(serial, ipAddress, port, password);
+ }
+
+ /**
+ * Open this Phidget remotely using a Server ID, and a specific serial number.
+ * <p>
+ * This version of open is network based.
+ * <p>
+ * Open is pervasive. What this means is that you can call open on a device before it is plugged in,
+ * and on a server before it is running, and keep the device opened across device, and server dis- and re-connections.
+ * <p>
+ * Open is Asynchronous. What this means is that open will return immediately --
+ * before the device being opened is actually available, so you need to use either the {@link #addAttachListener(AttachListener l) attach event}
+ * or the {@link #waitForAttachment() waitForAttachment} method to determine if a device
+ * is available before using it.
+ * <p>
+ * This version of open specifies a serial number - The serial number is a unique number assigned to each Phidget
+ * during production and can be used to uniquely identify specific phidgets.
+ * use {@link #openAny(String) openAny(String serverID)} to open a device without specifying the serial number.
+ * <p>
+ * ServerID can be set to null, if the ServerID does not matter. In this case, the specified Phidget (by serial number) will be opened
+ * whenever it is seen on the network, regardless of which server it appears on. This also applies when not specifying a serial number.
+ * <p>
+ * Note: All open methods that specify a ServerID rather then an IP Addresss and Port require that both the client and host sides of the
+ * connection be running an implementation of zeroconf:
+ * <ul><li>On Windows, this means installing Apple's Bonjour - available <a href="http://www.apple.com/support/downloads/bonjourforwindows.html">here</a>.</li>
+ * <li>On Linux, this means Avahi, which is usually either installed by default or available as a package install.</li>
+ * <li>On MacOSX, Bonjour is already integrated into the operationg system.</li></ul>
+ *
+ * @param serial Serial Number
+ * @param serverID ServerID of the Phidget Webservice
+ */
+ public final void open(int serial, String serverID) throws PhidgetException
+ {
+ open(serial, serverID, "");
+ }
+
+ /**
+ * Open this Phidget remotely and securely, using a Server ID, and a specific serial number.
+ * <p>
+ * This method is the same as {@link #open(int, String) open(int serial, String serverID)}, except that it specifies a password.
+ * This password can be set as a parameter when starting the Phidget Webservice.
+ */
+ public final void open(int serial, String serverID, String password) throws PhidgetException
+ {
+ enableEvents(true);
+ nativeOpenRemote(serial, serverID, password);
+ }
+
+ /**
+ * Open a this Phidget without a serial number. This method is the same as {@link #open(int) open}, except that it specifies no serial number. Therefore, the first available
+ * Phidget will be opened. If there are two Phidgets of the same type attached to the system, you should specify a serial number, as
+ * there is no guarantee which Phidget will be selected by the call to openAny().
+ */
+ public final void openAny() throws PhidgetException {
+ open(-1);
+ }
+
+ /**
+ * Open this Phidget remotely using an IP Address, without a serial number.
+ * This method is the same as {@link #open(int, String, int) open(int serial, String ipAddress, int port)},
+ * except that it specifies no serial number. Therefore, the first available
+ * Phidget will be opened. If there are two Phidgets of the same type attached to the system, you should specify a serial number, as
+ * there is no guarantee which Phidget will be selected by the call to openAny().
+ */
+ public final void openAny(String ipAddress, int port) throws PhidgetException
+ {
+ open(-1, ipAddress, port, "");
+ }
+
+
+ /**
+ * Open this Phidget remotely and securely, using an IP Address, without a serial number.
+ * This method is the same as {@link #open(int, String, int, String) open(int serial, String ipAddress, int port, String password)},
+ * except that it specifies no serial number. Therefore, the first available
+ * Phidget will be opened. If there are two Phidgets of the same type attached to the system, you should specify a serial number, as
+ * there is no guarantee which Phidget will be selected by the call to openAny().
+ */
+ public final void openAny(String ipAddress, int port, String password) throws PhidgetException
+ {
+ open(-1, ipAddress, port, password);
+ }
+
+
+ /**
+ * Open this Phidget remotely using a Server ID, without a serial number.
+ * This method is the same as {@link #open(int, String) open(int serial, String serverID)},
+ * except that it specifies no serial number. Therefore, the first available
+ * Phidget will be opened. If there are two Phidgets of the same type attached to the system, you should specify a serial number, as
+ * there is no guarantee which Phidget will be selected by the call to openAny().
+ */
+ public final void openAny(String serverID) throws PhidgetException
+ {
+ open(-1, serverID, "");
+ }
+
+ /**
+ * Open this Phidget remotely and securely, using a Server ID, without a serial number.
+ * This method is the same as {@link #open(int, String, String) open(int serial, String serverID, String password)},
+ * except that it specifies no serial number. Therefore, the first available
+ * Phidget will be opened. If there are two Phidgets of the same type attached to the system, you should specify a serial number, as
+ * there is no guarantee which Phidget will be selected by the call to openAny().
+ */
+ public final void openAny(String serverID, String password) throws PhidgetException
+ {
+ open(-1, serverID, password);
+ }
+
+ /**
+ * Open this Phidget with a specific label.
+ * <p>
+ * Open is pervasive. What this means is that you can call open on a device before it is plugged in,
+ * and keep the device opened across device dis- and re-connections.
+ * <p>
+ * Open is Asynchronous. What this means is that open will return immediately --
+ * before the device being opened is actually available, so you need to use either the {@link #addAttachListener(AttachListener l) attach event}
+ * or the {@link #waitForAttachment() waitForAttachment} method to determine if a device
+ * is available before using it.
+ * <p>
+ * This version of open specifies a label - The label can be set and changed by using the setLabel method (setLabel is unsupported on Windows).
+ * use {@link #openAny() openAny} to open a device without specifying the label.
+ *
+ * @param label The Label
+ */
+ public final void openLabel(String label) throws PhidgetException {
+ enableEvents(true);
+ nativeOpenLabel(label);
+ }
+
+ /**
+ * Open this Phidget remotely using an IP Address, and a specific label.
+ * <p>
+ * This version of open is network based.
+ * <p>
+ * Open is pervasive. What this means is that you can call open on a device before it is plugged in,
+ * and on a server before it is running, and keep the device opened across device, and server dis- and re-connections.
+ * <p>
+ * Open is Asynchronous. What this means is that open will return immediately --
+ * before the device being opened is actually available, so you need to use either the {@link #addAttachListener(AttachListener l) attach event}
+ * or the {@link #waitForAttachment() waitForAttachment} method to determine if a device
+ * is available before using it.
+ * <p>
+ * This version of open specifies a label - The label can be set and changed by using the setLabel method (setLabel is unsupported on Windows).
+ * use {@link #openAny(String ipAddress, int port) openAny(String ipAddress, int port)} to open a device without specifying the label.
+ *
+ * @param label The Label
+ * @param ipAddress IP Address or hostname of the Phidget Webservice
+ * @param port Port of the Phidget Webservice
+ * @throws PhidgetException if the Phidget Webservice cannot be contacted
+ */
+ public final void openLabel(String label, String ipAddress, int port) throws PhidgetException
+ {
+ openLabel(label, ipAddress, port, "");
+ }
+ /**
+ * Open this Phidget remotely and securely, using an IP Address, and a specific label.
+ * <p>
+ * This method is the same as {@link #openLabel(String, String, int) openLabel(String label, String ipAddress, int port)}, except that it specifies a password.
+ * This password can be set as a parameter when starting the Phidget Webservice.
+ */
+ public final void openLabel(String label, String ipAddress, int port, String password) throws PhidgetException
+ {
+ enableEvents(true);
+ nativeOpenLabelRemoteIP(label, ipAddress, port, password);
+ }
+
+ /**
+ * Open this Phidget remotely using a Server ID, and a specific label.
+ * <p>
+ * This version of open is network based.
+ * <p>
+ * Open is pervasive. What this means is that you can call open on a device before it is plugged in,
+ * and on a server before it is running, and keep the device opened across device, and server dis- and re-connections.
+ * <p>
+ * Open is Asynchronous. What this means is that open will return immediately --
+ * before the device being opened is actually available, so you need to use either the {@link #addAttachListener(AttachListener l) attach event}
+ * or the {@link #waitForAttachment() waitForAttachment} method to determine if a device
+ * is available before using it.
+ * <p>
+ * This version of open specifies a label - The label can be set and changed by using the setLabel method (setLabel is unsupported on Windows).
+ * use {@link #openAny(String) openAny(String serverID)} to open a device without specifying the label.
+ * <p>
+ * ServerID can be set to null, if the ServerID does not matter. In this case, the specified Phidget (by label) will be opened
+ * whenever it is seen on the network, regardless of which server it appears on. This also applies when not specifying a label.
+ * <p>
+ * Note: All open methods that specify a ServerID rather then an IP Addresss and Port require that both the client and host sides of the
+ * connection be running an implementation of zeroconf:
+ * <ul><li>On Windows, this means installing Apple's Bonjour - available <a href="http://www.apple.com/support/downloads/bonjourforwindows.html">here</a>.</li>
+ * <li>On Linux, this means Avahi, which is usually either installed by default or available as a package install.</li>
+ * <li>On MacOSX, Bonjour is already integrated into the operationg system.</li></ul>
+ *
+ * @param label The Label
+ * @param serverID ServerID of the Phidget Webservice
+ */
+ public final void openLabel(String label, String serverID) throws PhidgetException
+ {
+ openLabel(label, serverID, "");
+ }
+
+ /**
+ * Open this Phidget remotely and securely, using a Server ID, and a specific label.
+ * <p>
+ * This method is the same as {@link #openLabel(String, String) openLabel(String label, String serverID)}, except that it specifies a password.
+ * This password can be set as a parameter when starting the Phidget Webservice.
+ */
+ public final void openLabel(String label, String serverID, String password) throws PhidgetException
+ {
+ enableEvents(true);
+ nativeOpenLabelRemote(label, serverID, password);
+ }
+
+ /**
+ * Closes this Phidget.
+ * This will shut down all threads dealing with this Phidget and you won't recieve any more events.
+ *
+ * @throws PhidgetException If this Phidget is not opened.
+ */
+ public final void close() throws PhidgetException {
+ if(!managerPhidget)
+ {
+ enableEvents(false);
+ nativeClose();
+ }
+ }
+
+ private void enableEvents(boolean b) {
+ enableAttachEvents(b && attachListeners.size() > 0);
+ enableDetachEvents(b && detachListeners.size() > 0);
+ enableErrorEvents(b && errorListeners.size() > 0);
+ enableServerConnectEvents(b && serverConnectListeners.size() > 0);
+ enableServerDisconnectEvents(b && serverDisconnectListeners.size() > 0);
+ enableDeviceSpecificEvents(b);
+ }
+
+ /**
+ * Waits for this Phidget to become available. This method can be called after open has been called
+ * to wait for thid Phidget to become available. This is usefull because open is asynchronous (and thus returns immediately),
+ * and most methods will throw a PhidgetException is they are called before a device is actually ready. This method is
+ * synonymous with polling the isAttached method until it returns True, or using the Attach event.
+ * <p>
+ * This method blocks for up to the timeout, at which point it will throw a PhidgetException. Otherwise, it returns when
+ * the phidget is attached and initialized.
+ * <p>
+ * A timeout of 0 is infinite.
+ *
+ * @param timeout Timeout in milliseconds
+ * @throws PhidgetException If this Phidget is not opened.
+ */
+ public final native void waitForAttachment(int timeout) throws PhidgetException;
+ /**
+ * Waits for this Phidget to become available. This method can be called after open has been called
+ * to wait for thid Phidget to become available. This is usefull because open is asynchronous (and thus returns immediately),
+ * and most methods will throw a PhidgetException is they are called before a device is actually ready. This method is
+ * synonymous with polling the isAttached method until it returns True, or using the Attach event.
+ * <p>
+ * This method blocks indefinitely until the Phidget becomes available. This can be quite some time
+ * (forever), if the Phidget is never plugged in.
+ *
+ * @throws PhidgetException If this Phidget is not opened.
+ */
+ public final void waitForAttachment() throws PhidgetException
+ {
+ waitForAttachment(0);
+ }
+
+ private void enableDeviceSpecificEvents(boolean b) { }
+
+ private LinkedList attachListeners = new LinkedList();
+ private long nativeAttachHandler = 0;
+
+ /**
+ * Adds an attach listener. The attach handler is a method that will be called when this Phidget is phisically attached
+ * to the system, and has gone through its initalization, and so is ready to be used.
+ * <p>
+ * There is no limit on the number of attach handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.AttachListener AttachListener} interface
+ */
+ public final void addAttachListener(AttachListener l) {
+ synchronized (attachListeners) {
+ attachListeners.add(l);
+ enableAttachEvents(true);
+ }
+ }
+
+ /**
+ * Removes an attach listener. This will remove a previously added attach listener.
+ */
+ public final void removeAttachListener(AttachListener l) {
+ synchronized (attachListeners) {
+ attachListeners.remove(l);
+ enableAttachEvents(attachListeners.size() > 0);
+ }
+ }
+ private void fireAttach(AttachEvent e) {
+ synchronized (attachListeners) {
+ for (Iterator it = attachListeners.iterator();
+ it.hasNext(); )
+ ((AttachListener)it.next()).attached(e);
+ }
+ }
+ private native void enableAttachEvents(boolean b);
+
+ private LinkedList errorListeners = new LinkedList();
+ private long nativeErrorHandler = 0;
+
+ /**
+ * Adds an error listener. The error handler is a method that will be called when an asynchronous error occurs.
+ * Error events are not currently used, but will be in the future to report any problems that happen out of context from
+ * a direct function call.
+ * <p>
+ * There is no limit on the number of error handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.ErrorListener ErrorListener} interface
+ */
+ public final void addErrorListener(ErrorListener l) {
+ synchronized (errorListeners) {
+ errorListeners.add(l);
+ enableErrorEvents(true);
+ }
+ }
+
+ /**
+ * Removes an error listener. This will remove a previously added error listener.
+ */
+ public final void removeErrorListener(ErrorListener l) {
+ synchronized (errorListeners) {
+ errorListeners.remove(l);
+ enableErrorEvents(errorListeners.size() > 0);
+ }
+ }
+ private void fireError(ErrorEvent e) {
+ synchronized (errorListeners) {
+ for (Iterator it = errorListeners.iterator();
+ it.hasNext(); )
+ ((ErrorListener)it.next()).error(e);
+ }
+ }
+ private native void enableErrorEvents(boolean b);
+
+ private LinkedList detachListeners = new LinkedList();
+ private long nativeDetachHandler = 0;
+
+ /**
+ * Adds a detach listener. The detach handler is a method that will be called when this Phidget is phisically detached
+ * from the system, and is no longer available. This is particularly usefull for applications when a phisical detach would be expected.
+ * <p>
+ * Remember that many of the methods, if called on an unattached device, will throw a PhidgetException. This Exception can be checked to see if it
+ * was caused by a device being unattached, but a better method would be to regiter the detach handler, which could notify the main program logic that
+ * the device is no longer available, disable GUI controls, etc.
+ * <p>
+ * There is no limit on the number of detach handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.DetachListener DetachListener} interface
+ */
+ public final void addDetachListener(DetachListener l) {
+ synchronized (detachListeners) {
+ detachListeners.add(l);
+ enableDetachEvents(true);
+ }
+ }
+ /**
+ * Removes a detach listener. This will remove a previously added detach listener.
+ */
+ public final void removeDetachListener(DetachListener l) {
+ synchronized (detachListeners) {
+ detachListeners.remove(l);
+ enableDetachEvents(detachListeners.size() > 0);
+ }
+ }
+ private void fireDetach(DetachEvent e) {
+ synchronized (detachListeners) {
+ for (Iterator it = detachListeners.iterator();
+ it.hasNext(); )
+ ((DetachListener)it.next()).detached(e);
+ }
+ }
+ private native void enableDetachEvents(boolean b);
+
+
+ private LinkedList serverConnectListeners = new LinkedList();
+ private long nativeServerConnectHandler = 0;
+
+ /**
+ * Adds an serverConnect listener. The serverConnect handler is a method that will be called when a connection to a server is made.
+ * This is only usefull for Phidgets opened remotely.
+ * <p>
+ * There is no limit on the number of serverConnect handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.ServerConnectListener ServerConnectListener} interface
+ */
+ public final void addServerConnectListener(ServerConnectListener l)
+ {
+ synchronized (serverConnectListeners)
+ {
+ serverConnectListeners.add(l);
+ enableServerConnectEvents(true);
+ }
+ }
+
+ /**
+ * Removes an serverConnect listener. This will remove a previously added serverConnect listener.
+ */
+ public final void removeServerConnectListener(ServerConnectListener l)
+ {
+ synchronized (serverConnectListeners)
+ {
+ serverConnectListeners.remove(l);
+ enableServerConnectEvents(serverConnectListeners.size() > 0);
+ }
+ }
+ private void fireServerConnect(ServerConnectEvent e)
+ {
+ synchronized (serverConnectListeners)
+ {
+ for (Iterator it = serverConnectListeners.iterator();
+ it.hasNext(); )
+ ((ServerConnectListener)it.next()).serverConnected(e);
+ }
+ }
+ private native void enableServerConnectEvents(boolean b);
+
+
+ private LinkedList serverDisconnectListeners = new LinkedList();
+ private long nativeServerDisconnectHandler = 0;
+
+ /**
+ * Adds an serverDisconnect listener. The serverDisconnect handler is a method that will be called when a connection to a server is terminated.
+ * This is only usefull for Phidgets opened remotely.
+ * <p>
+ * There is no limit on the number of serverDisconnect handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.ServerDisconnectListener ServerDisconnectListener} interface
+ */
+ public final void addServerDisconnectListener(ServerDisconnectListener l)
+ {
+ synchronized (serverDisconnectListeners)
+ {
+ serverDisconnectListeners.add(l);
+ enableServerDisconnectEvents(true);
+ }
+ }
+
+ /**
+ * Removes an serverDisconnect listener. This will remove a previously added serverDisconnect listener.
+ */
+ public final void removeServerDisconnectListener(ServerDisconnectListener l)
+ {
+ synchronized (serverDisconnectListeners)
+ {
+ serverDisconnectListeners.remove(l);
+ enableServerDisconnectEvents(serverDisconnectListeners.size() > 0);
+ }
+ }
+ private void fireServerDisconnect(ServerDisconnectEvent e)
+ {
+ synchronized (serverDisconnectListeners)
+ {
+ for (Iterator it = serverDisconnectListeners.iterator();
+ it.hasNext(); )
+ ((ServerDisconnectListener)it.next()).serverDisconnected(e);
+ }
+ }
+ private native void enableServerDisconnectEvents(boolean b);
+
+ /**
+ * Return a Sring describing this Phidget.
+ */
+ public String toString() {
+ int dv = -1;
+ int sn = -1;
+ String dt = null;
+ String at = "";
+
+ try {
+ dv = getDeviceVersion();
+ sn = getSerialNumber();
+ dt = getDeviceType();
+ at = isAttached() ? " (attached)" : " (unattached)";
+ } catch (PhidgetException e) {
+ ;
+ } finally {
+ if (dt == null)
+ dt = getClass().getName().replaceFirst(
+ ".*\\.", "");
+ }
+ return dt + " v" + dv + " #" + sn + at;
+ }
+
+ protected void finalize() throws Throwable
+ {
+ try
+ {
+ if(!managerPhidget)
+ {
+ try
+ {
+ close();
+ }
+ catch (Exception e)
+ {
+ ;
+ }
+ try
+ {
+ nativeDelete();
+ }
+ catch (Exception e)
+ {
+ ;
+ }
+ }
+ }
+ finally
+ {
+ handle = 0;
+ super.finalize();
+ }
+ }
+
+ /**
+ * Compares two Phidgets. This method compares two Phidgets using serial number, device type and version.
+ */
+ public boolean equals(Object comp)
+ {
+ Phidget temp = (Phidget)comp;
+ try
+ {
+ if (temp.getSerialNumber() == getSerialNumber() && temp.getDeviceType().equals(getDeviceType()) &&
+ temp.getDeviceVersion() == getDeviceVersion())
+ return true;
+ }
+ catch (Exception e) { }
+ return false;
+ }
+}
diff --git a/Java/com/phidgets/PhidgetException.java b/Java/com/phidgets/PhidgetException.java
new file mode 100644
index 0000000..f33d345
--- /dev/null
+++ b/Java/com/phidgets/PhidgetException.java
@@ -0,0 +1,337 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets;
+
+/**
+ * This class represents Phidget related exceptions. All Phidget exceptions originate in the phidget21 C library.
+ * These exceptions can be thrown by most function in the library and cover such things as trying to access
+ * a Phidget before opening it, or before it is attached and ready to use, out of bounds Index and data values,
+ * trying to read data that isn't available, and other less common problems. EPHIDGET_(error) errors are thrown
+ * by any API calls, EEPHIDGET_(error) errors are returned via the {@link com.phidgets.event.ErrorEvent Error} event.
+ */
+public class PhidgetException extends java.lang.Exception {
+ private int errno;
+ private String description;
+
+ /**
+ * Constructor which takes in an error number and description.
+ * These exceptions originate from and are filled in by the phidget 21 C library.
+ */
+ public PhidgetException(int errno, String description) {
+ this.description = description;
+ this.errno = errno;
+ }
+
+ /**
+ * Phidget not found exception. "A Phidget matching the type and or serial number could not be found."
+ * <P>
+ * This exception is not currently used externally.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_NOTFOUND = 1;
+ /**
+ * No memory exception. "Memory could not be allocated."
+ * <P>
+ * This exception is thrown when a memory allocation (malloc) call fails in the c library.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_NOMEMORY = 2;
+ /**
+ * Unexpected exception. "Unexpected Error. Contact Phidgets Inc. for support."
+ * <P>
+ * This exception is thrown when something unexpected happens (more enexpected then another exception). This generally
+ * points to a bug or bad code in the C library, and hopefully won't even be seen.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_UNEXPECTED = 3;
+ /**
+ * Invalid argument exception. "Invalid argument passed to function."
+ * <P>
+ * This exception is thrown whenever a function recieves an unexpected null pointer, or a value that is out of range. ie setting a motor's speed to 101 when the maximum is 100.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_INVALIDARG = 4;
+ /**
+ * Phidget not attached exception. "Phidget not physically attached."
+ * <P>
+ * This exception is thrown when a method is called on a device that is not attached, and the method requires the device to be attached. ie trying to read the serial number, or
+ * the state of an ouput.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_NOTATTACHED = 5;
+ /**
+ * Interrupted exception. "Read/Write operation was interrupted."
+ * <P>
+ * This exception is not currently used externally.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_INTERRUPTED = 6;
+ /**
+ * Invalid error exception. "The Error Code is not defined."
+ * <P>
+ * This exception is thrown when trying to get the string description of an undefined error code. This should not be seen in Java.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_INVALID = 7;
+ /**
+ * Network exception. "Network Error."
+ * <P>
+ * This exception is thrown when a network related error occurs. The {@link #EEPHIDGET_NETWORK EEPHIDGET_NETWORK} code is more often used (in error events)
+ * because most network exceptions come through asynchronously.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_NETWORK = 8;
+ /**
+ * Value unknown exception. "Value is Unknown (State not yet received from device, or not yet set by user)."
+ * <P>
+ * This exception is thrown when a device that is set to unknow is read. ie trying to read the position of a servo before setting it's position.
+ * <p>
+ * Every effort is made in the library to fill in as much of a device's state before the attach event gets thrown, however, many there are some states
+ * that cannot be filled in automatically. ie older interface kits do not return their output states, and so these will be unknown until they are set.
+ * <p>
+ * This is a quite common exception for some devices, and so should always be caught
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_UNKNOWNVAL = 9;
+ /**
+ * Authorization exception. "Authorization Failed."
+ * <P>
+ * This exception has been replaced by {@link #EEPHIDGET_BADPASSWORD EEPHIDGET_BADPASSWORD}.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_BADPASSWORD = 10;
+ /**
+ * Unsupported exception. "Not Supported."
+ * <P>
+ * This exception is thrown when a method is called that is not supported, either by that device, or by the system. ie calling setRatiometric on an interfaceKit that does not have sensors.
+ * <p>
+ * This is also used for methods that are not yet complete, ie setLabel on Windows.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_UNSUPPORTED = 11;
+ /**
+ * Duplicate request exception. "Duplicated request."
+ * <P>
+ * This exception is thrown when open is called twice on a device, without calling close in between. The second call to open is ignored.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_DUPLICATE = 12;
+ /**
+ * Timeout exception. "Given timeout has been exceeded."
+ * <P>
+ * This exception is thrown by {@link com.phidgets.Phidget#waitForAttachment(int) waitForAttachment(int)} if the provided timeout expires before an attach happens.
+ * This may also be thrown by a device set request, if the set times out - though this should not happen, and would generally mean a problem with the device.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_TIMEOUT = 13;
+ /**
+ * Out of bounds exception. "Index out of Bounds."
+ * <P>
+ * This exception is thrown anytime an indexed set or get method is called with an out of bounds index.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_OUTOFBOUNDS = 14;
+ /**
+ * Event exception. "A non-null error code was returned from an event handler."
+ * <P>
+ * This exception is not currently used.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_EVENT = 15;
+ /**
+ * Network not connected exception. "A connection to the server does not exist."
+ * <P>
+ * This exception is thrown when a network specific method is called on a device that was opened remotely, but there is no connection to a server. ie getServerID.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_NETWORK_NOTCONNECTED = 16;
+ /**
+ * Wrong device exception. "Function is not applicable for this device."
+ * <P>
+ * This exception is thrown when a method from device is called by another device. ie casting an InterfaceKit to a Servo and calling setPosition.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_WRONGDEVICE = 17;
+ /**
+ * Phidget closed exception. "Phidget handle was closed."
+ * <P>
+ * This exception is thrown when {@link com.phidgets.Phidget#waitForAttachment waitForAttachment} is called on a Phidget that has not been opened, or was closed.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_CLOSED = 18;
+ /**
+ * Version mismatch exception. "Webservice and Client protocol versions don't match. Update to newest release."
+ * <P>
+ * This exception has been replaced by {@link #EEPHIDGET_BADVERSION EEPHIDGET_BADVERSION}.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EPHIDGET_BADVERSION = 19;
+
+
+ //Error Event codes
+
+ /**
+ * Network exception. "Network Error."
+ * <P>
+ * This exception is sent via the {@link com.phidgets.event.ErrorEvent Error} event. It will be accompanied by a specific Description of the network problem.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EEPHIDGET_NETWORK = 0x8001;
+ /**
+ * Authorization exception. "Authorization Failed."
+ * <P>
+ * This exception is sent via the {@link com.phidgets.event.ErrorEvent Error} event. It means that a connection could not be authenticated because of a passwrod missmatch.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EEPHIDGET_BADPASSWORD = 0x8002;
+ /**
+ * Version mismatch exception. "Webservice and Client protocol versions don't match. Update to newest release."
+ * <P>
+ * This exception is sent via the {@link com.phidgets.event.ErrorEvent Error} event when trying to connect to a remote phidget and the webservice version does not match your client library version.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EEPHIDGET_BADVERSION = 0x8003;
+ /**
+ * Overrun exception. "A sampling overrun happend in firmware."
+ * <P>
+ * This exception sent via in the {@link com.phidgets.event.ErrorEvent Error} event. It is accompanied by a specific {@link #getDescription description}.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EEPHIDGET_OVERRUN = 0x9002;
+ /**
+ * Packet lost exception. "One or more packets were lost."
+ * <P>
+ * This exception sent via in the {@link com.phidgets.event.ErrorEvent Error} event. It is accompanied by a specific {@link #getDescription description}.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EEPHIDGET_PACKETLOST = 0x9003;
+ /**
+ * Wraparound exception. "A variable has wrapped around."
+ * <P>
+ * This exception sent via in the {@link com.phidgets.event.ErrorEvent Error} event. It is accompanied by a specific {@link #getDescription description}.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EEPHIDGET_WRAP = 0x9004;
+ /**
+ * Overtemperature exception. "Overtemperature condition detected."
+ * <P>
+ * This exception sent via in the {@link com.phidgets.event.ErrorEvent Error} event. It is accompanied by a specific {@link #getDescription description}.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EEPHIDGET_OVERTEMP = 0x9005;
+ /**
+ * Overcurrent exception. "Overcurrent condition detected."
+ * <P>
+ * This exception sent via in the {@link com.phidgets.event.ErrorEvent Error} event. It is accompanied by a specific {@link #getDescription description}.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EEPHIDGET_OVERCURRENT = 0x9006;
+ /**
+ * Out of range exception. "Out of range condition detected."
+ * <P>
+ * This exception sent via in the {@link com.phidgets.event.ErrorEvent Error} event. It is accompanied by a specific {@link #getDescription description}.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EEPHIDGET_OUTOFRANGE = 0x9007;
+ /**
+ * Bad power exception. "Power supply problem detected."
+ * <P>
+ * This exception sent via in the {@link com.phidgets.event.ErrorEvent Error} event. It is accompanied by a specific {@link #getDescription description}.
+ * <p>
+ * This is returned by {@link #getErrorNumber getErrorNumber}
+ */
+ public static final int EEPHIDGET_BADPOWER = 0x9008;
+
+ /**
+ * Returns the error number of this exception. This error number will match one of the EPHIDGET_(error) or EEPHIDGET_(error) constants defined in this class.
+ * These numbers are defined in the phidget21 c library and are consistent across all APIs.
+ * <p>
+ * There are 19 error codes defined, as follows:
+ * <br>
+ * {@link #EPHIDGET_NOTFOUND EPHIDGET_NOTFOUND},
+ * {@link #EPHIDGET_NOMEMORY EPHIDGET_NOMEMORY},
+ * {@link #EPHIDGET_UNEXPECTED EPHIDGET_UNEXPECTED},
+ * {@link #EPHIDGET_INVALIDARG EPHIDGET_INVALIDARG},
+ * {@link #EPHIDGET_NOTATTACHED EPHIDGET_NOTATTACHED},
+ * {@link #EPHIDGET_INTERRUPTED EPHIDGET_INTERRUPTED},
+ * {@link #EPHIDGET_INVALID EPHIDGET_INVALID},
+ * {@link #EPHIDGET_NETWORK EPHIDGET_NETWORK},
+ * {@link #EPHIDGET_UNKNOWNVAL EPHIDGET_UNKNOWNVAL},
+ * {@link #EPHIDGET_BADPASSWORD EPHIDGET_BADPASSWORD},
+ * {@link #EPHIDGET_UNSUPPORTED EPHIDGET_UNSUPPORTED},
+ * {@link #EPHIDGET_DUPLICATE EPHIDGET_DUPLICATE},
+ * {@link #EPHIDGET_TIMEOUT EPHIDGET_TIMEOUT},
+ * {@link #EPHIDGET_OUTOFBOUNDS EPHIDGET_OUTOFBOUNDS},
+ * {@link #EPHIDGET_EVENT EPHIDGET_EVENT},
+ * {@link #EPHIDGET_NETWORK_NOTCONNECTED EPHIDGET_NETWORK_NOTCONNECTED},
+ * {@link #EPHIDGET_WRONGDEVICE EPHIDGET_WRONGDEVICE},
+ * {@link #EPHIDGET_CLOSED EPHIDGET_CLOSED} and
+ * {@link #EPHIDGET_BADVERSION EPHIDGET_BADVERSION}</pre>
+ * <p>
+ * There are also 9 error event codes defined, as follows:
+ * <br>
+ * {@link #EEPHIDGET_NETWORK EEPHIDGET_NETWORK},
+ * {@link #EEPHIDGET_BADPASSWORD EEPHIDGET_BADPASSWORD},
+ * {@link #EEPHIDGET_BADVERSION EEPHIDGET_BADVERSION},
+ * {@link #EEPHIDGET_OVERRUN EEPHIDGET_OVERRUN},
+ * {@link #EEPHIDGET_PACKETLOST EEPHIDGET_PACKETLOST},
+ * {@link #EEPHIDGET_WRAP EEPHIDGET_WRAP},
+ * {@link #EEPHIDGET_OVERTEMP EEPHIDGET_OVERTEMP},
+ * {@link #EEPHIDGET_OVERCURRENT EEPHIDGET_OVERCURRENT},
+ * {@link #EEPHIDGET_OUTOFRANGE EEPHIDGET_OUTOFRANGE}</pre>
+ *
+ * @return The error code
+ */
+ public int getErrorNumber() {
+ return errno;
+ }
+
+ /**
+ * Returns a description of this exception. This is an english phrase that describes the exception that
+ * occured. These strings originate in the base phidget21 C library, and should help to diagnose problems.
+ *
+ * @return The error description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Returns a string containing the error number and exception description.
+ *
+ * @return A string describing the error
+ */
+ public String toString() {
+ return "PhidgetException " + errno + " (" + description + ")";
+ }
+}
diff --git a/Java/com/phidgets/RFIDPhidget.java b/Java/com/phidgets/RFIDPhidget.java
new file mode 100644
index 0000000..b102b67
--- /dev/null
+++ b/Java/com/phidgets/RFIDPhidget.java
@@ -0,0 +1,197 @@
+
+/*
+ * 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 RFID Reader. All methods
+ * to read tags and set outputs on the RFID reader are implemented in this class.
+ * <p>
+ * The Phidget RFID reader can read one tag at a time. Both tag and tagloss event handlers are provided,
+ * as well as control over the antenna so that multiple readers can exists in close proximity without interference.
+ *
+ * @author Phidgets Inc.
+ */
+public final class RFIDPhidget extends Phidget
+{
+ public RFIDPhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+ /**
+ * Returns the number of outputs. These are the outputs provided by the terminal block.
+ * Older RFID readers do not have these outputs, and this method will return 0.
+ * @return number of outputs
+ * @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 int getOutputCount () throws PhidgetException;
+ /**
+ * Returns the state of an output. True indicated activated, False deactivated, which is the default.
+ * @param index index of the output
+ * @return state of the output
+ * @throws PhidgetException If this Phidget is not opened and attached, or the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getOutputState (int index) throws PhidgetException;
+ /**
+ * Sets the state of a digital output. True indicated activated, False deactivated, which is the default.
+ * @param index index of the output
+ * @param state desired state
+ * @throws PhidgetException If this Phidget is not opened and attached, or the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setOutputState (int index, boolean state) throws PhidgetException;
+ /**
+ * Returns the state of the antenna. True indicated that the antenna is active, False indicated inactive.
+ * @return state of the antenna
+ * @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 boolean getAntennaOn () throws PhidgetException;
+ /**
+ * Sets the state of the antenna. True turns the antenna on, False turns it off. The antenna if by default
+ * turned off, and needs to be explicitely activated before tags can be read. Control over the antenna
+ * allows multiple readers to be used in close proximity, as multiple readers will interfere with each other if
+ * their antenna's are activated simultaneously.
+ * @param state new state for the antenna
+ * @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 setAntennaOn (boolean state) throws PhidgetException;
+ /**
+ * Returns the state of the onboard LED. This LED is by default turned off.
+ * @return state of the LED
+ * @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 boolean getLEDOn () throws PhidgetException;
+ /**
+ * Sets the state of the onboard LED. True turns the LED on, False turns it off. The LED is by default turned off.
+ * @param state new state for the LED
+ * @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 setLEDOn (boolean state) throws PhidgetException;
+ /**
+ * Returns the last tag read. This method will only return a valid tag after a tag has been seen.
+ * This method can be used even after a tag has been removed from the reader
+ * @return tag
+ * @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 String getLastTag () throws PhidgetException;
+ /**
+ * Returns the state of whether or not a tag is being read by the reader.
+ * True indicated that a tag is on (or near) the reader, false indicates that one is not.
+ * @return tag read state
+ * @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 boolean getTagStatus () throws PhidgetException;
+
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ enableTagGainEvents (b && tagGainListeners.size () > 0);
+ enableTagLossEvents (b && tagLossListeners.size () > 0);
+ enableOutputChangeEvents (b && outputChangeListeners.size () > 0);
+ }
+ /**
+ * Adds a tag gained listener. The tag gaiend handler is a method that will be called when a new tag is
+ seen by the reader. The event is only fired one time for a new tag, so the tag has to be removed and then replaced before
+ another tag gained event will fire.
+ * <p>
+ * There is no limit on the number of tag gained change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.TagGainListener TagGainListener} interface
+ */
+ public final void addTagGainListener (TagGainListener l)
+ {
+ synchronized (tagGainListeners)
+ {
+ tagGainListeners.add (l);
+ enableTagGainEvents (true);
+ }} private LinkedList tagGainListeners = new LinkedList ();
+ private long nativeTagGainHandler = 0;
+ public final void removeTagGainListener (TagGainListener l)
+ {
+ synchronized (tagGainListeners)
+ {
+ tagGainListeners.remove (l);
+ enableTagGainEvents (tagGainListeners.size () > 0);
+ }} private void fireTagGain (TagGainEvent e)
+ {
+ synchronized (tagGainListeners)
+ {
+ for (Iterator it = tagGainListeners.iterator (); it.hasNext ();)
+ ((TagGainListener) it.next ()).tagGained (e);
+ }
+ }
+ private native void enableTagGainEvents (boolean b);
+ /**
+ * Adds a tag lost listener. The tag lost handler is a method that will be called when a tag is
+ removed from the reader.
+ * <p>
+ * There is no limit on the number of tag lost change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.TagLossListener TagLossListener} interface
+ */
+ public final void addTagLossListener (TagLossListener l)
+ {
+ synchronized (tagLossListeners)
+ {
+ tagLossListeners.add (l);
+ enableTagLossEvents (true);
+ }} private LinkedList tagLossListeners = new LinkedList ();
+ private long nativeTagLossHandler = 0;
+ public final void removeTagLossListener (TagLossListener l)
+ {
+ synchronized (tagLossListeners)
+ {
+ tagLossListeners.remove (l);
+ enableTagLossEvents (tagLossListeners.size () > 0);
+ }} private void fireTagLoss (TagLossEvent e)
+ {
+ synchronized (tagLossListeners)
+ {
+ for (Iterator it = tagLossListeners.iterator (); it.hasNext ();)
+ ((TagLossListener) it.next ()).tagLost (e);
+ }
+ }
+ private native void enableTagLossEvents (boolean b);
+ /**
+ * Adds an output change listener. The output change handler is a method that will be called when an output has changed.
+ * <p>
+ * There is no limit on the number of output change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.OutputChangeListener OutputChangeListener} interface
+ */
+ public final void addOutputChangeListener (OutputChangeListener l)
+ {
+ synchronized (outputChangeListeners)
+ {
+ outputChangeListeners.add (l);
+ enableOutputChangeEvents (true);
+ }} private LinkedList outputChangeListeners = new LinkedList ();
+ private long nativeOutputChangeHandler = 0;
+ public final void removeOutputChangeListener (OutputChangeListener l)
+ {
+ synchronized (outputChangeListeners)
+ {
+ outputChangeListeners.remove (l);
+ enableOutputChangeEvents (outputChangeListeners.size () > 0);
+ }} private void fireOutputChange (OutputChangeEvent e)
+ {
+ synchronized (outputChangeListeners)
+ {
+ for (Iterator it = outputChangeListeners.iterator (); it.hasNext ();)
+ ((OutputChangeListener) it.next ()).outputChanged (e);
+ }
+ }
+ private native void enableOutputChangeEvents (boolean b);
+}
diff --git a/Java/com/phidgets/ServoPhidget.java b/Java/com/phidgets/ServoPhidget.java
new file mode 100644
index 0000000..aa9f05f
--- /dev/null
+++ b/Java/com/phidgets/ServoPhidget.java
@@ -0,0 +1,286 @@
+
+/*
+ * 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 servo Controller. All methods
+ * to control a Servo Controller are implemented in this class.
+ * <p>
+ * The Phidget Sevo controller simply outputs varying widths of PWM, which is what
+ * most servo motors take as an input driving signal.
+ *
+ * @author Phidgets Inc.
+ */
+public final class ServoPhidget extends Phidget
+{
+ public ServoPhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+
+ /**
+ * Default - This is what the servo API been historically used, originally based on the Futaba FP-S148. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_DEFAULT = 1;
+ /**
+ * Raw us mode - all position, velocity, acceleration functions are specified in microseconds rather then degrees. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_RAW_us_MODE = 2;
+ /**
+ * HiTec HS-322HD Standard Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_HS322HD = 3;
+ /**
+ * HiTec HS-5245MG Digital Mini Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_HS5245MG = 4;
+ /**
+ * HiTec HS-805BB Mega Quarter Scale Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_805BB = 5;
+ /**
+ * HiTec HS-422 Standard Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_HS422 = 6;
+ /**
+ * Tower Pro MG90 Micro Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_TOWERPRO_MG90 = 7;
+ /**
+ * HiTec HSR-1425CR Continuous Rotation Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_HSR1425CR = 8;
+ /**
+ * HiTec HS-785HB Sail Winch Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_HS785HB = 9;
+ /**
+ * HiTec HS-485HB Deluxe Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_HS485HB = 10;
+ /**
+ * HiTec HS-645MG Ultra Torque Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_HS645MG = 11;
+ /**
+ * HiTec HS-815BB Mega Sail Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_HITEC_815BB = 12;
+ /**
+ * Firgelli L12 Linear Actuator 30mm 50:1. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_FIRGELLI_L12_30_50_06_R = 13;
+ /**
+ * Firgelli L12 Linear Actuator 50mm 100:1. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_FIRGELLI_L12_50_100_06_R = 14;
+ /**
+ * Firgelli L12 Linear Actuator 50mm 210:1. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_FIRGELLI_L12_50_210_06_R = 15;
+ /**
+ * Firgelli L12 Linear Actuator 100mm 50:1. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_FIRGELLI_L12_100_50_06_R = 16;
+ /**
+ * Firgelli L12 Linear Actuator 100mm 100:1. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_FIRGELLI_L12_100_100_06_R = 17;
+ /**
+ * SpringRC SM-S2313M Micro Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_SPRINGRC_SM_S2313M = 18;
+ /**
+ * SpringRC SM-S3317M Small Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_SPRINGRC_SM_S3317M = 19;
+ /**
+ * SpringRC SM-S3317SR Small Continuous Rotation Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_SPRINGRC_SM_S3317SR = 20;
+ /**
+ * SpringRC SM-S4303R Standard Continuous Rotation Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_SPRINGRC_SM_S4303R = 21;
+ /**
+ * SpringRC SM-S4315M High Torque Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_SPRINGRC_SM_S4315M = 22;
+ /**
+ * SpringRC SM-S4315R High Torque Continuous Rotation Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_SPRINGRC_SM_S4315R = 23;
+ /**
+ * SpringRC SM-S4505B Standard Servo. This is used with {@link #getServoType getServoType} and {@link #setServoType setServoType}
+ */
+ public static final int PHIDGET_SERVO_SPRINGRC_SM_S4505B = 24;
+ /**
+ * User Defined servo parameters. This is used with {@link #getServoType getServoType}
+ */
+ public static final int PHIDGET_SERVO_USER_DEFINED = 25;
+
+ /**
+ * Returns the number of motors this Phidget can support. Note that there is no way of programatically
+ * determining how many motors are actaully attached to the board.
+ * @return number of motors
+ */
+ public native int getMotorCount () throws PhidgetException;
+ /**
+ * Returns the position of a servo motor. Note that since servo motors do not offer any feedback in their interface,
+ * this value is simply whatever the servo was last set to. There is no way of determining the position of a servo
+ * that has been plugged in, until it's position has been set. Therefore, if an initial position is important, it
+ * should be set as part of initialization.
+ * <p>
+ * If the servo is not engaged, the position is unknown and calling this function will throw an exception.
+ * <p>
+ * The range here is between {@link #getPositionMin getPositionMin} and {@link #getPositionMax getPositionMax},
+ * and corresponds aproximately to an angle in degrees. Note that most servos will not be able to operate
+ * accross this entire range.
+ * @param index index of the motor
+ * @return current position of the selected motor
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getPosition (int index) throws PhidgetException;
+ /**
+ * Returns the maximum position that a servo will accept, or return.
+ * @param index Index of the servo
+ * @return Maximum position in degrees
+ * @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 getPositionMax (int index) throws PhidgetException;
+ /**
+ * Returns the minimum position that a servo will accept, or return.
+ * @param index Index of the servo
+ * @return Minimum position in degrees
+ * @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 getPositionMin (int index) throws PhidgetException;
+ /**
+ * Sets the position of a servo motor.
+ * <p>
+ * The range here is between {@link #getPositionMin getPositionMin} and {@link #getPositionMax getPositionMax},
+ * and corresponds aproximately to an angle in degrees. Note that most servos will not be able to operate
+ * accross this entire range. Typically, the range might be 25 - 180 degrees, but this depends on the servo
+ * @param index index of the motor
+ * @param position desired position
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index or position is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setPosition (int index, double position) throws PhidgetException;
+ /**
+ * Engage or disengage a servo motor.
+ * <p>
+ * This engages or disengages the servo. The motor is engaged whenever you set a position,
+ * use this function to disengage, and reengage without setting a position.
+ *
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setEngaged (int index, boolean state) throws PhidgetException;
+ /**
+ * @deprecated Replaced by
+ * {@link #setEngaged}
+ */
+ public native void setMotorOn (int index, boolean state) throws PhidgetException;
+ /**
+ * Returns the engaged state or a servo.
+ *
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getEngaged (int index) throws PhidgetException;
+ /**
+ * @deprecated Replaced by
+ * {@link #getEngaged}
+ */
+ public native boolean getMotorOn (int index) throws PhidgetException;
+ /**
+ * Returns the servo type for an index.
+ * The possible values for type are {@link #PHIDGET_SERVO_DEFAULT PHIDGET_SERVO_DEFAULT},
+ * {@link #PHIDGET_SERVO_RAW_us_MODE PHIDGET_SERVO_RAW_us_MODE}, {@link #PHIDGET_SERVO_HITEC_HS322HD PHIDGET_SERVO_HITEC_HS322HD},
+ * {@link #PHIDGET_SERVO_HITEC_HS5245MG PHIDGET_SERVO_HITEC_HS5245MG}, {@link #PHIDGET_SERVO_HITEC_805BB PHIDGET_SERVO_HITEC_805BB},
+ * {@link #PHIDGET_SERVO_HITEC_HS422 PHIDGET_SERVO_HITEC_HS422}, etc.
+ * @param index Input
+ * @return Servo Type
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getServoType (int index) throws PhidgetException;
+ /**
+ * Sets the servo type for an index.
+ * <p>
+ * This constrains the PCM to the valid range of the servo, and sets the degrees-to-PCM ratio to match the actual servo rotation.
+ * <p>
+ * The possible values for type are {@link #PHIDGET_SERVO_DEFAULT PHIDGET_SERVO_DEFAULT},
+ * {@link #PHIDGET_SERVO_RAW_us_MODE PHIDGET_SERVO_RAW_us_MODE}, {@link #PHIDGET_SERVO_HITEC_HS322HD PHIDGET_SERVO_HITEC_HS322HD},
+ * {@link #PHIDGET_SERVO_HITEC_HS5245MG PHIDGET_SERVO_HITEC_HS5245MG}, {@link #PHIDGET_SERVO_HITEC_805BB PHIDGET_SERVO_HITEC_805BB},
+ * {@link #PHIDGET_SERVO_HITEC_HS422 PHIDGET_SERVO_HITEC_HS422}, etc.
+ * <p>
+ * Support for other servo types can be achieved by using {@link #setServoParameters setServoParameters}.
+ * <p>
+ * The default setting is {@link #PHIDGET_SERVO_DEFAULT PHIDGET_SERVO_DEFAULT}, which is used for historical (backwards compatibility) reasons.
+ * @param index Input
+ * @param type Servo Type
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setServoType (int index, int type) throws PhidgetException;
+ /**
+ * Sets the servo parameters for a custom servo definition.
+ * <p>
+ * This constrains the PCM to the valid range of the servo, and sets the degrees-to-PCM ratio to match the actual servo rotation.
+ * <p>
+ * @param index Servo Index
+ * @param minUs Minimum PCM supported in microseconds
+ * @param maxUs Maximum PCM supported in microseconds
+ * @param degrees Degrees of rotation represented by the given PCM range
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setServoParameters (int index, double minUs, double maxUs, double degrees) throws PhidgetException;
+
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ enableServoPositionChangeEvents (b && servoPositionChangeListeners.size () > 0);
+ }
+ /**
+ * Adds a servo position change listener. The servo position change handler is a method that will be called when the servo position
+ * has changed. The event will get fired after every call to {@link #setPosition(int, double) setPosition}.
+ * <p>
+ * There is no limit on the number of servo position change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.ServoPositionChangeListener ServoPositionChangeListener} interface
+ */
+ public final void addServoPositionChangeListener (ServoPositionChangeListener l)
+ {
+ synchronized (servoPositionChangeListeners)
+ {
+ servoPositionChangeListeners.add (l);
+ enableServoPositionChangeEvents (true);
+ }} private LinkedList servoPositionChangeListeners = new LinkedList ();
+ private long nativeServoPositionChangeHandler = 0;
+ public final void removeServoPositionChangeListener (ServoPositionChangeListener l)
+ {
+ synchronized (servoPositionChangeListeners)
+ {
+ servoPositionChangeListeners.remove (l);
+ enableServoPositionChangeEvents (servoPositionChangeListeners.size () > 0);
+ }} private void fireServoPositionChange (ServoPositionChangeEvent e)
+ {
+ synchronized (servoPositionChangeListeners)
+ {
+ for (Iterator it = servoPositionChangeListeners.iterator (); it.hasNext ();)
+ ((ServoPositionChangeListener) it.next ()).servoPositionChanged (e);
+ }
+ }
+ private native void enableServoPositionChangeEvents (boolean b);
+}
diff --git a/Java/com/phidgets/SpatialEventData.java b/Java/com/phidgets/SpatialEventData.java
new file mode 100644
index 0000000..0f7f9c9
--- /dev/null
+++ b/Java/com/phidgets/SpatialEventData.java
@@ -0,0 +1,101 @@
+
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets;
+/**
+ * This class represents an a set of spatial data. It's used in the SpatialData event.
+ *
+ * @author Phidget Inc.
+ */
+public final class SpatialEventData
+{
+ private double[] acceleration;
+ private double[] angularRate;
+ private double[] magneticField;
+ private int timeSeconds, timeMicroSeconds;
+
+ /**
+ * Creates a new SpatialEventData object.
+ * @param acceleration the acceleration data
+ * @param angularRate the gyro data
+ * @param magneticField the compass data
+ * @param timeSeconds the timestamp in seconds
+ * @param timeMicroSeconds the time since the last second in microseconds
+ */
+ public SpatialEventData(double[] acceleration, double[] angularRate, double[] magneticField, int timeSeconds, int timeMicroSeconds)
+ {
+ this.acceleration = new double[acceleration.length];
+ this.angularRate = new double[angularRate.length];
+ this.magneticField = new double[magneticField.length];
+ for(int i=0;i<acceleration.length;i++)
+ this.acceleration[i] = acceleration[i];
+ for(int i=0;i<angularRate.length;i++)
+ this.angularRate[i] = angularRate[i];
+ for(int i=0;i<magneticField.length;i++)
+ this.magneticField[i] = magneticField[i];
+ this.timeSeconds = timeSeconds;
+ this.timeMicroSeconds = timeMicroSeconds;
+ }
+
+ /**
+ * Returns the acceleration data.
+ * @return acceleration data
+ */
+ public double[] getAcceleration()
+ {
+ return acceleration;
+ }
+
+ /**
+ * Returns the angularRate data.
+ * @return angularRate data
+ */
+ public double[] getAngularRate()
+ {
+ return angularRate;
+ }
+
+ /**
+ * Returns the magneticField data.
+ * @return magneticField data
+ */
+ public double[] getMagneticField()
+ {
+ return magneticField;
+ }
+
+ /**
+ * Returns the seconds since attach timestamp.
+ * @return whole seconds
+ */
+ public int getTimeSeconds()
+ {
+ return timeSeconds;
+ }
+
+ /**
+ * Returns the microseconds since last second.
+ * @return microseconds
+ */
+ public int getTimeMicroSeconds()
+ {
+ return timeMicroSeconds;
+ }
+
+ /**
+ * Returns time since attach in seconds
+ * @return seconds
+ */
+ public double getTime()
+ {
+ return (timeMicroSeconds/1000000.0 + timeSeconds);
+ }
+
+ public String toString()
+ {
+ return "Spatial Data";
+ }
+}
+
diff --git a/Java/com/phidgets/SpatialPhidget.java b/Java/com/phidgets/SpatialPhidget.java
new file mode 100644
index 0000000..bec1de7
--- /dev/null
+++ b/Java/com/phidgets/SpatialPhidget.java
@@ -0,0 +1,205 @@
+
+/*
+ * 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 Spatial. All methods for a PhidgetSpatial are implemented in this class.
+ <p>
+ The Phidget Spatial may provide up to 3 axes of acceleration data, 3 axes of angular rate data and 3 axes of magnetic field data.
+
+ * @author Phidgets Inc.
+ */
+public final class SpatialPhidget extends Phidget
+{
+ public SpatialPhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+
+ /**
+ * Returns the number of accelerometer axes.
+ * @return number of axes of acceleration
+ */
+ public native int getAccelerationAxisCount () throws PhidgetException;
+ /**
+ * Returns the acceleration of a particular axis.
+ *
+ * @param index index of the axis
+ * @return acceleration of the selected axis
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getAcceleration (int index) throws PhidgetException;
+ /**
+ * Returns the maximum acceleration value that this axis will report.
+ * @return maximum acceleration
+ */
+ public native double getAccelerationMax (int index) throws PhidgetException;
+ /**
+ * Returns the minimum acceleration value that this axis will report.
+ * @return minimum acceleration
+ */
+ public native double getAccelerationMin (int index) throws PhidgetException;
+
+ /**
+ * Returns the number of gyro axes.
+ * @return number of axes of angularRate
+ */
+ public native int getGyroAxisCount () throws PhidgetException;
+ /**
+ * Returns the angularRate of a particular axis.
+ *
+ * @param index index of the axis
+ * @return angularRate of the selected axis
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getAngularRate (int index) throws PhidgetException;
+ /**
+ * Returns the maximum angularRate value that this axis will report.
+ * @return maximum angularRate
+ */
+ public native double getAngularRateMax (int index) throws PhidgetException;
+ /**
+ * Returns the minimum angularRate value that this axis will report.
+ * @return minimum angularRate
+ */
+ public native double getAngularRateMin (int index) throws PhidgetException;
+
+ /**
+ * Returns the number of compass axes.
+ * @return number of axes of magneticField
+ */
+ public native int getCompassAxisCount () throws PhidgetException;
+ /**
+ * Returns the magneticField of a particular axis.
+ *
+ * @param index index of the axis
+ * @return magneticField of the selected axis
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getMagneticField (int index) throws PhidgetException;
+ /**
+ * Returns the maximum magneticField value that this axis will report.
+ * @return maximum magneticField
+ */
+ public native double getMagneticFieldMax (int index) throws PhidgetException;
+ /**
+ * Returns the minimum magneticField value that this axis will report.
+ * @return minimum magneticField
+ */
+ public native double getMagneticFieldMin (int index) throws PhidgetException;
+
+ /**
+ * Returns the data rate, in milliseconds.
+ *
+ * @return data rate
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getDataRate () throws PhidgetException;
+ /**
+ * Sets the data rate, in milliseconds.
+ *
+ * @param rate data rate
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setDataRate (int rate) throws PhidgetException;
+ /**
+ * Returns the minimum data rate, in milliseconds.
+ *
+ * @return minimum data rate
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getDataRateMin () throws PhidgetException;
+ /**
+ * Returns the maximum data rate, in milliseconds.
+ *
+ * @return maximum data rate
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getDataRateMax () throws PhidgetException;
+
+ /**
+ * Zeroes the gyroscope. This takes about two seconds and the gyro zxes will report 0 during the process.
+ * This should only be called when the board is not moving.
+ *
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void zeroGyro () throws PhidgetException;
+ /**
+ * Sets the compass correction factors. This can be used to correcting any sensor errors, including hard and soft iron offsets and sensor error factors.
+ *
+ * @param magField Local magnetic field strength.
+ * @param offset0 Axis 0 offset correction.
+ * @param offset1 Axis 1 offset correction.
+ * @param offset2 Axis 2 offset correction.
+ * @param gain0 Axis 0 gain correction.
+ * @param gain1 Axis 1 gain correction.
+ * @param gain2 Axis 2 gain correction.
+ * @param T0 Non-orthogonality correction factor 0.
+ * @param T1 Non-orthogonality correction factor 1.
+ * @param T2 Non-orthogonality correction factor 2.
+ * @param T3 Non-orthogonality correction factor 3.
+ * @param T4 Non-orthogonality correction factor 4.
+ * @param T5 Non-orthogonality correction factor 5.
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setCompassCorrectionParameters (double magField, double offset0, double offset1, double offset2, double gain0, double gain1, double gain2, double T0, double T1, double T2,
+ double T3, double T4, double T5) throws PhidgetException;
+ /**
+ * Resets the compass correction factors. Magnetic field data will be presented directly as reported by the sensor.
+ *
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void resetCompassCorrectionParameters () throws PhidgetException;
+
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ enableSpatialDataEvents (b && spatialDataListeners.size () > 0);
+ }
+ /**
+ * Adds a spatial data listener. The spatial data handler is a method that will be called at a rate of
+ * {@link #getDataRate() DataRate} that has been set for the device. This event contains data for all axes of all sensors.
+ * <p>
+ * There is no limit on the number of spatial data handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.SpatialDataListener SpatialDataListener} interface
+ */
+ public final void addSpatialDataListener (SpatialDataListener l)
+ {
+ synchronized (spatialDataListeners)
+ {
+ spatialDataListeners.add (l);
+ enableSpatialDataEvents (true);
+ }} private LinkedList spatialDataListeners = new LinkedList ();
+ private long nativeSpatialDataHandler = 0;
+ public final void removeSpatialDataListener (SpatialDataListener l)
+ {
+ synchronized (spatialDataListeners)
+ {
+ spatialDataListeners.remove (l);
+ enableSpatialDataEvents (spatialDataListeners.size () > 0);
+ }} private void fireSpatialData (SpatialDataEvent e)
+ {
+ synchronized (spatialDataListeners)
+ {
+ for (Iterator it = spatialDataListeners.iterator (); it.hasNext ();)
+ ((SpatialDataListener) it.next ()).data (e);
+ }
+ }
+ private native void enableSpatialDataEvents (boolean b);
+}
diff --git a/Java/com/phidgets/StepperPhidget.java b/Java/com/phidgets/StepperPhidget.java
new file mode 100644
index 0000000..83fa772
--- /dev/null
+++ b/Java/com/phidgets/StepperPhidget.java
@@ -0,0 +1,422 @@
+
+/*
+ * 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 Stepper Controller. All methods
+ * to to control a stepper controller and read back stepper data are implemented in this class.
+ * <p>
+ * The Phidget Stepper is able to control 1 or more Stepper motors. Motor Acceleration and Velocity are
+ * controllable, and micro-stepping is used. The type and number of motors that can be controlled
+ * depend on the Stepper Controller. Digital inputs are available on select Phidget Stepper Controllers.
+ *
+ * @author Phidgets Inc.
+ */
+public final class StepperPhidget extends Phidget
+{
+ public StepperPhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+ /**
+ * Returns the number of stepper motors supported by this Phidget. This does not neccesarily correspond
+ to the number of motors actually attached to the board.
+ * @return number of supported motors
+ * @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 int getMotorCount () throws PhidgetException;
+ /**
+ * Returns the number of digital inputs. Not all Stepper Controllers have digital inputs.
+ * @return number of digital inputs
+ * @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 int getInputCount () throws PhidgetException;
+ /**
+ * Returns the state of a digital input. True means that the input is activated, and False indicated the default state.
+ * @param index index of the input
+ * @return state of the input
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getInputState (int index) throws PhidgetException;
+ /**
+ * Returns a motor's acceleration. The valid range is between {@link #getAccelerationMin getAccelerationMin}
+ * and {@link #getAccelerationMax getAccelerationMax}, and refers to how fast the Stepper Controller will change the speed of a motor.
+ * <p>This value is in (micro)steps per second squared. The step unit will depend on the Stepper Controller. For example, the Bipolar
+ * Stepper controller has an accuracy of 16th steps, so this value would be in 16th steps per second squared.
+ * @param index index of motor
+ * @return acceleration of motor
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is invalid, or if the acceleration is unknown.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getAcceleration (int index) throws PhidgetException;
+ /**
+ * Returns the maximum acceleration that a motor will accept, or return.
+ * <p>This value uses the same units as {@link #setAcceleration setAcceleration}/{@link #getAcceleration getAcceleration}.
+ * @param index Index of the motor
+ * @return Maximum acceleration
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getAccelerationMax (int index) throws PhidgetException;
+ /**
+ * Returns the minimum acceleration that a motor will accept, or return.
+ * <p>This value uses the same units as {@link #setAcceleration setAcceleration}/{@link #getAcceleration getAcceleration}.
+ * @param index Index of the motor
+ * @return Minimum acceleration
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getAccelerationMin (int index) throws PhidgetException;
+ /**
+ * Sets a motor's acceleration.
+ * The valid range is between {@link #getAccelerationMin getAccelerationMin} and {@link #getAccelerationMax getAccelerationMax}.
+ * This controls how fast the motor changes speed.
+ * <p>This value is in (micro)steps per second squared. The step unit will depend on the Stepper Controller. For example, the Bipolar
+ * Stepper controller has an accuracy of 16th steps, so this value would be in 16th steps per second squared.
+ * @param index index of the motor
+ * @param acceleration requested acceleration for that motor
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index or acceleration are invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setAcceleration (int index, double acceleration) throws PhidgetException;
+ /**
+ * Returns a motor's current velocity. The valid range is between {@link #getVelocityMin getVelocityMin} and {@link #getVelocityMax getVelocityMax},
+ * with 0 being stopped.
+ * <p>This value is in (micro)steps per second. The step unit will depend on the Stepper Controller. For example, the Bipolar
+ * Stepper controller has an accuracy of 16th steps, so this value would be in 16th steps per second.
+ * @param index index of the motor
+ * @return current speed of the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is invalid, or if the velocity in unknown.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getVelocity (int index) throws PhidgetException;
+ /**
+ * Returns the maximum velocity that a stepper motor will accept, or return.
+ * <p>This value uses the same units as {@link #setVelocityLimit setVelocityLimit}/{@link #getVelocityLimit getVelocityLimit} and {@link #getVelocity getVelocity}.
+ * @param index Index of the motor
+ * @return Maximum velocity
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getVelocityMax (int index) throws PhidgetException;
+ /**
+ * Returns the minimum velocity that a stepper motor will accept, or return.
+ * <p>This value uses the same units as {@link #setVelocityLimit setVelocityLimit}/{@link #getVelocityLimit getVelocityLimit} and {@link #getVelocity getVelocity}.
+ * @param index Index of the motor
+ * @return Minimum velocity
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getVelocityMin (int index) throws PhidgetException;
+ /**
+ * Sets a motor's velocity limit. This is the maximum velocity that the motor will turn at.
+ * The valid range is between {@link #getVelocityMin getVelocityMin} and {@link #getVelocityMax getVelocityMax},
+ * with 0 being stopped.
+ * <p>This value is in (micro)steps per second. The step unit will depend on the Stepper Controller. For example, the Bipolar
+ * Stepper controller has an accuracy of 16th steps, so this value would be in 16th steps per second.
+ * @param index index of the motor
+ * @param velocity requested velocity for the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index or velocity are invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setVelocityLimit (int index, double velocity) throws PhidgetException;
+ /**
+ * Returns a motor's velocity limit. This is the maximum velocity that the motor will turn at.
+ * The valid range is between {@link #getVelocityMin getVelocityMin} and {@link #getVelocityMax getVelocityMax},
+ * with 0 being stopped.
+ * <p>This value is in (micro)steps per second. The step unit will depend on the Stepper Controller. For example, the Bipolar
+ * Stepper controller has an accuracy of 16th steps, so this value would be in 16th steps per second.
+ * @param index index of the motor
+ * @return current speed of the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is invalid, or if the velocity in unknown.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getVelocityLimit (int index) throws PhidgetException;
+ /**
+ * Returns the maximum position that a stepper motor will accept, or return.
+ * <p>This value uses the same units as
+ * {@link #setTargetPosition setTargetPosition}/{@link #getTargetPosition getTargetPosition} and {@link #setCurrentPosition setCurrentPosition}/{@link #getCurrentPosition getCurrentPosition}.
+ * @param index Index of the motor
+ * @return Maximum position
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native long getPositionMax (int index) throws PhidgetException;
+ /**
+ * Returns the minimum position that a stepper motor will accept, or return.
+ * <p>This value uses the same units as
+ * {@link #setTargetPosition setTargetPosition}/{@link #getTargetPosition getTargetPosition} and {@link #setCurrentPosition setCurrentPosition}/{@link #getCurrentPosition getCurrentPosition}.
+ * @param index Index of the motor
+ * @return Minimum position
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native long getPositionMin (int index) throws PhidgetException;
+ /**
+ * Sets a motor's current position. Use this is (re)set the current physical position of the motor to a specific position value.
+ * This does not move the motor, and if the motor is moving, calling this will cause it to stop moving. Use {@link #setTargetPosition setTargetPosition}
+ * to move the motor to a position.
+ * The valid range is between {@link #getPositionMin getPositionMin} and {@link #getPositionMax getPositionMax}.
+ * <p>This value is in (micro)steps. The step unit will depend on the Stepper Controller. For example, the Bipolar
+ * Stepper controller has an accuracy of 16th steps, so this value would be in 16th steps.
+ * @param index index of the motor
+ * @param position current position of the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index or position are invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setCurrentPosition (int index, long position) throws PhidgetException;
+ /**
+ * Returns a motor's current position. This is the actual step position that the motor is at right now.
+ * The valid range is between {@link #getPositionMin getPositionMin} and {@link #getPositionMax getPositionMax}.
+ * <p>This value is in (micro)steps. The step unit will depend on the Stepper Controller. For example, the Bipolar
+ * Stepper controller has an accuracy of 16th steps, so this value would be in 16th steps.
+ * @param index index of the motor
+ * @return current position of the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is invalid, or if the position in unknown.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native long getCurrentPosition (int index) throws PhidgetException;
+ /**
+ * Sets a motor's target position. Use this is set the target position for the stepper. If the stepper is {@link #setEngaged engaged} it will start moving towards
+ * this target position.
+ * The valid range is between {@link #getPositionMin getPositionMin} and {@link #getPositionMax getPositionMax}.
+ * <p>This value is in (micro)steps. The step unit will depend on the Stepper Controller. For example, the Bipolar
+ * Stepper controller has an accuracy of 16th steps, so this value would be in 16th steps.
+ * @param index index of the motor
+ * @param position target position of the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index or position are invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setTargetPosition (int index, long position) throws PhidgetException;
+ /**
+ * Returns a motor's target position. This is the position that the motor wants to be at. If the motor is not moving,
+ * it probably has reached the target position, and this will match {@link #getCurrentPosition current position}.
+ * The valid range is between {@link #getPositionMin getPositionMin} and {@link #getPositionMax getPositionMax}.
+ * <p>This value is in (micro)steps. The step unit will depend on the Stepper Controller. For example, the Bipolar
+ * Stepper controller has an accuracy of 16th steps, so this value would be in 16th steps.
+ * @param index index of the motor
+ * @return target position of the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is invalid, or if the position in unknown.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native long getTargetPosition (int index) throws PhidgetException;
+ /**
+ * Returns a motor's current usage. The valid range is between {@link #getCurrentMin getCurrentMin} and {@link #getCurrentMax getCurrentMax}.
+ * This value is in Amps.
+ * <p>Note that this is not supported on all stepper controllers.
+ * @param index index of the motor
+ * @return current usage of the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is invalid, if the value is unknown, or if this is not supported.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getCurrent (int index) throws PhidgetException;
+ /**
+ * Returns the current limit.
+ * <p>This value is in Amps.
+ * @param index Index of the motor
+ * @return Current Limit
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is invalid, if the value is unknown, or if this is not supported.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getCurrentLimit (int index) throws PhidgetException;
+ /**
+ * Sets a motor's current usage limit. The valid range is between {@link #getCurrentMin getCurrentMin} and {@link #getCurrentMax getCurrentMax}.
+ * This sets the maximum current that a motor will be allowed to draw. Use this with the Bipolar stepper controller to get smooth micro stepping -
+ * see the product manual for more details. This value is in Amps.
+ * <p>Note that this is not supported on all stepper controllers.
+ * @param index index of the motor
+ * @param current current limit for the motor
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is invalid, if the value is unknown, or if this is not supported.
+ *
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setCurrentLimit (int index, double current) throws PhidgetException;
+ /**
+ * Returns the maximum current that a stepper motor will accept, or return.
+ * <p>This value is in Amps.
+ * @param index Index of the motor
+ * @return Maximum current
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is invalid, or if this is not supported.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getCurrentMax (int index) throws PhidgetException;
+ /**
+ * Returns the minimum current that a stepper motor will accept, or return.
+ * <p>This value is in Amps.
+ * @param index Index of the motor
+ * @return Minimum current
+ * @throws PhidgetException If this Phidget is not opened and attached, if the index is invalid, or if this is not supported.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getCurrentMin (int index) throws PhidgetException;
+ /**
+ * Engage or disengage a motor.
+ * <p>
+ * This engages or disengages the stepper motor. The motors are by default disengaged when the stepper controller is plugged in.
+ * When the stepper is disengaged, position, velocity, etc. can all be set, but the motor will not start moving until it is engaged.
+ * If position is read when a motor is disengaged, it will throw an exception.
+ *
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setEngaged (int index, boolean state) throws PhidgetException;
+ /**
+ * Returns the engaged state of a motor.
+ *
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getEngaged (int index) throws PhidgetException;
+ /**
+ * Returns the stopped state of a motor. Use this to determine if the motor is moving and/or up to date with the latest commands you have sent.
+ * If this is true, the motor is guaranteed to be stopped and to have processed every command issued. Generally, this would
+ * be polled after a target position is set to wait until that position is reached.
+ *
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native boolean getStopped (int index) throws PhidgetException;
+
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ enableStepperPositionChangeEvents (b && stepperPositionChangeListeners.size () > 0);
+ enableStepperVelocityChangeEvents (b && stepperVelocityChangeListeners.size () > 0);
+ enableCurrentChangeEvents (b && currentChangeListeners.size () > 0);
+ enableInputChangeEvents (b && inputChangeListeners.size () > 0);
+ }
+ /**
+ * Adds a position change listener. The position change handler is a method that will be called when the stepper
+ * position has changed.
+ * <p>
+ * There is no limit on the number of position change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.StepperPositionChangeListener StepperPositionChangeListener} interface
+ */
+ public final void addStepperPositionChangeListener (StepperPositionChangeListener l)
+ {
+ synchronized (stepperPositionChangeListeners)
+ {
+ stepperPositionChangeListeners.add (l);
+ enableStepperPositionChangeEvents (true);
+ }} private LinkedList stepperPositionChangeListeners = new LinkedList ();
+ private long nativeStepperPositionChangeHandler = 0;
+ public final void removeStepperPositionChangeListener (StepperPositionChangeListener l)
+ {
+ synchronized (stepperPositionChangeListeners)
+ {
+ stepperPositionChangeListeners.remove (l);
+ enableStepperPositionChangeEvents (stepperPositionChangeListeners.size () > 0);
+ }} private void fireStepperPositionChange (StepperPositionChangeEvent e)
+ {
+ synchronized (stepperPositionChangeListeners)
+ {
+ for (Iterator it = stepperPositionChangeListeners.iterator (); it.hasNext ();)
+ ((StepperPositionChangeListener) it.next ()).stepperPositionChanged (e);
+ }
+ }
+ private native void enableStepperPositionChangeEvents (boolean b);
+ /**
+ * Adds a velocity change listener. The velocity change handler is a method that will be called when the stepper
+ * velocity has changed.
+ * <p>
+ * There is no limit on the number of velocity change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.StepperVelocityChangeListener StepperVelocityChangeListener} interface
+ */
+ public final void addStepperVelocityChangeListener (StepperVelocityChangeListener l)
+ {
+ synchronized (stepperVelocityChangeListeners)
+ {
+ stepperVelocityChangeListeners.add (l);
+ enableStepperVelocityChangeEvents (true);
+ }} private LinkedList stepperVelocityChangeListeners = new LinkedList ();
+ private long nativeStepperVelocityChangeHandler = 0;
+ public final void removeStepperVelocityChangeListener (StepperVelocityChangeListener l)
+ {
+ synchronized (stepperVelocityChangeListeners)
+ {
+ stepperVelocityChangeListeners.remove (l);
+ enableStepperVelocityChangeEvents (stepperVelocityChangeListeners.size () > 0);
+ }} private void fireStepperVelocityChange (StepperVelocityChangeEvent e)
+ {
+ synchronized (stepperVelocityChangeListeners)
+ {
+ for (Iterator it = stepperVelocityChangeListeners.iterator (); it.hasNext ();)
+ ((StepperVelocityChangeListener) it.next ()).stepperVelocityChanged (e);
+ }
+ }
+ private native void enableStepperVelocityChangeEvents (boolean b);
+ /**
+ * Adds a current change listener. The current change handler is a method that will be called when the stepper
+ * current has changed.
+ * <p>
+ * There is no limit on the number of current change handlers that can be registered for a particular Phidget.
+ * <p>
+ * Note that not all stepper controllers support current sensing.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.CurrentChangeListener CurrentChangeListener} interface
+ */
+ public final void addCurrentChangeListener (CurrentChangeListener l)
+ {
+ synchronized (currentChangeListeners)
+ {
+ currentChangeListeners.add (l);
+ enableCurrentChangeEvents (true);
+ }} private LinkedList currentChangeListeners = new LinkedList ();
+ private long nativeCurrentChangeHandler = 0;
+ public final void removeCurrentChangeListener (CurrentChangeListener l)
+ {
+ synchronized (currentChangeListeners)
+ {
+ currentChangeListeners.remove (l);
+ enableCurrentChangeEvents (currentChangeListeners.size () > 0);
+ }} private void fireCurrentChange (CurrentChangeEvent e)
+ {
+ synchronized (currentChangeListeners)
+ {
+ for (Iterator it = currentChangeListeners.iterator (); it.hasNext ();)
+ ((CurrentChangeListener) it.next ()).currentChanged (e);
+ }
+ }
+ private native void enableCurrentChangeEvents (boolean b);
+ /**
+ * Adds an input change listener. The input change handler is a method that will be called when an input on this
+ * Stepper Controller board has changed.
+ * <p>
+ * There is no limit on the number of input change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.InputChangeListener InputChangeListener} interface
+ */
+ public final void addInputChangeListener (InputChangeListener l)
+ {
+ synchronized (inputChangeListeners)
+ {
+ inputChangeListeners.add (l);
+ enableInputChangeEvents (true);
+ }} private LinkedList inputChangeListeners = new LinkedList ();
+ private long nativeInputChangeHandler = 0;
+ public final void removeInputChangeListener (InputChangeListener l)
+ {
+ synchronized (inputChangeListeners)
+ {
+ inputChangeListeners.remove (l);
+ enableInputChangeEvents (inputChangeListeners.size () > 0);
+ }} private void fireInputChange (InputChangeEvent e)
+ {
+ synchronized (inputChangeListeners)
+ {
+ for (Iterator it = inputChangeListeners.iterator (); it.hasNext ();)
+ ((InputChangeListener) it.next ()).inputChanged (e);
+ }
+ }
+ private native void enableInputChangeEvents (boolean b);
+}
diff --git a/Java/com/phidgets/TemperatureSensorPhidget.java b/Java/com/phidgets/TemperatureSensorPhidget.java
new file mode 100644
index 0000000..baaa589
--- /dev/null
+++ b/Java/com/phidgets/TemperatureSensorPhidget.java
@@ -0,0 +1,213 @@
+
+/*
+ * 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 temperature Sensor. All methods
+ * to read temperaure data from the sensor are implemented in this class.
+ * <p>
+ * The Temperature Phidget consists of a thermocouple interface, and a temperature
+ * sensing IC, which is used to measure the temperature of the thermocouple cold junction
+ * and calibrate the thermocouple sensed temperature.
+ * <p>
+ * Both the thermocouple and temperature IC temperatures can be read. Value are returned in degrees celcius.
+ *
+ * @author Phidgets Inc.
+ */
+public final class TemperatureSensorPhidget extends Phidget
+{
+ public TemperatureSensorPhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+
+ /**
+ * K-Type Thermocouple. This is used with {@link #getThermocoupleType getThermocoupleType} and {@link #setThermocoupleType setThermocoupleType}
+ */
+ public static final int PHIDGET_TEMPERATURE_SENSOR_K_TYPE = 1;
+ /**
+ * J-Type Thermocouple. This is used with {@link #getThermocoupleType getThermocoupleType} and {@link #setThermocoupleType setThermocoupleType}
+ */
+ public static final int PHIDGET_TEMPERATURE_SENSOR_J_TYPE = 2;
+ /**
+ * E-Type Thermocouple. This is used with {@link #getThermocoupleType getThermocoupleType} and {@link #setThermocoupleType setThermocoupleType}
+ */
+ public static final int PHIDGET_TEMPERATURE_SENSOR_E_TYPE = 3;
+ /**
+ * T-Type Thermocouple. This is used with {@link #getThermocoupleType getThermocoupleType} and {@link #setThermocoupleType setThermocoupleType}
+ */
+ public static final int PHIDGET_TEMPERATURE_SENSOR_T_TYPE = 4;
+
+ /**
+ * Returns the number of thermocouples.
+ * @return Number of inputs
+ */
+ public native int getTemperatureInputCount () throws PhidgetException;
+ /**
+ * @deprecated Replaced by
+ * {@link #getTemperatureInputCount}
+ */
+ public native int getSensorCount () throws PhidgetException;
+ /**
+ * Returns the temperature of a thermocouple. This value is returned in degrees celcius but can easily be converted into other units.
+ * This value will always be between {@link #getTemperatureMin getTemperatureMin} and {@link #getTemperatureMax getTemperatureMax}.
+ * The accuracy depends on the thermocouple used. The board is calibrated during manufacture.
+ * @param index Index of the thermocouple
+ * @return Temperature in derees celcius
+ * @throws PhidgetException If this Phidget is not opened and attached, or if a thermocouple sensor is not plugged into the board.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getTemperature (int index) throws PhidgetException;
+ /**
+ * Returns the maximum temperature that will be returned by a thermocouple input. This value depends on the thermocouple type.
+ * @param index Index of the thermocouple
+ * @return Maximum temperature in derees celcius
+ * @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 getTemperatureMax (int index) throws PhidgetException;
+ /**
+ * Returns the minimum temperature that will be returned by a thermocouple input. This value depends on the thermocouple type.
+ * @param index Index of the thermocouple
+ * @return Minimum temperature in derees celcius
+ * @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 getTemperatureMin (int index) throws PhidgetException;
+ /**
+ * Returns the temperature of the ambient sensor. This value is returned in degrees celcius but can easily be converted into other units.
+ * This value will always be between {@link #getAmbientTemperatureMin getAmbientTemperatureMin} and {@link #getAmbientTemperatureMax getAmbientTemperatureMax}.
+ * This is the temperature of the board at the thermocouple cold junction.
+ * @return Temperature in derees celcius
+ * @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 getAmbientTemperature () throws PhidgetException;
+ /**
+ * Returns the maximum temperature that will be returned by the ambient sensor.
+ * @return Maximum ambient temperature in derees celcius
+ * @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 getAmbientTemperatureMax () throws PhidgetException;
+ /**
+ * Returns the minimum temperature that will be returned by the ambient sensor.
+ * @return Minimum ambient temperature in derees celcius
+ * @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 getAmbientTemperatureMin () throws PhidgetException;
+ /**
+ * Returns the potential of a thermocouple input. This value is returned in millivolts.
+ * This value will always be between {@link #getPotentialMin getPotentialMin} and {@link #getPotentialMax getPotentialMax}.
+ * This is very accurate, as it is a raw value from the A/D. This is the value that is internally used to calculate temperature in the library.
+ * @param index Index of the thermocouple
+ * @return 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 getPotential (int index) throws PhidgetException;
+ /**
+ * Returns the maximum potential that will be returned by a thermocouple input.
+ * @param index Index of the thermocouple
+ * @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 (int index) throws PhidgetException;
+ /**
+ * Returns the minimum potential that will be returned by a thermocouple input.
+ * @param index Index of the thermocouple
+ * @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 (int index) throws PhidgetException;
+ /**
+ * Sets the change trigger for an input. This is the ammount by which the sensed temperature must
+ * change between TemperatureChangeEvents. By default this is set to 0.5.
+ * @param index Input
+ * @param newVal Trigger
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setTemperatureChangeTrigger (int index, double newVal) throws PhidgetException;
+ /**
+ * Returns the change trigger for an input. This is the ammount by which the sensed temperature must
+ * change between TemperatureChangeEvents. By default this is set to 0.5.
+ * @param index Input
+ * @return Trigger
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native double getTemperatureChangeTrigger (int index) throws PhidgetException;
+ /**
+ * Returns the thermocouple type for an input.
+ * The possible values for type are {@link #PHIDGET_TEMPERATURE_SENSOR_K_TYPE PHIDGET_TEMPERATURE_SENSOR_K_TYPE},
+ * {@link #PHIDGET_TEMPERATURE_SENSOR_J_TYPE PHIDGET_TEMPERATURE_SENSOR_J_TYPE}, {@link #PHIDGET_TEMPERATURE_SENSOR_E_TYPE PHIDGET_TEMPERATURE_SENSOR_E_TYPE} and
+ * {@link #PHIDGET_TEMPERATURE_SENSOR_T_TYPE PHIDGET_TEMPERATURE_SENSOR_T_TYPE}
+ * @param index Input
+ * @return Thermocouple Type
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getThermocoupleType (int index) throws PhidgetException;
+ /**
+ * Sets the thermocouple type for an input. The Phidget Temperature Sensor board can be used with K, E, J and T-Type Thermocouples.
+ * Support for other thermocouple types, and voltage sources other then thermocouples in the valid range (between {@link #getPotentialMin getPotentialMin} and {@link #getPotentialMax getPotentialMax}) can
+ * be achieved using {@link #getPotential getPotential}.
+ * <p>
+ * The possible values for type are {@link #PHIDGET_TEMPERATURE_SENSOR_K_TYPE PHIDGET_TEMPERATURE_SENSOR_K_TYPE},
+ * {@link #PHIDGET_TEMPERATURE_SENSOR_J_TYPE PHIDGET_TEMPERATURE_SENSOR_J_TYPE}, {@link #PHIDGET_TEMPERATURE_SENSOR_E_TYPE PHIDGET_TEMPERATURE_SENSOR_E_TYPE} and
+ * {@link #PHIDGET_TEMPERATURE_SENSOR_T_TYPE PHIDGET_TEMPERATURE_SENSOR_T_TYPE}
+ * <p>
+ * By default, type is set to {@link #PHIDGET_TEMPERATURE_SENSOR_K_TYPE PHIDGET_TEMPERATURE_SENSOR_K_TYPE}.
+ * @param index Input
+ * @param type Thermocouple Type
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setThermocoupleType (int index, int type) throws PhidgetException;
+
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ enableTemperatureChangeEvents (b && temperatureChangeListeners.size () > 0);
+ }
+ /**
+ * Adds a temperature change listener. The temperature change handler is a method that will be called when the temperature
+ * has changed by at least the {@link #getTemperatureChangeTrigger(int) Trigger} that has been set.
+ * <p>
+ * There is no limit on the number of temperature change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.TemperatureChangeListener TemperatureChangeListener} interface
+ */
+ public final void addTemperatureChangeListener (TemperatureChangeListener l)
+ {
+ synchronized (temperatureChangeListeners)
+ {
+ temperatureChangeListeners.add (l);
+ enableTemperatureChangeEvents (true);
+ }} private LinkedList temperatureChangeListeners = new LinkedList ();
+ private long nativeTemperatureChangeHandler = 0;
+ public final void removeTemperatureChangeListener (TemperatureChangeListener l)
+ {
+ synchronized (temperatureChangeListeners)
+ {
+ temperatureChangeListeners.remove (l);
+ enableTemperatureChangeEvents (temperatureChangeListeners.size () > 0);
+ }} private void fireTemperatureChange (TemperatureChangeEvent e)
+ {
+ synchronized (temperatureChangeListeners)
+ {
+ for (Iterator it = temperatureChangeListeners.iterator (); it.hasNext ();)
+ ((TemperatureChangeListener) it.next ()).temperatureChanged (e);
+ }
+ }
+ private native void enableTemperatureChangeEvents (boolean b);
+}
diff --git a/Java/com/phidgets/TextLCDPhidget.java b/Java/com/phidgets/TextLCDPhidget.java
new file mode 100644
index 0000000..ac4c500
--- /dev/null
+++ b/Java/com/phidgets/TextLCDPhidget.java
@@ -0,0 +1,278 @@
+
+/*
+ * Copyright 2011 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 Text LCD. All methods
+ * to control the Text LCD are implemented in this class.
+ * <p>
+ * The TextLCD Phidget consists of a Vacuum Fluorescent display that is capable of
+ * displaying Standard as well as custom characters in multiple rows.
+ *
+ * @author Phidgets Inc.
+ */
+public final class TextLCDPhidget extends Phidget
+{
+ public TextLCDPhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+ /**
+ * No screens attached. This is used with {@link #getScreenSize() getScreenSize} and {@link #setScreenSize(int) setScreenSize}
+ */
+ public static final int PHIDGET_TEXTLCD_SCREEN_NONE = 1;
+ /**
+ * 1 row, 8 column screen. This is used with {@link #getScreenSize() getScreenSize} and {@link #setScreenSize(int) setScreenSize}
+ */
+ public static final int PHIDGET_TEXTLCD_SCREEN_1x8 = 2;
+ /**
+ * 2 row, 8 column screen. This is used with {@link #getScreenSize() getScreenSize} and {@link #setScreenSize(int) setScreenSize}
+ */
+ public static final int PHIDGET_TEXTLCD_SCREEN_2x8 = 3;
+ /**
+ * 1 row, 16 column screen. This is used with {@link #getScreenSize() getScreenSize} and {@link #setScreenSize(int) setScreenSize}
+ */
+ public static final int PHIDGET_TEXTLCD_SCREEN_1x16 = 4;
+ /**
+ * 2 row, 16 column screen. This is used with {@link #getScreenSize() getScreenSize} and {@link #setScreenSize(int) setScreenSize}
+ */
+ public static final int PHIDGET_TEXTLCD_SCREEN_2x16 = 5;
+ /**
+ * 4 row, 16 column screen. This is used with {@link #getScreenSize() getScreenSize} and {@link #setScreenSize(int) setScreenSize}
+ */
+ public static final int PHIDGET_TEXTLCD_SCREEN_4x16 = 6;
+ /**
+ * 2 row, 20 column screen. This is used with {@link #getScreenSize() getScreenSize} and {@link #setScreenSize(int) setScreenSize}
+ */
+ public static final int PHIDGET_TEXTLCD_SCREEN_2x20 = 7;
+ /**
+ * 4 row, 20 column screen. This is used with {@link #getScreenSize() getScreenSize} and {@link #setScreenSize(int) setScreenSize}
+ */
+ public static final int PHIDGET_TEXTLCD_SCREEN_4x20 = 8;
+ /**
+ * 2 row, 24 column screen. This is used with {@link #getScreenSize() getScreenSize} and {@link #setScreenSize(int) setScreenSize}
+ */
+ public static final int PHIDGET_TEXTLCD_SCREEN_2x24 = 9;
+ /**
+ * 1 row, 40 column screen. This is used with {@link #getScreenSize() getScreenSize} and {@link #setScreenSize(int) setScreenSize}
+ */
+ public static final int PHIDGET_TEXTLCD_SCREEN_1x40 = 10;
+ /**
+ * 2 row, 40 column screen. This is used with {@link #getScreenSize() getScreenSize} and {@link #setScreenSize(int) setScreenSize}
+ */
+ public static final int PHIDGET_TEXTLCD_SCREEN_2x40 = 11;
+ /**
+ * 4 row, 40 column screen. This is used with {@link #getScreenSize() getScreenSize} and {@link #setScreenSize(int) setScreenSize}
+ */
+ public static final int PHIDGET_TEXTLCD_SCREEN_4x40 = 12;
+ /**
+ * Unknown screen size. This is used with {@link #getScreenSize() getScreenSize} and {@link #setScreenSize(int) setScreenSize}
+ */
+ public static final int PHIDGET_TEXTLCD_SCREEN_UNKNOWN = 13;
+ /**
+ * Returns the number of rows available on the display.
+ * @return Number of rows
+ * @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 int getRowCount () throws PhidgetException;
+ /**
+ * Returns the number of columns (characters per row) available on the display. This value is
+ * the same for every row.
+ * @return Number of columns
+ * @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 int getColumnCount () throws PhidgetException;
+ /**
+ * Returns the number of screens supported by the TextLCD. Not all TextLCDs support this method.
+ * @return Number of screens.
+ * @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 int getScreenCount () throws PhidgetException;
+ /**
+ * Returns the active screen. Not all TextLCDs support this method.
+ * @return active screen
+ * @throws PhidgetException If this Phidget is not opened and attached, or screen is not supported.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getScreen () throws PhidgetException;
+ /**
+ * Sets the active screen. All other API calls depend on this being called first to select the screen that subsequent calls affect.
+ * When making calls from multiple threads, selecting the screen should be synchronized with setting screen properties in order to avoid
+ * having messages go to the wrong display. Not all TextLCDs support this method.
+ * @param screen Screen
+ * @throws PhidgetException If this Phidget is not opened and attached, the screen number is out of range, or screen is not supported.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setScreen (int screen) throws PhidgetException;
+
+ /**
+ * Returns the screen size for the active TextLCD display. The TextLCD Adapter supports a pre-defined set of screen sizes to choose from.
+ * By default, all screens are set to {@link #PHIDGET_TEXTLCD_SCREEN_NONE PHIDGET_TEXTLCD_SCREEN_NONE}.
+ * Not all TextLCDs support this method.
+ * <p>
+ * The possible values for screen size are {@link #PHIDGET_TEXTLCD_SCREEN_NONE PHIDGET_TEXTLCD_SCREEN_NONE},
+ * {@link #PHIDGET_TEXTLCD_SCREEN_1x8 PHIDGET_TEXTLCD_SCREEN_1x8}, {@link #PHIDGET_TEXTLCD_SCREEN_2x8 PHIDGET_TEXTLCD_SCREEN_2x8},
+ * {@link #PHIDGET_TEXTLCD_SCREEN_1x16 PHIDGET_TEXTLCD_SCREEN_1x16}, {@link #PHIDGET_TEXTLCD_SCREEN_2x16 PHIDGET_TEXTLCD_SCREEN_2x16},
+ * {@link #PHIDGET_TEXTLCD_SCREEN_4x16 PHIDGET_TEXTLCD_SCREEN_4x16}, {@link #PHIDGET_TEXTLCD_SCREEN_2x20 PHIDGET_TEXTLCD_SCREEN_2x20},
+ * {@link #PHIDGET_TEXTLCD_SCREEN_4x20 PHIDGET_TEXTLCD_SCREEN_4x20}, {@link #PHIDGET_TEXTLCD_SCREEN_2x24 PHIDGET_TEXTLCD_SCREEN_2x24},
+ * {@link #PHIDGET_TEXTLCD_SCREEN_1x40 PHIDGET_TEXTLCD_SCREEN_1x40}, {@link #PHIDGET_TEXTLCD_SCREEN_2x40 PHIDGET_TEXTLCD_SCREEN_2x40},
+ * {@link #PHIDGET_TEXTLCD_SCREEN_4x40 PHIDGET_TEXTLCD_SCREEN_4x40}, {@link #PHIDGET_TEXTLCD_SCREEN_UNKNOWN PHIDGET_TEXTLCD_SCREEN_UNKNOWN}
+ * <p>
+ * By default, all screens are set to {@link #PHIDGET_TEXTLCD_SCREEN_NONE PHIDGET_TEXTLCD_SCREEN_NONE}
+ * <p>
+ * @return screen size
+ * @throws PhidgetException If this Phidget is not opened and attached, or screen size is not supported.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native int getScreenSize () throws PhidgetException;
+ /**
+ * Sets the screen size for the active TextLCD display. The TextLCD Adapter supports a pre-defined set of screen sizes to choose from.
+ * This method must always be called when trying to write text to a display.
+ * Not all TextLCDs support this method.
+ * @param screenSize Screen size
+ * The possible values for screen size are {@link #PHIDGET_TEXTLCD_SCREEN_NONE PHIDGET_TEXTLCD_SCREEN_NONE},
+ * {@link #PHIDGET_TEXTLCD_SCREEN_1x8 PHIDGET_TEXTLCD_SCREEN_1x8}, {@link #PHIDGET_TEXTLCD_SCREEN_2x8 PHIDGET_TEXTLCD_SCREEN_2x8},
+ * {@link #PHIDGET_TEXTLCD_SCREEN_1x16 PHIDGET_TEXTLCD_SCREEN_1x16}, {@link #PHIDGET_TEXTLCD_SCREEN_2x16 PHIDGET_TEXTLCD_SCREEN_2x16},
+ * {@link #PHIDGET_TEXTLCD_SCREEN_4x16 PHIDGET_TEXTLCD_SCREEN_4x16}, {@link #PHIDGET_TEXTLCD_SCREEN_2x20 PHIDGET_TEXTLCD_SCREEN_2x20},
+ * {@link #PHIDGET_TEXTLCD_SCREEN_4x20 PHIDGET_TEXTLCD_SCREEN_4x20}, {@link #PHIDGET_TEXTLCD_SCREEN_2x24 PHIDGET_TEXTLCD_SCREEN_2x24},
+ * {@link #PHIDGET_TEXTLCD_SCREEN_1x40 PHIDGET_TEXTLCD_SCREEN_1x40}, {@link #PHIDGET_TEXTLCD_SCREEN_2x40 PHIDGET_TEXTLCD_SCREEN_2x40},
+ * {@link #PHIDGET_TEXTLCD_SCREEN_4x40 PHIDGET_TEXTLCD_SCREEN_4x40}, {@link #PHIDGET_TEXTLCD_SCREEN_UNKNOWN PHIDGET_TEXTLCD_SCREEN_UNKNOWN}
+ * <p>
+ * By default, all screens are set to {@link #PHIDGET_TEXTLCD_SCREEN_NONE PHIDGET_TEXTLCD_SCREEN_NONE}
+ * <p>
+ * @throws PhidgetException If this Phidget is not opened and attached, the screen number is out of range, or screen size is not supported.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setScreenSize (int screenSize) throws PhidgetException;
+ /**
+ * Returns the contrast of the display. This is the contrast of the entire display.
+ * @return Current contrast
+ * @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 int getContrast () throws PhidgetException;
+ /**
+ * Sets the contrast of the display. The valid range is 0-255. Changing the contrast can increase the readability
+ * of the display in certain viewing situation, such as at an odd angle.
+ * @param contrast New contrast to set
+ * @throws PhidgetException If this Phidget is not opened and attached, or the contrast value is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setContrast (int contrast) throws PhidgetException;
+ /**
+ * Returns the brightness of the display. This is the brightness of the backlight. Not all TextLCDs support this method.
+ * @return Current brightness
+ * @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, or brightness is not supported.
+ */
+ public native int getBrightness () throws PhidgetException;
+ /**
+ * Sets the brightness of the display. The valid range is 0-255. Changing the brightness can increase the readability of the display in certain viewing situation, such as at an odd angle.
+ * Not all TextLCDs support this method.
+ * @param brightness New brightness to set
+ * @throws PhidgetException If this Phidget is not opened and attached, or the brightness value is out of range, or brightness is not supported.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setBrightness (int brightness) throws PhidgetException;
+ /**
+ * Returns the status of the backlight. True indicated that the backlight is on, False indicated that it is off.
+ * The backlight is by default turned on.
+ * @return Status of the backlight
+ * @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 boolean getBacklight () throws PhidgetException;
+ /**
+ * Sets the status of the backlight. True turns the backlight on, False turns it off.
+ * The backlight is by default turned on.
+ * @param backlight New backlight state
+ * @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 setBacklight (boolean backlight) throws PhidgetException;
+ /**
+ * Returns the status of the cursor. True turns the cursor is on, False turns it off.
+ * The cursor is an underscore which appears directly to the right of the last entered character
+ * on the display. The cursor is by default disabled.
+ * @return Status of the cursor
+ * @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 boolean getCursor () throws PhidgetException;
+ /**
+ * Sets the state of the cursor. True indicates that the cursor on, False indicates that it is off.
+ * The cursor is an underscore which appears directly to the right of the last entered character
+ * on the display. The cursor is by default disabled.
+ * @param cursor New cursor state
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the cursor has not been set
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setCursor (boolean cursor) throws PhidgetException;
+ /**
+ * Returns the status of the cursor blink. True turns the cursor blink on, False turns it off.
+ * The cursor blink is an flashing box which appears directly to the right of the last entered character
+ * on the display, in the same spot as the cursor if it is enabled. The cursor blink is by default disabled.
+ * @return Status of the cursor blink
+ * @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 boolean getCursorBlink () throws PhidgetException;
+ /**
+ * Sets the state of the cursor blink. True indicates that the cursor blink is on, False indicates that it is off.
+ * The cursor blink is an flashing box which appears directly to the right of the last entered character
+ * on the display, in the same spot as the cursor if it is enabled. The cursor blink is by default disabled.
+ * @param cursorblink New cursor blink state
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the cursor has not been set.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setCursorBlink (boolean cursorblink) throws PhidgetException;
+ /**
+ * Sets the display string of a certain row.
+ * @param index row
+ * @param text String
+ * @throws PhidgetException If this Phidget is not opened and attached, if the string is too long, or if the row is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setDisplayString (int index, String text) throws PhidgetException;
+ /**
+ * Sets the character to display at a certain row and column.
+ * @param row row
+ * @param column column
+ * @param character character
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the row or column is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setDisplayCharacter (int row, int column, char character) throws PhidgetException;
+ /**
+ * Sets a custom character. You can set up to 8 custom characters, each one is completely defined by two integers, and gets
+ * stored in the character display until power is removed, whence they must be re-programmed. The characters lie in positions 8-15, and
+ * can be displayed by sending these codes to setDisplayString in amongst standard ASCII characters. See the TextLCD Java example for
+ * more information.
+ * @param index position ( 8-15 )
+ * @param param1 first half of the character code
+ * @param param2 second half of the character code
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setCustomCharacter (int index, int param1, int param2) throws PhidgetException;
+ /**
+ * Initializes the active TextLCD Display. This runs an initialization routine which sets up and clears the display. This can be used for
+ * activating a display that was plugged in after the TextLCD Adapter was attached, to clear the display after setting/getting the screen size,
+ * and to re-initialize a display if it has become corrupted(display not working). Not all TextLCDs supported this method.
+ * @throws PhidgetException If this Phidget is not opened and attached, or initialize is not supported.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void initialize () throws PhidgetException;
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ }
+}
diff --git a/Java/com/phidgets/TextLEDPhidget.java b/Java/com/phidgets/TextLEDPhidget.java
new file mode 100644
index 0000000..a2f39c8
--- /dev/null
+++ b/Java/com/phidgets/TextLEDPhidget.java
@@ -0,0 +1,68 @@
+
+/*
+ * 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 Text LED. All methods
+ * to control the Text LED are implemented in this class.
+ * <p>
+ * The Text LED is a Phidget that displays text and numerals on LED
+ * numeric display in rows. The number of rows and size of each row depends on
+ * your configuration.
+ *
+ * @author Phidgets Inc.
+ */
+public final class TextLEDPhidget extends Phidget
+{
+ public TextLEDPhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+ /**
+ * Returns the number of rows. This returns the maximum number of rows supported by the device, not neccessarily
+ * the number of rows actually available with your coniguration.
+ * @return rows
+ * @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 int getRowCount () throws PhidgetException;
+ /**
+ * Returns the number of columns (Characters per row). This returns the maximum number of columns supported by the device, not neccessarily
+ * the number of columns actually available with your coniguration.
+ * @return columns
+ * @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 int getColumnCount () throws PhidgetException;
+ /**
+ * Returns the bringhtness. This is the brightneww of all rows. The Default brightness is 100.
+ * @return brightness
+ * @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 int getBrightness () throws PhidgetException;
+ /**
+ * Sets the brightness of all rows. The valid range is 0-100.
+ * @param brightness brightness
+ * @throws PhidgetException If this Phidget is not opened and attached, or the brightness value is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setBrightness (int brightness) throws PhidgetException;
+ /**
+ * Sets the display string of a certain row. If the string is longer then the row, it will be truncated.
+ * @param index Row
+ * @param text String
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the row is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ public native void setDisplayString (int index, String text) throws PhidgetException;
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ }
+}
diff --git a/Java/com/phidgets/WeightSensorPhidget.java b/Java/com/phidgets/WeightSensorPhidget.java
new file mode 100644
index 0000000..b2bd9e8
--- /dev/null
+++ b/Java/com/phidgets/WeightSensorPhidget.java
@@ -0,0 +1,89 @@
+
+/*
+ * 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 Weight Sensor. All methods
+ * to read weight data from the weight sensor are implemented in this class.
+ * <p>
+ * The Phidget Weight Sensor is simply an electronic scale with a USB interface.
+ * It provides one weight value, in kg.
+ *
+ * @author Phidget Inc.
+ */
+public final class WeightSensorPhidget extends Phidget
+{
+ public WeightSensorPhidget () throws PhidgetException
+ {
+ super (create ());
+ }
+ private static native long create () throws PhidgetException;
+ /**
+ * Returns the sensed weight in kg. This weight is in kg (kilograms), but can
+ * easily be converted into other units. The accuracy, sesitivity and range depends on the scale and version.
+ *
+ * @return The sensed weight
+ * @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 getWeight () throws PhidgetException;
+ /**
+ * Sets the weight change trigger. This is the ammount by which the sensed weight must
+ * change between WeightChangeEvents. By default this is set to 5.
+ *
+ * @param newVal The new trigger value
+ * @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 setWeightChangeTrigger (double newVal) throws PhidgetException;
+ /**
+ * Returns the weight change trigger. This is the ammount by which the sensed weight must
+ * change between WeightChangeEvents. By default this is set to 5.
+ *
+ * @return The trigger value
+ * @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 getWeightChangeTrigger () throws PhidgetException;
+
+ private final void enableDeviceSpecificEvents (boolean b)
+ {
+ enableWeightChangeEvents (b && weightChangeListeners.size () > 0);
+ }
+ /**
+ * Adds a weight change listener. The weight change handler is a method that will be called when the weight
+ * has changed by at least the {@link #getWeightChangeTrigger() Trigger} that has been set.
+ * <p>
+ * There is no limit on the number of weight change handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.WeightChangeListener WeightChangeListener} interface
+ */
+ public final void addWeightChangeListener (WeightChangeListener l)
+ {
+ synchronized (weightChangeListeners)
+ {
+ weightChangeListeners.add (l);
+ enableWeightChangeEvents (true);
+ }} private LinkedList weightChangeListeners = new LinkedList ();
+ private long nativeWeightChangeHandler = 0;
+ public final void removeWeightChangeListener (WeightChangeListener l)
+ {
+ synchronized (weightChangeListeners)
+ {
+ weightChangeListeners.remove (l);
+ enableWeightChangeEvents (weightChangeListeners.size () > 0);
+ }} private void fireWeightChange (WeightChangeEvent e)
+ {
+ synchronized (weightChangeListeners)
+ {
+ for (Iterator it = weightChangeListeners.iterator (); it.hasNext ();)
+ ((WeightChangeListener) it.next ()).weightChanged (e);
+ }
+ }
+ private native void enableWeightChangeEvents (boolean b);
+}
diff --git a/Java/com/phidgets/event/AccelerationChangeEvent.java b/Java/com/phidgets/event/AccelerationChangeEvent.java
new file mode 100644
index 0000000..92f9c69
--- /dev/null
+++ b/Java/com/phidgets/event/AccelerationChangeEvent.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for an AccelerationChangeEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class AccelerationChangeEvent
+{
+ Phidget source;
+ int index;
+ double value;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public AccelerationChangeEvent(Phidget source, int index, double value) {
+ this.source = source;
+ this.index = index;
+ this.value = value;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the axis.
+ *
+ * @return the index of the axis
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Returns the acceleration. This is returned in g's
+ *
+ * @return the acceleration of the axis
+ */
+ public double getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " Acceleration " + index + " changed to "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/AccelerationChangeListener.java b/Java/com/phidgets/event/AccelerationChangeListener.java
new file mode 100644
index 0000000..b97172e
--- /dev/null
+++ b/Java/com/phidgets/event/AccelerationChangeListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a AccelerationChangeEvent. This event originates from the Phidget Accelerometer
+ *
+ * @author Phidgets Inc.
+ */
+public interface AccelerationChangeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void accelerationChanged(AccelerationChangeEvent ae);
+}
diff --git a/Java/com/phidgets/event/AttachEvent.java b/Java/com/phidgets/event/AttachEvent.java
new file mode 100644
index 0000000..eecb7b0
--- /dev/null
+++ b/Java/com/phidgets/event/AttachEvent.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a AttachEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class AttachEvent
+{
+ Phidget source;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public AttachEvent(Phidget source) {
+ this.source = source;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString();
+ }
+}
diff --git a/Java/com/phidgets/event/AttachListener.java b/Java/com/phidgets/event/AttachListener.java
new file mode 100644
index 0000000..5fe8c00
--- /dev/null
+++ b/Java/com/phidgets/event/AttachListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a AttachEvent. This event originates from all Phidgets.
+ *
+ * @author Phidgets Inc.
+ */
+public interface AttachListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void attached(AttachEvent ae);
+}
diff --git a/Java/com/phidgets/event/BackEMFUpdateEvent.java b/Java/com/phidgets/event/BackEMFUpdateEvent.java
new file mode 100644
index 0000000..7dace73
--- /dev/null
+++ b/Java/com/phidgets/event/BackEMFUpdateEvent.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2011 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a BackEMFUpdateEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class BackEMFUpdateEvent
+{
+ Phidget source;
+ int index;
+ double voltage;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public BackEMFUpdateEvent(Phidget source, int index, double voltage)
+ {
+ this.source = source;
+ this.index = index;
+ this.voltage = voltage;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the motor.
+ *
+ * @return the index of the motor
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Returns the backEMF value.
+ *
+ * @return the backEMF value
+ */
+ public double getVoltage() {
+ return voltage;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " BackEMF Value " + index + " is "
+ + voltage;
+ }
+}
diff --git a/Java/com/phidgets/event/BackEMFUpdateListener.java b/Java/com/phidgets/event/BackEMFUpdateListener.java
new file mode 100644
index 0000000..9a99a97
--- /dev/null
+++ b/Java/com/phidgets/event/BackEMFUpdateListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2011 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a BackEMFUpdateEvent. This event originates from the
+ * Phidget Motor Control. This event is not supported by all Motor Controllers.
+ *
+ * @author Phidgets Inc.
+ */
+public interface BackEMFUpdateListener
+{
+ /**
+ * This method is called with the event data every 16ms, when back EMF sensing is enabled for that motor.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void backEMFUpdated(BackEMFUpdateEvent ae);
+}
diff --git a/Java/com/phidgets/event/BridgeDataEvent.java b/Java/com/phidgets/event/BridgeDataEvent.java
new file mode 100644
index 0000000..3dd1578
--- /dev/null
+++ b/Java/com/phidgets/event/BridgeDataEvent.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2011 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a BridgeDataEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class BridgeDataEvent
+{
+ Phidget source;
+ int index;
+ double value;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public BridgeDataEvent(Phidget source, int index, double value) {
+ this.source = source;
+ this.index = index;
+ this.value = value;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the bridge.
+ *
+ * @return the index of the bridge
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Retuns the bridge value, in mV/V.
+ *
+ * @return the bridge value
+ */
+ public double getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " bridge " + index + " value changed to "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/BridgeDataListener.java b/Java/com/phidgets/event/BridgeDataListener.java
new file mode 100644
index 0000000..de2f993
--- /dev/null
+++ b/Java/com/phidgets/event/BridgeDataListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2011 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+/**
+ * This interface represents a BridgeDataEvent. This event originates from the Phidget Bridge
+ *
+ * @author Phidgets Inc.
+ */
+public interface BridgeDataListener
+{
+ /**
+ * This method is called with the event data when a new event arrives. The event is issued at the specified data rate, for
+ * each enabled bridge.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void bridgeData(BridgeDataEvent ae);
+}
diff --git a/Java/com/phidgets/event/CodeEvent.java b/Java/com/phidgets/event/CodeEvent.java
new file mode 100644
index 0000000..0cb5336
--- /dev/null
+++ b/Java/com/phidgets/event/CodeEvent.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+import com.phidgets.IRCode;
+
+/**
+ * This class represents the data for a CodeEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class CodeEvent
+{
+ Phidget source;
+ IRCode code;
+ boolean repeat;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ * @param code the IR code
+ * @param repeat whether the code is a repeat
+ */
+ public CodeEvent(Phidget source, IRCode code, boolean repeat)
+ {
+ this.source = source;
+ this.code = code;
+ this.repeat = repeat;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the code.
+ *
+ * @return the code
+ */
+ public IRCode getCode() {
+ return code;
+ }
+
+ /**
+ * Returns the repeat identifier.
+ *
+ * @return whether this is a repeat
+ */
+ public boolean getRepeat() {
+ return repeat;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " Code: "
+ + code.toString();
+ }
+}
diff --git a/Java/com/phidgets/event/CodeListener.java b/Java/com/phidgets/event/CodeListener.java
new file mode 100644
index 0000000..30bdde1
--- /dev/null
+++ b/Java/com/phidgets/event/CodeListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a CodeEvent. This event originates from the Phidget IR.
+ * This event occurs when a code is seen by the reader.
+ *
+ * @author Phidgets Inc.
+ */
+public interface CodeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void code(CodeEvent ae);
+}
diff --git a/Java/com/phidgets/event/CurrentChangeEvent.java b/Java/com/phidgets/event/CurrentChangeEvent.java
new file mode 100644
index 0000000..b279ce8
--- /dev/null
+++ b/Java/com/phidgets/event/CurrentChangeEvent.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a CurrentChangeEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class CurrentChangeEvent
+{
+ Phidget source;
+ int index;
+ double value;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public CurrentChangeEvent(Phidget source, int index, double value) {
+ this.source = source;
+ this.index = index;
+ this.value = value;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the motor.
+ *
+ * @return the index of the motor
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Returns the current of the motor. This is a representation of the ammount of current being used by the motor.
+ *
+ * @return the motor's current draw
+ */
+ public double getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " current " + index + " changed to "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/CurrentChangeListener.java b/Java/com/phidgets/event/CurrentChangeListener.java
new file mode 100644
index 0000000..f45681c
--- /dev/null
+++ b/Java/com/phidgets/event/CurrentChangeListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2011 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a CurrentChangeEvent. This event originates from the Phidget Motor Controller.
+ * This event is not supported by all Motor Controllers.
+ *
+ * @author Phidgets Inc.
+ */
+public interface CurrentChangeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void currentChanged(CurrentChangeEvent ae);
+}
diff --git a/Java/com/phidgets/event/CurrentUpdateEvent.java b/Java/com/phidgets/event/CurrentUpdateEvent.java
new file mode 100644
index 0000000..12265e5
--- /dev/null
+++ b/Java/com/phidgets/event/CurrentUpdateEvent.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a CurrentUpdateEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class CurrentUpdateEvent
+{
+ Phidget source;
+ int index;
+ double value;
+
+ /**
+ * Class constructor. This is called internally by the Phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public CurrentUpdateEvent(Phidget source, int index, double value)
+ {
+ this.source = source;
+ this.index = index;
+ this.value = value;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the motor.
+ *
+ * @return the index of the motor
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Returns the current of the motor. This is a representation of the amount of current being used by the motor.
+ *
+ * @return the motor's current draw
+ */
+ public double getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " current " + index + " is "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/CurrentUpdateListener.java b/Java/com/phidgets/event/CurrentUpdateListener.java
new file mode 100644
index 0000000..20a6784
--- /dev/null
+++ b/Java/com/phidgets/event/CurrentUpdateListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2011 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a CurrentUpdateEvent. This event originates from the Phidget Motor Controller. This event is not supported by all Motor Controllers.
+ *
+ * @author Phidgets Inc.
+ */
+public interface CurrentUpdateListener
+{
+ /**
+ * This method is called with every 8ms.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void currentUpdated(CurrentUpdateEvent ae);
+}
diff --git a/Java/com/phidgets/event/DetachEvent.java b/Java/com/phidgets/event/DetachEvent.java
new file mode 100644
index 0000000..97bfe29
--- /dev/null
+++ b/Java/com/phidgets/event/DetachEvent.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a DetachEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class DetachEvent
+{
+ Phidget source;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public DetachEvent(Phidget source) {
+ this.source = source;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString();
+ }
+}
diff --git a/Java/com/phidgets/event/DetachListener.java b/Java/com/phidgets/event/DetachListener.java
new file mode 100644
index 0000000..b74e0ec
--- /dev/null
+++ b/Java/com/phidgets/event/DetachListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a DetachEvent. This event originates from all Phidgets, as well as the Phidget Manager.
+ *
+ * @author Phidgets Inc.
+ */
+public interface DetachListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void detached(DetachEvent ae);
+}
diff --git a/Java/com/phidgets/event/EncoderPositionChangeEvent.java b/Java/com/phidgets/event/EncoderPositionChangeEvent.java
new file mode 100644
index 0000000..52118a7
--- /dev/null
+++ b/Java/com/phidgets/event/EncoderPositionChangeEvent.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a EncoderPositionChangeEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class EncoderPositionChangeEvent
+{
+ Phidget source;
+ int index;
+ int value;
+ int time;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public EncoderPositionChangeEvent(Phidget source, int index, int time, int value) {
+ this.source = source;
+ this.index = index;
+ this.value = value;
+ this.time = time;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the encoder.
+ *
+ * @return the index of the encoder
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Returns the position change of the encoder. This is the amount of change in the encoder's position
+ * since the last {@link #EncoderPositionChangeEvent}.
+ *
+ * @return the change in position of the encoder
+ */
+ public int getValue() {
+ return value;
+ }
+
+ /**
+ * Returns the timestamp of this position change. This is the time since the last {@link #EncoderPositionChangeEvent}.
+ * This time is not represented in a real quantitly such as seconds, but can be used as a qualitative quantity.
+ *
+ * @return the timestamp of this change event
+ */
+ public int getTime()
+ {
+ return time;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+
+ return source.toString() + " encoder position " + index + " changed by "
+ + value + " Time: " + time;
+ }
+}
diff --git a/Java/com/phidgets/event/EncoderPositionChangeListener.java b/Java/com/phidgets/event/EncoderPositionChangeListener.java
new file mode 100644
index 0000000..dabdb08
--- /dev/null
+++ b/Java/com/phidgets/event/EncoderPositionChangeListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents an EncoderPositionChangeEvent. This event originates from the Phidget Encoder and the Phidget Motor Controller. This event is not supported by all Motor Controllers.
+ *
+ * @author Phidgets Inc.
+ */
+public interface EncoderPositionChangeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void encoderPositionChanged(EncoderPositionChangeEvent ae);
+}
diff --git a/Java/com/phidgets/event/EncoderPositionUpdateEvent.java b/Java/com/phidgets/event/EncoderPositionUpdateEvent.java
new file mode 100644
index 0000000..8124b04
--- /dev/null
+++ b/Java/com/phidgets/event/EncoderPositionUpdateEvent.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2011 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a EncoderPositionUpdateEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class EncoderPositionUpdateEvent
+{
+ Phidget source;
+ int index;
+ int value;
+
+ /**
+ * Class constructor. This is called internally by the Phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public EncoderPositionUpdateEvent(Phidget source, int index, int value)
+ {
+ this.source = source;
+ this.index = index;
+ this.value = value;
+
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the encoder.
+ *
+ * @return the index of the encoder
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Returns the position change of the encoder. This is the amount of change in the encoder's position
+ * since the last {@link #EncoderPositionUpdateEvent}.
+ *
+ * @return the change in position of the encoder
+ */
+ public int getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+
+ return source.toString() + " encoder position " + index + " is "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/EncoderPositionUpdateListener.java b/Java/com/phidgets/event/EncoderPositionUpdateListener.java
new file mode 100644
index 0000000..f16c899
--- /dev/null
+++ b/Java/com/phidgets/event/EncoderPositionUpdateListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2011 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents an EncoderPositionUpdateEvent. This event originates from the Phidget Motor Controller. This event is not supported by all Motor Controllers.
+ *
+ * @author Phidgets Inc.
+ */
+public interface EncoderPositionUpdateListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void encoderPositionUpdated(EncoderPositionUpdateEvent ae);
+}
diff --git a/Java/com/phidgets/event/ErrorEvent.java b/Java/com/phidgets/event/ErrorEvent.java
new file mode 100644
index 0000000..e0dc374
--- /dev/null
+++ b/Java/com/phidgets/event/ErrorEvent.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+import com.phidgets.PhidgetException;
+
+/**
+ * This class represents the data for a ErrorEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class ErrorEvent
+{
+ Phidget source;
+ PhidgetException exception;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public ErrorEvent(Phidget source, PhidgetException ex) {
+ this.source = source;
+ this.exception = ex;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the exception that describes the error.
+ *
+ * @return the event exception
+ */
+ public PhidgetException getException()
+ {
+ return exception;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return "Error Event (" + exception.getErrorNumber() + "): " + exception.getDescription();
+ }
+}
diff --git a/Java/com/phidgets/event/ErrorListener.java b/Java/com/phidgets/event/ErrorListener.java
new file mode 100644
index 0000000..a1a0207
--- /dev/null
+++ b/Java/com/phidgets/event/ErrorListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a ErrorEvent. This event originates from all Phidgets.
+ * It is used for asynchronous error handling.
+ *
+ * @author Phidgets Inc.
+ */
+public interface ErrorListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void error(ErrorEvent ae);
+}
diff --git a/Java/com/phidgets/event/FrequencyCounterCountEvent.java b/Java/com/phidgets/event/FrequencyCounterCountEvent.java
new file mode 100644
index 0000000..4a9291b
--- /dev/null
+++ b/Java/com/phidgets/event/FrequencyCounterCountEvent.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2011 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a FrequencyCounterCountEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class FrequencyCounterCountEvent
+{
+ Phidget source;
+ int index;
+ int time;
+ int count;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public FrequencyCounterCountEvent(Phidget source, int index, int time, int count) {
+ this.source = source;
+ this.index = index;
+ this.time = time;
+ this.count = count;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the channel.
+ *
+ * @return the index of the channel
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Returns the amount of time in which the number of counts occured, in microseconds.
+ *
+ * @return the amount of time in which the number of counts occured
+ */
+ public int getTime() {
+ return time;
+ }
+
+ /**
+ * Returns the number of counts detected.
+ *
+ * @return the number of counts detected
+ */
+ public int getCount() {
+ return count;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+
+ return source.toString() + " Channel " + index + ": " + count + " pulses in "
+ + time + " miroseconds";
+ }
+}
diff --git a/Java/com/phidgets/event/FrequencyCounterCountListener.java b/Java/com/phidgets/event/FrequencyCounterCountListener.java
new file mode 100644
index 0000000..fd19348
--- /dev/null
+++ b/Java/com/phidgets/event/FrequencyCounterCountListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2011 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a FrequencyCounterCountEvent. This event originates from the Phidget Frequency Counter
+ *
+ * @author Phidgets Inc.
+ */
+public interface FrequencyCounterCountListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void frequencyCounterCounted(FrequencyCounterCountEvent ae);
+}
diff --git a/Java/com/phidgets/event/GPSPositionChangeEvent.java b/Java/com/phidgets/event/GPSPositionChangeEvent.java
new file mode 100644
index 0000000..42b9199
--- /dev/null
+++ b/Java/com/phidgets/event/GPSPositionChangeEvent.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a GPSPositionChangeEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class GPSPositionChangeEvent
+{
+ Phidget source;
+ double latitude;
+ double longitude;
+ double altitude;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public GPSPositionChangeEvent(Phidget source, double latitude, double longitude, double altitude) {
+ this.source = source;
+ this.latitude = latitude;
+ this.longitude = longitude;
+ this.altitude = altitude;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the latitude of the GPS, in signed degrees format.
+ *
+ * @return the latitude
+ */
+ public double getLatitude() {
+ return latitude;
+ }
+
+ /**
+ * Returns the longitude of the GPS, in signed degrees format
+ *
+ * @return the longitude
+ */
+ public double getLongitude() {
+ return longitude;
+ }
+
+ /**
+ * Returns the altitude of the GPS, in meters.
+ *
+ * @return the altitude
+ */
+ public double getAltitude() {
+ return altitude;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return("Position is - Latitude: "+ latitude + " degrees" +
+ ", Longitude: " + longitude + " degrees" + ", Altitude: "+ altitude + "m");
+ }
+}
diff --git a/Java/com/phidgets/event/GPSPositionChangeListener.java b/Java/com/phidgets/event/GPSPositionChangeListener.java
new file mode 100644
index 0000000..dceb712
--- /dev/null
+++ b/Java/com/phidgets/event/GPSPositionChangeListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2011 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a GPSPositionChangeEvent. This event originates from the Phidget GPS
+ *
+ * @author Phidgets Inc.
+ */
+public interface GPSPositionChangeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void gpsPositionChanged(GPSPositionChangeEvent ae);
+}
diff --git a/Java/com/phidgets/event/GPSPositionFixStatusChangeEvent.java b/Java/com/phidgets/event/GPSPositionFixStatusChangeEvent.java
new file mode 100644
index 0000000..94f08a9
--- /dev/null
+++ b/Java/com/phidgets/event/GPSPositionFixStatusChangeEvent.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a GPSPositionFixStatusChangeEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class GPSPositionFixStatusChangeEvent
+{
+ Phidget source;
+ boolean status;
+
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public GPSPositionFixStatusChangeEvent(Phidget source, boolean status) {
+ this.source = source;
+ this.status = status;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the position fix status of the GPS.
+ *
+ * @return the position fix status
+ */
+ public boolean getStatus() {
+ return status;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return("Position fix status IS : " + status);
+ }
+}
diff --git a/Java/com/phidgets/event/GPSPositionFixStatusChangeListener.java b/Java/com/phidgets/event/GPSPositionFixStatusChangeListener.java
new file mode 100644
index 0000000..2768cea
--- /dev/null
+++ b/Java/com/phidgets/event/GPSPositionFixStatusChangeListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2011 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a GPSPositionFixStatusChangeEvent. This event originates from the Phidget GPS
+ *
+ * @author Phidgets Inc.
+ */
+public interface GPSPositionFixStatusChangeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void gpsPositionFixStatusChanged(GPSPositionFixStatusChangeEvent ae);
+}
diff --git a/Java/com/phidgets/event/InputChangeEvent.java b/Java/com/phidgets/event/InputChangeEvent.java
new file mode 100644
index 0000000..273bb9b
--- /dev/null
+++ b/Java/com/phidgets/event/InputChangeEvent.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a InputChangeEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class InputChangeEvent
+{
+ Phidget source;
+ int index;
+ boolean state;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public InputChangeEvent(Phidget source, int index, boolean state) {
+ this.source = source;
+ this.index = index;
+ this.state = state;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the digital input.
+ *
+ * @return the index of the input
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Returns the state of the input. True indicates that it is activated, False indicated the default state.
+ *
+ * @return the state of the input
+ */
+ public boolean getState() {
+ return state;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " input " + index + " changed to "
+ + state;
+ }
+}
diff --git a/Java/com/phidgets/event/InputChangeListener.java b/Java/com/phidgets/event/InputChangeListener.java
new file mode 100644
index 0000000..c63ade9
--- /dev/null
+++ b/Java/com/phidgets/event/InputChangeListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a InputChangeEvent. This event originates from the Phidget Encoder, the Phidget InterfaceKit,
+ * and the Phidget Motor Controller.
+ *
+ * @author Phidgets Inc.
+ */
+public interface InputChangeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void inputChanged(InputChangeEvent ae);
+}
diff --git a/Java/com/phidgets/event/KeyChangeEvent.java b/Java/com/phidgets/event/KeyChangeEvent.java
new file mode 100644
index 0000000..fe86cda
--- /dev/null
+++ b/Java/com/phidgets/event/KeyChangeEvent.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006 Dictionarys Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Dictionary;
+
+/**
+ * This class represents the data for a KeyChangeEvent.
+ *
+ * @author Dictionarys Inc.
+ */
+public class KeyChangeEvent
+{
+ Dictionary source;
+ String value;
+ String key;
+
+ /**
+ * Class constructor. This is called internally by the Dictionary library when creating this event.
+ *
+ * @param source the Dictionary object from which this event originated
+ */
+ public KeyChangeEvent(Dictionary source, String key, String value)
+ {
+ this.source = source;
+ this.value = value;
+ this.key = key;
+ }
+
+ /**
+ * Returns the source Dictionary of this event. This is a reference to the Dictionary object from which this
+ * event was called. This object can be cast into a specific type of Dictionary object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Dictionary getSource() {
+ return source;
+ }
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString()
+ {
+ return source.toString() + " Key changed: "
+ + key + ":" + value;
+ }
+}
diff --git a/Java/com/phidgets/event/KeyChangeListener.java b/Java/com/phidgets/event/KeyChangeListener.java
new file mode 100644
index 0000000..07772c2
--- /dev/null
+++ b/Java/com/phidgets/event/KeyChangeListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a KeyChangeEvent. This event originates from the Phidget Dictionary. Key Change events
+ * occur when key that matches the listen pattern is either added or changes in the Dictionary.
+ *
+ * @author Phidgets Inc.
+ */
+public interface KeyChangeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void keyChanged(KeyChangeEvent ae);
+}
diff --git a/Java/com/phidgets/event/KeyRemovalEvent.java b/Java/com/phidgets/event/KeyRemovalEvent.java
new file mode 100644
index 0000000..1a7fe9f
--- /dev/null
+++ b/Java/com/phidgets/event/KeyRemovalEvent.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2006 Dictionarys Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Dictionary;
+
+/**
+ * This class represents the data for a KeyRemovalEvent.
+ *
+ * @author Dictionarys Inc.
+ */
+public class KeyRemovalEvent
+{
+ Dictionary source;
+ String value;
+ String key;
+
+ /**
+ * Class constructor. This is called internally by the Dictionary library when creating this event.
+ *
+ * @param source the Dictionary object from which this event originated
+ */
+ public KeyRemovalEvent(Dictionary source, String key, String value)
+ {
+ this.source = source;
+ this.value = value;
+ this.key = key;
+ }
+
+ /**
+ * Returns the source Dictionary of this event. This is a reference to the Dictionary object from which this
+ * event was called. This object can be cast into a specific type of Dictionary object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Dictionary getSource() {
+ return source;
+ }
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " Key removed: "
+ + key + ":" + value;
+ }
+}
diff --git a/Java/com/phidgets/event/KeyRemovalListener.java b/Java/com/phidgets/event/KeyRemovalListener.java
new file mode 100644
index 0000000..bac9a92
--- /dev/null
+++ b/Java/com/phidgets/event/KeyRemovalListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a KeyRemovalEvent. This event originates from the Phidget Dictionary.
+ * This event occurs key that matches the listen pattern is removed.
+ *
+ * @author Phidgets Inc.
+ */
+public interface KeyRemovalListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void keyRemoved(KeyRemovalEvent ae);
+}
diff --git a/Java/com/phidgets/event/LearnEvent.java b/Java/com/phidgets/event/LearnEvent.java
new file mode 100644
index 0000000..f0a784d
--- /dev/null
+++ b/Java/com/phidgets/event/LearnEvent.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+import com.phidgets.IRLearnedCode;
+
+/**
+ * This class represents the data for a LearnEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class LearnEvent
+{
+ Phidget source;
+ IRLearnedCode value;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public LearnEvent(Phidget source, IRLearnedCode value)
+ {
+ this.source = source;
+ this.value = value;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the learned code.
+ *
+ * @return the learned code
+ */
+ public IRLearnedCode getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " Learned Code: "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/LearnListener.java b/Java/com/phidgets/event/LearnListener.java
new file mode 100644
index 0000000..174aa30
--- /dev/null
+++ b/Java/com/phidgets/event/LearnListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a LearnEvent. This event originates from the Phidget IR.
+ * This event occurs when a code is learned by the reader.
+ *
+ * @author Phidgets Inc.
+ */
+public interface LearnListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void learn(LearnEvent ae);
+}
diff --git a/Java/com/phidgets/event/MotorVelocityChangeEvent.java b/Java/com/phidgets/event/MotorVelocityChangeEvent.java
new file mode 100644
index 0000000..b3aef63
--- /dev/null
+++ b/Java/com/phidgets/event/MotorVelocityChangeEvent.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a MotorVelocityChangeEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class MotorVelocityChangeEvent
+{
+ Phidget source;
+ int index;
+ double value;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public MotorVelocityChangeEvent(Phidget source, int index, double value) {
+ this.source = source;
+ this.index = index;
+ this.value = value;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the motor.
+ *
+ * @return the index of the motor
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Return the velocity of the motor. This is reported back from the motor controller as the motor changes speed.
+ *
+ * @return the motor velocity
+ */
+ public double getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " motor velocity " + index + " changed to "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/MotorVelocityChangeListener.java b/Java/com/phidgets/event/MotorVelocityChangeListener.java
new file mode 100644
index 0000000..88cd722
--- /dev/null
+++ b/Java/com/phidgets/event/MotorVelocityChangeListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a MotorVelocityChangeEvent. This event originates from the Phidget Motor Controller
+ *
+ * @author Phidgets Inc.
+ */
+public interface MotorVelocityChangeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void motorVelocityChanged(MotorVelocityChangeEvent ae);
+}
diff --git a/Java/com/phidgets/event/OutputChangeEvent.java b/Java/com/phidgets/event/OutputChangeEvent.java
new file mode 100644
index 0000000..01e6af5
--- /dev/null
+++ b/Java/com/phidgets/event/OutputChangeEvent.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a OutputChangeEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class OutputChangeEvent
+{
+ Phidget source;
+ int index;
+ boolean state;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public OutputChangeEvent(Phidget source, int index, boolean state) {
+ this.source = source;
+ this.index = index;
+ this.state = state;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the output.
+ *
+ * @return the index of the output
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Returns the state of the output. True indicated that the output is active, False indicated the default inactive state.
+ *
+ * @return the state of the output
+ */
+ public boolean getState() {
+ return state;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " output " + index + " changed to "
+ + state;
+ }
+}
diff --git a/Java/com/phidgets/event/OutputChangeListener.java b/Java/com/phidgets/event/OutputChangeListener.java
new file mode 100644
index 0000000..998ffbf
--- /dev/null
+++ b/Java/com/phidgets/event/OutputChangeListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a OutputChangeEvent. This event originates from the
+ * Phidget Interface Kit and the Phidget RFID Reader
+ *
+ * @author Phidgets Inc.
+ */
+public interface OutputChangeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void outputChanged(OutputChangeEvent ae);
+}
diff --git a/Java/com/phidgets/event/PHChangeEvent.java b/Java/com/phidgets/event/PHChangeEvent.java
new file mode 100644
index 0000000..a885132
--- /dev/null
+++ b/Java/com/phidgets/event/PHChangeEvent.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a PHChangeEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class PHChangeEvent
+{
+ Phidget source;
+ double value;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public PHChangeEvent(Phidget source, double value) {
+ this.source = source;
+ this.value = value;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the pH. This value can range from 0-14
+ *
+ * @return the pH
+ */
+ public double getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " ph changed to "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/PHChangeListener.java b/Java/com/phidgets/event/PHChangeListener.java
new file mode 100644
index 0000000..0791631
--- /dev/null
+++ b/Java/com/phidgets/event/PHChangeListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a PHChangeEvent. This event originates from the Phidget PH Sensor
+ *
+ * @author Phidgets Inc.
+ */
+public interface PHChangeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void phChanged(PHChangeEvent ae);
+}
diff --git a/Java/com/phidgets/event/RawDataEvent.java b/Java/com/phidgets/event/RawDataEvent.java
new file mode 100644
index 0000000..ba0c644
--- /dev/null
+++ b/Java/com/phidgets/event/RawDataEvent.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a RawDataEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class RawDataEvent
+{
+ Phidget source;
+ int[] data;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public RawDataEvent(Phidget source, int[] data)
+ {
+ this.source = source;
+ this.data = new int[data.length];
+ for(int i=0;i<data.length;i++)
+ this.data[i] = data[i];
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the raw data.
+ *
+ * @return the raw data
+ */
+ public int[] getData() {
+ return data;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ String out = " Raw data:";
+ for(int i=0;i<data.length;i++)
+ {
+ if(i%8 == 0) out = out + "\n";
+ if(data[i]==com.phidgets.IRPhidget.RAWDATA_LONGSPACE)
+ out = out + "LONG";
+ else
+ out = out + data[i];
+ if((i+1)%8 != 0) out = out + ", ";
+ }
+ return out;
+ }
+}
diff --git a/Java/com/phidgets/event/RawDataListener.java b/Java/com/phidgets/event/RawDataListener.java
new file mode 100644
index 0000000..2a656bd
--- /dev/null
+++ b/Java/com/phidgets/event/RawDataListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a RawDataEvent. This event originates from the Phidget IR.
+ * This event occurs when the reader sees IR data.
+ *
+ * @author Phidgets Inc.
+ */
+public interface RawDataListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void rawData(RawDataEvent ae);
+}
diff --git a/Java/com/phidgets/event/SensorChangeEvent.java b/Java/com/phidgets/event/SensorChangeEvent.java
new file mode 100644
index 0000000..fce96ca
--- /dev/null
+++ b/Java/com/phidgets/event/SensorChangeEvent.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a SensorChangeEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class SensorChangeEvent
+{
+ Phidget source;
+ int index;
+ int value;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public SensorChangeEvent(Phidget source, int index, int value) {
+ this.source = source;
+ this.index = index;
+ this.value = value;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the sensor.
+ *
+ * @return the index of the sensor
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Retuns the value of the sensor. This value can range from 0-1000.
+ *
+ * @return the value of the sensor
+ */
+ public int getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " sensor " + index + " changed to "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/SensorChangeListener.java b/Java/com/phidgets/event/SensorChangeListener.java
new file mode 100644
index 0000000..5a4cb40
--- /dev/null
+++ b/Java/com/phidgets/event/SensorChangeListener.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+/**
+ * This interface represents a SensorChangeEvent. This event originates from the Phidget Interface Kit
+ *
+ * @author Phidgets Inc.
+ */
+public interface SensorChangeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void sensorChanged(SensorChangeEvent ae);
+}
diff --git a/Java/com/phidgets/event/SensorUpdateEvent.java b/Java/com/phidgets/event/SensorUpdateEvent.java
new file mode 100644
index 0000000..24edd6e
--- /dev/null
+++ b/Java/com/phidgets/event/SensorUpdateEvent.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2011 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a SensorUpdateEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class SensorUpdateEvent
+{
+ Phidget source;
+ int index;
+ int value;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public SensorUpdateEvent(Phidget source, int index, int value)
+ {
+ this.source = source;
+ this.index = index;
+ this.value = value;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the sensor.
+ *
+ * @return the index of the sensor
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Retuns the value of the sensor. This value ranges from 0-1000.
+ *
+ * @return the value of the sensor
+ */
+ public int getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " sensor " + index + " is "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/SensorUpdateListener.java b/Java/com/phidgets/event/SensorUpdateListener.java
new file mode 100644
index 0000000..5c491cc
--- /dev/null
+++ b/Java/com/phidgets/event/SensorUpdateListener.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2011 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+/**
+ * This interface represents a SensorUpdateEvent. This event originates from the Phidget Motor Control
+ *
+ * @author Phidgets Inc.
+ */
+public interface SensorUpdateListener
+{
+ /**
+ * This method is called with the event data every 8ms.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void sensorUpdated(SensorUpdateEvent ae);
+}
diff --git a/Java/com/phidgets/event/ServerConnectEvent.java b/Java/com/phidgets/event/ServerConnectEvent.java
new file mode 100644
index 0000000..cc89dde
--- /dev/null
+++ b/Java/com/phidgets/event/ServerConnectEvent.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a ServerConnectEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class ServerConnectEvent
+{
+ Object source;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the object from which this event originated
+ */
+ public ServerConnectEvent(Object source)
+ {
+ this.source = source;
+ }
+
+ /**
+ * Returns the source Object of this event. This is a reference to the object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Object getSource()
+ {
+ return source;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString();
+ }
+}
diff --git a/Java/com/phidgets/event/ServerConnectListener.java b/Java/com/phidgets/event/ServerConnectListener.java
new file mode 100644
index 0000000..5667a30
--- /dev/null
+++ b/Java/com/phidgets/event/ServerConnectListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a ServerConnectEvent. This event originates from all Phidgets.
+ *
+ * @author Phidgets Inc.
+ */
+public interface ServerConnectListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void serverConnected(ServerConnectEvent ae);
+}
diff --git a/Java/com/phidgets/event/ServerDisconnectEvent.java b/Java/com/phidgets/event/ServerDisconnectEvent.java
new file mode 100644
index 0000000..1b4740d
--- /dev/null
+++ b/Java/com/phidgets/event/ServerDisconnectEvent.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a ServerDisconnectEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class ServerDisconnectEvent
+{
+ Object source;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the object from which this event originated
+ */
+ public ServerDisconnectEvent(Object source)
+ {
+ this.source = source;
+ }
+
+ /**
+ * Returns the source Object of this event. This is a reference to the object from which this
+ * event was called. This object can be cast into a specific type of object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Object getSource()
+ {
+ return source;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString();
+ }
+}
diff --git a/Java/com/phidgets/event/ServerDisconnectListener.java b/Java/com/phidgets/event/ServerDisconnectListener.java
new file mode 100644
index 0000000..93df8f9
--- /dev/null
+++ b/Java/com/phidgets/event/ServerDisconnectListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a ServerDisconnectEvent. This event originates from all Phidgets.
+ *
+ * @author Phidgets Inc.
+ */
+public interface ServerDisconnectListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void serverDisconnected(ServerDisconnectEvent ae);
+}
diff --git a/Java/com/phidgets/event/ServoPositionChangeEvent.java b/Java/com/phidgets/event/ServoPositionChangeEvent.java
new file mode 100644
index 0000000..f685964
--- /dev/null
+++ b/Java/com/phidgets/event/ServoPositionChangeEvent.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a ServoPositionChangeEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class ServoPositionChangeEvent
+{
+ Phidget source;
+ int index;
+ double value;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public ServoPositionChangeEvent(Phidget source, int index, double value) {
+ this.source = source;
+ this.index = index;
+ this.value = value;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the servo motor.
+ *
+ * @return index of the servo
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Returns the position of the servo motor. This is esentially just the last position that the
+ * servo was set to, echoed back from the controller board.
+ *
+ * @return position of the servo
+ */
+ public double getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " servo position " + index + " changed to "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/ServoPositionChangeListener.java b/Java/com/phidgets/event/ServoPositionChangeListener.java
new file mode 100644
index 0000000..00e8cf8
--- /dev/null
+++ b/Java/com/phidgets/event/ServoPositionChangeListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a ServoPositionChangeEvent. This event originates from the Phidget Servo Controller and the
+ * Phidget Advanced Servo Controller.
+ *
+ * @author Phidgets Inc.
+ */
+public interface ServoPositionChangeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void servoPositionChanged(ServoPositionChangeEvent ae);
+}
diff --git a/Java/com/phidgets/event/ServoVelocityChangeEvent.java b/Java/com/phidgets/event/ServoVelocityChangeEvent.java
new file mode 100644
index 0000000..9c43651
--- /dev/null
+++ b/Java/com/phidgets/event/ServoVelocityChangeEvent.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a ServoVelocityChangeEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class ServoVelocityChangeEvent
+{
+ Phidget source;
+ int index;
+ double value;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public ServoVelocityChangeEvent(Phidget source, int index, double value) {
+ this.source = source;
+ this.index = index;
+ this.value = value;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the Servo.
+ *
+ * @return the index of the servo
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Return the velocity of the Servo. This is reported back from the Servo controller as the Servo changes speed.
+ *
+ * @return the Servo velocity
+ */
+ public double getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " Servo velocity " + index + " changed to "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/ServoVelocityChangeListener.java b/Java/com/phidgets/event/ServoVelocityChangeListener.java
new file mode 100644
index 0000000..962ca53
--- /dev/null
+++ b/Java/com/phidgets/event/ServoVelocityChangeListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a ServoVelocityChangeEvent. This event originates from the Phidget Advanced Servo Controller
+ *
+ * @author Phidgets Inc.
+ */
+public interface ServoVelocityChangeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void servoVelocityChanged(ServoVelocityChangeEvent ae);
+}
diff --git a/Java/com/phidgets/event/SpatialDataEvent.java b/Java/com/phidgets/event/SpatialDataEvent.java
new file mode 100644
index 0000000..e6c6dae
--- /dev/null
+++ b/Java/com/phidgets/event/SpatialDataEvent.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+import com.phidgets.SpatialEventData;
+
+/**
+ * This class represents the data for a SpatialDataEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class SpatialDataEvent
+{
+ Phidget source;
+ SpatialEventData[] data;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ * @param data the spatial data
+ */
+ public SpatialDataEvent(Phidget source, SpatialEventData[] data)
+ {
+ this.source = source;
+ this.data = data;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the data. This may contain multiple sets of data for high data rates.
+ *
+ * @return the data
+ */
+ public SpatialEventData[] getData() {
+ return data;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " Spatial Data";
+ }
+}
diff --git a/Java/com/phidgets/event/SpatialDataListener.java b/Java/com/phidgets/event/SpatialDataListener.java
new file mode 100644
index 0000000..a381777
--- /dev/null
+++ b/Java/com/phidgets/event/SpatialDataListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a SpatialDataEvent. This event originates from the Phidget Spatial.
+ * This event occurs when spatial data comes in
+ *
+ * @author Phidgets Inc.
+ */
+public interface SpatialDataListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void data(SpatialDataEvent ae);
+}
diff --git a/Java/com/phidgets/event/StepperPositionChangeEvent.java b/Java/com/phidgets/event/StepperPositionChangeEvent.java
new file mode 100644
index 0000000..e002dd9
--- /dev/null
+++ b/Java/com/phidgets/event/StepperPositionChangeEvent.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a StepperPositionChangeEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class StepperPositionChangeEvent
+{
+ Phidget source;
+ int index;
+ long value;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public StepperPositionChangeEvent(Phidget source, int index, long value) {
+ this.source = source;
+ this.index = index;
+ this.value = value;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the Stepper motor.
+ *
+ * @return index of the Stepper
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Returns the position of the Stepper motor. This is esentially just the last position that the
+ * Stepper was set to, echoed back from the controller board.
+ *
+ * @return position of the Stepper
+ */
+ public double getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " Stepper position " + index + " changed to "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/StepperPositionChangeListener.java b/Java/com/phidgets/event/StepperPositionChangeListener.java
new file mode 100644
index 0000000..b1cf3fc
--- /dev/null
+++ b/Java/com/phidgets/event/StepperPositionChangeListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a StepperPositionChangeEvent. This event originates from the Phidget Stepper Controller and the
+ * Phidget Advanced Stepper Controller.
+ *
+ * @author Phidgets Inc.
+ */
+public interface StepperPositionChangeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void stepperPositionChanged(StepperPositionChangeEvent ae);
+}
diff --git a/Java/com/phidgets/event/StepperVelocityChangeEvent.java b/Java/com/phidgets/event/StepperVelocityChangeEvent.java
new file mode 100644
index 0000000..6154170
--- /dev/null
+++ b/Java/com/phidgets/event/StepperVelocityChangeEvent.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a StepperVelocityChangeEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class StepperVelocityChangeEvent
+{
+ Phidget source;
+ int index;
+ double value;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public StepperVelocityChangeEvent(Phidget source, int index, double value) {
+ this.source = source;
+ this.index = index;
+ this.value = value;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the Stepper.
+ *
+ * @return the index of the Stepper
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Return the velocity of the Stepper. This is reported back from the Stepper controller as the Stepper changes speed.
+ *
+ * @return the Stepper velocity
+ */
+ public double getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " Stepper velocity " + index + " changed to "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/StepperVelocityChangeListener.java b/Java/com/phidgets/event/StepperVelocityChangeListener.java
new file mode 100644
index 0000000..b416441
--- /dev/null
+++ b/Java/com/phidgets/event/StepperVelocityChangeListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a StepperVelocityChangeEvent. This event originates from the Phidget Stepper Controller
+ *
+ * @author Phidgets Inc.
+ */
+public interface StepperVelocityChangeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void stepperVelocityChanged(StepperVelocityChangeEvent ae);
+}
diff --git a/Java/com/phidgets/event/TagGainEvent.java b/Java/com/phidgets/event/TagGainEvent.java
new file mode 100644
index 0000000..6cb7a74
--- /dev/null
+++ b/Java/com/phidgets/event/TagGainEvent.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a TagGainEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class TagGainEvent
+{
+ Phidget source;
+ String value;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public TagGainEvent(Phidget source, String value)
+ {
+ this.source = source;
+ this.value = value;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the gained tag. The tag is a 10 digit hex number represented as a string.
+ *
+ * @return the gained tag
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " Tag Gained: "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/TagGainListener.java b/Java/com/phidgets/event/TagGainListener.java
new file mode 100644
index 0000000..df7b43f
--- /dev/null
+++ b/Java/com/phidgets/event/TagGainListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a TagGainEvent. This event originates from the Phidget RFID Reader.
+ * This event occurs when a tag is placed on a reader.
+ *
+ * @author Phidgets Inc.
+ */
+public interface TagGainListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void tagGained(TagGainEvent ae);
+}
diff --git a/Java/com/phidgets/event/TagLossEvent.java b/Java/com/phidgets/event/TagLossEvent.java
new file mode 100644
index 0000000..ccca4fe
--- /dev/null
+++ b/Java/com/phidgets/event/TagLossEvent.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a TagLossEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class TagLossEvent
+{
+ Phidget source;
+ String value;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public TagLossEvent(Phidget source, String value)
+ {
+ this.source = source;
+ this.value = value;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the Tag that was lost. This is a 10 digit hex number as a string.
+ *
+ * @return the lost tag
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " Tag lost: "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/TagLossListener.java b/Java/com/phidgets/event/TagLossListener.java
new file mode 100644
index 0000000..66a3a8a
--- /dev/null
+++ b/Java/com/phidgets/event/TagLossListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a TagLossEvent. This event originates from the Phidget RFID reader. Tag loss events
+ * occur when a tag is removed from the RFID reader.
+ *
+ * @author Phidgets Inc.
+ */
+public interface TagLossListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void tagLost(TagLossEvent ae);
+}
diff --git a/Java/com/phidgets/event/TemperatureChangeEvent.java b/Java/com/phidgets/event/TemperatureChangeEvent.java
new file mode 100644
index 0000000..5de528c
--- /dev/null
+++ b/Java/com/phidgets/event/TemperatureChangeEvent.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a TemperatureChangeEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class TemperatureChangeEvent
+{
+ Phidget source;
+ int index;
+ double value;
+
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public TemperatureChangeEvent(Phidget source, int index, double value) {
+ this.source = source;
+ this.index = index;
+ this.value = value;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the index of the temperature sensor. An index of 0 indicated the Cold Juction Temperature sensing IC.
+ * An index of 1 indicated the thermocouple.
+ *
+ * @return the index of the sensor
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * Returns the temperature of the sensor is degrees celcius.
+ *
+ * @return the temperature of the sensor
+ */
+ public double getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " Temperature " + index + " changed to "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/TemperatureChangeListener.java b/Java/com/phidgets/event/TemperatureChangeListener.java
new file mode 100644
index 0000000..a9eccb7
--- /dev/null
+++ b/Java/com/phidgets/event/TemperatureChangeListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a TemperatureChangeEvent. This event originates from the Phidget Temperature Sensor
+ *
+ * @author Phidgets Inc.
+ */
+public interface TemperatureChangeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void temperatureChanged(TemperatureChangeEvent ae);
+}
diff --git a/Java/com/phidgets/event/WeightChangeEvent.java b/Java/com/phidgets/event/WeightChangeEvent.java
new file mode 100644
index 0000000..1277003
--- /dev/null
+++ b/Java/com/phidgets/event/WeightChangeEvent.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+import com.phidgets.Phidget;
+
+/**
+ * This class represents the data for a WeightChangeEvent.
+ *
+ * @author Phidgets Inc.
+ */
+public class WeightChangeEvent
+{
+ Phidget source;
+ double value;
+ /**
+ * Class constructor. This is called internally by the phidget library when creating this event.
+ *
+ * @param source the Phidget object from which this event originated
+ */
+ public WeightChangeEvent(Phidget source, double value)
+ {
+ this.source = source;
+ this.value = value;
+ }
+
+ /**
+ * Returns the source Phidget of this event. This is a reference to the Phidget object from which this
+ * event was called. This object can be cast into a specific type of Phidget object to call specific
+ * device calls on it.
+ *
+ * @return the event caller
+ */
+ public Phidget getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the weight in kg.
+ *
+ * @return the weight
+ */
+ public double getValue() {
+ return value;
+ }
+
+ /**
+ * Returns a string containing information about the event.
+ *
+ * @return an informative event string
+ */
+ public String toString() {
+ return source.toString() + " Weight changed to "
+ + value;
+ }
+}
diff --git a/Java/com/phidgets/event/WeightChangeListener.java b/Java/com/phidgets/event/WeightChangeListener.java
new file mode 100644
index 0000000..d6794db
--- /dev/null
+++ b/Java/com/phidgets/event/WeightChangeListener.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2006 Phidgets Inc. All rights reserved.
+ */
+
+package com.phidgets.event;
+
+/**
+ * This interface represents a WeightChangeEvent. This event originates from the Phidget Weight Sensor
+ *
+ * @author Phidgets Inc.
+ */
+public interface WeightChangeListener
+{
+ /**
+ * This method is called with the event data when a new event arrives.
+ *
+ * @param ae the event data object containing event data
+ */
+ public void weightChanged(WeightChangeEvent ae);
+}
diff --git a/Java/com/phidgets/macros/BridgePhidget.jm b/Java/com/phidgets/macros/BridgePhidget.jm
new file mode 100644
index 0000000..d2c2cf5
--- /dev/null
+++ b/Java/com/phidgets/macros/BridgePhidget.jm
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2011 Phidgets Inc. All rights reserved.
+ */
+
+ #include "javamacros.h"
+PACKAGEIMPORTS
+/**
+ * This class represents a Phidget Bridge. All methods
+ * to manipulate the Phidget Bridge are implemented in this class.
+ * <p>
+ *
+ * @author Phidgets Inc.
+ */
+CLASSDEF(Bridge)
+ /**
+ * 1 Gain. This is used with {@link #getGain(int) getGain} and {@link #setGain(int, int) setGain}
+ */
+ public static final int PHIDGET_BRIDGE_GAIN_1 = 1;
+ /**
+ * 8 Gain. This is used with {@link #getGain(int) getGain} and {@link #setGain(int, int) setGain}
+ */
+ public static final int PHIDGET_BRIDGE_GAIN_8 = 2;
+ /**
+ * 16 Gain. This is used with {@link #getGain(int) getGain} and {@link #setGain(int, int) setGain}
+ */
+ public static final int PHIDGET_BRIDGE_GAIN_16 = 3;
+ /**
+ * 32 Gain. This is used with {@link #getGain(int) getGain} and {@link #setGain(int, int) setGain}
+ */
+ public static final int PHIDGET_BRIDGE_GAIN_32 = 4;
+ /**
+ * 64 Gain. This is used with {@link #getGain(int) getGain} and {@link #setGain(int, int) setGain}
+ */
+ public static final int PHIDGET_BRIDGE_GAIN_64 = 5;
+ /**
+ * 128 Gain. This is used with {@link #getGain(int) getGain} and {@link #setGain(int, int) setGain}
+ */
+ public static final int PHIDGET_BRIDGE_GAIN_128 = 6;
+ /**
+ * Unknown Gain. This is used with {@link #getGain(int) getGain} and {@link #setGain(int, int) setGain}
+ */
+ public static final int PHIDGET_BRIDGE_GAIN_UNKNOWN = 7;
+ /**
+ * Returns the number of bridges.
+ * @return Number of bridges
+ */
+ PUBLIC_NATIVE(int, getInputCount,)
+ /**
+ * Returns the value of the selected input, in mV/V. If the input is not enabled, an EPHIDGET_UNKNOWNVAL exception will be thrown. If the bridge is saturated
+ *, this will be equal to BridgeMax or BridgeMin and an error event will be fired - in this case, gain should be reduced if possible.
+ * @param index Index of the bridge
+ * @return bridge value
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ PUBLIC_NATIVE(double, getBridgeValue, int index)
+ /**
+ * Returns the minimum value that the selected bridge can measure, in mV/V. This value will depend on the selected gain. At a gain of 1, BridgeMin == -1000 mV/V.
+ * @param index Index of the bridge
+ * @return minimum value
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ PUBLIC_NATIVE(double, getBridgeMin, int index)
+ /**
+ * Returns the maximum value that the selected bridge can measure, in mV/V. This value will depend on the selected gain. At a gain of 1, BridgeMin == 1000 mV/V.
+ * @param index Index of the bridge
+ * @return maximum value
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is out of range.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ PUBLIC_NATIVE(double, getBridgeMax, int index)
+ /**
+ * Returns the enabled state of the specified bridge. This applies power between +5v and Ground, and starts measuring the differential on the +/- pins. By default, all bridges are
+ * disabled, and need to be explicitly enabled on startup.
+ * @param index Index of the bridge
+ * @return state of the specified bridge
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ PUBLIC_NATIVE(boolean, getEnabled, int index)
+ /**
+ * Sets the enabled state of the specified bridge. This applies power between +5v and Ground, and starts measuring the differential on the +/- pins. By default, all bridges are
+ * disabled, and need to be explicitly enabled on startup.
+ * @param index Index of the bridge
+ * @param state new state of the specified bridge
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ PUBLIC_NATIVE(void, setEnabled, int index, boolean state)
+ /**
+ * Returns the gain for the selected bridge. Note that increasing the gains will reduce the measurable
+ * voltage difference by the gain factor, with +-1000 mV/V being the maximum, with no gain.
+ * The possible values for gain are {@link #PHIDGET_BRIDGE_GAIN_1 PHIDGET_BRIDGE_GAIN_1},
+ * {@link #PHIDGET_BRIDGE_GAIN_8 PHIDGET_BRIDGE_GAIN_8}, {@link #PHIDGET_BRIDGE_GAIN_16 PHIDGET_BRIDGE_GAIN_16},
+ * {@link #PHIDGET_BRIDGE_GAIN_32 PHIDGET_BRIDGE_GAIN_32}, {@link #PHIDGET_BRIDGE_GAIN_64 PHIDGET_BRIDGE_GAIN_64},
+ * {@link #PHIDGET_BRIDGE_GAIN_128 PHIDGET_BRIDGE_GAIN_128}, {@link #PHIDGET_BRIDGE_GAIN_UNKNOWN PHIDGET_BRIDGE_GAIN_UNKNOWN}
+ * <p>
+ * @param index Index of the bridge
+ * @return gain
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ PUBLIC_NATIVE(int, getGain, int index)
+ /**
+ * Sets the gain for the selected bridge. Note that increasing the gains will reduce the measurable
+ * voltage difference by the gain factor, with +-1000 mV/V being the maximum, with no gain.
+ * <p>
+ * The possible values for gain are {@link #PHIDGET_BRIDGE_GAIN_1 PHIDGET_BRIDGE_GAIN_1},
+ * {@link #PHIDGET_BRIDGE_GAIN_8 PHIDGET_BRIDGE_GAIN_8}, {@link #PHIDGET_BRIDGE_GAIN_16 PHIDGET_BRIDGE_GAIN_16},
+ * {@link #PHIDGET_BRIDGE_GAIN_32 PHIDGET_BRIDGE_GAIN_32}, {@link #PHIDGET_BRIDGE_GAIN_64 PHIDGET_BRIDGE_GAIN_64},
+ * {@link #PHIDGET_BRIDGE_GAIN_128 PHIDGET_BRIDGE_GAIN_128}, {@link #PHIDGET_BRIDGE_GAIN_UNKNOWN PHIDGET_BRIDGE_GAIN_UNKNOWN}
+ * <p>
+ * @param index Index of the bridge
+ * @param gain new gain
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ PUBLIC_NATIVE(void, setGain, int index, int gain)
+ /**
+ * Returns the data rate, in ms. Data rate applies to all 4 bridges simultaneously. Setting a slower data rate will reduce
+ * noise at the cost of sample time. Also note that each bridge is being sampled only 1/4 of the time - this is okay for very stable signals,
+ * but for changing signals, it is best to set a higher sampling rate and do averaging in the software.
+ * <p>
+ * Data rate must be a multiple of 8ms. Trying to set something between multiplies of 8 will cause an EPHIDGET_INVALIDARG exception.
+ * <p>
+ * @return Data Rate
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the index is invalid.
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ PUBLIC_NATIVE(int, getDataRate,)
+ /**
+ * Sets the data rate, in ms. Data rate applies to all 4 bridges simultaneously. Setting a slower data rate will reduce
+ * noise at the cost of sample time. Also note that each bridge is being sampled only 1/4 of the time - this is okay for very stable signals,
+ * but for changing signals, it is best to set a higher sampling rate and do averaging in the software.
+ * <p>
+ * Data rate must be a multiple of 8ms. Trying to set something between multiplies of 8 will cause an EPHIDGET_INVALIDARG exception.
+ * <p>
+ * @param rate new data rate
+ * @throws PhidgetException If this Phidget is not opened and attached, or if the data rate is out of range
+ * See {@link com.phidgets.Phidget#open(int) open} for information on determining if a device is attached.
+ */
+ PUBLIC_NATIVE(void, setDataRate, int rate)
+ /**
+ * Gets the minimum supported data rate, in ms.
+ * @return minimum supported data rate
+ * @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(int, getDataRateMin,)
+ /**
+ * Gets the maximum supported data rate, in ms.
+ * @return maximum supported data rate
+ * @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(int, getDataRateMax,)
+
+ ENABLE_EVENTS
+ {
+ EVENT_ENABLE(bridgeData, BridgeData)
+ }
+ /**
+ * Adds a bridge data listener. The bridge data handler is a method that will be called at the specified data rate, for each enabled bridge. Value is the bridgeValue, in mV/V.
+ * <p>
+ * There is no limit on the number of bridge data handlers that can be registered for a particular Phidget.
+ *
+ * @param l An implemetation of the {@link com.phidgets.event.BridgeDataListener BridgeDataListener} interface
+ */
+ EVENT(bridgeData, BridgeData, bridgeData)
+} \ No newline at end of file
diff --git a/Java/com_phidgets_AccelerometerPhidget.c b/Java/com_phidgets_AccelerometerPhidget.c
new file mode 100644
index 0000000..6d7bd0b
--- /dev/null
+++ b/Java/com_phidgets_AccelerometerPhidget.c
@@ -0,0 +1,21 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_AccelerometerPhidget.h"
+#include "../cphidgetaccelerometer.h"
+
+EVENT_VARS(accelerationChange, AccelerationChange)
+
+JNI_LOAD(accel, Accelerometer)
+ EVENT_VAR_SETUP(accel, accelerationChange, AccelerationChange, ID, V)
+}
+
+EVENT_HANDLER_INDEXED(Accelerometer, accelerationChange, AccelerationChange,
+ CPhidgetAccelerometer_set_OnAccelerationChange_Handler, double)
+
+JNI_CREATE(Accelerometer)
+JNI_INDEXED_GETFUNC(Accelerometer, AccelerationChangeTrigger, AccelerationChangeTrigger, jdouble)
+JNI_INDEXED_SETFUNC(Accelerometer, AccelerationChangeTrigger, AccelerationChangeTrigger, jdouble)
+JNI_INDEXED_GETFUNC(Accelerometer, AccelerationMax, AccelerationMax, jdouble)
+JNI_INDEXED_GETFUNC(Accelerometer, AccelerationMin, AccelerationMin, jdouble)
+JNI_INDEXED_GETFUNC(Accelerometer, Acceleration, Acceleration, jdouble)
+JNI_GETFUNC(Accelerometer, AxisCount, AxisCount, jint)
diff --git a/Java/com_phidgets_AccelerometerPhidget.h b/Java/com_phidgets_AccelerometerPhidget.h
new file mode 100644
index 0000000..15de1ca
--- /dev/null
+++ b/Java/com_phidgets_AccelerometerPhidget.h
@@ -0,0 +1,221 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_AccelerometerPhidget */
+
+#ifndef _Included_com_phidgets_AccelerometerPhidget
+#define _Included_com_phidgets_AccelerometerPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_AccelerometerPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_AccelerometerPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_AccelerometerPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_AccelerometerPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_AccelerometerPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_AccelerometerPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_AccelerometerPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_AccelerometerPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_AccelerometerPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_AccelerometerPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_AccelerometerPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_AccelerometerPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_NOTHING
+#define com_phidgets_AccelerometerPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_AccelerometerPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_AccelerometerPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_AccelerometerPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_AccelerometerPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_AccelerometerPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_AccelerometerPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_AccelerometerPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_AccelerometerPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_AccelerometerPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_AccelerometerPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_GPS
+#define com_phidgets_AccelerometerPhidget_PHIDID_GPS 121L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_AccelerometerPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_AccelerometerPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_AccelerometerPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_AccelerometerPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_AccelerometerPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_IR
+#define com_phidgets_AccelerometerPhidget_PHIDID_IR 77L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_LED_64
+#define com_phidgets_AccelerometerPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_AccelerometerPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_AccelerometerPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_AccelerometerPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_AccelerometerPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_AccelerometerPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_PHSENSOR
+#define com_phidgets_AccelerometerPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_AccelerometerPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_AccelerometerPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_AccelerometerPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_AccelerometerPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_AccelerometerPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_AccelerometerPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_AccelerometerPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_AccelerometerPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_AccelerometerPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_AccelerometerPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_AccelerometerPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_AccelerometerPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_AccelerometerPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_RFID
+#define com_phidgets_AccelerometerPhidget_PHIDID_RFID 48L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_AccelerometerPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_AccelerometerPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_AccelerometerPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_AccelerometerPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_AccelerometerPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_AccelerometerPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_AccelerometerPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_AccelerometerPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_AccelerometerPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_GPS
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_LED
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_RFID
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_SERVO
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_AccelerometerPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_AccelerometerPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+/*
+ * Class: com_phidgets_AccelerometerPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_AccelerometerPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_AccelerometerPhidget
+ * Method: getAxisCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_AccelerometerPhidget_getAxisCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_AccelerometerPhidget
+ * Method: getAcceleration
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AccelerometerPhidget_getAcceleration
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AccelerometerPhidget
+ * Method: getAccelerationMax
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AccelerometerPhidget_getAccelerationMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AccelerometerPhidget
+ * Method: getAccelerationMin
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AccelerometerPhidget_getAccelerationMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AccelerometerPhidget
+ * Method: setAccelerationChangeTrigger
+ * Signature: (ID)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_AccelerometerPhidget_setAccelerationChangeTrigger
+ (JNIEnv *, jobject, jint, jdouble);
+
+/*
+ * Class: com_phidgets_AccelerometerPhidget
+ * Method: getAccelerationChangeTrigger
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AccelerometerPhidget_getAccelerationChangeTrigger
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AccelerometerPhidget
+ * Method: enableAccelerationChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_AccelerometerPhidget_enableAccelerationChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_AdvancedServoPhidget.c b/Java/com_phidgets_AdvancedServoPhidget.c
new file mode 100644
index 0000000..960ce29
--- /dev/null
+++ b/Java/com_phidgets_AdvancedServoPhidget.c
@@ -0,0 +1,66 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_AdvancedServoPhidget.h"
+#include "../cphidgetadvancedservo.h"
+
+EVENT_VARS(servoPositionChange, ServoPositionChange)
+EVENT_VARS(servoVelocityChange, ServoVelocityChange)
+EVENT_VARS(currentChange, CurrentChange)
+
+JNI_LOAD(advservo, AdvancedServo)
+ EVENT_VAR_SETUP(advservo, servoPositionChange, ServoPositionChange, ID, V)
+ EVENT_VAR_SETUP(advservo, servoVelocityChange, ServoVelocityChange, ID, V)
+ EVENT_VAR_SETUP(advservo, currentChange, CurrentChange, ID, V)
+}
+
+EVENT_HANDLER_INDEXED(AdvancedServo, servoPositionChange, ServoPositionChange,
+ CPhidgetAdvancedServo_set_OnPositionChange_Handler, double)
+EVENT_HANDLER_INDEXED(AdvancedServo, servoVelocityChange, ServoVelocityChange,
+ CPhidgetAdvancedServo_set_OnVelocityChange_Handler, double)
+EVENT_HANDLER_INDEXED(AdvancedServo, currentChange, CurrentChange,
+ CPhidgetAdvancedServo_set_OnCurrentChange_Handler, double)
+
+JNI_CREATE(AdvancedServo)
+JNI_INDEXED_GETFUNC(AdvancedServo, Acceleration, Acceleration, jdouble)
+JNI_INDEXED_SETFUNC(AdvancedServo, Acceleration, Acceleration, jdouble)
+JNI_INDEXED_GETFUNC(AdvancedServo, AccelerationMin, AccelerationMin, jdouble)
+JNI_INDEXED_GETFUNC(AdvancedServo, AccelerationMax, AccelerationMax, jdouble)
+JNI_INDEXED_GETFUNC(AdvancedServo, VelocityLimit, VelocityLimit, jdouble)
+JNI_INDEXED_SETFUNC(AdvancedServo, VelocityLimit, VelocityLimit, jdouble)
+JNI_INDEXED_GETFUNC(AdvancedServo, Velocity, Velocity, jdouble)
+JNI_INDEXED_GETFUNC(AdvancedServo, VelocityMin, VelocityMin, jdouble)
+JNI_INDEXED_GETFUNC(AdvancedServo, VelocityMax, VelocityMax, jdouble)
+JNI_INDEXED_GETFUNC(AdvancedServo, Position, Position, jdouble)
+JNI_INDEXED_SETFUNC(AdvancedServo, Position, Position, jdouble)
+JNI_INDEXED_GETFUNC(AdvancedServo, PositionMin, PositionMin, jdouble)
+JNI_INDEXED_GETFUNC(AdvancedServo, PositionMax, PositionMax, jdouble)
+JNI_INDEXED_SETFUNC(AdvancedServo, PositionMin, PositionMin, jdouble)
+JNI_INDEXED_SETFUNC(AdvancedServo, PositionMax, PositionMax, jdouble)
+JNI_INDEXED_GETFUNCBOOL(AdvancedServo, Engaged, Engaged)
+JNI_INDEXED_SETFUNC(AdvancedServo, Engaged, Engaged, jboolean)
+JNI_INDEXED_GETFUNCBOOL(AdvancedServo, Stopped, Stopped)
+JNI_INDEXED_GETFUNCBOOL(AdvancedServo, SpeedRampingOn, SpeedRampingOn)
+JNI_INDEXED_SETFUNC(AdvancedServo, SpeedRampingOn, SpeedRampingOn, jboolean)
+JNI_INDEXED_GETFUNC(AdvancedServo, Current, Current, jdouble)
+JNIEXPORT jint JNICALL
+Java_com_phidgets_AdvancedServoPhidget_getServoType(JNIEnv *env, jobject obj, jint index)
+{
+ CPhidgetAdvancedServoHandle h = (CPhidgetAdvancedServoHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+ int error;
+ CPhidget_ServoType v;
+ if ((error = CPhidgetAdvancedServo_getServoType(h, index, &v)))
+ PH_THROW(error);
+ return (jint)v;
+}
+JNI_INDEXED_SETFUNC(AdvancedServo, ServoType, ServoType, jint)
+JNIEXPORT void JNICALL
+Java_com_phidgets_AdvancedServoPhidget_setServoParameters(JNIEnv *env, jobject obj, jint index, jdouble minUs, jdouble maxUs, jdouble degrees, jdouble velocityMax)
+{
+ CPhidgetAdvancedServoHandle h = (CPhidgetAdvancedServoHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+ int error;
+ if ((error = CPhidgetAdvancedServo_setServoParameters(h, index, minUs, maxUs, degrees, velocityMax)))
+ PH_THROW(error);
+}
+JNI_GETFUNC(AdvancedServo, MotorCount, MotorCount, jint)
diff --git a/Java/com_phidgets_AdvancedServoPhidget.h b/Java/com_phidgets_AdvancedServoPhidget.h
new file mode 100644
index 0000000..1f7b40c
--- /dev/null
+++ b/Java/com_phidgets_AdvancedServoPhidget.h
@@ -0,0 +1,439 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_AdvancedServoPhidget */
+
+#ifndef _Included_com_phidgets_AdvancedServoPhidget
+#define _Included_com_phidgets_AdvancedServoPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_NOTHING
+#define com_phidgets_AdvancedServoPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_AdvancedServoPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_AdvancedServoPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_AdvancedServoPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_AdvancedServoPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_AdvancedServoPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_AdvancedServoPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_AdvancedServoPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_AdvancedServoPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_AdvancedServoPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_AdvancedServoPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_GPS
+#define com_phidgets_AdvancedServoPhidget_PHIDID_GPS 121L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_AdvancedServoPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_AdvancedServoPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_AdvancedServoPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_AdvancedServoPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_AdvancedServoPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_IR
+#define com_phidgets_AdvancedServoPhidget_PHIDID_IR 77L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_LED_64
+#define com_phidgets_AdvancedServoPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_AdvancedServoPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_AdvancedServoPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_AdvancedServoPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_AdvancedServoPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_AdvancedServoPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_PHSENSOR
+#define com_phidgets_AdvancedServoPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_AdvancedServoPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_AdvancedServoPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_AdvancedServoPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_AdvancedServoPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_AdvancedServoPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_AdvancedServoPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_AdvancedServoPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_AdvancedServoPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_AdvancedServoPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_AdvancedServoPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_AdvancedServoPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_AdvancedServoPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_AdvancedServoPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_RFID
+#define com_phidgets_AdvancedServoPhidget_PHIDID_RFID 48L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_AdvancedServoPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_AdvancedServoPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_AdvancedServoPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_AdvancedServoPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_AdvancedServoPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_AdvancedServoPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_AdvancedServoPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_AdvancedServoPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_AdvancedServoPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_GPS
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_LED
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_RFID
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_SERVO
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_AdvancedServoPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_AdvancedServoPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_DEFAULT
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_DEFAULT 1L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_RAW_us_MODE
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_RAW_us_MODE 2L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_HS322HD
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_HS322HD 3L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_HS5245MG
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_HS5245MG 4L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_805BB
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_805BB 5L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_HS422
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_HS422 6L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_TOWERPRO_MG90
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_TOWERPRO_MG90 7L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_HSR1425CR
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_HSR1425CR 8L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_HS785HB
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_HS785HB 9L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_HS485HB
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_HS485HB 10L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_HS645MG
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_HS645MG 11L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_815BB
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_HITEC_815BB 12L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_30_50_06_R
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_30_50_06_R 13L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_50_100_06_R
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_50_100_06_R 14L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_50_210_06_R
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_50_210_06_R 15L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_100_50_06_R
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_100_50_06_R 16L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_100_100_06_R
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_100_100_06_R 17L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S2313M
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S2313M 18L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S3317M
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S3317M 19L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S3317SR
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S3317SR 20L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S4303R
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S4303R 21L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S4315M
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S4315M 22L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S4315R
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S4315R 23L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S4505B
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S4505B 24L
+#undef com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_USER_DEFINED
+#define com_phidgets_AdvancedServoPhidget_PHIDGET_SERVO_USER_DEFINED 25L
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_AdvancedServoPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: getMotorCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_AdvancedServoPhidget_getMotorCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: getAccelerationMax
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AdvancedServoPhidget_getAccelerationMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: getAccelerationMin
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AdvancedServoPhidget_getAccelerationMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: getVelocityMax
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AdvancedServoPhidget_getVelocityMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: getVelocityMin
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AdvancedServoPhidget_getVelocityMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: getPositionMax
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AdvancedServoPhidget_getPositionMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: setPositionMax
+ * Signature: (ID)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_AdvancedServoPhidget_setPositionMax
+ (JNIEnv *, jobject, jint, jdouble);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: getPositionMin
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AdvancedServoPhidget_getPositionMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: setPositionMin
+ * Signature: (ID)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_AdvancedServoPhidget_setPositionMin
+ (JNIEnv *, jobject, jint, jdouble);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: getAcceleration
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AdvancedServoPhidget_getAcceleration
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: setAcceleration
+ * Signature: (ID)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_AdvancedServoPhidget_setAcceleration
+ (JNIEnv *, jobject, jint, jdouble);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: getVelocityLimit
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AdvancedServoPhidget_getVelocityLimit
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: setVelocityLimit
+ * Signature: (ID)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_AdvancedServoPhidget_setVelocityLimit
+ (JNIEnv *, jobject, jint, jdouble);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: getVelocity
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AdvancedServoPhidget_getVelocity
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: getPosition
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AdvancedServoPhidget_getPosition
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: setPosition
+ * Signature: (ID)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_AdvancedServoPhidget_setPosition
+ (JNIEnv *, jobject, jint, jdouble);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: getEngaged
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_AdvancedServoPhidget_getEngaged
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: setEngaged
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_AdvancedServoPhidget_setEngaged
+ (JNIEnv *, jobject, jint, jboolean);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: getSpeedRampingOn
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_AdvancedServoPhidget_getSpeedRampingOn
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: setSpeedRampingOn
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_AdvancedServoPhidget_setSpeedRampingOn
+ (JNIEnv *, jobject, jint, jboolean);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: getCurrent
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AdvancedServoPhidget_getCurrent
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: getStopped
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_AdvancedServoPhidget_getStopped
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: getServoType
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_AdvancedServoPhidget_getServoType
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: setServoType
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_AdvancedServoPhidget_setServoType
+ (JNIEnv *, jobject, jint, jint);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: setServoParameters
+ * Signature: (IDDDD)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_AdvancedServoPhidget_setServoParameters
+ (JNIEnv *, jobject, jint, jdouble, jdouble, jdouble, jdouble);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: enableServoPositionChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_AdvancedServoPhidget_enableServoPositionChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: enableServoVelocityChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_AdvancedServoPhidget_enableServoVelocityChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_AdvancedServoPhidget
+ * Method: enableCurrentChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_AdvancedServoPhidget_enableCurrentChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_AnalogPhidget.c b/Java/com_phidgets_AnalogPhidget.c
new file mode 100644
index 0000000..35bd2d5
--- /dev/null
+++ b/Java/com_phidgets_AnalogPhidget.c
@@ -0,0 +1,17 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_AnalogPhidget.h"
+#include "../cphidgetanalog.h"
+
+JNI_LOAD(analog, Analog)
+}
+
+JNI_CREATE(Analog)
+
+JNI_GETFUNC(Analog, OutputCount, OutputCount, jint)
+JNI_INDEXED_GETFUNC(Analog, Voltage, Voltage, jdouble)
+JNI_INDEXED_SETFUNC(Analog, Voltage, Voltage, jdouble)
+JNI_INDEXED_GETFUNC(Analog, VoltageMax, VoltageMax, jdouble)
+JNI_INDEXED_GETFUNC(Analog, VoltageMin, VoltageMin, jdouble)
+JNI_INDEXED_GETFUNCBOOL(Analog, Enabled, Enabled)
+JNI_INDEXED_SETFUNC(Analog, Enabled, Enabled, jboolean) \ No newline at end of file
diff --git a/Java/com_phidgets_AnalogPhidget.h b/Java/com_phidgets_AnalogPhidget.h
new file mode 100644
index 0000000..047a063
--- /dev/null
+++ b/Java/com_phidgets_AnalogPhidget.h
@@ -0,0 +1,221 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_AnalogPhidget */
+
+#ifndef _Included_com_phidgets_AnalogPhidget
+#define _Included_com_phidgets_AnalogPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_AnalogPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_AnalogPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_AnalogPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_AnalogPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_AnalogPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_AnalogPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_AnalogPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_AnalogPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_AnalogPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_AnalogPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_AnalogPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_AnalogPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_AnalogPhidget_PHIDID_NOTHING
+#define com_phidgets_AnalogPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_AnalogPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_AnalogPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_AnalogPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_AnalogPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_AnalogPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_AnalogPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_AnalogPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_AnalogPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_AnalogPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_AnalogPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_AnalogPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_AnalogPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_AnalogPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_AnalogPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_AnalogPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_AnalogPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_AnalogPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_AnalogPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_AnalogPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_AnalogPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_AnalogPhidget_PHIDID_GPS
+#define com_phidgets_AnalogPhidget_PHIDID_GPS 121L
+#undef com_phidgets_AnalogPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_AnalogPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_AnalogPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_AnalogPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_AnalogPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_AnalogPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_AnalogPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_AnalogPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_AnalogPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_AnalogPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_AnalogPhidget_PHIDID_IR
+#define com_phidgets_AnalogPhidget_PHIDID_IR 77L
+#undef com_phidgets_AnalogPhidget_PHIDID_LED_64
+#define com_phidgets_AnalogPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_AnalogPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_AnalogPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_AnalogPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_AnalogPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_AnalogPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_AnalogPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_AnalogPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_AnalogPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_AnalogPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_AnalogPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_AnalogPhidget_PHIDID_PHSENSOR
+#define com_phidgets_AnalogPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_AnalogPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_AnalogPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_AnalogPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_AnalogPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_AnalogPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_AnalogPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_AnalogPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_AnalogPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_AnalogPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_AnalogPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_AnalogPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_AnalogPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_AnalogPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_AnalogPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_AnalogPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_AnalogPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_AnalogPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_AnalogPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_AnalogPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_AnalogPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_AnalogPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_AnalogPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_AnalogPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_AnalogPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_AnalogPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_AnalogPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_AnalogPhidget_PHIDID_RFID
+#define com_phidgets_AnalogPhidget_PHIDID_RFID 48L
+#undef com_phidgets_AnalogPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_AnalogPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_AnalogPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_AnalogPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_AnalogPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_AnalogPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_AnalogPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_AnalogPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_AnalogPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_AnalogPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_AnalogPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_AnalogPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_AnalogPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_AnalogPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_AnalogPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_AnalogPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_AnalogPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_AnalogPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_AnalogPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_AnalogPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_AnalogPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_AnalogPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_AnalogPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_GPS
+#define com_phidgets_AnalogPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_AnalogPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_LED
+#define com_phidgets_AnalogPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_AnalogPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_AnalogPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_RFID
+#define com_phidgets_AnalogPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_SERVO
+#define com_phidgets_AnalogPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_AnalogPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_AnalogPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_AnalogPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_AnalogPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_AnalogPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_AnalogPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+/*
+ * Class: com_phidgets_AnalogPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_AnalogPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_AnalogPhidget
+ * Method: getOutputCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_AnalogPhidget_getOutputCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_AnalogPhidget
+ * Method: getVoltage
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AnalogPhidget_getVoltage
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AnalogPhidget
+ * Method: setVoltage
+ * Signature: (ID)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_AnalogPhidget_setVoltage
+ (JNIEnv *, jobject, jint, jdouble);
+
+/*
+ * Class: com_phidgets_AnalogPhidget
+ * Method: getVoltageMin
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AnalogPhidget_getVoltageMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AnalogPhidget
+ * Method: getVoltageMax
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_AnalogPhidget_getVoltageMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AnalogPhidget
+ * Method: getEnabled
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_AnalogPhidget_getEnabled
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_AnalogPhidget
+ * Method: setEnabled
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_AnalogPhidget_setEnabled
+ (JNIEnv *, jobject, jint, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_BridgePhidget.c b/Java/com_phidgets_BridgePhidget.c
new file mode 100644
index 0000000..6f42cf7
--- /dev/null
+++ b/Java/com_phidgets_BridgePhidget.c
@@ -0,0 +1,40 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_BridgePhidget.h"
+#include "../cphidgetbridge.h"
+
+EVENT_VARS(bridgeData, BridgeData)
+
+JNI_LOAD(bridge, Bridge)
+ EVENT_VAR_SETUP(bridge, bridgeData, BridgeData, ID, V)
+}
+
+EVENT_HANDLER_INDEXED(Bridge, bridgeData, BridgeData,
+ CPhidgetBridge_set_OnBridgeData_Handler, double)
+
+JNI_CREATE(Bridge)
+
+JNI_GETFUNC(Bridge, InputCount, InputCount, jint)
+JNI_INDEXED_GETFUNC(Bridge, BridgeValue, BridgeValue, jdouble)
+JNI_INDEXED_GETFUNC(Bridge, BridgeMin, BridgeMin, jdouble)
+JNI_INDEXED_GETFUNC(Bridge, BridgeMax, BridgeMax, jdouble)
+JNI_INDEXED_GETFUNCBOOL(Bridge, Enabled, Enabled)
+JNI_INDEXED_SETFUNC(Bridge, Enabled, Enabled, jboolean)
+
+JNIEXPORT jint JNICALL
+Java_com_phidgets_BridgePhidget_getGain(JNIEnv *env, jobject obj, jint index)
+{
+ CPhidgetBridgeHandle h = (CPhidgetBridgeHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+ int error;
+ CPhidgetBridge_Gain v;
+ if ((error = CPhidgetBridge_getGain(h, index, &v)))
+ PH_THROW(error);
+ return (jint)v;
+}
+
+JNI_INDEXED_SETFUNC(Bridge, Gain, Gain, jint)
+JNI_GETFUNC(Bridge, DataRate, DataRate, jint)
+JNI_SETFUNC(Bridge, DataRate, DataRate, jint)
+JNI_GETFUNC(Bridge, DataRateMin, DataRateMin, jint)
+JNI_GETFUNC(Bridge, DataRateMax, DataRateMax, jint) \ No newline at end of file
diff --git a/Java/com_phidgets_BridgePhidget.h b/Java/com_phidgets_BridgePhidget.h
new file mode 100644
index 0000000..4575081
--- /dev/null
+++ b/Java/com_phidgets_BridgePhidget.h
@@ -0,0 +1,283 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_BridgePhidget */
+
+#ifndef _Included_com_phidgets_BridgePhidget
+#define _Included_com_phidgets_BridgePhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_BridgePhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_BridgePhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_BridgePhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_BridgePhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_BridgePhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_BridgePhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_BridgePhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_BridgePhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_BridgePhidget_PHIDGET_LOG_INFO
+#define com_phidgets_BridgePhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_BridgePhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_BridgePhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_BridgePhidget_PHIDID_NOTHING
+#define com_phidgets_BridgePhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_BridgePhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_BridgePhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_BridgePhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_BridgePhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_BridgePhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_BridgePhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_BridgePhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_BridgePhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_BridgePhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_BridgePhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_BridgePhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_BridgePhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_BridgePhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_BridgePhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_BridgePhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_BridgePhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_BridgePhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_BridgePhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_BridgePhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_BridgePhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_BridgePhidget_PHIDID_GPS
+#define com_phidgets_BridgePhidget_PHIDID_GPS 121L
+#undef com_phidgets_BridgePhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_BridgePhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_BridgePhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_BridgePhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_BridgePhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_BridgePhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_BridgePhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_BridgePhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_BridgePhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_BridgePhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_BridgePhidget_PHIDID_IR
+#define com_phidgets_BridgePhidget_PHIDID_IR 77L
+#undef com_phidgets_BridgePhidget_PHIDID_LED_64
+#define com_phidgets_BridgePhidget_PHIDID_LED_64 74L
+#undef com_phidgets_BridgePhidget_PHIDID_LED_64_ADV
+#define com_phidgets_BridgePhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_BridgePhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_BridgePhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_BridgePhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_BridgePhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_BridgePhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_BridgePhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_BridgePhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_BridgePhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_BridgePhidget_PHIDID_PHSENSOR
+#define com_phidgets_BridgePhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_BridgePhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_BridgePhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_BridgePhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_BridgePhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_BridgePhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_BridgePhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_BridgePhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_BridgePhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_BridgePhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_BridgePhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_BridgePhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_BridgePhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_BridgePhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_BridgePhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_BridgePhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_BridgePhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_BridgePhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_BridgePhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_BridgePhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_BridgePhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_BridgePhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_BridgePhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_BridgePhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_BridgePhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_BridgePhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_BridgePhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_BridgePhidget_PHIDID_RFID
+#define com_phidgets_BridgePhidget_PHIDID_RFID 48L
+#undef com_phidgets_BridgePhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_BridgePhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_BridgePhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_BridgePhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_BridgePhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_BridgePhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_BridgePhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_BridgePhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_BridgePhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_BridgePhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_BridgePhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_BridgePhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_BridgePhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_BridgePhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_BridgePhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_BridgePhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_NOTHING
+#define com_phidgets_BridgePhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_BridgePhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_BridgePhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_ANALOG
+#define com_phidgets_BridgePhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_BridgePhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_ENCODER
+#define com_phidgets_BridgePhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_BridgePhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_GPS
+#define com_phidgets_BridgePhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_BridgePhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_LED
+#define com_phidgets_BridgePhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_BridgePhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_BridgePhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_RFID
+#define com_phidgets_BridgePhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_SERVO
+#define com_phidgets_BridgePhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_STEPPER
+#define com_phidgets_BridgePhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_BridgePhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_BridgePhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_BridgePhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_BridgePhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_BridgePhidget_PHIDCLASS_WEIGHTSENSOR 17L
+#undef com_phidgets_BridgePhidget_PHIDGET_BRIDGE_GAIN_1
+#define com_phidgets_BridgePhidget_PHIDGET_BRIDGE_GAIN_1 1L
+#undef com_phidgets_BridgePhidget_PHIDGET_BRIDGE_GAIN_8
+#define com_phidgets_BridgePhidget_PHIDGET_BRIDGE_GAIN_8 2L
+#undef com_phidgets_BridgePhidget_PHIDGET_BRIDGE_GAIN_16
+#define com_phidgets_BridgePhidget_PHIDGET_BRIDGE_GAIN_16 3L
+#undef com_phidgets_BridgePhidget_PHIDGET_BRIDGE_GAIN_32
+#define com_phidgets_BridgePhidget_PHIDGET_BRIDGE_GAIN_32 4L
+#undef com_phidgets_BridgePhidget_PHIDGET_BRIDGE_GAIN_64
+#define com_phidgets_BridgePhidget_PHIDGET_BRIDGE_GAIN_64 5L
+#undef com_phidgets_BridgePhidget_PHIDGET_BRIDGE_GAIN_128
+#define com_phidgets_BridgePhidget_PHIDGET_BRIDGE_GAIN_128 6L
+#undef com_phidgets_BridgePhidget_PHIDGET_BRIDGE_GAIN_UNKNOWN
+#define com_phidgets_BridgePhidget_PHIDGET_BRIDGE_GAIN_UNKNOWN 7L
+/*
+ * Class: com_phidgets_BridgePhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_BridgePhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_BridgePhidget
+ * Method: getInputCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_BridgePhidget_getInputCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_BridgePhidget
+ * Method: getBridgeValue
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_BridgePhidget_getBridgeValue
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_BridgePhidget
+ * Method: getBridgeMin
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_BridgePhidget_getBridgeMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_BridgePhidget
+ * Method: getBridgeMax
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_BridgePhidget_getBridgeMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_BridgePhidget
+ * Method: getEnabled
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_BridgePhidget_getEnabled
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_BridgePhidget
+ * Method: setEnabled
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_BridgePhidget_setEnabled
+ (JNIEnv *, jobject, jint, jboolean);
+
+/*
+ * Class: com_phidgets_BridgePhidget
+ * Method: getGain
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_BridgePhidget_getGain
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_BridgePhidget
+ * Method: setGain
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_BridgePhidget_setGain
+ (JNIEnv *, jobject, jint, jint);
+
+/*
+ * Class: com_phidgets_BridgePhidget
+ * Method: getDataRate
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_BridgePhidget_getDataRate
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_BridgePhidget
+ * Method: setDataRate
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_BridgePhidget_setDataRate
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_BridgePhidget
+ * Method: getDataRateMin
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_BridgePhidget_getDataRateMin
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_BridgePhidget
+ * Method: getDataRateMax
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_BridgePhidget_getDataRateMax
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_BridgePhidget
+ * Method: enableBridgeDataEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_BridgePhidget_enableBridgeDataEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_Dictionary.c b/Java/com_phidgets_Dictionary.c
new file mode 100644
index 0000000..2a83f4c
--- /dev/null
+++ b/Java/com_phidgets_Dictionary.c
@@ -0,0 +1,334 @@
+#include "../stdafx.h"
+#include <stdlib.h>
+#include "com_phidgets_Dictionary.h"
+#include "../cphidgetdictionary.h"
+#include "../csocket.h"
+#include "phidget_jni.h"
+
+static int CCONV serverConnect_handler(CPhidgetDictionaryHandle h, void *arg);
+static int CCONV serverDisconnect_handler(CPhidgetDictionaryHandle h, void *arg);
+
+static jclass dictionary_class;
+
+static jfieldID dictionary_handle_fid;
+static jfieldID nativeServerConnectHandler_fid;
+static jfieldID nativeServerDisconnectHandler_fid;
+
+static jmethodID fireServerConnect_mid;
+static jmethodID fireServerDisconnect_mid;
+
+void
+com_phidgets_Dictionary_OnLoad(JNIEnv *env)
+{
+ //Dictionary
+ if (!(dictionary_class = (*env)->FindClass(env, "com/phidgets/Dictionary")))
+ JNI_ABORT_STDERR("Couldn't FindClass com/phidgets/Dictionary");
+ if (!(dictionary_class = (jclass)(*env)->NewGlobalRef(env, dictionary_class)))
+ JNI_ABORT_STDERR("Couldn't create global ref dictionary_class");
+
+ if (!(dictionary_handle_fid = (*env)->GetFieldID(env, dictionary_class, "handle", "J")))
+ JNI_ABORT_STDERR("Couldn't get Field ID handle from dictionary_class");
+ if (!(nativeServerConnectHandler_fid = (*env)->GetFieldID(env, dictionary_class, "nativeServerConnectHandler", "J")))
+ JNI_ABORT_STDERR("Couldn't get Field ID nativeServerConnectHandler from dictionary_class");
+ if (!(nativeServerDisconnectHandler_fid = (*env)->GetFieldID(env, dictionary_class, "nativeServerDisconnectHandler", "J")))
+ JNI_ABORT_STDERR("Couldn't get Field ID nativeServerDisconnectHandler from dictionary_class");
+
+ if (!(fireServerConnect_mid = (*env)->GetMethodID(env, dictionary_class, "fireServerConnect", "(Lcom/phidgets/event/ServerConnectEvent;)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID fireServerConnect from dictionary_class");
+ if (!(fireServerDisconnect_mid = (*env)->GetMethodID(env, dictionary_class, "fireServerDisconnect", "(Lcom/phidgets/event/ServerDisconnectEvent;)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID fireServerDisconnect from dictionary_class");
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Dictionary_enableServerConnectEvents(JNIEnv *env, jobject obj,
+ jboolean b)
+{
+ jlong gr = updateGlobalRef(env, obj, nativeServerConnectHandler_fid, b);
+ CPhidgetDictionaryHandle h = (CPhidgetDictionaryHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, dictionary_handle_fid);
+
+ CPhidgetDictionary_set_OnServerConnect_Handler(h, b ? serverConnect_handler : 0,
+ (void *)(uintptr_t)gr);
+}
+
+static int CCONV
+serverConnect_handler(CPhidgetDictionaryHandle h, void *arg)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject serverConnectEvent;
+ jint result;
+
+ result = (*ph_vm)->GetEnv(ph_vm, (void **)&env, JNI_VERSION_1_4);
+
+ if(result == JNI_EDETACHED)
+ {
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+ }
+
+ obj = (jobject)arg;
+
+ if (!(serverConnectEvent = (*env)->NewObject(env, serverConnectEvent_class, serverConnectEvent_cons,
+ obj)))
+ return -1;
+ (*env)->CallVoidMethod(env, obj, fireServerConnect_mid, serverConnectEvent);
+ (*env)->DeleteLocalRef(env, serverConnectEvent);
+ (*ph_vm)->DetachCurrentThread(ph_vm);
+
+ return 0;
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Dictionary_enableServerDisconnectEvents(JNIEnv *env, jobject obj,
+ jboolean b)
+{
+ jlong gr = updateGlobalRef(env, obj, nativeServerDisconnectHandler_fid, b);
+ CPhidgetDictionaryHandle h = (CPhidgetDictionaryHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, dictionary_handle_fid);
+
+ CPhidgetDictionary_set_OnServerDisconnect_Handler(h, b ? serverDisconnect_handler : 0,
+ (void *)(uintptr_t)gr);
+}
+
+static int CCONV
+serverDisconnect_handler(CPhidgetDictionaryHandle h, void *arg)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject serverDisconnectEvent;
+ jint result;
+
+ result = (*ph_vm)->GetEnv(ph_vm, (void **)&env, JNI_VERSION_1_4);
+
+ if(result == JNI_EDETACHED)
+ {
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+ }
+
+ obj = (jobject)arg;
+
+ if (!(serverDisconnectEvent = (*env)->NewObject(env, serverDisconnectEvent_class, serverDisconnectEvent_cons,
+ obj)))
+ return -1;
+ (*env)->CallVoidMethod(env, obj, fireServerDisconnect_mid, serverDisconnectEvent);
+ (*env)->DeleteLocalRef(env, serverDisconnectEvent);
+ (*ph_vm)->DetachCurrentThread(ph_vm);
+
+ return 0;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_com_phidgets_Dictionary_isAttached(JNIEnv *env, jobject obj)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, dictionary_handle_fid);
+ int error;
+ int s;
+
+ if ((error = CPhidget_getDeviceStatus(h, &s)))
+ PH_THROW(error);
+
+ return s == PHIDGET_ATTACHED;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_com_phidgets_Dictionary_isAttachedToServer(JNIEnv *env, jobject obj)
+{
+ CPhidgetDictionaryHandle h = (CPhidgetDictionaryHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, dictionary_handle_fid);
+ int error;
+ int s;
+
+ if ((error = CPhidgetDictionary_getServerStatus(h, &s)))
+ PH_THROW(error);
+
+ return s == PHIDGET_ATTACHED;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_phidgets_Dictionary_getServerPort(JNIEnv *env, jobject obj)
+{
+ CPhidgetDictionaryHandle h = (CPhidgetDictionaryHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, dictionary_handle_fid);
+ int error;
+ int port;
+ const char *addr;
+
+ if ((error = CPhidgetDictionary_getServerAddress(h, &addr, &port)))
+ PH_THROW(error);
+
+ return port;
+}
+
+JNIEXPORT jstring JNICALL
+Java_com_phidgets_Dictionary_getServerAddress(JNIEnv *env, jobject obj)
+{
+ CPhidgetDictionaryHandle h = (CPhidgetDictionaryHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, dictionary_handle_fid);
+ int error;
+ int port;
+ const char *addr;
+
+ if ((error = CPhidgetDictionary_getServerAddress(h, &addr, &port)))
+ PH_THROW(error);
+
+ return (*env)->NewStringUTF(env, addr);
+}
+
+JNIEXPORT jstring JNICALL
+Java_com_phidgets_Dictionary_getServerID(JNIEnv *env, jobject obj)
+{
+ CPhidgetDictionaryHandle h = (CPhidgetDictionaryHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, dictionary_handle_fid);
+ int error;
+ const char *id;
+
+ if ((error = CPhidgetDictionary_getServerID(h, &id)))
+ PH_THROW(error);
+
+ return (*env)->NewStringUTF(env, id);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Dictionary_nativeOpenRemote(JNIEnv *env, jobject obj, jstring serverID, jstring pass)
+{
+ int error;
+ jboolean iscopy;
+ const char *serverIDcopy = serverID?(*env)->GetStringUTFChars(
+ env, serverID, &iscopy):0;
+ const char *passcopy = (*env)->GetStringUTFChars(
+ env, pass, &iscopy);
+
+ CPhidgetDictionaryHandle h = (CPhidgetDictionaryHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, dictionary_handle_fid);
+
+ if ((error = CPhidgetDictionary_openRemote(h, serverIDcopy, passcopy)))
+ PH_THROW(error);
+
+ if(serverID)
+ (*env)->ReleaseStringUTFChars(env, serverID, serverIDcopy);
+ (*env)->ReleaseStringUTFChars(env, pass, passcopy);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Dictionary_nativeOpenRemoteIP(JNIEnv *env, jobject obj, jstring ipAddr, jint port, jstring pass)
+{
+ int error;
+ jboolean iscopy;
+ const char *ipAddrcopy = (*env)->GetStringUTFChars(
+ env, ipAddr, &iscopy);
+ const char *passcopy = (*env)->GetStringUTFChars(
+ env, pass, &iscopy);
+
+ CPhidgetDictionaryHandle h = (CPhidgetDictionaryHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, dictionary_handle_fid);
+
+ if ((error = CPhidgetDictionary_openRemoteIP(h, ipAddrcopy, port, passcopy)))
+ PH_THROW(error);
+
+ (*env)->ReleaseStringUTFChars(env, ipAddr, ipAddrcopy);
+ (*env)->ReleaseStringUTFChars(env, pass, passcopy);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Dictionary_nativeDelete(JNIEnv *env, jobject obj)
+{
+ int error;
+
+ CPhidgetDictionaryHandle h = (CPhidgetDictionaryHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, dictionary_handle_fid);
+
+ if ((error = CPhidgetDictionary_delete(h)))
+ PH_THROW(error);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Dictionary_nativeClose(JNIEnv *env, jobject obj)
+{
+ int error;
+
+ CPhidgetDictionaryHandle h = (CPhidgetDictionaryHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, dictionary_handle_fid);
+
+ if ((error = CPhidgetDictionary_close(h)))
+ PH_THROW(error);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Dictionary_nativeAddKey(JNIEnv *env, jobject obj, jstring key, jstring val, jint persistent)
+{
+ int error;
+
+ jboolean iscopy;
+ const char *keyString = (*env)->GetStringUTFChars(
+ env, key, &iscopy);
+ const char *valString = (*env)->GetStringUTFChars(
+ env, val, &iscopy);
+
+ CPhidgetDictionaryHandle h = (CPhidgetDictionaryHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, dictionary_handle_fid);
+
+ if ((error = CPhidgetDictionary_addKey(h, keyString, valString, persistent)))
+ PH_THROW(error);
+
+ (*env)->ReleaseStringUTFChars(env, key, keyString);
+ (*env)->ReleaseStringUTFChars(env, val, valString);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Dictionary_nativeRemoveKey(JNIEnv *env, jobject obj, jstring pattern)
+{
+ int error;
+
+ jboolean iscopy;
+ const char *patternString = (*env)->GetStringUTFChars(
+ env, pattern, &iscopy);
+
+ CPhidgetDictionaryHandle h = (CPhidgetDictionaryHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, dictionary_handle_fid);
+
+ if ((error = CPhidgetDictionary_removeKey(h, patternString)))
+ PH_THROW(error);
+
+ (*env)->ReleaseStringUTFChars(env, pattern, patternString);
+}
+
+JNIEXPORT jstring JNICALL
+Java_com_phidgets_Dictionary_nativeGetKey(JNIEnv *env, jobject obj, jstring key)
+{
+ int error;
+
+ char val[1024]; //TODO: unimpose this limit
+
+ jboolean iscopy;
+ const char *keyString = (*env)->GetStringUTFChars(
+ env, key, &iscopy);
+
+ CPhidgetDictionaryHandle h = (CPhidgetDictionaryHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, dictionary_handle_fid);
+
+ if ((error = CPhidgetDictionary_getKey(h, keyString, val, sizeof(val))))
+ {
+ PH_THROW(error);
+ (*env)->ReleaseStringUTFChars(env, key, keyString);
+ return (*env)->NewStringUTF(env, "");
+ }
+ else
+ {
+ (*env)->ReleaseStringUTFChars(env, key, keyString);
+ return (*env)->NewStringUTF(env, val);
+ }
+}
+
+JNIEXPORT jlong JNICALL
+Java_com_phidgets_Dictionary_create(JNIEnv *env, jobject obj)
+{
+ int error;
+ CPhidgetDictionaryHandle dict;
+
+ if ((error = CPhidgetDictionary_create(&dict)))
+ PH_THROW(error);
+ return (jlong)(uintptr_t)dict;
+}
diff --git a/Java/com_phidgets_Dictionary.h b/Java/com_phidgets_Dictionary.h
new file mode 100644
index 0000000..82bc3c5
--- /dev/null
+++ b/Java/com_phidgets_Dictionary.h
@@ -0,0 +1,133 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_Dictionary */
+
+#ifndef _Included_com_phidgets_Dictionary
+#define _Included_com_phidgets_Dictionary
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: com_phidgets_Dictionary
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_Dictionary_create
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Dictionary
+ * Method: nativeClose
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Dictionary_nativeClose
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Dictionary
+ * Method: nativeDelete
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Dictionary_nativeDelete
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Dictionary
+ * Method: nativeOpenRemote
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Dictionary_nativeOpenRemote
+ (JNIEnv *, jobject, jstring, jstring);
+
+/*
+ * Class: com_phidgets_Dictionary
+ * Method: nativeOpenRemoteIP
+ * Signature: (Ljava/lang/String;ILjava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Dictionary_nativeOpenRemoteIP
+ (JNIEnv *, jobject, jstring, jint, jstring);
+
+/*
+ * Class: com_phidgets_Dictionary
+ * Method: nativeAddKey
+ * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Dictionary_nativeAddKey
+ (JNIEnv *, jobject, jstring, jstring, jint);
+
+/*
+ * Class: com_phidgets_Dictionary
+ * Method: nativeRemoveKey
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Dictionary_nativeRemoveKey
+ (JNIEnv *, jobject, jstring);
+
+/*
+ * Class: com_phidgets_Dictionary
+ * Method: nativeGetKey
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_phidgets_Dictionary_nativeGetKey
+ (JNIEnv *, jobject, jstring);
+
+/*
+ * Class: com_phidgets_Dictionary
+ * Method: getServerAddress
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_phidgets_Dictionary_getServerAddress
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Dictionary
+ * Method: getServerID
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_phidgets_Dictionary_getServerID
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Dictionary
+ * Method: getServerPort
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_Dictionary_getServerPort
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Dictionary
+ * Method: isAttached
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_Dictionary_isAttached
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Dictionary
+ * Method: isAttachedToServer
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_Dictionary_isAttachedToServer
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Dictionary
+ * Method: enableServerConnectEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Dictionary_enableServerConnectEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_Dictionary
+ * Method: enableServerDisconnectEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Dictionary_enableServerDisconnectEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_DictionaryKeyListener.c b/Java/com_phidgets_DictionaryKeyListener.c
new file mode 100644
index 0000000..a4f6593
--- /dev/null
+++ b/Java/com_phidgets_DictionaryKeyListener.c
@@ -0,0 +1,132 @@
+#include "../stdafx.h"
+#include <stdlib.h>
+#include "com_phidgets_Dictionary.h"
+#include "../cphidgetdictionary.h"
+#include "../csocket.h"
+#include "phidget_jni.h"
+
+static int CCONV
+key_handler(CPhidgetDictionaryHandle h, void *arg, const char *key, const char *val, CPhidgetDictionary_keyChangeReason reason);
+
+static jfieldID dictionaryKeyListener_handle_fid;
+static jfieldID nativeHandler_fid;
+static jfieldID nativeListener_fid;
+static jmethodID keyChangeEvent_cons; //constructor
+static jmethodID keyRemovalEvent_cons;
+static jmethodID fireKeyChange_mid;
+static jmethodID fireKeyRemoval_mid;
+static jclass dicitonaryKeyListener_class;
+static jclass keyChangeEvent_class;
+static jclass keyRemovalEvent_class;
+
+void
+com_phidgets_DictionaryKeyListener_OnLoad(JNIEnv *env)
+{
+ //DictionaryKeyListener
+ if (!(dicitonaryKeyListener_class = (*env)->FindClass(env, "com/phidgets/DictionaryKeyListener")))
+ JNI_ABORT_STDERR("Couldn't FindClass com/phidgets/DictionaryKeyListener");
+ if (!(dicitonaryKeyListener_class = (jclass)(*env)->NewGlobalRef(env, dicitonaryKeyListener_class)))
+ JNI_ABORT_STDERR("Couldn't create global ref dicitonaryKeyListener_class");
+
+ if (!(dictionaryKeyListener_handle_fid = (*env)->GetFieldID(env, dicitonaryKeyListener_class, "handle", "J")))
+ JNI_ABORT_STDERR("Couldn't get Field ID handle from dicitonaryKeyListener_class");
+ if (!(nativeHandler_fid = (*env)->GetFieldID(env, dicitonaryKeyListener_class, "nativeHandler", "J")))
+ JNI_ABORT_STDERR("Couldn't get Field ID nativeHandler from dicitonaryKeyListener_class");
+ if (!(nativeListener_fid = (*env)->GetFieldID(env, dicitonaryKeyListener_class, "listenerhandle", "J")))
+ JNI_ABORT_STDERR("Couldn't get Field ID listenerhandle from dicitonaryKeyListener_class");
+
+ if (!(fireKeyChange_mid = (*env)->GetMethodID(env, dicitonaryKeyListener_class, "fireKeyChange", "(Lcom/phidgets/event/KeyChangeEvent;)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID fireKeyChange from dicitonaryKeyListener_class");
+ if (!(fireKeyRemoval_mid = (*env)->GetMethodID(env, dicitonaryKeyListener_class, "fireKeyRemoval", "(Lcom/phidgets/event/KeyRemovalEvent;)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID fireKeyRemoval from dicitonaryKeyListener_class");
+
+ //KeyChangeEvent
+ if (!(keyChangeEvent_class = (*env)->FindClass(env, "com/phidgets/event/KeyChangeEvent")))
+ JNI_ABORT_STDERR("Couldn't FindClass com/phidgets/event/KeyChangeEvent");
+ if (!(keyChangeEvent_class = (jclass)(*env)->NewGlobalRef(env, keyChangeEvent_class)))
+ JNI_ABORT_STDERR("Couldn't create global ref keyChangeEvent_class");
+ if (!(keyChangeEvent_cons = (*env)->GetMethodID(env, keyChangeEvent_class, "<init>", "(Lcom/phidgets/Dictionary;Ljava/lang/String;Ljava/lang/String;)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID <init> from keyChangeEvent_class");
+
+ //KeyRemovalEvent
+ if (!(keyRemovalEvent_class = (*env)->FindClass(env, "com/phidgets/event/KeyRemovalEvent")))
+ JNI_ABORT_STDERR("Couldn't FindClass com/phidgets/event/KeyRemovalEvent");
+ if (!(keyRemovalEvent_class = (jclass)(*env)->NewGlobalRef(env, keyRemovalEvent_class)))
+ JNI_ABORT_STDERR("Couldn't create global ref keyRemovalEvent_class");
+ if (!(keyRemovalEvent_cons = (*env)->GetMethodID(env, keyRemovalEvent_class, "<init>", "(Lcom/phidgets/Dictionary;Ljava/lang/String;Ljava/lang/String;)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID <init> from keyRemovalEvent_class");
+}
+
+JNIEXPORT jlong JNICALL
+Java_com_phidgets_DictionaryKeyListener_enableDictionaryKeyEvents(JNIEnv *env, jobject obj,
+ jboolean b, jstring pattern)
+{
+ CPhidgetDictionaryListenerHandle keylistener;
+ jlong gr = updateGlobalRef(env, obj, nativeHandler_fid, b);
+
+ jboolean iscopy;
+ const char *textString = (*env)->GetStringUTFChars(
+ env, pattern, &iscopy);
+
+ CPhidgetDictionaryHandle h = (CPhidgetDictionaryHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, dictionaryKeyListener_handle_fid);
+
+ if(b)
+ {
+ CPhidgetDictionary_set_OnKeyChange_Handler(h, &keylistener, textString, b ? key_handler : 0,
+ (void *)(uintptr_t)gr);
+ }
+ else
+ {
+ keylistener = (CPhidgetDictionaryListenerHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, nativeListener_fid);
+ CPhidgetDictionary_remove_OnKeyChange_Handler(keylistener);
+ keylistener = NULL;
+ }
+
+ (*env)->ReleaseStringUTFChars(env, pattern, textString);
+
+ return (jlong)(uintptr_t)keylistener;
+}
+
+static int CCONV
+key_handler(CPhidgetDictionaryHandle h, void *arg, const char *key, const char *val, CPhidgetDictionary_keyChangeReason reason)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject keyEvent;
+ jstring k;
+ jstring v;
+
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+
+ obj = (jobject)arg;
+
+ k=(*env)->NewStringUTF(env, key);
+ v=(*env)->NewStringUTF(env, val);
+
+ switch(reason)
+ {
+ case PHIDGET_DICTIONARY_ENTRY_REMOVING:
+ {
+ if (!(keyEvent = (*env)->NewObject(env, keyRemovalEvent_class, keyRemovalEvent_cons,
+ obj, k, v)))
+ return -1;
+ (*env)->CallVoidMethod(env, obj, fireKeyRemoval_mid, keyEvent);
+ break;
+ }
+ default:
+ {
+ if (!(keyEvent = (*env)->NewObject(env, keyChangeEvent_class, keyChangeEvent_cons,
+ obj, k, v)))
+ return -1;
+ (*env)->CallVoidMethod(env, obj, fireKeyChange_mid, keyEvent);
+ }
+ }
+
+ (*env)->DeleteLocalRef(env, keyEvent);
+ (*ph_vm)->DetachCurrentThread(ph_vm);
+
+ return 0;
+}
diff --git a/Java/com_phidgets_DictionaryKeyListener.h b/Java/com_phidgets_DictionaryKeyListener.h
new file mode 100644
index 0000000..5d8515a
--- /dev/null
+++ b/Java/com_phidgets_DictionaryKeyListener.h
@@ -0,0 +1,21 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_DictionaryKeyListener */
+
+#ifndef _Included_com_phidgets_DictionaryKeyListener
+#define _Included_com_phidgets_DictionaryKeyListener
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: com_phidgets_DictionaryKeyListener
+ * Method: enableDictionaryKeyEvents
+ * Signature: (ZLjava/lang/String;)J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_DictionaryKeyListener_enableDictionaryKeyEvents
+ (JNIEnv *, jobject, jboolean, jstring);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_EncoderPhidget.c b/Java/com_phidgets_EncoderPhidget.c
new file mode 100644
index 0000000..e46389e
--- /dev/null
+++ b/Java/com_phidgets_EncoderPhidget.c
@@ -0,0 +1,31 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_EncoderPhidget.h"
+#include "../cphidgetencoder.h"
+
+EVENT_VARS(inputChange, InputChange)
+EVENT_VARS(encoderPositionChange, EncoderPositionChange)
+
+JNI_LOAD(enc, Encoder)
+ EVENT_VAR_SETUP(enc, inputChange, InputChange, IZ, V)
+ EVENT_VAR_SETUP(enc, encoderPositionChange, EncoderPositionChange, III, V)
+}
+
+EVENT_HANDLER_INDEXED(Encoder, inputChange, InputChange,
+ CPhidgetEncoder_set_OnInputChange_Handler, int)
+EVENT_HANDLER_INDEXED2(Encoder, encoderPositionChange, EncoderPositionChange,
+ CPhidgetEncoder_set_OnPositionChange_Handler, int, int)
+
+JNI_CREATE(Encoder)
+JNI_INDEXED_GETFUNC(Encoder, Position, Position, jint)
+JNI_INDEXED_SETFUNC(Encoder, Position, Position, jint)
+JNI_INDEXED_GETFUNCBOOL(Encoder, InputState, InputState)
+JNI_GETFUNC(Encoder, EncoderCount, EncoderCount, jint)
+JNI_GETFUNC(Encoder, InputCount, InputCount, jint)
+JNI_INDEXED_GETFUNC(Encoder, IndexPosition, IndexPosition, jint)
+JNI_INDEXED_GETFUNCBOOL(Encoder, Enabled, Enabled)
+JNI_INDEXED_SETFUNC(Encoder, Enabled, Enabled, jboolean)
+
+//Deprecated
+JNI_INDEXED_GETFUNC(Encoder, EncoderPosition, Position, jint)
+JNI_INDEXED_SETFUNC(Encoder, EncoderPosition, Position, jint)
diff --git a/Java/com_phidgets_EncoderPhidget.h b/Java/com_phidgets_EncoderPhidget.h
new file mode 100644
index 0000000..fa7cefc
--- /dev/null
+++ b/Java/com_phidgets_EncoderPhidget.h
@@ -0,0 +1,261 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_EncoderPhidget */
+
+#ifndef _Included_com_phidgets_EncoderPhidget
+#define _Included_com_phidgets_EncoderPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_EncoderPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_EncoderPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_EncoderPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_EncoderPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_EncoderPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_EncoderPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_EncoderPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_EncoderPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_EncoderPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_EncoderPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_EncoderPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_EncoderPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_EncoderPhidget_PHIDID_NOTHING
+#define com_phidgets_EncoderPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_EncoderPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_EncoderPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_EncoderPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_EncoderPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_EncoderPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_EncoderPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_EncoderPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_EncoderPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_EncoderPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_EncoderPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_EncoderPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_EncoderPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_EncoderPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_EncoderPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_EncoderPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_EncoderPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_EncoderPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_EncoderPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_EncoderPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_EncoderPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_EncoderPhidget_PHIDID_GPS
+#define com_phidgets_EncoderPhidget_PHIDID_GPS 121L
+#undef com_phidgets_EncoderPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_EncoderPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_EncoderPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_EncoderPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_EncoderPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_EncoderPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_EncoderPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_EncoderPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_EncoderPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_EncoderPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_EncoderPhidget_PHIDID_IR
+#define com_phidgets_EncoderPhidget_PHIDID_IR 77L
+#undef com_phidgets_EncoderPhidget_PHIDID_LED_64
+#define com_phidgets_EncoderPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_EncoderPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_EncoderPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_EncoderPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_EncoderPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_EncoderPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_EncoderPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_EncoderPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_EncoderPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_EncoderPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_EncoderPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_EncoderPhidget_PHIDID_PHSENSOR
+#define com_phidgets_EncoderPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_EncoderPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_EncoderPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_EncoderPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_EncoderPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_EncoderPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_EncoderPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_EncoderPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_EncoderPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_EncoderPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_EncoderPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_EncoderPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_EncoderPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_EncoderPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_EncoderPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_EncoderPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_EncoderPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_EncoderPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_EncoderPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_EncoderPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_EncoderPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_EncoderPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_EncoderPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_EncoderPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_EncoderPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_EncoderPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_EncoderPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_EncoderPhidget_PHIDID_RFID
+#define com_phidgets_EncoderPhidget_PHIDID_RFID 48L
+#undef com_phidgets_EncoderPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_EncoderPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_EncoderPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_EncoderPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_EncoderPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_EncoderPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_EncoderPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_EncoderPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_EncoderPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_EncoderPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_EncoderPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_EncoderPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_EncoderPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_EncoderPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_EncoderPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_EncoderPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_EncoderPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_EncoderPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_EncoderPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_EncoderPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_EncoderPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_EncoderPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_EncoderPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_GPS
+#define com_phidgets_EncoderPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_EncoderPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_LED
+#define com_phidgets_EncoderPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_EncoderPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_EncoderPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_RFID
+#define com_phidgets_EncoderPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_SERVO
+#define com_phidgets_EncoderPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_EncoderPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_EncoderPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_EncoderPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_EncoderPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_EncoderPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_EncoderPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+/*
+ * Class: com_phidgets_EncoderPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_EncoderPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_EncoderPhidget
+ * Method: getEncoderCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_EncoderPhidget_getEncoderCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_EncoderPhidget
+ * Method: getInputCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_EncoderPhidget_getInputCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_EncoderPhidget
+ * Method: getPosition
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_EncoderPhidget_getPosition
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_EncoderPhidget
+ * Method: getIndexPosition
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_EncoderPhidget_getIndexPosition
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_EncoderPhidget
+ * Method: getEncoderPosition
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_EncoderPhidget_getEncoderPosition
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_EncoderPhidget
+ * Method: setPosition
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_EncoderPhidget_setPosition
+ (JNIEnv *, jobject, jint, jint);
+
+/*
+ * Class: com_phidgets_EncoderPhidget
+ * Method: setEncoderPosition
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_EncoderPhidget_setEncoderPosition
+ (JNIEnv *, jobject, jint, jint);
+
+/*
+ * Class: com_phidgets_EncoderPhidget
+ * Method: getInputState
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_EncoderPhidget_getInputState
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_EncoderPhidget
+ * Method: getEnabled
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_EncoderPhidget_getEnabled
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_EncoderPhidget
+ * Method: setEnabled
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_EncoderPhidget_setEnabled
+ (JNIEnv *, jobject, jint, jboolean);
+
+/*
+ * Class: com_phidgets_EncoderPhidget
+ * Method: enableEncoderPositionChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_EncoderPhidget_enableEncoderPositionChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_EncoderPhidget
+ * Method: enableInputChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_EncoderPhidget_enableInputChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_FrequencyCounterPhidget.c b/Java/com_phidgets_FrequencyCounterPhidget.c
new file mode 100644
index 0000000..dd3d38c
--- /dev/null
+++ b/Java/com_phidgets_FrequencyCounterPhidget.c
@@ -0,0 +1,49 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_FrequencyCounterPhidget.h"
+#include "../cphidgetfrequencycounter.h"
+
+EVENT_VARS(frequencyCounterCount, FrequencyCounterCount)
+
+JNI_LOAD(frequencyCounter, FrequencyCounter)
+ EVENT_VAR_SETUP(frequencyCounter, frequencyCounterCount, FrequencyCounterCount, III, V)
+}
+
+EVENT_HANDLER_INDEXED2(FrequencyCounter, frequencyCounterCount, FrequencyCounterCount,
+ CPhidgetFrequencyCounter_set_OnCount_Handler, int, int)
+
+JNI_CREATE(FrequencyCounter)
+
+JNI_GETFUNC(FrequencyCounter, FrequencyInputCount, FrequencyInputCount, jint)
+JNI_INDEXED_GETFUNC(FrequencyCounter, Frequency, Frequency, jdouble)
+JNI_INDEXED_GETFUNC(FrequencyCounter, TotalTime, TotalTime, jlong)
+JNI_INDEXED_GETFUNC(FrequencyCounter, TotalCount, TotalCount, jlong)
+JNI_INDEXED_GETFUNC(FrequencyCounter, Timeout, Timeout, jint)
+JNI_INDEXED_SETFUNC(FrequencyCounter, Timeout, Timeout, jint)
+JNI_INDEXED_GETFUNCBOOL(FrequencyCounter, Enabled, Enabled)
+JNI_INDEXED_SETFUNC(FrequencyCounter, Enabled, Enabled, jboolean)
+
+JNIEXPORT jint JNICALL
+Java_com_phidgets_FrequencyCounterPhidget_getFilter(JNIEnv *env, jobject obj, jint index)
+{
+ CPhidgetFrequencyCounterHandle h = (CPhidgetFrequencyCounterHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+ int error;
+ CPhidgetFrequencyCounter_FilterType v;
+ if ((error = CPhidgetFrequencyCounter_getFilter(h, index, &v)))
+ PH_THROW(error);
+ return (jint)v;
+}
+
+JNI_INDEXED_SETFUNC(FrequencyCounter, Filter, Filter, jint)
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_FrequencyCounterPhidget_reset(JNIEnv *env, jobject obj, jint index)
+{
+ CPhidgetFrequencyCounterHandle h = (CPhidgetFrequencyCounterHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+ int error;
+
+ if ((error = CPhidgetFrequencyCounter_reset(h, index)))
+ PH_THROW(error);
+} \ No newline at end of file
diff --git a/Java/com_phidgets_FrequencyCounterPhidget.h b/Java/com_phidgets_FrequencyCounterPhidget.h
new file mode 100644
index 0000000..59c0075
--- /dev/null
+++ b/Java/com_phidgets_FrequencyCounterPhidget.h
@@ -0,0 +1,267 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_FrequencyCounterPhidget */
+
+#ifndef _Included_com_phidgets_FrequencyCounterPhidget
+#define _Included_com_phidgets_FrequencyCounterPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_FrequencyCounterPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_FrequencyCounterPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_FrequencyCounterPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_FrequencyCounterPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_FrequencyCounterPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_FrequencyCounterPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_FrequencyCounterPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_NOTHING
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_GPS
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_GPS 121L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_IR
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_IR 77L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_LED_64
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_PHSENSOR
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_RFID
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_RFID 48L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_FrequencyCounterPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_GPS
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_LED
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_RFID
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_SERVO
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_FrequencyCounterPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_ZERO_CROSSING
+#define com_phidgets_FrequencyCounterPhidget_PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_ZERO_CROSSING 1L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_LOGIC_LEVEL
+#define com_phidgets_FrequencyCounterPhidget_PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_LOGIC_LEVEL 2L
+#undef com_phidgets_FrequencyCounterPhidget_PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_UNKNOWN
+#define com_phidgets_FrequencyCounterPhidget_PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_UNKNOWN 3L
+/*
+ * Class: com_phidgets_FrequencyCounterPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_FrequencyCounterPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_FrequencyCounterPhidget
+ * Method: getFrequencyInputCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_FrequencyCounterPhidget_getFrequencyInputCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_FrequencyCounterPhidget
+ * Method: getFrequency
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_FrequencyCounterPhidget_getFrequency
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_FrequencyCounterPhidget
+ * Method: getTotalCount
+ * Signature: (I)J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_FrequencyCounterPhidget_getTotalCount
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_FrequencyCounterPhidget
+ * Method: getTotalTime
+ * Signature: (I)J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_FrequencyCounterPhidget_getTotalTime
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_FrequencyCounterPhidget
+ * Method: getTimeout
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_FrequencyCounterPhidget_getTimeout
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_FrequencyCounterPhidget
+ * Method: setTimeout
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_FrequencyCounterPhidget_setTimeout
+ (JNIEnv *, jobject, jint, jint);
+
+/*
+ * Class: com_phidgets_FrequencyCounterPhidget
+ * Method: getEnabled
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_FrequencyCounterPhidget_getEnabled
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_FrequencyCounterPhidget
+ * Method: setEnabled
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_FrequencyCounterPhidget_setEnabled
+ (JNIEnv *, jobject, jint, jboolean);
+
+/*
+ * Class: com_phidgets_FrequencyCounterPhidget
+ * Method: getFilter
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_FrequencyCounterPhidget_getFilter
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_FrequencyCounterPhidget
+ * Method: setFilter
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_FrequencyCounterPhidget_setFilter
+ (JNIEnv *, jobject, jint, jint);
+
+/*
+ * Class: com_phidgets_FrequencyCounterPhidget
+ * Method: reset
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_FrequencyCounterPhidget_reset
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_FrequencyCounterPhidget
+ * Method: enableFrequencyCounterCountEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_FrequencyCounterPhidget_enableFrequencyCounterCountEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_GPSPhidget.c b/Java/com_phidgets_GPSPhidget.c
new file mode 100644
index 0000000..f2769d5
--- /dev/null
+++ b/Java/com_phidgets_GPSPhidget.c
@@ -0,0 +1,101 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_GPSPhidget.h"
+#include "../cphidgetgps.h"
+
+static jclass irCode_class;
+static jmethodID irCode_getInstance;
+static jmethodID irCode_set;
+
+static jclass javaTimeZone_class; //class
+static jmethodID javaTimeZone_getTimeZone;
+
+EVENT_VARS(gpsPositionFixStatusChange, GPSPositionFixStatusChange)
+EVENT_VARS(gpsPositionChange, GPSPositionChange)
+
+JNI_LOAD(gps, GPS)
+
+ if (!(irCode_class = (*env)->FindClass(env,"java/util/Calendar")))
+ JNI_ABORT_STDERR("Couldn't FindClass java.util.Calendar");
+ if (!(irCode_class = (jclass)(*env)->NewGlobalRef(env, irCode_class)))
+ JNI_ABORT_STDERR("Couldn't create global ref irCode_class");
+ if (!(irCode_getInstance = (*env)->GetStaticMethodID(env, irCode_class, "getInstance", "(Ljava/util/TimeZone;)Ljava/util/Calendar;")))
+ JNI_ABORT_STDERR("Couldn't get method ID getInstance");
+ if (!(irCode_set = (*env)->GetMethodID(env, irCode_class, "set", "(II)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID set");
+
+ if (!(javaTimeZone_class = (*env)->FindClass(env,"java/util/TimeZone")))
+ JNI_ABORT_STDERR("Couldn't FindClass java.util.TimeZone");
+ if (!(javaTimeZone_class = (jclass)(*env)->NewGlobalRef(env, javaTimeZone_class)))
+ JNI_ABORT_STDERR("Couldn't create global ref java.util.TimeZone");
+ if (!(javaTimeZone_getTimeZone = (*env)->GetStaticMethodID(env, javaTimeZone_class, "getTimeZone", "(Ljava/lang/String;)Ljava/util/TimeZone;")))
+ JNI_ABORT_STDERR("Couldn't get method ID from getTimeZone");
+
+ EVENT_VAR_SETUP(gps, gpsPositionFixStatusChange, GPSPositionFixStatusChange, Z, V)
+ EVENT_VAR_SETUP(gps, gpsPositionChange, GPSPositionChange, DDD, V)
+}
+
+EVENT_HANDLER(GPS, gpsPositionFixStatusChange, GPSPositionFixStatusChange, CPhidgetGPS_set_OnPositionFixStatusChange_Handler, int)
+EVENT_HANDLER_3(GPS, gpsPositionChange, GPSPositionChange, CPhidgetGPS_set_OnPositionChange_Handler, double, double, double)
+
+JNI_CREATE(GPS)
+
+JNI_GETFUNC(GPS, Latitude, Latitude, jdouble)
+JNI_GETFUNC(GPS, Longitude, Longitude, jdouble)
+JNI_GETFUNC(GPS, Altitude, Altitude, jdouble)
+JNI_GETFUNC(GPS, Heading, Heading, jdouble)
+JNI_GETFUNC(GPS, Velocity, Velocity, jdouble)
+JNI_GETFUNCBOOL(GPS, PositionFixStatus, PositionFixStatus)
+
+JNIEXPORT jobject JNICALL
+Java_com_phidgets_GPSPhidget_getDateAndTime(JNIEnv *env, jobject obj)
+{
+ CPhidgetGPSHandle h = (CPhidgetGPSHandle)(uintptr_t)(*env)->GetLongField( env, obj, handle_fid);
+ int error;
+ GPSTime cGPSTime;
+ GPSDate cGPSDate;
+ jobject GPSTimeAndDate, GPSTimeZone;
+
+ char* buf;
+
+ if ((error = CPhidgetGPS_getTime(h, &cGPSTime)))
+ {
+ PH_THROW(error);
+ return NULL;
+ }
+
+ if ((error = CPhidgetGPS_getDate(h, &cGPSDate)))
+ {
+ PH_THROW(error);
+ return NULL;
+ }
+
+ buf = "PST\0";
+ //create a Java abstract TimeZone object with a time zone of UTC
+ if(!(GPSTimeZone=(*env)->CallStaticObjectMethod(env, javaTimeZone_class, javaTimeZone_getTimeZone,
+ (*env)->NewStringUTF(env, buf)))){
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+
+ //calls the Java static method Calendar.getInstance object said TimeZone
+ if (!(GPSTimeAndDate = (*env)->CallStaticObjectMethod(env, irCode_class, irCode_getInstance, GPSTimeZone)))
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+
+ (*env)->CallVoidMethod(env, GPSTimeAndDate, irCode_set, 1, cGPSDate.tm_year); //year
+ (*env)->CallVoidMethod(env, GPSTimeAndDate, irCode_set, 2, (cGPSDate.tm_mon-1)); //month(0-11)
+ (*env)->CallVoidMethod(env, GPSTimeAndDate, irCode_set, 5, cGPSDate.tm_mday); //day(1-31)
+
+ (*env)->CallVoidMethod(env, GPSTimeAndDate, irCode_set, 11, (jint)cGPSTime.tm_hour); //hour(0-23)
+ (*env)->CallVoidMethod(env, GPSTimeAndDate, irCode_set, 12, cGPSTime.tm_min); //minute(0-59)
+ (*env)->CallVoidMethod(env, GPSTimeAndDate, irCode_set, 13, cGPSTime.tm_sec); //second(0-59)
+ (*env)->CallVoidMethod(env, GPSTimeAndDate, irCode_set, 14, cGPSTime.tm_ms); //milliseconds
+
+ return GPSTimeAndDate;
+}
+
+
+
diff --git a/Java/com_phidgets_GPSPhidget.h b/Java/com_phidgets_GPSPhidget.h
new file mode 100644
index 0000000..de6c01d
--- /dev/null
+++ b/Java/com_phidgets_GPSPhidget.h
@@ -0,0 +1,237 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_GPSPhidget */
+
+#ifndef _Included_com_phidgets_GPSPhidget
+#define _Included_com_phidgets_GPSPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_GPSPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_GPSPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_GPSPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_GPSPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_GPSPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_GPSPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_GPSPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_GPSPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_GPSPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_GPSPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_GPSPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_GPSPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_GPSPhidget_PHIDID_NOTHING
+#define com_phidgets_GPSPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_GPSPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_GPSPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_GPSPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_GPSPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_GPSPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_GPSPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_GPSPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_GPSPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_GPSPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_GPSPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_GPSPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_GPSPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_GPSPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_GPSPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_GPSPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_GPSPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_GPSPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_GPSPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_GPSPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_GPSPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_GPSPhidget_PHIDID_GPS
+#define com_phidgets_GPSPhidget_PHIDID_GPS 121L
+#undef com_phidgets_GPSPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_GPSPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_GPSPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_GPSPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_GPSPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_GPSPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_GPSPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_GPSPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_GPSPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_GPSPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_GPSPhidget_PHIDID_IR
+#define com_phidgets_GPSPhidget_PHIDID_IR 77L
+#undef com_phidgets_GPSPhidget_PHIDID_LED_64
+#define com_phidgets_GPSPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_GPSPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_GPSPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_GPSPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_GPSPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_GPSPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_GPSPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_GPSPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_GPSPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_GPSPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_GPSPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_GPSPhidget_PHIDID_PHSENSOR
+#define com_phidgets_GPSPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_GPSPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_GPSPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_GPSPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_GPSPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_GPSPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_GPSPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_GPSPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_GPSPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_GPSPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_GPSPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_GPSPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_GPSPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_GPSPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_GPSPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_GPSPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_GPSPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_GPSPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_GPSPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_GPSPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_GPSPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_GPSPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_GPSPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_GPSPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_GPSPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_GPSPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_GPSPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_GPSPhidget_PHIDID_RFID
+#define com_phidgets_GPSPhidget_PHIDID_RFID 48L
+#undef com_phidgets_GPSPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_GPSPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_GPSPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_GPSPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_GPSPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_GPSPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_GPSPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_GPSPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_GPSPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_GPSPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_GPSPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_GPSPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_GPSPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_GPSPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_GPSPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_GPSPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_GPSPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_GPSPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_GPSPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_GPSPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_GPSPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_GPSPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_GPSPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_GPS
+#define com_phidgets_GPSPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_GPSPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_LED
+#define com_phidgets_GPSPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_GPSPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_GPSPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_RFID
+#define com_phidgets_GPSPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_SERVO
+#define com_phidgets_GPSPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_GPSPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_GPSPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_GPSPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_GPSPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_GPSPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_GPSPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+/*
+ * Class: com_phidgets_GPSPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_GPSPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_GPSPhidget
+ * Method: getLatitude
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_GPSPhidget_getLatitude
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_GPSPhidget
+ * Method: getLongitude
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_GPSPhidget_getLongitude
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_GPSPhidget
+ * Method: getAltitude
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_GPSPhidget_getAltitude
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_GPSPhidget
+ * Method: getHeading
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_GPSPhidget_getHeading
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_GPSPhidget
+ * Method: getVelocity
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_GPSPhidget_getVelocity
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_GPSPhidget
+ * Method: getDateAndTime
+ * Signature: ()Ljava/util/Calendar;
+ */
+JNIEXPORT jobject JNICALL Java_com_phidgets_GPSPhidget_getDateAndTime
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_GPSPhidget
+ * Method: getPositionFixStatus
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_GPSPhidget_getPositionFixStatus
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_GPSPhidget
+ * Method: enableGPSPositionFixStatusChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_GPSPhidget_enableGPSPositionFixStatusChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_GPSPhidget
+ * Method: enableGPSPositionChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_GPSPhidget_enableGPSPositionChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_IRPhidget.c b/Java/com_phidgets_IRPhidget.c
new file mode 100644
index 0000000..e2cfb45
--- /dev/null
+++ b/Java/com_phidgets_IRPhidget.c
@@ -0,0 +1,777 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_IRPhidget.h"
+#include "../cphidgetir.h"
+
+EVENT_VARS(code, Code)
+EVENT_VARS(learn, Learn)
+EVENT_VARS(rawData, RawData)
+
+static jclass irCode_class; //class
+static jmethodID irCode_cons; //constructor
+static jmethodID irCode_getData;
+static jclass irCodeInfo_class; //class
+static jmethodID irCodeInfo_cons; //constructor
+static jmethodID irCodeInfo_getEncoding;
+static jmethodID irCodeInfo_getLength;
+static jmethodID irCodeInfo_getBitCount;
+static jmethodID irCodeInfo_getGap;
+static jmethodID irCodeInfo_getTrail;
+static jmethodID irCodeInfo_getMinRepeat;
+static jmethodID irCodeInfo_getCarrierFrequency;
+static jmethodID irCodeInfo_getDutyCycle;
+static jmethodID irCodeInfo_getHeader;
+static jmethodID irCodeInfo_getZero;
+static jmethodID irCodeInfo_getOne;
+static jmethodID irCodeInfo_getRepeat;
+static jmethodID irCodeInfo_getToggleMask;
+static jclass irLearn_class; //class
+static jmethodID irLearn_cons; //constructor
+
+JNI_LOAD(ir, IR)
+ EVENT_VAR_SETUP(ir, learn, Learn, Lcom/phidgets/IRLearnedCode;, V)
+ EVENT_VAR_SETUP(ir, rawData, RawData, [I, V)
+ EVENT_VAR_SETUP(ir, code, Code, Lcom/phidgets/IRCode;Z, V)
+
+ if (!(irCode_class = (*env)->FindClass(env,"com/phidgets/IRCode")))
+ JNI_ABORT_STDERR("Couldn't FindClass com/phidgets/IRCode");
+ if (!(irCode_class = (jclass)(*env)->NewGlobalRef(env, irCode_class)))
+ JNI_ABORT_STDERR("Couldn't create global ref irCode_class");
+ if (!(irCode_cons = (*env)->GetMethodID(env, irCode_class, "<init>", "([SI)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID <init> from irCode_class");
+
+ if (!(irCode_getData = (*env)->GetMethodID(env, irCode_class, "getData", "()[S")))
+ JNI_ABORT_STDERR("Couldn't get method ID getData from irCode_class");
+
+ if (!(irCodeInfo_class = (*env)->FindClass(env,"com/phidgets/IRCodeInfo")))
+ JNI_ABORT_STDERR("Couldn't FindClass com/phidgets/IRCodeInfo");
+ if (!(irCodeInfo_class = (jclass)(*env)->NewGlobalRef(env, irCodeInfo_class)))
+ JNI_ABORT_STDERR("Couldn't create global ref irCodeInfo_class");
+ if (!(irCodeInfo_cons = (*env)->GetMethodID(env, irCodeInfo_class, "<init>", "(II[I[I[III[IILcom/phidgets/IRCode;III)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID <init> from irCodeInfo_class");
+
+ if (!(irCodeInfo_getEncoding = (*env)->GetMethodID(env, irCodeInfo_class, "getEncoding", "()I")))
+ JNI_ABORT_STDERR("Couldn't get method ID getEncoding from irCodeInfo_class");
+ if (!(irCodeInfo_getLength = (*env)->GetMethodID(env, irCodeInfo_class, "getLength", "()I")))
+ JNI_ABORT_STDERR("Couldn't get method ID getLength from irCodeInfo_class");
+ if (!(irCodeInfo_getBitCount = (*env)->GetMethodID(env, irCodeInfo_class, "getBitCount", "()I")))
+ JNI_ABORT_STDERR("Couldn't get method ID getBitCount from irCodeInfo_class");
+ if (!(irCodeInfo_getGap = (*env)->GetMethodID(env, irCodeInfo_class, "getGap", "()I")))
+ JNI_ABORT_STDERR("Couldn't get method ID getGap from irCodeInfo_class");
+ if (!(irCodeInfo_getTrail = (*env)->GetMethodID(env, irCodeInfo_class, "getTrail", "()I")))
+ JNI_ABORT_STDERR("Couldn't get method ID getTrail from irCodeInfo_class");
+ if (!(irCodeInfo_getMinRepeat = (*env)->GetMethodID(env, irCodeInfo_class, "getMinRepeat", "()I")))
+ JNI_ABORT_STDERR("Couldn't get method ID getMinRepeat from irCodeInfo_class");
+ if (!(irCodeInfo_getCarrierFrequency = (*env)->GetMethodID(env, irCodeInfo_class, "getCarrierFrequency", "()I")))
+ JNI_ABORT_STDERR("Couldn't get method ID getCarrierFrequency from irCodeInfo_class");
+ if (!(irCodeInfo_getDutyCycle = (*env)->GetMethodID(env, irCodeInfo_class, "getDutyCycle", "()I")))
+ JNI_ABORT_STDERR("Couldn't get method ID getDutyCycle from irCodeInfo_class");
+ if (!(irCodeInfo_getHeader = (*env)->GetMethodID(env, irCodeInfo_class, "getHeader", "()[I")))
+ JNI_ABORT_STDERR("Couldn't get method ID getHeader from irCodeInfo_class");
+ if (!(irCodeInfo_getZero = (*env)->GetMethodID(env, irCodeInfo_class, "getZero", "()[I")))
+ JNI_ABORT_STDERR("Couldn't get method ID getZero from irCodeInfo_class");
+ if (!(irCodeInfo_getOne = (*env)->GetMethodID(env, irCodeInfo_class, "getOne", "()[I")))
+ JNI_ABORT_STDERR("Couldn't get method ID getOne from irCodeInfo_class");
+ if (!(irCodeInfo_getRepeat = (*env)->GetMethodID(env, irCodeInfo_class, "getRepeat", "()[I")))
+ JNI_ABORT_STDERR("Couldn't get method ID getRepeat from irCodeInfo_class");
+ if (!(irCodeInfo_getToggleMask = (*env)->GetMethodID(env, irCodeInfo_class, "getToggleMask", "()Lcom/phidgets/IRCode;")))
+ JNI_ABORT_STDERR("Couldn't get method ID getToggleMask from irCodeInfo_class");
+
+ if (!(irLearn_class = (*env)->FindClass(env,"com/phidgets/IRLearnedCode")))
+ JNI_ABORT_STDERR("Couldn't FindClass com/phidgets/IRLearnedCode");
+ if (!(irLearn_class = (jclass)(*env)->NewGlobalRef(env, irLearn_class)))
+ JNI_ABORT_STDERR("Couldn't create global ref irLearn_class");
+ if (!(irLearn_cons = (*env)->GetMethodID(env, irLearn_class, "<init>", "(Lcom/phidgets/IRCode;Lcom/phidgets/IRCodeInfo;)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID <init> from irLearn_class");
+}
+
+//Code event
+static int CCONV code_handler(CPhidgetIRHandle h, void *arg, unsigned char *data, int dataLength, int bitCount, int repeat);
+JNIEXPORT void JNICALL
+Java_com_phidgets_IRPhidget_enableCodeEvents(JNIEnv *env, jobject obj, jboolean b)
+{
+ jlong gr = updateGlobalRef(env, obj, nativeCodeHandler_fid, b);
+ CPhidgetIRHandle h = (CPhidgetIRHandle)(uintptr_t)(*env)->GetLongField(env, obj, handle_fid);
+ CPhidgetIR_set_OnCode_Handler(h, b ? code_handler : 0, (void *)(uintptr_t)gr);
+}
+static int CCONV
+code_handler(CPhidgetIRHandle h, void *arg, unsigned char *data, int dataLength, int bitCount, int repeat)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject codeEv;
+ jobject ircode;
+ jshortArray js;
+ jshort *datas;
+ int i;
+
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+
+ obj = (jobject)arg;
+
+ //create and fill in short array
+ js = (*env)->NewShortArray(env, dataLength);
+ if (!js)
+ return -1;
+ datas = (*env)->GetShortArrayElements(env, js, 0);
+ if (!datas)
+ return -1;
+ for (i=0; i<dataLength; i++)
+ datas[i] = (jshort)data[i];
+ (*env)->ReleaseShortArrayElements(env, js, datas, 0);
+
+ if (!(ircode = (*env)->NewObject(env, irCode_class, irCode_cons, js, bitCount)))
+ {
+ return -1;
+ }
+
+ if (!(codeEv = (*env)->NewObject(env, codeEvent_class,
+ codeEvent_cons, obj, ircode, repeat)))
+ {
+ (*env)->DeleteLocalRef(env, ircode);
+ return -1;
+ }
+
+ (*env)->CallVoidMethod(env, obj, fireCode_mid, codeEv);
+
+ (*env)->DeleteLocalRef(env, codeEv);
+ (*env)->DeleteLocalRef(env, ircode);
+
+ (*ph_vm)->DetachCurrentThread(ph_vm);
+
+ return 0;
+
+}
+
+//Learn event
+static int CCONV learn_handler(CPhidgetIRHandle h, void *arg, unsigned char *data, int dataLength, CPhidgetIR_CodeInfoHandle codeInfo);
+JNIEXPORT void JNICALL
+Java_com_phidgets_IRPhidget_enableLearnEvents(JNIEnv *env, jobject obj, jboolean b)
+{
+ jlong gr = updateGlobalRef(env, obj, nativeLearnHandler_fid, b);
+ CPhidgetIRHandle h = (CPhidgetIRHandle)(uintptr_t)(*env)->GetLongField(env, obj, handle_fid);
+ CPhidgetIR_set_OnLearn_Handler(h, b ? learn_handler : 0, (void *)(uintptr_t)gr);
+}
+static int CCONV
+learn_handler(CPhidgetIRHandle h, void *arg, unsigned char *data, int dataLength, CPhidgetIR_CodeInfoHandle codeInfo)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject learnEv;
+ jobject ircode, ircodeinfo, irlearn, togglemask;
+ jshortArray codeData;
+ jintArray headerArray, zeroArray, oneArray, repeatArray;
+ jshort *datas;
+ jint *datai;
+ int i,j;
+
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+
+ obj = (jobject)arg;
+
+ //create and fill in short array
+ if(dataLength > 0){
+ codeData = (*env)->NewShortArray(env, dataLength);
+ if (!codeData)
+ return -1;
+ datas = (*env)->GetShortArrayElements(env, codeData, 0);
+ if (!datas)
+ return -1;
+ for (i=0; i<dataLength; i++)
+ datas[i] = (jshort)data[i];
+ (*env)->ReleaseShortArrayElements(env, codeData, datas, 0);
+ }
+ else
+ codeData=NULL;
+ //create IRCode object
+ if (!(ircode = (*env)->NewObject(env, irCode_class, irCode_cons, codeData, codeInfo->bitCount)))
+ {
+ return -1;
+ }
+
+ //Header
+ if(codeInfo->header[0])
+ {
+ headerArray = (*env)->NewIntArray(env, 2);
+ if (!headerArray)
+ return -1;
+ datai = (*env)->GetIntArrayElements(env, headerArray, 0);
+ if (!datai)
+ return -1;
+ for (i=0; i<2; i++)
+ datai[i] = (jint)codeInfo->header[i];
+ (*env)->ReleaseIntArrayElements(env, headerArray, datai, 0);
+ }
+ else
+ headerArray=NULL;
+
+ //Zero
+ zeroArray = (*env)->NewIntArray(env, 2);
+ if (!zeroArray)
+ return -1;
+ datai = (*env)->GetIntArrayElements(env, zeroArray, 0);
+ if (!datai)
+ return -1;
+ for (i=0; i<2; i++)
+ datai[i] = (jint)codeInfo->zero[i];
+ (*env)->ReleaseIntArrayElements(env, zeroArray, datai, 0);
+
+ //One
+ oneArray = (*env)->NewIntArray(env, 2);
+ if (!oneArray)
+ return -1;
+ datai = (*env)->GetIntArrayElements(env, oneArray, 0);
+ if (!datai)
+ return -1;
+ for (i=0; i<2; i++)
+ datai[i] = (jint)codeInfo->one[i];
+ (*env)->ReleaseIntArrayElements(env, oneArray, datai, 0);
+
+ //Repeat
+ i=0;
+ while(codeInfo->repeat[i])
+ i++;
+ if(i)
+ {
+ repeatArray = (*env)->NewIntArray(env, i);
+ if (!repeatArray)
+ return -1;
+ datai = (*env)->GetIntArrayElements(env, repeatArray, 0);
+ if (!datai)
+ return -1;
+ for (j=0; j<i; j++)
+ datai[j] = (jint)codeInfo->repeat[j];
+ (*env)->ReleaseIntArrayElements(env, repeatArray, datai, 0);
+ }
+ else{
+ repeatArray = NULL;
+ }
+
+ //ToggleMask
+ if(dataLength > 0){
+ codeData = (*env)->NewShortArray(env, dataLength);
+ if (!codeData)
+ return -1;
+ datas = (*env)->GetShortArrayElements(env, codeData, 0);
+ if (!datas)
+ return -1;
+ for (i=0; i<dataLength; i++)
+ datas[i] = (jshort)codeInfo->toggle_mask[i];
+ (*env)->ReleaseShortArrayElements(env, codeData, datas, 0);
+ if (!(togglemask = (*env)->NewObject(env, irCode_class, irCode_cons, codeData, codeInfo->bitCount)))
+ {
+ return -1;
+ }
+ }
+ else{
+ codeData=NULL;
+ }
+ //create IRCodeInfo object
+ if (!(ircodeinfo = (*env)->NewObject(env, irCodeInfo_class, irCodeInfo_cons,
+ codeInfo->encoding, codeInfo->bitCount, headerArray, zeroArray, oneArray,
+ codeInfo->trail, codeInfo->gap, repeatArray, codeInfo->min_repeat, togglemask,
+ codeInfo->length, codeInfo->carrierFrequency, codeInfo->dutyCycle)))
+ {
+ (*env)->DeleteLocalRef(env, ircode);
+ return -1;
+ }
+
+ //create IRLearn object
+ if (!(irlearn = (*env)->NewObject(env, irLearn_class, irLearn_cons, ircode, ircodeinfo)))
+ {
+ (*env)->DeleteLocalRef(env, ircode);
+ (*env)->DeleteLocalRef(env, ircodeinfo);
+ return -1;
+ }
+
+ if (!(learnEv = (*env)->NewObject(env, learnEvent_class,
+ learnEvent_cons, obj, irlearn)))
+ {
+ (*env)->DeleteLocalRef(env, ircode);
+ (*env)->DeleteLocalRef(env, ircodeinfo);
+ (*env)->DeleteLocalRef(env, irlearn);
+ return -1;
+ }
+
+ (*env)->CallVoidMethod(env, obj, fireLearn_mid, learnEv);
+
+ (*env)->DeleteLocalRef(env, learnEv);
+ (*env)->DeleteLocalRef(env, ircode);
+ (*env)->DeleteLocalRef(env, ircodeinfo);
+ (*env)->DeleteLocalRef(env, irlearn);
+
+ (*ph_vm)->DetachCurrentThread(ph_vm);
+
+ return 0;
+}
+
+//RawData event
+static int CCONV rawData_handler(CPhidgetIRHandle h, void *arg, int *data, int dataLength);
+JNIEXPORT void JNICALL
+Java_com_phidgets_IRPhidget_enableRawDataEvents(JNIEnv *env, jobject obj, jboolean b)
+{
+ jlong gr = updateGlobalRef(env, obj, nativeRawDataHandler_fid, b);
+ CPhidgetIRHandle h = (CPhidgetIRHandle)(uintptr_t)(*env)->GetLongField(env, obj, handle_fid);
+ CPhidgetIR_set_OnRawData_Handler(h, b ? rawData_handler : 0, (void *)(uintptr_t)gr);
+}
+static int CCONV
+rawData_handler(CPhidgetIRHandle h, void *arg, int *data, int dataLength)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject rawDataEv;
+ jintArray js;
+ jint *datas;
+ int i;
+
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+
+ obj = (jobject)arg;
+
+ //create and fill in int array
+ js = (*env)->NewIntArray(env, dataLength);
+ if (!js)
+ return -1;
+ datas = (*env)->GetIntArrayElements(env, js, 0);
+ if (!datas)
+ return -1;
+ for (i=0; i<dataLength; i++)
+ datas[i] = (jint)data[i];
+ (*env)->ReleaseIntArrayElements(env, js, datas, 0);
+
+ if (!(rawDataEv = (*env)->NewObject(env, rawDataEvent_class, rawDataEvent_cons, obj, js)))
+ return -1;
+
+ (*env)->CallVoidMethod(env, obj, fireRawData_mid, rawDataEv);
+
+ (*env)->DeleteLocalRef(env, rawDataEv);
+
+ (*ph_vm)->DetachCurrentThread(ph_vm);
+
+ return 0;
+}
+
+JNI_CREATE(IR)
+
+JNIEXPORT jobject JNICALL
+Java_com_phidgets_IRPhidget_getLastCode(JNIEnv *env, jobject obj)
+{
+ CPhidgetIRHandle h = (CPhidgetIRHandle)(uintptr_t)(*env)->GetLongField( env, obj, handle_fid);
+ int error;
+ unsigned char data[IR_MAX_CODE_DATA_LENGTH];
+ int dataLength=IR_MAX_CODE_DATA_LENGTH, bitCount, i;
+ jobject ircode;
+ jshortArray js;
+ jshort *datas;
+
+ if ((error = CPhidgetIR_getLastCode(h, data, &dataLength, &bitCount)))
+ {
+ PH_THROW(error);
+ return NULL;
+ }
+
+ //create and fill in short array
+ js = (*env)->NewShortArray(env, dataLength);
+ if (!js)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+ datas = (*env)->GetShortArrayElements(env, js, 0);
+ if (!datas)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+ for (i=0; i<dataLength; i++)
+ datas[i] = (jshort)data[i];
+ (*env)->ReleaseShortArrayElements(env, js, datas, 0);
+
+ //create and return IRCode object
+ if (!(ircode = (*env)->NewObject(env, irCode_class, irCode_cons, js, bitCount)))
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+
+ return ircode;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_phidgets_IRPhidget_readRaw(JNIEnv *env, jobject obj, jintArray intArray, jint offset, jint count)
+{
+ CPhidgetIRHandle h = (CPhidgetIRHandle)(uintptr_t)(*env)->GetLongField( env, obj, handle_fid);
+ int error, dataLength = count;
+ jint *datai;
+
+ //create and fill in int array
+ datai = (*env)->GetIntArrayElements(env, intArray, 0);
+ if (!datai)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return -1;
+ }
+ if ((error = CPhidgetIR_getRawData(h, datai, &dataLength)))
+ {
+ (*env)->ReleaseIntArrayElements(env, intArray, datai, 0);
+ PH_THROW(error);
+ return -1;
+ }
+ (*env)->ReleaseIntArrayElements(env, intArray, datai, 0);
+
+ return dataLength;
+}
+
+JNIEXPORT jobject JNICALL
+Java_com_phidgets_IRPhidget_getLastLearnedCode(JNIEnv *env, jobject obj)
+{
+ CPhidgetIRHandle h = (CPhidgetIRHandle)(uintptr_t)(*env)->GetLongField( env, obj, handle_fid);
+ int error;
+ unsigned char data[IR_MAX_CODE_DATA_LENGTH];
+ int dataLength=IR_MAX_CODE_DATA_LENGTH;
+ CPhidgetIR_CodeInfo codeInfoReal;
+ CPhidgetIR_CodeInfoHandle codeInfo = &codeInfoReal;
+ jobject ircode, ircodeinfo, irlearn, togglemask;
+ jshortArray codeData;
+ jintArray headerArray, zeroArray, oneArray, repeatArray;
+ jshort *datas;
+ jint *datai;
+ int i,j;
+
+ if ((error = CPhidgetIR_getLastLearnedCode(h, data, &dataLength, codeInfo)))
+ {
+ PH_THROW(error);
+ return NULL;
+ }
+
+ //create and fill in short array
+ if(dataLength > 0){
+ codeData = (*env)->NewShortArray(env, dataLength);
+ if (!codeData)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+ datas = (*env)->GetShortArrayElements(env, codeData, 0);
+ if (!datas)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+ for (i=0; i<dataLength; i++)
+ datas[i] = (jshort)data[i];
+ (*env)->ReleaseShortArrayElements(env, codeData, datas, 0);
+ }
+ else
+ codeData=NULL;
+ //create IRCode object
+ if (!(ircode = (*env)->NewObject(env, irCode_class, irCode_cons, codeData, codeInfo->bitCount)))
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+
+ //Header
+ if(codeInfo->header[0])
+ {
+ headerArray = (*env)->NewIntArray(env, 2);
+ if (!headerArray)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+ datai = (*env)->GetIntArrayElements(env, headerArray, 0);
+ if (!datai)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+ for (i=0; i<2; i++)
+ datai[i] = (jint)codeInfo->header[i];
+ (*env)->ReleaseIntArrayElements(env, headerArray, datai, 0);
+ }
+ else
+ headerArray=NULL;
+
+ //Zero
+ zeroArray = (*env)->NewIntArray(env, 2);
+ if (!zeroArray)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+ datai = (*env)->GetIntArrayElements(env, zeroArray, 0);
+ if (!datai)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+ for (i=0; i<2; i++)
+ datai[i] = (jint)codeInfo->zero[i];
+ (*env)->ReleaseIntArrayElements(env, zeroArray, datai, 0);
+
+ //One
+ oneArray = (*env)->NewIntArray(env, 2);
+ if (!oneArray)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+ datai = (*env)->GetIntArrayElements(env, oneArray, 0);
+ if (!datai)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+ for (i=0; i<2; i++)
+ datai[i] = (jint)codeInfo->one[i];
+ (*env)->ReleaseIntArrayElements(env, oneArray, datai, 0);
+
+ //Repeat
+ i=0;
+ while(codeInfo->repeat[i])
+ i++;
+ if(i)
+ {
+ repeatArray = (*env)->NewIntArray(env, i);
+ if (!repeatArray)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+ datai = (*env)->GetIntArrayElements(env, repeatArray, 0);
+ if (!datai)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+ for (j=0; j<i; j++)
+ datai[j] = (jint)codeInfo->repeat[j];
+ (*env)->ReleaseIntArrayElements(env, repeatArray, datai, 0);
+ }
+ else{
+ repeatArray=NULL;
+ }
+
+ //ToggleMask
+
+ if(dataLength > 0){
+ codeData = (*env)->NewShortArray(env, dataLength);
+ if (!codeData)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+ datas = (*env)->GetShortArrayElements(env, codeData, 0);
+ if (!datas)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+ for (i=0; i<dataLength; i++){
+
+ datas[i] = (jshort)codeInfo->toggle_mask[i];
+ }
+ (*env)->ReleaseShortArrayElements(env, codeData, datas, 0);
+ }
+ else{
+ codeData=NULL;
+ }
+
+ if (!(togglemask = (*env)->NewObject(env, irCode_class, irCode_cons, codeData, codeInfo->bitCount)))
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+
+ //create IRCodeInfo object
+ if (!(ircodeinfo = (*env)->NewObject(env, irCodeInfo_class, irCodeInfo_cons,
+ codeInfo->encoding, codeInfo->bitCount, headerArray, zeroArray, oneArray,
+ codeInfo->trail, codeInfo->gap, repeatArray, codeInfo->min_repeat, togglemask,
+ codeInfo->length, codeInfo->carrierFrequency, codeInfo->dutyCycle)))
+ {
+ (*env)->DeleteLocalRef(env, ircode);
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+
+ //create IRLearn object
+ if (!(irlearn = (*env)->NewObject(env, irLearn_class, irLearn_cons, ircode, ircodeinfo)))
+ {
+ (*env)->DeleteLocalRef(env, ircode);
+ (*env)->DeleteLocalRef(env, ircodeinfo);
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return NULL;
+ }
+
+ return irlearn;
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_IRPhidget_transmit(JNIEnv *env, jobject obj, jobject code, jobject irCodeInfo)
+{
+ CPhidgetIRHandle h = (CPhidgetIRHandle)(uintptr_t)(*env)->GetLongField( env, obj, handle_fid);
+ jshortArray codeData;
+ jintArray headerArray, zeroArray, oneArray, repeatArray;
+ jobject togglemask;
+ jshort *datas;
+ jint *datai;
+ unsigned char data[IR_MAX_CODE_DATA_LENGTH];
+ jsize len;
+ CPhidgetIR_CodeInfo codeInfoReal = {0};
+ CPhidgetIR_CodeInfoHandle codeInfo = &codeInfoReal;
+ int i;
+ int error;
+
+ //read in code
+ if (!(codeData = (*env)->CallObjectMethod(env, code, irCode_getData)))
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return;
+ }
+ datas = (*env)->GetShortArrayElements(env, codeData, 0);
+ if (!datas)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return;
+ }
+ len = (*env)->GetArrayLength(env, codeData);
+ for(i=0;i<len;i++)
+ {
+ data[i] = (unsigned char)datas[i];
+ }
+ (*env)->ReleaseShortArrayElements(env, codeData, datas, 0);
+
+ //read in codeInfo
+ //ints
+ codeInfo->encoding = (*env)->CallIntMethod(env, irCodeInfo, irCodeInfo_getEncoding);
+ codeInfo->length = (*env)->CallIntMethod(env, irCodeInfo, irCodeInfo_getLength);
+ codeInfo->bitCount = (*env)->CallIntMethod(env, irCodeInfo, irCodeInfo_getBitCount);
+ codeInfo->gap = (*env)->CallIntMethod(env, irCodeInfo, irCodeInfo_getGap);
+ codeInfo->trail = (*env)->CallIntMethod(env, irCodeInfo, irCodeInfo_getTrail);
+ codeInfo->min_repeat = (*env)->CallIntMethod(env, irCodeInfo, irCodeInfo_getMinRepeat);
+ codeInfo->carrierFrequency = (*env)->CallIntMethod(env, irCodeInfo, irCodeInfo_getCarrierFrequency);
+ codeInfo->dutyCycle = (*env)->CallIntMethod(env, irCodeInfo, irCodeInfo_getDutyCycle);
+ //arrays/objects
+ //Header
+ headerArray = (*env)->CallObjectMethod(env, irCodeInfo, irCodeInfo_getHeader);
+ if(headerArray)
+ {
+ datai = (*env)->GetIntArrayElements(env, headerArray, 0);
+ if (!datai)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return;
+ }
+ for (i=0; i<2; i++)
+ codeInfo->header[i] = datai[i];
+ (*env)->ReleaseIntArrayElements(env, headerArray, datai, 0);
+ }
+ else
+ headerArray=NULL;
+
+ //Zero
+ zeroArray = (*env)->CallObjectMethod(env, irCodeInfo, irCodeInfo_getZero);
+ datai = (*env)->GetIntArrayElements(env, zeroArray, 0);
+ if (!datai)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return;
+ }
+ for (i=0; i<2; i++)
+ codeInfo->zero[i] = datai[i];
+ (*env)->ReleaseIntArrayElements(env, zeroArray, datai, 0);
+
+ //One
+ oneArray = (*env)->CallObjectMethod(env, irCodeInfo, irCodeInfo_getOne);
+ datai = (*env)->GetIntArrayElements(env, oneArray, 0);
+ if (!datai)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return;
+ }
+ for (i=0; i<2; i++)
+ codeInfo->one[i] = datai[i];
+ (*env)->ReleaseIntArrayElements(env, oneArray, datai, 0);
+
+ //Repeat
+ repeatArray = (*env)->CallObjectMethod(env, irCodeInfo, irCodeInfo_getRepeat);
+ if(repeatArray)
+ {
+ len = (*env)->GetArrayLength(env, repeatArray);
+ if(len)
+ {
+ datai = (*env)->GetIntArrayElements(env, repeatArray, 0);
+ if (!datai)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return;
+ }
+ for (i=0; i<len; i++)
+ codeInfo->repeat[i] = datai[i];
+ (*env)->ReleaseIntArrayElements(env, repeatArray, datai, 0);
+ }
+ }
+ else
+ repeatArray=NULL;
+
+ //ToggleMask
+ togglemask = (*env)->CallObjectMethod(env, irCodeInfo, irCodeInfo_getToggleMask);
+ if(togglemask)
+ {
+ if (!(codeData = (*env)->CallObjectMethod(env, togglemask, irCode_getData)))
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return;
+ }
+ datas = (*env)->GetShortArrayElements(env, codeData, 0);
+ if (!datas)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return;
+ }
+ len = (*env)->GetArrayLength(env, codeData);
+ for(i=0;i<len;i++)
+ {
+ codeInfo->toggle_mask[i] = (unsigned char)datas[i];
+ }
+ (*env)->ReleaseShortArrayElements(env, codeData, datas, 0);
+ }
+ else
+ togglemask=NULL;
+
+ if ((error = CPhidgetIR_Transmit(h, data, codeInfo)))
+ PH_THROW(error);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_IRPhidget_transmitRepeat(JNIEnv *env, jobject obj)
+{
+ CPhidgetIRHandle h = (CPhidgetIRHandle)(uintptr_t)(*env)->GetLongField( env, obj, handle_fid);
+ int error;
+ if ((error = CPhidgetIR_TransmitRepeat(h)))
+ PH_THROW(error);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_IRPhidget_transmitRaw(JNIEnv *env, jobject obj, jintArray data, jint offset, jint count, jint gap, jint carrierFrequency, jint dutyCycle)
+{
+ CPhidgetIRHandle h = (CPhidgetIRHandle)(uintptr_t)(*env)->GetLongField( env, obj, handle_fid);
+ int error;
+ jint *datai;
+
+ datai = (*env)->GetIntArrayElements(env, data, 0);
+ if (!datai)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return;
+ }
+
+ if ((error = CPhidgetIR_TransmitRaw(h, datai+offset, count, carrierFrequency, dutyCycle, gap)))
+ PH_THROW(error);
+
+ (*env)->ReleaseIntArrayElements(env, data, datai, 0);
+}
diff --git a/Java/com_phidgets_IRPhidget.h b/Java/com_phidgets_IRPhidget.h
new file mode 100644
index 0000000..66feca2
--- /dev/null
+++ b/Java/com_phidgets_IRPhidget.h
@@ -0,0 +1,239 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_IRPhidget */
+
+#ifndef _Included_com_phidgets_IRPhidget
+#define _Included_com_phidgets_IRPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_IRPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_IRPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_IRPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_IRPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_IRPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_IRPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_IRPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_IRPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_IRPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_IRPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_IRPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_IRPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_IRPhidget_PHIDID_NOTHING
+#define com_phidgets_IRPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_IRPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_IRPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_IRPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_IRPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_IRPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_IRPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_IRPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_IRPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_IRPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_IRPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_IRPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_IRPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_IRPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_IRPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_IRPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_IRPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_IRPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_IRPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_IRPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_IRPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_IRPhidget_PHIDID_GPS
+#define com_phidgets_IRPhidget_PHIDID_GPS 121L
+#undef com_phidgets_IRPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_IRPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_IRPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_IRPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_IRPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_IRPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_IRPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_IRPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_IRPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_IRPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_IRPhidget_PHIDID_IR
+#define com_phidgets_IRPhidget_PHIDID_IR 77L
+#undef com_phidgets_IRPhidget_PHIDID_LED_64
+#define com_phidgets_IRPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_IRPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_IRPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_IRPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_IRPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_IRPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_IRPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_IRPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_IRPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_IRPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_IRPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_IRPhidget_PHIDID_PHSENSOR
+#define com_phidgets_IRPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_IRPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_IRPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_IRPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_IRPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_IRPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_IRPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_IRPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_IRPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_IRPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_IRPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_IRPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_IRPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_IRPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_IRPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_IRPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_IRPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_IRPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_IRPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_IRPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_IRPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_IRPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_IRPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_IRPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_IRPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_IRPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_IRPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_IRPhidget_PHIDID_RFID
+#define com_phidgets_IRPhidget_PHIDID_RFID 48L
+#undef com_phidgets_IRPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_IRPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_IRPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_IRPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_IRPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_IRPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_IRPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_IRPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_IRPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_IRPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_IRPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_IRPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_IRPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_IRPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_IRPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_IRPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_IRPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_IRPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_IRPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_IRPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_IRPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_IRPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_IRPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_IRPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_IRPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_IRPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_IRPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_IRPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_IRPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_IRPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_IRPhidget_PHIDCLASS_GPS
+#define com_phidgets_IRPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_IRPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_IRPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_IRPhidget_PHIDCLASS_LED
+#define com_phidgets_IRPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_IRPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_IRPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_IRPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_IRPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_IRPhidget_PHIDCLASS_RFID
+#define com_phidgets_IRPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_IRPhidget_PHIDCLASS_SERVO
+#define com_phidgets_IRPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_IRPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_IRPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_IRPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_IRPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_IRPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_IRPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_IRPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_IRPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_IRPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_IRPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+#undef com_phidgets_IRPhidget_RAWDATA_LONGSPACE
+#define com_phidgets_IRPhidget_RAWDATA_LONGSPACE 2147483647L
+/*
+ * Class: com_phidgets_IRPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_IRPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_IRPhidget
+ * Method: transmit
+ * Signature: (Lcom/phidgets/IRCode;Lcom/phidgets/IRCodeInfo;)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_IRPhidget_transmit
+ (JNIEnv *, jobject, jobject, jobject);
+
+/*
+ * Class: com_phidgets_IRPhidget
+ * Method: transmitRepeat
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_IRPhidget_transmitRepeat
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_IRPhidget
+ * Method: transmitRaw
+ * Signature: ([IIIIII)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_IRPhidget_transmitRaw
+ (JNIEnv *, jobject, jintArray, jint, jint, jint, jint, jint);
+
+/*
+ * Class: com_phidgets_IRPhidget
+ * Method: readRaw
+ * Signature: ([III)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_IRPhidget_readRaw
+ (JNIEnv *, jobject, jintArray, jint, jint);
+
+/*
+ * Class: com_phidgets_IRPhidget
+ * Method: getLastCode
+ * Signature: ()Lcom/phidgets/IRCode;
+ */
+JNIEXPORT jobject JNICALL Java_com_phidgets_IRPhidget_getLastCode
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_IRPhidget
+ * Method: getLastLearnedCode
+ * Signature: ()Lcom/phidgets/IRLearnedCode;
+ */
+JNIEXPORT jobject JNICALL Java_com_phidgets_IRPhidget_getLastLearnedCode
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_IRPhidget
+ * Method: enableCodeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_IRPhidget_enableCodeEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_IRPhidget
+ * Method: enableLearnEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_IRPhidget_enableLearnEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_IRPhidget
+ * Method: enableRawDataEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_IRPhidget_enableRawDataEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_InterfaceKitPhidget.c b/Java/com_phidgets_InterfaceKitPhidget.c
new file mode 100644
index 0000000..923b83f
--- /dev/null
+++ b/Java/com_phidgets_InterfaceKitPhidget.c
@@ -0,0 +1,36 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_InterfaceKitPhidget.h"
+#include "../cphidgetinterfacekit.h"
+
+EVENT_VARS(inputChange, InputChange)
+EVENT_VARS(outputChange, OutputChange)
+EVENT_VARS(sensorChange, SensorChange)
+
+JNI_LOAD(ifkit, InterfaceKit)
+ EVENT_VAR_SETUP(ifkit, inputChange, InputChange, IZ, V)
+ EVENT_VAR_SETUP(ifkit, outputChange, OutputChange, IZ, V)
+ EVENT_VAR_SETUP(ifkit, sensorChange, SensorChange, II, V)
+}
+
+EVENT_HANDLER_INDEXED(InterfaceKit, inputChange, InputChange, CPhidgetInterfaceKit_set_OnInputChange_Handler, int)
+EVENT_HANDLER_INDEXED(InterfaceKit, outputChange, OutputChange, CPhidgetInterfaceKit_set_OnOutputChange_Handler, int)
+EVENT_HANDLER_INDEXED(InterfaceKit, sensorChange, SensorChange, CPhidgetInterfaceKit_set_OnSensorChange_Handler, int)
+
+JNI_CREATE(InterfaceKit)
+JNI_GETFUNC(InterfaceKit, OutputCount, OutputCount, jint)
+JNI_GETFUNC(InterfaceKit, InputCount, InputCount, jint)
+JNI_GETFUNC(InterfaceKit, SensorCount, SensorCount, jint)
+JNI_INDEXED_GETFUNCBOOL(InterfaceKit, InputState, InputState)
+JNI_INDEXED_GETFUNCBOOL(InterfaceKit, OutputState, OutputState)
+JNI_INDEXED_GETFUNC(InterfaceKit, SensorValue, SensorValue, jint)
+JNI_INDEXED_GETFUNC(InterfaceKit, SensorRawValue, SensorRawValue, jint)
+JNI_INDEXED_GETFUNC(InterfaceKit, DataRateMin, DataRateMin, jint)
+JNI_INDEXED_GETFUNC(InterfaceKit, DataRateMax, DataRateMax, jint)
+JNI_INDEXED_GETFUNC(InterfaceKit, DataRate, DataRate, jint)
+JNI_INDEXED_GETFUNC(InterfaceKit, SensorChangeTrigger, SensorChangeTrigger, jint)
+JNI_GETFUNCBOOL(InterfaceKit, Ratiometric, Ratiometric)
+JNI_INDEXED_SETFUNC(InterfaceKit, OutputState, OutputState, jboolean)
+JNI_INDEXED_SETFUNC(InterfaceKit, DataRate, DataRate, jint)
+JNI_INDEXED_SETFUNC(InterfaceKit, SensorChangeTrigger, SensorChangeTrigger, jint)
+JNI_SETFUNC(InterfaceKit, Ratiometric, Ratiometric, jboolean)
diff --git a/Java/com_phidgets_InterfaceKitPhidget.h b/Java/com_phidgets_InterfaceKitPhidget.h
new file mode 100644
index 0000000..c985f9e
--- /dev/null
+++ b/Java/com_phidgets_InterfaceKitPhidget.h
@@ -0,0 +1,317 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_InterfaceKitPhidget */
+
+#ifndef _Included_com_phidgets_InterfaceKitPhidget
+#define _Included_com_phidgets_InterfaceKitPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_InterfaceKitPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_InterfaceKitPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_InterfaceKitPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_InterfaceKitPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_InterfaceKitPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_InterfaceKitPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_InterfaceKitPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_InterfaceKitPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_InterfaceKitPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_InterfaceKitPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_InterfaceKitPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_InterfaceKitPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_NOTHING
+#define com_phidgets_InterfaceKitPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_InterfaceKitPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_InterfaceKitPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_InterfaceKitPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_InterfaceKitPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_InterfaceKitPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_InterfaceKitPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_InterfaceKitPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_InterfaceKitPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_InterfaceKitPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_InterfaceKitPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_GPS
+#define com_phidgets_InterfaceKitPhidget_PHIDID_GPS 121L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_InterfaceKitPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_InterfaceKitPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_InterfaceKitPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_InterfaceKitPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_InterfaceKitPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_IR
+#define com_phidgets_InterfaceKitPhidget_PHIDID_IR 77L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_LED_64
+#define com_phidgets_InterfaceKitPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_InterfaceKitPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_InterfaceKitPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_InterfaceKitPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_InterfaceKitPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_InterfaceKitPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_PHSENSOR
+#define com_phidgets_InterfaceKitPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_InterfaceKitPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_InterfaceKitPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_InterfaceKitPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_InterfaceKitPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_InterfaceKitPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_InterfaceKitPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_InterfaceKitPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_InterfaceKitPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_InterfaceKitPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_InterfaceKitPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_InterfaceKitPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_InterfaceKitPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_InterfaceKitPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_RFID
+#define com_phidgets_InterfaceKitPhidget_PHIDID_RFID 48L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_InterfaceKitPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_InterfaceKitPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_InterfaceKitPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_InterfaceKitPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_InterfaceKitPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_InterfaceKitPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_InterfaceKitPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_InterfaceKitPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_InterfaceKitPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_GPS
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_LED
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_RFID
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_SERVO
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_InterfaceKitPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_InterfaceKitPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_InterfaceKitPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: getOutputCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_InterfaceKitPhidget_getOutputCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: getInputCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_InterfaceKitPhidget_getInputCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: getSensorCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_InterfaceKitPhidget_getSensorCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: getDataRateMin
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_InterfaceKitPhidget_getDataRateMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: getDataRateMax
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_InterfaceKitPhidget_getDataRateMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: getInputState
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_InterfaceKitPhidget_getInputState
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: getOutputState
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_InterfaceKitPhidget_getOutputState
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: getSensorValue
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_InterfaceKitPhidget_getSensorValue
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: getSensorRawValue
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_InterfaceKitPhidget_getSensorRawValue
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: getSensorChangeTrigger
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_InterfaceKitPhidget_getSensorChangeTrigger
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: getDataRate
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_InterfaceKitPhidget_getDataRate
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: getRatiometric
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_InterfaceKitPhidget_getRatiometric
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: setOutputState
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_InterfaceKitPhidget_setOutputState
+ (JNIEnv *, jobject, jint, jboolean);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: setSensorChangeTrigger
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_InterfaceKitPhidget_setSensorChangeTrigger
+ (JNIEnv *, jobject, jint, jint);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: setDataRate
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_InterfaceKitPhidget_setDataRate
+ (JNIEnv *, jobject, jint, jint);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: setRatiometric
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_InterfaceKitPhidget_setRatiometric
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: enableInputChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_InterfaceKitPhidget_enableInputChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: enableOutputChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_InterfaceKitPhidget_enableOutputChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_InterfaceKitPhidget
+ * Method: enableSensorChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_InterfaceKitPhidget_enableSensorChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_LEDPhidget.c b/Java/com_phidgets_LEDPhidget.c
new file mode 100644
index 0000000..20097b9
--- /dev/null
+++ b/Java/com_phidgets_LEDPhidget.c
@@ -0,0 +1,38 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_LEDPhidget.h"
+#include "../cphidgetled.h"
+
+JNI_LOAD(accel, LED)
+}
+
+JNI_CREATE(LED)
+JNI_INDEXED_GETFUNC(LED, DiscreteLED, DiscreteLED, jint)
+JNI_INDEXED_SETFUNC(LED, DiscreteLED, DiscreteLED, jint)
+JNI_GETFUNC(LED, LEDCount, LEDCount, jint)
+
+JNIEXPORT jint JNICALL
+Java_com_phidgets_LEDPhidget_getCurrentLimit(JNIEnv *env, jobject obj)
+{
+ CPhidgetLEDHandle h = (CPhidgetLEDHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+ int error;
+ CPhidgetLED_CurrentLimit v;
+ if ((error = CPhidgetLED_getCurrentLimit(h, &v)))
+ PH_THROW(error);
+ return (jint)v;
+}
+JNI_SETFUNC(LED, CurrentLimit, CurrentLimit, jint)
+
+JNIEXPORT jint JNICALL
+Java_com_phidgets_LEDPhidget_getVoltage(JNIEnv *env, jobject obj)
+{
+ CPhidgetLEDHandle h = (CPhidgetLEDHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+ int error;
+ CPhidgetLED_Voltage v;
+ if ((error = CPhidgetLED_getVoltage(h, &v)))
+ PH_THROW(error);
+ return (jint)v;
+}
+JNI_SETFUNC(LED, Voltage, Voltage, jint) \ No newline at end of file
diff --git a/Java/com_phidgets_LEDPhidget.h b/Java/com_phidgets_LEDPhidget.h
new file mode 100644
index 0000000..be631c8
--- /dev/null
+++ b/Java/com_phidgets_LEDPhidget.h
@@ -0,0 +1,237 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_LEDPhidget */
+
+#ifndef _Included_com_phidgets_LEDPhidget
+#define _Included_com_phidgets_LEDPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_LEDPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_LEDPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_LEDPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_LEDPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_LEDPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_LEDPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_LEDPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_LEDPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_LEDPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_LEDPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_LEDPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_LEDPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_LEDPhidget_PHIDID_NOTHING
+#define com_phidgets_LEDPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_LEDPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_LEDPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_LEDPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_LEDPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_LEDPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_LEDPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_LEDPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_LEDPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_LEDPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_LEDPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_LEDPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_LEDPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_LEDPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_LEDPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_LEDPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_LEDPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_LEDPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_LEDPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_LEDPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_LEDPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_LEDPhidget_PHIDID_GPS
+#define com_phidgets_LEDPhidget_PHIDID_GPS 121L
+#undef com_phidgets_LEDPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_LEDPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_LEDPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_LEDPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_LEDPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_LEDPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_LEDPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_LEDPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_LEDPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_LEDPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_LEDPhidget_PHIDID_IR
+#define com_phidgets_LEDPhidget_PHIDID_IR 77L
+#undef com_phidgets_LEDPhidget_PHIDID_LED_64
+#define com_phidgets_LEDPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_LEDPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_LEDPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_LEDPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_LEDPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_LEDPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_LEDPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_LEDPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_LEDPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_LEDPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_LEDPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_LEDPhidget_PHIDID_PHSENSOR
+#define com_phidgets_LEDPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_LEDPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_LEDPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_LEDPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_LEDPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_LEDPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_LEDPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_LEDPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_LEDPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_LEDPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_LEDPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_LEDPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_LEDPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_LEDPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_LEDPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_LEDPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_LEDPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_LEDPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_LEDPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_LEDPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_LEDPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_LEDPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_LEDPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_LEDPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_LEDPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_LEDPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_LEDPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_LEDPhidget_PHIDID_RFID
+#define com_phidgets_LEDPhidget_PHIDID_RFID 48L
+#undef com_phidgets_LEDPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_LEDPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_LEDPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_LEDPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_LEDPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_LEDPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_LEDPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_LEDPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_LEDPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_LEDPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_LEDPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_LEDPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_LEDPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_LEDPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_LEDPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_LEDPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_LEDPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_LEDPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_LEDPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_LEDPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_LEDPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_LEDPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_LEDPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_GPS
+#define com_phidgets_LEDPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_LEDPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_LED
+#define com_phidgets_LEDPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_LEDPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_LEDPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_RFID
+#define com_phidgets_LEDPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_SERVO
+#define com_phidgets_LEDPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_LEDPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_LEDPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_LEDPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_LEDPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_LEDPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_LEDPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+#undef com_phidgets_LEDPhidget_PHIDGET_LED_CURRENT_LIMIT_20mA
+#define com_phidgets_LEDPhidget_PHIDGET_LED_CURRENT_LIMIT_20mA 1L
+#undef com_phidgets_LEDPhidget_PHIDGET_LED_CURRENT_LIMIT_40mA
+#define com_phidgets_LEDPhidget_PHIDGET_LED_CURRENT_LIMIT_40mA 2L
+#undef com_phidgets_LEDPhidget_PHIDGET_LED_CURRENT_LIMIT_60mA
+#define com_phidgets_LEDPhidget_PHIDGET_LED_CURRENT_LIMIT_60mA 3L
+#undef com_phidgets_LEDPhidget_PHIDGET_LED_CURRENT_LIMIT_80mA
+#define com_phidgets_LEDPhidget_PHIDGET_LED_CURRENT_LIMIT_80mA 4L
+#undef com_phidgets_LEDPhidget_PHIDGET_LED_VOLTAGE_1_7V
+#define com_phidgets_LEDPhidget_PHIDGET_LED_VOLTAGE_1_7V 1L
+#undef com_phidgets_LEDPhidget_PHIDGET_LED_VOLTAGE_2_75V
+#define com_phidgets_LEDPhidget_PHIDGET_LED_VOLTAGE_2_75V 2L
+#undef com_phidgets_LEDPhidget_PHIDGET_LED_VOLTAGE_3_9V
+#define com_phidgets_LEDPhidget_PHIDGET_LED_VOLTAGE_3_9V 3L
+#undef com_phidgets_LEDPhidget_PHIDGET_LED_VOLTAGE_5_0V
+#define com_phidgets_LEDPhidget_PHIDGET_LED_VOLTAGE_5_0V 4L
+/*
+ * Class: com_phidgets_LEDPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_LEDPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_LEDPhidget
+ * Method: getCurrentLimit
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_LEDPhidget_getCurrentLimit
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_LEDPhidget
+ * Method: setCurrentLimit
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_LEDPhidget_setCurrentLimit
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_LEDPhidget
+ * Method: getVoltage
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_LEDPhidget_getVoltage
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_LEDPhidget
+ * Method: setVoltage
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_LEDPhidget_setVoltage
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_LEDPhidget
+ * Method: getLEDCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_LEDPhidget_getLEDCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_LEDPhidget
+ * Method: getDiscreteLED
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_LEDPhidget_getDiscreteLED
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_LEDPhidget
+ * Method: setDiscreteLED
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_LEDPhidget_setDiscreteLED
+ (JNIEnv *, jobject, jint, jint);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_Manager.c b/Java/com_phidgets_Manager.c
new file mode 100644
index 0000000..95e131a
--- /dev/null
+++ b/Java/com_phidgets_Manager.c
@@ -0,0 +1,392 @@
+#include "../stdafx.h"
+#include <stdlib.h>
+#include "com_phidgets_Manager.h"
+#include "../cphidgetmanager.h"
+#include "../csocket.h"
+#include "phidget_jni.h"
+
+static int CCONV attach_handler(CPhidgetHandle h, void *arg);
+static int CCONV detach_handler(CPhidgetHandle h, void *arg);
+static int CCONV serverConnect_handler(CPhidgetManagerHandle h, void *arg);
+static int CCONV serverDisconnect_handler(CPhidgetManagerHandle h, void *arg);
+
+extern jfieldID managerPhidget_fid;
+
+static jclass manager_class;
+
+static jfieldID manager_handle_fid;
+static jfieldID nativeAttachHandler_fid;
+static jfieldID nativeDetachHandler_fid;
+static jfieldID nativeServerConnectHandler_fid;
+static jfieldID nativeServerDisconnectHandler_fid;
+
+static jmethodID fireAttach_mid;
+static jmethodID fireDetach_mid;
+static jmethodID fireServerConnect_mid;
+static jmethodID fireServerDisconnect_mid;
+
+void
+com_phidgets_Manager_OnLoad(JNIEnv *env)
+{
+ //Manager
+ if (!(manager_class = (*env)->FindClass(env, "com/phidgets/Manager")))
+ JNI_ABORT_STDERR("");
+ if (!(manager_class = (jclass)(*env)->NewGlobalRef(env, manager_class)))
+ JNI_ABORT_STDERR("");
+
+ if (!(manager_handle_fid = (*env)->GetFieldID(env, manager_class, "handle", "J")))
+ JNI_ABORT_STDERR("");
+ if (!(nativeAttachHandler_fid = (*env)->GetFieldID(env, manager_class, "nativeAttachHandler", "J")))
+ JNI_ABORT_STDERR("");
+ if (!(nativeDetachHandler_fid = (*env)->GetFieldID(env, manager_class, "nativeDetachHandler", "J")))
+ JNI_ABORT_STDERR("");
+ if (!(nativeServerConnectHandler_fid = (*env)->GetFieldID(env, manager_class, "nativeServerConnectHandler", "J")))
+ JNI_ABORT_STDERR("");
+ if (!(nativeServerDisconnectHandler_fid = (*env)->GetFieldID(env, manager_class, "nativeServerDisconnectHandler", "J")))
+ JNI_ABORT_STDERR("");
+
+ if (!(fireAttach_mid = (*env)->GetMethodID(env, manager_class, "fireAttach", "(Lcom/phidgets/event/AttachEvent;)V")))
+ JNI_ABORT_STDERR("");
+ if (!(fireDetach_mid = (*env)->GetMethodID(env, manager_class, "fireDetach", "(Lcom/phidgets/event/DetachEvent;)V")))
+ JNI_ABORT_STDERR("");
+ if (!(fireServerConnect_mid = (*env)->GetMethodID(env, manager_class, "fireServerConnect", "(Lcom/phidgets/event/ServerConnectEvent;)V")))
+ JNI_ABORT_STDERR("");
+ if (!(fireServerDisconnect_mid = (*env)->GetMethodID(env, manager_class, "fireServerDisconnect", "(Lcom/phidgets/event/ServerDisconnectEvent;)V")))
+ JNI_ABORT_STDERR("");
+}
+
+JNIEXPORT jboolean JNICALL
+Java_com_phidgets_Manager_isAttached(JNIEnv *env, jobject obj)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, manager_handle_fid);
+ int error;
+ int s;
+
+ if ((error = CPhidget_getDeviceStatus(h, &s)))
+ PH_THROW(error);
+
+ return s == PHIDGET_ATTACHED;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_com_phidgets_Manager_isAttachedToServer(JNIEnv *env, jobject obj)
+{
+ CPhidgetManagerHandle h = (CPhidgetManagerHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, manager_handle_fid);
+ int error;
+ int s;
+
+ if ((error = CPhidgetManager_getServerStatus(h, &s)))
+ PH_THROW(error);
+
+ return s == PHIDGET_ATTACHED;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_phidgets_Manager_getServerPort(JNIEnv *env, jobject obj)
+{
+ CPhidgetManagerHandle h = (CPhidgetManagerHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, manager_handle_fid);
+ int error;
+ int port;
+ const char *addr;
+
+ if ((error = CPhidgetManager_getServerAddress(h, &addr, &port)))
+ PH_THROW(error);
+
+ return port;
+}
+
+JNIEXPORT jstring JNICALL
+Java_com_phidgets_Manager_getServerAddress(JNIEnv *env, jobject obj)
+{
+ CPhidgetManagerHandle h = (CPhidgetManagerHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, manager_handle_fid);
+ int error;
+ int port;
+ const char *addr;
+
+ if ((error = CPhidgetManager_getServerAddress(h, &addr, &port)))
+ PH_THROW(error);
+
+ return (*env)->NewStringUTF(env, addr);
+}
+
+JNIEXPORT jstring JNICALL
+Java_com_phidgets_Manager_getServerID(JNIEnv *env, jobject obj)
+{
+ CPhidgetManagerHandle h = (CPhidgetManagerHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, manager_handle_fid);
+ int error;
+ const char *id;
+
+ if ((error = CPhidgetManager_getServerID(h, &id)))
+ PH_THROW(error);
+
+ return (*env)->NewStringUTF(env, id);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Manager_enableManagerAttachEvents(JNIEnv *env, jobject obj,
+ jboolean b)
+{
+ jlong gr = updateGlobalRef(env, obj, nativeAttachHandler_fid, b);
+
+ CPhidgetManagerHandle h = (CPhidgetManagerHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, manager_handle_fid);
+
+ CPhidgetManager_set_OnAttach_Handler(h, b ? attach_handler : 0,
+ (void *)(uintptr_t)gr);
+}
+
+static int CCONV
+attach_handler(CPhidgetHandle h, void *arg)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject device;
+ jobject attachEvent;
+ jlong devhandle;
+
+ //could pass this to AttachCurrentThread for named threads.
+ //Test first!
+ JavaVMAttachArgs args;
+ args.version = JNI_VERSION_1_2;
+ args.name = "Central Thread";
+ args.group = NULL;
+
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+
+ obj = (jobject)arg;
+ devhandle = (jlong)(uintptr_t)h;
+
+ if (!(device = (*env)->NewObject(env, phidget_class, phidget_cons,
+ devhandle)))
+ return -1;
+
+ (*env)->SetBooleanField(env, device, managerPhidget_fid, JNI_TRUE);
+
+ if (!(attachEvent = (*env)->NewObject(env, attachEvent_class, attachEvent_cons,
+ device)))
+ return -1;
+ (*env)->CallVoidMethod(env, obj, fireAttach_mid, attachEvent);
+ (*env)->DeleteLocalRef(env, device);
+ (*env)->DeleteLocalRef(env, attachEvent);
+ (*ph_vm)->DetachCurrentThread(ph_vm);
+
+ return 0;
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Manager_enableManagerDetachEvents(JNIEnv *env, jobject obj,
+ jboolean b)
+{
+ jlong gr = updateGlobalRef(env, obj, nativeDetachHandler_fid, b);
+
+ CPhidgetManagerHandle h = (CPhidgetManagerHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, manager_handle_fid);
+
+ CPhidgetManager_set_OnDetach_Handler(h, b ? detach_handler : 0, (void *)(uintptr_t)gr);
+}
+
+static int CCONV
+detach_handler(CPhidgetHandle h, void *arg)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject device;
+ jobject detachEvent;
+ jlong devhandle;
+
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+
+ obj = (jobject)arg;
+ devhandle = (jlong)(uintptr_t)h;
+
+ if (!(device = (*env)->NewObject(env, phidget_class, phidget_cons,
+ devhandle)))
+ return -1;
+
+ (*env)->SetBooleanField(env, device, managerPhidget_fid, JNI_TRUE);
+
+ if (!(detachEvent = (*env)->NewObject(env, detachEvent_class, detachEvent_cons,
+ device)))
+ return -1;
+ (*env)->CallVoidMethod(env, obj, fireDetach_mid, detachEvent);
+ (*env)->DeleteLocalRef(env, device);
+ (*env)->DeleteLocalRef(env, detachEvent);
+ (*ph_vm)->DetachCurrentThread(ph_vm);
+
+ return 0;
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Manager_enableServerConnectEvents(JNIEnv *env, jobject obj,
+ jboolean b)
+{
+ jlong gr = updateGlobalRef(env, obj, nativeServerConnectHandler_fid, b);
+ CPhidgetManagerHandle h = (CPhidgetManagerHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, manager_handle_fid);
+
+ CPhidgetManager_set_OnServerConnect_Handler(h, b ? serverConnect_handler : 0,
+ (void *)(uintptr_t)gr);
+}
+
+static int CCONV
+serverConnect_handler(CPhidgetManagerHandle h, void *arg)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject serverConnectEvent;
+ jint result;
+
+ result = (*ph_vm)->GetEnv(ph_vm, (void **)&env, JNI_VERSION_1_4);
+
+ if(result == JNI_EDETACHED)
+ {
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+ }
+
+ obj = (jobject)arg;
+
+ if (!(serverConnectEvent = (*env)->NewObject(env, serverConnectEvent_class, serverConnectEvent_cons,
+ obj)))
+ return -1;
+ (*env)->CallVoidMethod(env, obj, fireServerConnect_mid, serverConnectEvent);
+ (*env)->DeleteLocalRef(env, serverConnectEvent);
+ (*ph_vm)->DetachCurrentThread(ph_vm);
+
+ return 0;
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Manager_enableServerDisconnectEvents(JNIEnv *env, jobject obj,
+ jboolean b)
+{
+ jlong gr = updateGlobalRef(env, obj, nativeServerDisconnectHandler_fid, b);
+ CPhidgetManagerHandle h = (CPhidgetManagerHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, manager_handle_fid);
+
+ CPhidgetManager_set_OnServerDisconnect_Handler(h, b ? serverDisconnect_handler : 0,
+ (void *)(uintptr_t)gr);
+}
+
+static int CCONV
+serverDisconnect_handler(CPhidgetManagerHandle h, void *arg)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject serverDisconnectEvent;
+ jint result;
+
+ result = (*ph_vm)->GetEnv(ph_vm, (void **)&env, JNI_VERSION_1_4);
+
+ if(result == JNI_EDETACHED)
+ {
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+ }
+
+ obj = (jobject)arg;
+
+ if (!(serverDisconnectEvent = (*env)->NewObject(env, serverDisconnectEvent_class, serverDisconnectEvent_cons,
+ obj)))
+ return -1;
+ (*env)->CallVoidMethod(env, obj, fireServerDisconnect_mid, serverDisconnectEvent);
+ (*env)->DeleteLocalRef(env, serverDisconnectEvent);
+ (*ph_vm)->DetachCurrentThread(ph_vm);
+
+ return 0;
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Manager_nativeOpen(JNIEnv *env, jobject obj)
+{
+ int error;
+
+ CPhidgetManagerHandle h = (CPhidgetManagerHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, manager_handle_fid);
+
+ if ((error = CPhidgetManager_open(h)))
+ PH_THROW(error);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Manager_nativeOpenRemote(JNIEnv *env, jobject obj, jstring serverID, jstring pass)
+{
+ int error;
+ jboolean iscopy;
+ const char *serverIDcopy = serverID?(*env)->GetStringUTFChars(
+ env, serverID, &iscopy):0;
+ const char *passcopy = (*env)->GetStringUTFChars(
+ env, pass, &iscopy);
+
+ CPhidgetManagerHandle h = (CPhidgetManagerHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, manager_handle_fid);
+
+ if ((error = CPhidgetManager_openRemote(h, serverIDcopy, passcopy)))
+ PH_THROW(error);
+
+ if(serverID)
+ (*env)->ReleaseStringUTFChars(env, serverID, serverIDcopy);
+ (*env)->ReleaseStringUTFChars(env, pass, passcopy);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Manager_nativeOpenRemoteIP(JNIEnv *env, jobject obj, jstring ipAddr, jint port, jstring pass)
+{
+ int error;
+ jboolean iscopy;
+ const char *ipAddrcopy = (*env)->GetStringUTFChars(
+ env, ipAddr, &iscopy);
+ const char *passcopy = (*env)->GetStringUTFChars(
+ env, pass, &iscopy);
+
+ CPhidgetManagerHandle h = (CPhidgetManagerHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, manager_handle_fid);
+
+ if ((error = CPhidgetManager_openRemoteIP(h, ipAddrcopy, port, passcopy)))
+ PH_THROW(error);
+
+ (*env)->ReleaseStringUTFChars(env, ipAddr, ipAddrcopy);
+ (*env)->ReleaseStringUTFChars(env, pass, passcopy);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Manager_nativeDelete(JNIEnv *env, jobject obj)
+{
+ int error;
+
+ CPhidgetManagerHandle h = (CPhidgetManagerHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, manager_handle_fid);
+
+ if ((error = CPhidgetManager_delete(h)))
+ PH_THROW(error);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Manager_nativeClose(JNIEnv *env, jobject obj)
+{
+ int error;
+
+ CPhidgetManagerHandle h = (CPhidgetManagerHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, manager_handle_fid);
+
+ if ((error = CPhidgetManager_close(h)))
+ PH_THROW(error);
+}
+
+JNIEXPORT jlong JNICALL
+Java_com_phidgets_Manager_create(JNIEnv *env, jobject obj)
+{
+ int error;
+ CPhidgetManagerHandle phidm;
+
+ if ((error = CPhidgetManager_create(&phidm)))
+ PH_THROW(error);
+ return (jlong)(uintptr_t)phidm;
+}
diff --git a/Java/com_phidgets_Manager.h b/Java/com_phidgets_Manager.h
new file mode 100644
index 0000000..5dcf1a5
--- /dev/null
+++ b/Java/com_phidgets_Manager.h
@@ -0,0 +1,133 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_Manager */
+
+#ifndef _Included_com_phidgets_Manager
+#define _Included_com_phidgets_Manager
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: com_phidgets_Manager
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_Manager_create
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Manager
+ * Method: getServerAddress
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_phidgets_Manager_getServerAddress
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Manager
+ * Method: getServerID
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_phidgets_Manager_getServerID
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Manager
+ * Method: getServerPort
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_Manager_getServerPort
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Manager
+ * Method: isAttached
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_Manager_isAttached
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Manager
+ * Method: isAttachedToServer
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_Manager_isAttachedToServer
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Manager
+ * Method: nativeClose
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Manager_nativeClose
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Manager
+ * Method: nativeDelete
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Manager_nativeDelete
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Manager
+ * Method: nativeOpen
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Manager_nativeOpen
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Manager
+ * Method: nativeOpenRemote
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Manager_nativeOpenRemote
+ (JNIEnv *, jobject, jstring, jstring);
+
+/*
+ * Class: com_phidgets_Manager
+ * Method: nativeOpenRemoteIP
+ * Signature: (Ljava/lang/String;ILjava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Manager_nativeOpenRemoteIP
+ (JNIEnv *, jobject, jstring, jint, jstring);
+
+/*
+ * Class: com_phidgets_Manager
+ * Method: enableManagerAttachEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Manager_enableManagerAttachEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_Manager
+ * Method: enableManagerDetachEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Manager_enableManagerDetachEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_Manager
+ * Method: enableServerConnectEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Manager_enableServerConnectEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_Manager
+ * Method: enableServerDisconnectEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Manager_enableServerDisconnectEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_MotorControlPhidget.c b/Java/com_phidgets_MotorControlPhidget.c
new file mode 100644
index 0000000..582b1bd
--- /dev/null
+++ b/Java/com_phidgets_MotorControlPhidget.c
@@ -0,0 +1,75 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_MotorControlPhidget.h"
+#include "../cphidgetmotorcontrol.h"
+
+EVENT_VARS(inputChange, InputChange)
+EVENT_VARS(motorVelocityChange, MotorVelocityChange)
+EVENT_VARS(currentChange, CurrentChange)
+EVENT_VARS(currentUpdate, CurrentUpdate)
+EVENT_VARS(encoderPositionChange, EncoderPositionChange)
+EVENT_VARS(encoderPositionUpdate, EncoderPositionUpdate)
+EVENT_VARS(backEMFUpdate, BackEMFUpdate)
+EVENT_VARS(sensorUpdate, SensorUpdate)
+
+JNI_LOAD(motor, MotorControl)
+ EVENT_VAR_SETUP(motor, inputChange, InputChange, IZ, V)
+ EVENT_VAR_SETUP(motor, motorVelocityChange, MotorVelocityChange, ID, V)
+ EVENT_VAR_SETUP(motor, currentChange, CurrentChange, ID, V)
+ EVENT_VAR_SETUP(motor, currentUpdate, CurrentUpdate, ID, V)
+ EVENT_VAR_SETUP(motor, encoderPositionChange, EncoderPositionChange, III, V)
+ EVENT_VAR_SETUP(motor, encoderPositionUpdate, EncoderPositionUpdate, II, V)
+ EVENT_VAR_SETUP(motor, backEMFUpdate, BackEMFUpdate, ID, V)
+ EVENT_VAR_SETUP(motor, sensorUpdate, SensorUpdate, II, V)
+
+}
+
+EVENT_HANDLER_INDEXED(MotorControl, inputChange, InputChange,
+ CPhidgetMotorControl_set_OnInputChange_Handler, int)
+EVENT_HANDLER_INDEXED(MotorControl, motorVelocityChange, MotorVelocityChange,
+ CPhidgetMotorControl_set_OnVelocityChange_Handler, double)
+EVENT_HANDLER_INDEXED(MotorControl, currentChange, CurrentChange,
+ CPhidgetMotorControl_set_OnCurrentChange_Handler, double)
+EVENT_HANDLER_INDEXED(MotorControl, currentUpdate, CurrentUpdate,
+ CPhidgetMotorControl_set_OnCurrentUpdate_Handler, double)
+EVENT_HANDLER_INDEXED2(MotorControl, encoderPositionChange, EncoderPositionChange,
+ CPhidgetMotorControl_set_OnEncoderPositionChange_Handler, int, int)
+EVENT_HANDLER_INDEXED(MotorControl, encoderPositionUpdate, EncoderPositionUpdate,
+ CPhidgetMotorControl_set_OnEncoderPositionUpdate_Handler, int)
+EVENT_HANDLER_INDEXED(MotorControl, backEMFUpdate, BackEMFUpdate,
+ CPhidgetMotorControl_set_OnBackEMFUpdate_Handler, double)
+EVENT_HANDLER_INDEXED(MotorControl, sensorUpdate, SensorUpdate,
+ CPhidgetMotorControl_set_OnSensorUpdate_Handler, int)
+
+
+JNI_CREATE(MotorControl)
+JNI_INDEXED_GETFUNC(MotorControl, Acceleration, Acceleration, jdouble)
+JNI_INDEXED_SETFUNC(MotorControl, Acceleration, Acceleration, jdouble)
+JNI_INDEXED_GETFUNC(MotorControl, AccelerationMin, AccelerationMin, jdouble)
+JNI_INDEXED_GETFUNC(MotorControl, AccelerationMax, AccelerationMax, jdouble)
+JNI_INDEXED_GETFUNC(MotorControl, Velocity, Velocity, jdouble)
+JNI_INDEXED_SETFUNC(MotorControl, Velocity, Velocity, jdouble)
+JNI_INDEXED_GETFUNC(MotorControl, Current, Current, jdouble)
+JNI_INDEXED_GETFUNCBOOL(MotorControl, InputState, InputState)
+
+JNI_INDEXED_GETFUNC(MotorControl, EncoderPosition, EncoderPosition, jint)
+JNI_INDEXED_SETFUNC(MotorControl, EncoderPosition, EncoderPosition, jint)
+JNI_INDEXED_GETFUNCBOOL(MotorControl, BackEMFSensingState, BackEMFSensingState)
+JNI_INDEXED_SETFUNC(MotorControl, BackEMFSensingState, BackEMFSensingState, jboolean)
+JNI_INDEXED_GETFUNC(MotorControl, BackEMF, BackEMF, jdouble)
+JNI_GETFUNC(MotorControl, SupplyVoltage, SupplyVoltage, jdouble)
+JNI_INDEXED_GETFUNC(MotorControl, Braking, Braking, jdouble)
+JNI_INDEXED_SETFUNC(MotorControl, Braking, Braking, jdouble)
+JNI_INDEXED_GETFUNC(MotorControl, SensorValue, SensorValue, jint)
+JNI_INDEXED_GETFUNC(MotorControl, SensorRawValue, SensorRawValue, jint)
+JNI_GETFUNCBOOL(MotorControl, Ratiometric, Ratiometric)
+JNI_SETFUNC(MotorControl, Ratiometric, Ratiometric, jboolean)
+
+JNI_GETFUNC(MotorControl, MotorCount, MotorCount, jint)
+JNI_GETFUNC(MotorControl, InputCount, InputCount, jint)
+JNI_GETFUNC(MotorControl, EncoderCount, EncoderCount, jint)
+JNI_GETFUNC(MotorControl, SensorCount, SensorCount, jint)
+
+//Deprecated
+JNI_INDEXED_GETFUNC(MotorControl, Speed, Velocity, jdouble)
+JNI_INDEXED_SETFUNC(MotorControl, Speed, Velocity, jdouble)
diff --git a/Java/com_phidgets_MotorControlPhidget.h b/Java/com_phidgets_MotorControlPhidget.h
new file mode 100644
index 0000000..790e336
--- /dev/null
+++ b/Java/com_phidgets_MotorControlPhidget.h
@@ -0,0 +1,437 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_MotorControlPhidget */
+
+#ifndef _Included_com_phidgets_MotorControlPhidget
+#define _Included_com_phidgets_MotorControlPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_MotorControlPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_MotorControlPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_MotorControlPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_MotorControlPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_MotorControlPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_MotorControlPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_MotorControlPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_MotorControlPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_MotorControlPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_MotorControlPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_MotorControlPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_MotorControlPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_MotorControlPhidget_PHIDID_NOTHING
+#define com_phidgets_MotorControlPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_MotorControlPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_MotorControlPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_MotorControlPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_MotorControlPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_MotorControlPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_MotorControlPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_MotorControlPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_MotorControlPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_MotorControlPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_MotorControlPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_MotorControlPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_MotorControlPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_MotorControlPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_MotorControlPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_MotorControlPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_MotorControlPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_MotorControlPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_MotorControlPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_MotorControlPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_MotorControlPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_MotorControlPhidget_PHIDID_GPS
+#define com_phidgets_MotorControlPhidget_PHIDID_GPS 121L
+#undef com_phidgets_MotorControlPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_MotorControlPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_MotorControlPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_MotorControlPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_MotorControlPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_MotorControlPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_MotorControlPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_MotorControlPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_MotorControlPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_MotorControlPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_MotorControlPhidget_PHIDID_IR
+#define com_phidgets_MotorControlPhidget_PHIDID_IR 77L
+#undef com_phidgets_MotorControlPhidget_PHIDID_LED_64
+#define com_phidgets_MotorControlPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_MotorControlPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_MotorControlPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_MotorControlPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_MotorControlPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_MotorControlPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_MotorControlPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_MotorControlPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_MotorControlPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_MotorControlPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_MotorControlPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_MotorControlPhidget_PHIDID_PHSENSOR
+#define com_phidgets_MotorControlPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_MotorControlPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_MotorControlPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_MotorControlPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_MotorControlPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_MotorControlPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_MotorControlPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_MotorControlPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_MotorControlPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_MotorControlPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_MotorControlPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_MotorControlPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_MotorControlPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_MotorControlPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_MotorControlPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_MotorControlPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_MotorControlPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_MotorControlPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_MotorControlPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_MotorControlPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_MotorControlPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_MotorControlPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_MotorControlPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_MotorControlPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_MotorControlPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_MotorControlPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_MotorControlPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_MotorControlPhidget_PHIDID_RFID
+#define com_phidgets_MotorControlPhidget_PHIDID_RFID 48L
+#undef com_phidgets_MotorControlPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_MotorControlPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_MotorControlPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_MotorControlPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_MotorControlPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_MotorControlPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_MotorControlPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_MotorControlPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_MotorControlPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_MotorControlPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_MotorControlPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_MotorControlPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_MotorControlPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_MotorControlPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_MotorControlPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_MotorControlPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_GPS
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_LED
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_RFID
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_SERVO
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_MotorControlPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_MotorControlPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_MotorControlPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getMotorCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_MotorControlPhidget_getMotorCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getInputCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_MotorControlPhidget_getInputCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getEncoderCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_MotorControlPhidget_getEncoderCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getSensorCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_MotorControlPhidget_getSensorCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getInputState
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_MotorControlPhidget_getInputState
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getEncoderPosition
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_MotorControlPhidget_getEncoderPosition
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: setEncoderPosition
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_MotorControlPhidget_setEncoderPosition
+ (JNIEnv *, jobject, jint, jint);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getSensorValue
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_MotorControlPhidget_getSensorValue
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getSensorRawValue
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_MotorControlPhidget_getSensorRawValue
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getRatiometric
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_MotorControlPhidget_getRatiometric
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: setRatiometric
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_MotorControlPhidget_setRatiometric
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getAcceleration
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_MotorControlPhidget_getAcceleration
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: setAcceleration
+ * Signature: (ID)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_MotorControlPhidget_setAcceleration
+ (JNIEnv *, jobject, jint, jdouble);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getAccelerationMax
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_MotorControlPhidget_getAccelerationMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getAccelerationMin
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_MotorControlPhidget_getAccelerationMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getVelocity
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_MotorControlPhidget_getVelocity
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getSpeed
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_MotorControlPhidget_getSpeed
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: setVelocity
+ * Signature: (ID)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_MotorControlPhidget_setVelocity
+ (JNIEnv *, jobject, jint, jdouble);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: setSpeed
+ * Signature: (ID)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_MotorControlPhidget_setSpeed
+ (JNIEnv *, jobject, jint, jdouble);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getCurrent
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_MotorControlPhidget_getCurrent
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getBackEMFSensingState
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_MotorControlPhidget_getBackEMFSensingState
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: setBackEMFSensingState
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_MotorControlPhidget_setBackEMFSensingState
+ (JNIEnv *, jobject, jint, jboolean);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getBackEMF
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_MotorControlPhidget_getBackEMF
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getSupplyVoltage
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_MotorControlPhidget_getSupplyVoltage
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: getBraking
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_MotorControlPhidget_getBraking
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: setBraking
+ * Signature: (ID)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_MotorControlPhidget_setBraking
+ (JNIEnv *, jobject, jint, jdouble);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: enableMotorVelocityChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_MotorControlPhidget_enableMotorVelocityChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: enableCurrentChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_MotorControlPhidget_enableCurrentChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: enableCurrentUpdateEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_MotorControlPhidget_enableCurrentUpdateEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: enableInputChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_MotorControlPhidget_enableInputChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: enableEncoderPositionChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_MotorControlPhidget_enableEncoderPositionChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: enableEncoderPositionUpdateEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_MotorControlPhidget_enableEncoderPositionUpdateEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: enableBackEMFUpdateEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_MotorControlPhidget_enableBackEMFUpdateEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_MotorControlPhidget
+ * Method: enableSensorUpdateEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_MotorControlPhidget_enableSensorUpdateEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_PHSensorPhidget.c b/Java/com_phidgets_PHSensorPhidget.c
new file mode 100644
index 0000000..a6f20a1
--- /dev/null
+++ b/Java/com_phidgets_PHSensorPhidget.c
@@ -0,0 +1,24 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_PHSensorPhidget.h"
+#include "../cphidgetphsensor.h"
+
+EVENT_VARS(phChange, PHChange)
+
+JNI_LOAD(ph, PHSensor)
+ EVENT_VAR_SETUP(ph, phChange, PHChange, D, V)
+}
+
+EVENT_HANDLER(PHSensor, phChange, PHChange,
+ CPhidgetPHSensor_set_OnPHChange_Handler, double)
+
+JNI_CREATE(PHSensor)
+JNI_GETFUNC(PHSensor, PHChangeTrigger, PHChangeTrigger, jdouble)
+JNI_SETFUNC(PHSensor, PHChangeTrigger, PHChangeTrigger, jdouble)
+JNI_GETFUNC(PHSensor, PH, PH, jdouble)
+JNI_GETFUNC(PHSensor, PHMin, PHMin, jdouble)
+JNI_GETFUNC(PHSensor, PHMax, PHMax, jdouble)
+JNI_GETFUNC(PHSensor, Potential, Potential, jdouble)
+JNI_GETFUNC(PHSensor, PotentialMin, PotentialMin, jdouble)
+JNI_GETFUNC(PHSensor, PotentialMax, PotentialMax, jdouble)
+JNI_SETFUNC(PHSensor, Temperature, Temperature, jdouble)
diff --git a/Java/com_phidgets_PHSensorPhidget.h b/Java/com_phidgets_PHSensorPhidget.h
new file mode 100644
index 0000000..2fa9b2e
--- /dev/null
+++ b/Java/com_phidgets_PHSensorPhidget.h
@@ -0,0 +1,245 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_PHSensorPhidget */
+
+#ifndef _Included_com_phidgets_PHSensorPhidget
+#define _Included_com_phidgets_PHSensorPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_PHSensorPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_PHSensorPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_PHSensorPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_PHSensorPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_PHSensorPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_PHSensorPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_PHSensorPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_PHSensorPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_PHSensorPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_PHSensorPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_PHSensorPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_PHSensorPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_PHSensorPhidget_PHIDID_NOTHING
+#define com_phidgets_PHSensorPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_PHSensorPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_PHSensorPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_PHSensorPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_PHSensorPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_PHSensorPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_PHSensorPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_PHSensorPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_PHSensorPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_PHSensorPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_PHSensorPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_PHSensorPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_PHSensorPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_PHSensorPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_PHSensorPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_PHSensorPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_PHSensorPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_PHSensorPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_PHSensorPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_PHSensorPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_PHSensorPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_PHSensorPhidget_PHIDID_GPS
+#define com_phidgets_PHSensorPhidget_PHIDID_GPS 121L
+#undef com_phidgets_PHSensorPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_PHSensorPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_PHSensorPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_PHSensorPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_PHSensorPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_PHSensorPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_PHSensorPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_PHSensorPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_PHSensorPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_PHSensorPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_PHSensorPhidget_PHIDID_IR
+#define com_phidgets_PHSensorPhidget_PHIDID_IR 77L
+#undef com_phidgets_PHSensorPhidget_PHIDID_LED_64
+#define com_phidgets_PHSensorPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_PHSensorPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_PHSensorPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_PHSensorPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_PHSensorPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_PHSensorPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_PHSensorPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_PHSensorPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_PHSensorPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_PHSensorPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_PHSensorPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_PHSensorPhidget_PHIDID_PHSENSOR
+#define com_phidgets_PHSensorPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_PHSensorPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_PHSensorPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_PHSensorPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_PHSensorPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_PHSensorPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_PHSensorPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_PHSensorPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_PHSensorPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_PHSensorPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_PHSensorPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_PHSensorPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_PHSensorPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_PHSensorPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_PHSensorPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_PHSensorPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_PHSensorPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_PHSensorPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_PHSensorPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_PHSensorPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_PHSensorPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_PHSensorPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_PHSensorPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_PHSensorPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_PHSensorPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_PHSensorPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_PHSensorPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_PHSensorPhidget_PHIDID_RFID
+#define com_phidgets_PHSensorPhidget_PHIDID_RFID 48L
+#undef com_phidgets_PHSensorPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_PHSensorPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_PHSensorPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_PHSensorPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_PHSensorPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_PHSensorPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_PHSensorPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_PHSensorPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_PHSensorPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_PHSensorPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_PHSensorPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_PHSensorPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_PHSensorPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_PHSensorPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_PHSensorPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_PHSensorPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_GPS
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_LED
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_RFID
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_SERVO
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_PHSensorPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_PHSensorPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+/*
+ * Class: com_phidgets_PHSensorPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_PHSensorPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_PHSensorPhidget
+ * Method: getPH
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_PHSensorPhidget_getPH
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_PHSensorPhidget
+ * Method: getPHMax
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_PHSensorPhidget_getPHMax
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_PHSensorPhidget
+ * Method: getPHMin
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_PHSensorPhidget_getPHMin
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_PHSensorPhidget
+ * Method: getPotential
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_PHSensorPhidget_getPotential
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_PHSensorPhidget
+ * Method: getPotentialMax
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_PHSensorPhidget_getPotentialMax
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_PHSensorPhidget
+ * Method: getPotentialMin
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_PHSensorPhidget_getPotentialMin
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_PHSensorPhidget
+ * Method: setTemperature
+ * Signature: (D)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_PHSensorPhidget_setTemperature
+ (JNIEnv *, jobject, jdouble);
+
+/*
+ * Class: com_phidgets_PHSensorPhidget
+ * Method: setPHChangeTrigger
+ * Signature: (D)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_PHSensorPhidget_setPHChangeTrigger
+ (JNIEnv *, jobject, jdouble);
+
+/*
+ * Class: com_phidgets_PHSensorPhidget
+ * Method: getPHChangeTrigger
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_PHSensorPhidget_getPHChangeTrigger
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_PHSensorPhidget
+ * Method: enablePHChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_PHSensorPhidget_enablePHChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_Phidget.c b/Java/com_phidgets_Phidget.c
new file mode 100644
index 0000000..82a9294
--- /dev/null
+++ b/Java/com_phidgets_Phidget.c
@@ -0,0 +1,630 @@
+#include "../stdafx.h"
+#include <stdlib.h>
+#include "com_phidgets_Phidget.h"
+#include "../cphidget.h"
+#include "../csocket.h"
+#include "phidget_jni.h"
+
+static int CCONV attach_handler(CPhidgetHandle h, void *arg);
+static int CCONV detach_handler(CPhidgetHandle h, void *arg);
+static int CCONV serverConnect_handler(CPhidgetHandle h, void *arg);
+static int CCONV serverDisconnect_handler(CPhidgetHandle h, void *arg);
+static int CCONV error_handler(CPhidgetHandle h, void *, int l, const char *arg);
+
+jfieldID handle_fid;
+jfieldID managerPhidget_fid;
+static jfieldID nativeAttachHandler_fid;
+static jfieldID nativeDetachHandler_fid;
+static jfieldID nativeErrorHandler_fid;
+static jfieldID nativeServerConnectHandler_fid;
+static jfieldID nativeServerDisconnectHandler_fid;
+
+static jmethodID fireAttach_mid;
+static jmethodID fireDetach_mid;
+static jmethodID fireError_mid;
+static jmethodID fireServerConnect_mid;
+static jmethodID fireServerDisconnect_mid;
+
+void
+com_phidgets_Phidget_OnLoad(JNIEnv *env)
+{
+ if (!(handle_fid = (*env)->GetFieldID(env, phidget_class, "handle", "J")))
+ JNI_ABORT_STDERR("Couldn't get Field ID handle from phidget_class");
+ if (!(managerPhidget_fid = (*env)->GetFieldID(env, phidget_class, "managerPhidget", "Z")))
+ JNI_ABORT_STDERR("Couldn't get Field ID managerPhidget from phidget_class");
+ if (!(nativeAttachHandler_fid = (*env)->GetFieldID(env, phidget_class, "nativeAttachHandler", "J")))
+ JNI_ABORT_STDERR("Couldn't get Field ID nativeAttachHandler from phidget_class");
+ if (!(nativeDetachHandler_fid = (*env)->GetFieldID(env, phidget_class, "nativeDetachHandler", "J")))
+ JNI_ABORT_STDERR("Couldn't get Field ID nativeDetachHandler from phidget_class");
+ if (!(nativeErrorHandler_fid = (*env)->GetFieldID(env, phidget_class, "nativeErrorHandler", "J")))
+ JNI_ABORT_STDERR("Couldn't get Field ID nativeErrorHandler from phidget_class");
+ if (!(nativeServerConnectHandler_fid = (*env)->GetFieldID(env, phidget_class, "nativeServerConnectHandler", "J")))
+ JNI_ABORT_STDERR("Couldn't get Field ID nativeServerConnectHandler from phidget_class");
+ if (!(nativeServerDisconnectHandler_fid = (*env)->GetFieldID(env, phidget_class, "nativeServerDisconnectHandler", "J")))
+ JNI_ABORT_STDERR("Couldn't get Field ID nativeServerDisconnectHandler from phidget_class");
+
+ if (!(fireAttach_mid = (*env)->GetMethodID(env, phidget_class, "fireAttach", "(Lcom/phidgets/event/AttachEvent;)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID fireAttach from phidget_class");
+ if (!(fireDetach_mid = (*env)->GetMethodID(env, phidget_class, "fireDetach", "(Lcom/phidgets/event/DetachEvent;)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID fireDetach from phidget_class");
+ if (!(fireError_mid = (*env)->GetMethodID(env, phidget_class, "fireError", "(Lcom/phidgets/event/ErrorEvent;)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID fireError from phidget_class");
+ if (!(fireServerConnect_mid = (*env)->GetMethodID(env, phidget_class, "fireServerConnect", "(Lcom/phidgets/event/ServerConnectEvent;)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID fireServerConnect from phidget_class");
+ if (!(fireServerDisconnect_mid = (*env)->GetMethodID(env, phidget_class, "fireServerDisconnect", "(Lcom/phidgets/event/ServerDisconnectEvent;)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID fireServerDisconnect from phidget_class");
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_enableAttachEvents(JNIEnv *env, jobject obj,
+ jboolean b)
+{
+ jlong gr = updateGlobalRef(env, obj, nativeAttachHandler_fid, b);
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+
+ CPhidget_set_OnAttach_Handler(h, b ? attach_handler : 0,
+ (void *)(uintptr_t)gr);
+}
+
+static int CCONV
+attach_handler(CPhidgetHandle h, void *arg)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject attachEvent;
+ jint result;
+
+ result = (*ph_vm)->GetEnv(ph_vm, (void **)&env, JNI_VERSION_1_4);
+
+ if(result == JNI_EDETACHED)
+ {
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+ }
+
+ obj = (jobject)arg;
+
+ if (!(attachEvent = (*env)->NewObject(env, attachEvent_class, attachEvent_cons,
+ obj)))
+ return -1;
+ (*env)->CallVoidMethod(env, obj, fireAttach_mid, attachEvent);
+ (*env)->DeleteLocalRef(env, attachEvent);
+ (*ph_vm)->DetachCurrentThread(ph_vm);
+
+ return 0;
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_enableDetachEvents(JNIEnv *env, jobject obj,
+ jboolean b)
+{
+ jlong gr = updateGlobalRef(env, obj, nativeDetachHandler_fid, b);
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+
+ CPhidget_set_OnDetach_Handler(h, b ? detach_handler : 0, (void *)(uintptr_t)gr);
+}
+
+static int CCONV
+detach_handler(CPhidgetHandle h, void *arg)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject detachEvent;
+
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+
+ obj = (jobject)arg;
+
+ if (!(detachEvent = (*env)->NewObject(env, detachEvent_class, detachEvent_cons,
+ obj)))
+ return -1;
+ (*env)->CallVoidMethod(env, obj, fireDetach_mid, detachEvent);
+ (*env)->DeleteLocalRef(env, detachEvent);
+ (*ph_vm)->DetachCurrentThread(ph_vm);
+
+ return 0;
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_enableErrorEvents(JNIEnv *env, jobject obj,
+ jboolean b)
+{
+ jlong gr = updateGlobalRef(env, obj, nativeErrorHandler_fid, b);
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+
+ CPhidget_set_OnError_Handler(h, b ? error_handler : 0, (void *)(uintptr_t)gr);
+}
+
+static int CCONV
+error_handler(CPhidgetHandle h, void *arg, int l, const char *v)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject errorEvent;
+ jobject eobj;
+ jstring edesc;
+
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+
+ obj = (jobject)arg;
+
+ if (!(edesc = (*env)->NewStringUTF(env, v)))
+ return -1;
+
+ if (!(eobj = (*env)->NewObject(env, ph_exception_class, ph_exception_cons, l, edesc)))
+ return -1;
+
+ if (!(errorEvent = (*env)->NewObject(env, errorEvent_class, errorEvent_cons, obj, eobj)))
+ return -1;
+
+ (*env)->CallVoidMethod(env, obj, fireError_mid, errorEvent);
+ (*env)->DeleteLocalRef(env, errorEvent);
+ (*ph_vm)->DetachCurrentThread(ph_vm);
+
+ return 0;
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_enableServerConnectEvents(JNIEnv *env, jobject obj,
+ jboolean b)
+{
+ jlong gr = updateGlobalRef(env, obj, nativeServerConnectHandler_fid, b);
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+
+ CPhidget_set_OnServerConnect_Handler(h, b ? serverConnect_handler : 0,
+ (void *)(uintptr_t)gr);
+}
+
+static int CCONV
+serverConnect_handler(CPhidgetHandle h, void *arg)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject serverConnectEvent;
+ jint result;
+
+ result = (*ph_vm)->GetEnv(ph_vm, (void **)&env, JNI_VERSION_1_4);
+
+ if(result == JNI_EDETACHED)
+ {
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+ }
+
+ obj = (jobject)arg;
+
+ if (!(serverConnectEvent = (*env)->NewObject(env, serverConnectEvent_class, serverConnectEvent_cons,
+ obj)))
+ return -1;
+ (*env)->CallVoidMethod(env, obj, fireServerConnect_mid, serverConnectEvent);
+ (*env)->DeleteLocalRef(env, serverConnectEvent);
+ (*ph_vm)->DetachCurrentThread(ph_vm);
+
+ return 0;
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_enableServerDisconnectEvents(JNIEnv *env, jobject obj,
+ jboolean b)
+{
+ jlong gr = updateGlobalRef(env, obj, nativeServerDisconnectHandler_fid, b);
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+
+ CPhidget_set_OnServerDisconnect_Handler(h, b ? serverDisconnect_handler : 0,
+ (void *)(uintptr_t)gr);
+}
+
+static int CCONV
+serverDisconnect_handler(CPhidgetHandle h, void *arg)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject serverDisconnectEvent;
+ jint result;
+
+ result = (*ph_vm)->GetEnv(ph_vm, (void **)&env, JNI_VERSION_1_4);
+
+ if(result == JNI_EDETACHED)
+ {
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+ }
+
+ obj = (jobject)arg;
+
+ if (!(serverDisconnectEvent = (*env)->NewObject(env, serverDisconnectEvent_class, serverDisconnectEvent_cons,
+ obj)))
+ return -1;
+ (*env)->CallVoidMethod(env, obj, fireServerDisconnect_mid, serverDisconnectEvent);
+ (*env)->DeleteLocalRef(env, serverDisconnectEvent);
+ (*ph_vm)->DetachCurrentThread(ph_vm);
+
+ return 0;
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_nativeOpen(JNIEnv *env, jobject obj, jint ser)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+ int error;
+
+ if ((error = CPhidget_open(h, ser)))
+ PH_THROW(error);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_nativeOpenRemote(JNIEnv *env, jobject obj, jint ser, jstring serverID, jstring pass)
+{
+ int error;
+ jboolean iscopy;
+ const char *serverIDcopy = serverID?(*env)->GetStringUTFChars(
+ env, serverID, &iscopy):0;
+ const char *passcopy = (*env)->GetStringUTFChars(
+ env, pass, &iscopy);
+
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+
+ if ((error = CPhidget_openRemote(h, ser, serverIDcopy, passcopy)))
+ PH_THROW(error);
+
+ if(serverID)
+ (*env)->ReleaseStringUTFChars(env, serverID, serverIDcopy);
+ (*env)->ReleaseStringUTFChars(env, pass, passcopy);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_nativeOpenRemoteIP(JNIEnv *env, jobject obj, jint ser, jstring ipAddr, jint port, jstring pass)
+{
+ int error;
+ jboolean iscopy;
+ const char *ipAddrcopy = (*env)->GetStringUTFChars(
+ env, ipAddr, &iscopy);
+ const char *passcopy = (*env)->GetStringUTFChars(
+ env, pass, &iscopy);
+
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+
+ if ((error = CPhidget_openRemoteIP(h, ser, ipAddrcopy, port, passcopy)))
+ PH_THROW(error);
+
+ (*env)->ReleaseStringUTFChars(env, ipAddr, ipAddrcopy);
+ (*env)->ReleaseStringUTFChars(env, pass, passcopy);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_nativeOpenLabel(JNIEnv *env, jobject obj, jstring label)
+{
+ int error;
+ jboolean iscopy;
+ const char *labelcopy = (*env)->GetStringUTFChars(
+ env, label, &iscopy);
+
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+
+ if ((error = CPhidget_openLabel(h, labelcopy)))
+ PH_THROW(error);
+
+ (*env)->ReleaseStringUTFChars(env, label, labelcopy);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_nativeOpenLabelRemote(JNIEnv *env, jobject obj, jstring label, jstring serverID, jstring pass)
+{
+ int error;
+ jboolean iscopy;
+ const char *serverIDcopy = serverID?(*env)->GetStringUTFChars(
+ env, serverID, &iscopy):0;
+ const char *passcopy = (*env)->GetStringUTFChars(
+ env, pass, &iscopy);
+ const char *labelcopy = (*env)->GetStringUTFChars(
+ env, label, &iscopy);
+
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+
+ if ((error = CPhidget_openLabelRemote(h, labelcopy, serverIDcopy, passcopy)))
+ PH_THROW(error);
+
+ if(serverID)
+ (*env)->ReleaseStringUTFChars(env, serverID, serverIDcopy);
+ (*env)->ReleaseStringUTFChars(env, pass, passcopy);
+ (*env)->ReleaseStringUTFChars(env, label, labelcopy);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_nativeOpenLabelRemoteIP(JNIEnv *env, jobject obj, jstring label, jstring ipAddr, jint port, jstring pass)
+{
+ int error;
+ jboolean iscopy;
+ const char *ipAddrcopy = (*env)->GetStringUTFChars(
+ env, ipAddr, &iscopy);
+ const char *passcopy = (*env)->GetStringUTFChars(
+ env, pass, &iscopy);
+ const char *labelcopy = (*env)->GetStringUTFChars(
+ env, label, &iscopy);
+
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+
+ if ((error = CPhidget_openLabelRemoteIP(h, labelcopy, ipAddrcopy, port, passcopy)))
+ PH_THROW(error);
+
+ (*env)->ReleaseStringUTFChars(env, ipAddr, ipAddrcopy);
+ (*env)->ReleaseStringUTFChars(env, pass, passcopy);
+ (*env)->ReleaseStringUTFChars(env, label, labelcopy);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_nativeClose(JNIEnv *env, jobject obj)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+ int error;
+
+ if ((error = CPhidget_close(h)))
+ PH_THROW(error);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_nativeDelete(JNIEnv *env, jobject obj)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+ int error;
+
+ if ((error = CPhidget_delete(h)))
+ PH_THROW(error);
+}
+
+JNIEXPORT jint JNICALL
+Java_com_phidgets_Phidget_getSerialNumber(JNIEnv *env, jobject obj)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+ int error;
+ int ser;
+
+ if ((error = CPhidget_getSerialNumber(h, &ser)))
+ PH_THROW(error);
+
+ return ser;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_phidgets_Phidget_getServerPort(JNIEnv *env, jobject obj)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+ int error;
+ int port;
+ const char *addr;
+
+ if ((error = CPhidget_getServerAddress(h, &addr, &port)))
+ PH_THROW(error);
+
+ return port;
+}
+
+JNIEXPORT jstring JNICALL
+Java_com_phidgets_Phidget_getServerAddress(JNIEnv *env, jobject obj)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+ int error;
+ int port;
+ const char *addr;
+
+ if ((error = CPhidget_getServerAddress(h, &addr, &port)))
+ PH_THROW(error);
+
+ return (*env)->NewStringUTF(env, addr);
+}
+
+JNIEXPORT jstring JNICALL
+Java_com_phidgets_Phidget_getServerID(JNIEnv *env, jobject obj)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+ int error;
+ const char *id;
+
+ if ((error = CPhidget_getServerID(h, &id)))
+ PH_THROW(error);
+
+ return (*env)->NewStringUTF(env, id);
+}
+
+JNIEXPORT jint JNICALL
+Java_com_phidgets_Phidget_getDeviceID(JNIEnv *env, jobject obj)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+ int error;
+ CPhidget_DeviceID id;
+
+ if ((error = CPhidget_getDeviceID(h, &id)))
+ PH_THROW(error);
+
+ return (int)id;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_phidgets_Phidget_getDeviceClass(JNIEnv *env, jobject obj)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+ int error;
+ CPhidget_DeviceClass cls;
+
+ if ((error = CPhidget_getDeviceClass(h, &cls)))
+ PH_THROW(error);
+
+ return (int)cls;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_phidgets_Phidget_getDeviceVersion(JNIEnv *env, jobject obj)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+ int error;
+ int ver;
+
+ if ((error = CPhidget_getDeviceVersion(h, &ver)))
+ PH_THROW(error);
+
+ return ver;
+}
+
+JNIEXPORT jstring JNICALL
+Java_com_phidgets_Phidget_getDeviceType(JNIEnv *env, jobject obj)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+ const char *type;
+ int error;
+
+ if ((error = CPhidget_getDeviceType(h, &type)))
+ PH_THROW(error);
+
+ return (*env)->NewStringUTF(env, type);
+}
+
+JNIEXPORT jstring JNICALL
+Java_com_phidgets_Phidget_getDeviceName(JNIEnv *env, jobject obj)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+ const char *type;
+ int error;
+
+ if ((error = CPhidget_getDeviceName(h, &type)))
+ PH_THROW(error);
+
+ return (*env)->NewStringUTF(env, type);
+}
+
+JNIEXPORT jstring JNICALL
+Java_com_phidgets_Phidget_getDeviceLabel(JNIEnv *env, jobject obj)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+ const char *label;
+ int error;
+
+ if ((error = CPhidget_getDeviceLabel(h, &label)))
+ PH_THROW(error);
+
+ return (*env)->NewStringUTF(env, label);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_setDeviceLabel(JNIEnv *env, jobject obj, jstring v)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+ int error;
+ jboolean iscopy;
+ const char *textString = (*env)->GetStringUTFChars(
+ env, v, &iscopy);
+ if ((error = CPhidget_setDeviceLabel(h, (char *)textString)))
+ PH_THROW(error);
+ (*env)->ReleaseStringUTFChars(env, v, textString);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_nativeEnableLogging(JNIEnv *env, jclass cls, jint level, jstring file)
+{
+ int error;
+ jboolean iscopy;
+ const char *textString = file ? (*env)->GetStringUTFChars(
+ env, file, &iscopy) : NULL;
+ if ((error = CPhidget_enableLogging(level, (char *)textString)))
+ PH_THROW(error);
+ (*env)->ReleaseStringUTFChars(env, file, textString);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_disableLogging(JNIEnv *env, jclass cls)
+{
+ int error;
+ if ((error = CPhidget_disableLogging()))
+ PH_THROW(error);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_nativeLog(JNIEnv *env, jclass cls, jint level, jstring id, jstring log)
+{
+ int error;
+ jboolean iscopy1;
+ const char *textString1 = (*env)->GetStringUTFChars(
+ env, id, &iscopy1);
+ jboolean iscopy2;
+ const char *textString2 = (*env)->GetStringUTFChars(
+ env, log, &iscopy2);
+ if ((error = CPhidget_log(level, (char *)textString1, (char *)textString2)))
+ PH_THROW(error);
+ (*env)->ReleaseStringUTFChars(env, id, textString1);
+ (*env)->ReleaseStringUTFChars(env, log, textString2);
+}
+
+JNIEXPORT jstring JNICALL
+Java_com_phidgets_Phidget_getLibraryVersion(JNIEnv *env, jclass cls)
+{
+ const char *ver;
+
+ CPhidget_getLibraryVersion(&ver);
+
+ return (*env)->NewStringUTF(env, ver);
+}
+
+JNIEXPORT jboolean JNICALL
+Java_com_phidgets_Phidget_isAttached(JNIEnv *env, jobject obj)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+ int error;
+ int s;
+
+ if ((error = CPhidget_getDeviceStatus(h, &s)))
+ PH_THROW(error);
+
+ return s == PHIDGET_ATTACHED;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_com_phidgets_Phidget_isAttachedToServer(JNIEnv *env, jobject obj)
+{
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env,
+ obj, handle_fid);
+ int error;
+ int s;
+
+ if ((error = CPhidget_getServerStatus(h, &s)))
+ PH_THROW(error);
+
+ return s == PHIDGET_ATTACHED;
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_Phidget_waitForAttachment(JNIEnv *env, jobject obj, jint timeout)
+{
+ int error;
+ CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env, obj, handle_fid);
+
+ if ((error = CPhidget_waitForAttachment(h, timeout)))
+ PH_THROW(error);
+
+ return;
+}
diff --git a/Java/com_phidgets_Phidget.h b/Java/com_phidgets_Phidget.h
new file mode 100644
index 0000000..1def627
--- /dev/null
+++ b/Java/com_phidgets_Phidget.h
@@ -0,0 +1,405 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_Phidget */
+
+#ifndef _Included_com_phidgets_Phidget
+#define _Included_com_phidgets_Phidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_Phidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_Phidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_Phidget_PHIDGET_LOG_ERROR
+#define com_phidgets_Phidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_Phidget_PHIDGET_LOG_WARNING
+#define com_phidgets_Phidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_Phidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_Phidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_Phidget_PHIDGET_LOG_INFO
+#define com_phidgets_Phidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_Phidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_Phidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_Phidget_PHIDID_NOTHING
+#define com_phidgets_Phidget_PHIDID_NOTHING 1L
+#undef com_phidgets_Phidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_Phidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_Phidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_Phidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_Phidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_Phidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_Phidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_Phidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_Phidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_Phidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_Phidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_Phidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_Phidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_Phidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_Phidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_Phidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_Phidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_Phidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_Phidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_Phidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_Phidget_PHIDID_GPS
+#define com_phidgets_Phidget_PHIDID_GPS 121L
+#undef com_phidgets_Phidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_Phidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_Phidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_Phidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_Phidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_Phidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_Phidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_Phidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_Phidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_Phidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_Phidget_PHIDID_IR
+#define com_phidgets_Phidget_PHIDID_IR 77L
+#undef com_phidgets_Phidget_PHIDID_LED_64
+#define com_phidgets_Phidget_PHIDID_LED_64 74L
+#undef com_phidgets_Phidget_PHIDID_LED_64_ADV
+#define com_phidgets_Phidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_Phidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_Phidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_Phidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_Phidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_Phidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_Phidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_Phidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_Phidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_Phidget_PHIDID_PHSENSOR
+#define com_phidgets_Phidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_Phidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_Phidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_Phidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_Phidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_Phidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_Phidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_Phidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_Phidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_Phidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_Phidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_Phidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_Phidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_Phidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_Phidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_Phidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_Phidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_Phidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_Phidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_Phidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_Phidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_Phidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_Phidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_Phidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_Phidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_Phidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_Phidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_Phidget_PHIDID_RFID
+#define com_phidgets_Phidget_PHIDID_RFID 48L
+#undef com_phidgets_Phidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_Phidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_Phidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_Phidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_Phidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_Phidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_Phidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_Phidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_Phidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_Phidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_Phidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_Phidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_Phidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_Phidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_Phidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_Phidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_Phidget_PHIDCLASS_NOTHING
+#define com_phidgets_Phidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_Phidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_Phidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_Phidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_Phidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_Phidget_PHIDCLASS_ANALOG
+#define com_phidgets_Phidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_Phidget_PHIDCLASS_BRIDGE
+#define com_phidgets_Phidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_Phidget_PHIDCLASS_ENCODER
+#define com_phidgets_Phidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_Phidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_Phidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_Phidget_PHIDCLASS_GPS
+#define com_phidgets_Phidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_Phidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_Phidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_Phidget_PHIDCLASS_LED
+#define com_phidgets_Phidget_PHIDCLASS_LED 8L
+#undef com_phidgets_Phidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_Phidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_Phidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_Phidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_Phidget_PHIDCLASS_RFID
+#define com_phidgets_Phidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_Phidget_PHIDCLASS_SERVO
+#define com_phidgets_Phidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_Phidget_PHIDCLASS_STEPPER
+#define com_phidgets_Phidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_Phidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_Phidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_Phidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_Phidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_Phidget_PHIDCLASS_TEXTLED
+#define com_phidgets_Phidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_Phidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_Phidget_PHIDCLASS_WEIGHTSENSOR 17L
+/*
+ * Class: com_phidgets_Phidget
+ * Method: getLibraryVersion
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_phidgets_Phidget_getLibraryVersion
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: nativeEnableLogging
+ * Signature: (ILjava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_nativeEnableLogging
+ (JNIEnv *, jclass, jint, jstring);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: disableLogging
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_disableLogging
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: nativeLog
+ * Signature: (ILjava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_nativeLog
+ (JNIEnv *, jclass, jint, jstring, jstring);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: getDeviceID
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_Phidget_getDeviceID
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: getDeviceClass
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_Phidget_getDeviceClass
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: getSerialNumber
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_Phidget_getSerialNumber
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: getDeviceVersion
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_Phidget_getDeviceVersion
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: getDeviceType
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_phidgets_Phidget_getDeviceType
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: getDeviceName
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_phidgets_Phidget_getDeviceName
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: isAttached
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_Phidget_isAttached
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: isAttachedToServer
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_Phidget_isAttachedToServer
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: getDeviceLabel
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_phidgets_Phidget_getDeviceLabel
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: setDeviceLabel
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_setDeviceLabel
+ (JNIEnv *, jobject, jstring);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: getServerAddress
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_phidgets_Phidget_getServerAddress
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: getServerID
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_phidgets_Phidget_getServerID
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: getServerPort
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_Phidget_getServerPort
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: nativeClose
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_nativeClose
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: nativeDelete
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_nativeDelete
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: nativeOpen
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_nativeOpen
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: nativeOpenRemote
+ * Signature: (ILjava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_nativeOpenRemote
+ (JNIEnv *, jobject, jint, jstring, jstring);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: nativeOpenRemoteIP
+ * Signature: (ILjava/lang/String;ILjava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_nativeOpenRemoteIP
+ (JNIEnv *, jobject, jint, jstring, jint, jstring);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: nativeOpenLabel
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_nativeOpenLabel
+ (JNIEnv *, jobject, jstring);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: nativeOpenLabelRemote
+ * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_nativeOpenLabelRemote
+ (JNIEnv *, jobject, jstring, jstring, jstring);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: nativeOpenLabelRemoteIP
+ * Signature: (Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_nativeOpenLabelRemoteIP
+ (JNIEnv *, jobject, jstring, jstring, jint, jstring);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: waitForAttachment
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_waitForAttachment
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: enableAttachEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_enableAttachEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: enableErrorEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_enableErrorEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: enableDetachEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_enableDetachEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: enableServerConnectEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_enableServerConnectEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_Phidget
+ * Method: enableServerDisconnectEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_Phidget_enableServerDisconnectEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_RFIDPhidget.c b/Java/com_phidgets_RFIDPhidget.c
new file mode 100644
index 0000000..c20b8ad
--- /dev/null
+++ b/Java/com_phidgets_RFIDPhidget.c
@@ -0,0 +1,104 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_RFIDPhidget.h"
+#include "../cphidgetrfid.h"
+
+EVENT_VARS(outputChange, OutputChange)
+EVENT_VARS(tagLoss, TagLoss)
+EVENT_VARS(tagGain, TagGain)
+
+JNI_LOAD(rfid, RFID)
+ EVENT_VAR_SETUP(rfid, outputChange, OutputChange, IZ, V)
+ EVENT_VAR_SETUP(rfid, tagLoss, TagLoss, Ljava/lang/String;, V)
+ EVENT_VAR_SETUP(rfid, tagGain, TagGain, Ljava/lang/String;, V)
+}
+
+EVENT_HANDLER_INDEXED(RFID, outputChange, OutputChange,
+ CPhidgetRFID_set_OnOutputChange_Handler, int)
+
+static int CCONV tagLoss_handler (CPhidgetRFIDHandle h, void *arg, unsigned char *);
+JNIEXPORT void JNICALL Java_com_phidgets_RFIDPhidget_enableTagLossEvents (JNIEnv * env, jobject obj, jboolean b)
+{
+ jlong gr = updateGlobalRef (env, obj, nativeTagLossHandler_fid, b);
+ CPhidgetRFIDHandle h = (CPhidgetRFIDHandle) (uintptr_t) (*env)->GetLongField (env, obj, handle_fid);
+ CPhidgetRFID_set_OnTagLost_Handler (h, b ? tagLoss_handler : 0, (void *) (uintptr_t) gr);
+} static int CCONV
+tagLoss_handler (CPhidgetRFIDHandle h, void *arg, unsigned char *v)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject tagLossEv;
+ char stringbuffer[20];
+ jstring jb;
+ if ((*ph_vm)->AttachCurrentThread (ph_vm, (JNIEnvPtr) &env, ((void *) 0)))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+ obj = (jobject) arg;
+
+ sprintf(stringbuffer, "%02x%02x%02x%02x%02x",v[0],v[1],v[2],v[3],v[4]);
+ jb=(*env)->NewStringUTF(env, stringbuffer);
+
+ if (!(tagLossEv = (*env)->NewObject (env, tagLossEvent_class, tagLossEvent_cons, obj, jb)))
+ return -1;
+ (*env)->CallVoidMethod (env, obj, fireTagLoss_mid, tagLossEv);
+ (*env)->DeleteLocalRef (env, tagLossEv);
+ (*ph_vm)->DetachCurrentThread (ph_vm);
+ return 0;
+}
+
+static int CCONV tagGain_handler (CPhidgetRFIDHandle h, void *arg, unsigned char *);
+JNIEXPORT void JNICALL Java_com_phidgets_RFIDPhidget_enableTagGainEvents (JNIEnv * env, jobject obj, jboolean b)
+{
+ jlong gr = updateGlobalRef (env, obj, nativeTagGainHandler_fid, b);
+ CPhidgetRFIDHandle h = (CPhidgetRFIDHandle) (uintptr_t) (*env)->GetLongField (env, obj, handle_fid);
+ CPhidgetRFID_set_OnTag_Handler (h, b ? tagGain_handler : 0, (void *) (uintptr_t) gr);
+} static int CCONV
+tagGain_handler (CPhidgetRFIDHandle h, void *arg, unsigned char *v)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject tagGainEv;
+ char stringbuffer[20];
+ jstring jb;
+ if ((*ph_vm)->AttachCurrentThread (ph_vm, (JNIEnvPtr) &env, ((void *) 0)))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+ obj = (jobject) arg;
+
+ sprintf(stringbuffer, "%02x%02x%02x%02x%02x",v[0],v[1],v[2],v[3],v[4]);
+ jb=(*env)->NewStringUTF(env, stringbuffer);
+
+ if (!(tagGainEv = (*env)->NewObject (env, tagGainEvent_class, tagGainEvent_cons, obj, jb)))
+ return -1;
+ (*env)->CallVoidMethod (env, obj, fireTagGain_mid, tagGainEv);
+ (*env)->DeleteLocalRef (env, tagGainEv);
+ (*ph_vm)->DetachCurrentThread (ph_vm);
+ return 0;
+}
+
+
+JNI_CREATE(RFID)
+JNI_INDEXED_GETFUNCBOOL(RFID, OutputState, OutputState)
+JNI_INDEXED_SETFUNC(RFID, OutputState, OutputState, jboolean)
+JNI_GETFUNCBOOL(RFID, AntennaOn, AntennaOn)
+JNI_SETFUNC(RFID, AntennaOn, AntennaOn, jboolean)
+JNI_GETFUNCBOOL(RFID, LEDOn, LEDOn)
+JNI_GETFUNCBOOL(RFID, TagStatus, TagStatus)
+JNI_SETFUNC(RFID, LEDOn, LEDOn, jboolean)
+JNI_GETFUNC(RFID, OutputCount, OutputCount, jint)
+
+JNIEXPORT jstring JNICALL
+Java_com_phidgets_RFIDPhidget_getLastTag (JNIEnv *env, jobject obj)
+{
+ CPhidgetRFIDHandle h = (CPhidgetRFIDHandle)(uintptr_t)
+ (*env)->GetLongField( env, obj, handle_fid);
+ int error;
+ unsigned char buffer[11];
+ char stringbuffer[20];
+ jstring jb;
+ if ((error = CPhidgetRFID_getLastTag(h, (unsigned char *)&buffer)))
+ PH_THROW(error);
+
+ sprintf(stringbuffer, "%02x%02x%02x%02x%02x",buffer[0],buffer[1],buffer[2],buffer[3],buffer[4]);
+
+ jb=(*env)->NewStringUTF(env, stringbuffer);
+ return jb;
+}
diff --git a/Java/com_phidgets_RFIDPhidget.h b/Java/com_phidgets_RFIDPhidget.h
new file mode 100644
index 0000000..d6a123e
--- /dev/null
+++ b/Java/com_phidgets_RFIDPhidget.h
@@ -0,0 +1,261 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_RFIDPhidget */
+
+#ifndef _Included_com_phidgets_RFIDPhidget
+#define _Included_com_phidgets_RFIDPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_RFIDPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_RFIDPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_RFIDPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_RFIDPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_RFIDPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_RFIDPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_RFIDPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_RFIDPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_RFIDPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_RFIDPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_RFIDPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_RFIDPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_RFIDPhidget_PHIDID_NOTHING
+#define com_phidgets_RFIDPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_RFIDPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_RFIDPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_RFIDPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_RFIDPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_RFIDPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_RFIDPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_RFIDPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_RFIDPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_RFIDPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_RFIDPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_RFIDPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_RFIDPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_RFIDPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_RFIDPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_RFIDPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_RFIDPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_RFIDPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_RFIDPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_RFIDPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_RFIDPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_RFIDPhidget_PHIDID_GPS
+#define com_phidgets_RFIDPhidget_PHIDID_GPS 121L
+#undef com_phidgets_RFIDPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_RFIDPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_RFIDPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_RFIDPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_RFIDPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_RFIDPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_RFIDPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_RFIDPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_RFIDPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_RFIDPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_RFIDPhidget_PHIDID_IR
+#define com_phidgets_RFIDPhidget_PHIDID_IR 77L
+#undef com_phidgets_RFIDPhidget_PHIDID_LED_64
+#define com_phidgets_RFIDPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_RFIDPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_RFIDPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_RFIDPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_RFIDPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_RFIDPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_RFIDPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_RFIDPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_RFIDPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_RFIDPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_RFIDPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_RFIDPhidget_PHIDID_PHSENSOR
+#define com_phidgets_RFIDPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_RFIDPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_RFIDPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_RFIDPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_RFIDPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_RFIDPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_RFIDPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_RFIDPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_RFIDPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_RFIDPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_RFIDPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_RFIDPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_RFIDPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_RFIDPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_RFIDPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_RFIDPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_RFIDPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_RFIDPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_RFIDPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_RFIDPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_RFIDPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_RFIDPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_RFIDPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_RFIDPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_RFIDPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_RFIDPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_RFIDPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_RFIDPhidget_PHIDID_RFID
+#define com_phidgets_RFIDPhidget_PHIDID_RFID 48L
+#undef com_phidgets_RFIDPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_RFIDPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_RFIDPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_RFIDPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_RFIDPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_RFIDPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_RFIDPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_RFIDPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_RFIDPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_RFIDPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_RFIDPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_RFIDPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_RFIDPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_RFIDPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_RFIDPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_RFIDPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_RFIDPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_RFIDPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_RFIDPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_RFIDPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_RFIDPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_RFIDPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_RFIDPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_GPS
+#define com_phidgets_RFIDPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_RFIDPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_LED
+#define com_phidgets_RFIDPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_RFIDPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_RFIDPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_RFID
+#define com_phidgets_RFIDPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_SERVO
+#define com_phidgets_RFIDPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_RFIDPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_RFIDPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_RFIDPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_RFIDPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_RFIDPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_RFIDPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+/*
+ * Class: com_phidgets_RFIDPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_RFIDPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_RFIDPhidget
+ * Method: getOutputCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_RFIDPhidget_getOutputCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_RFIDPhidget
+ * Method: getOutputState
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_RFIDPhidget_getOutputState
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_RFIDPhidget
+ * Method: setOutputState
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_RFIDPhidget_setOutputState
+ (JNIEnv *, jobject, jint, jboolean);
+
+/*
+ * Class: com_phidgets_RFIDPhidget
+ * Method: getAntennaOn
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_RFIDPhidget_getAntennaOn
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_RFIDPhidget
+ * Method: setAntennaOn
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_RFIDPhidget_setAntennaOn
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_RFIDPhidget
+ * Method: getLEDOn
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_RFIDPhidget_getLEDOn
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_RFIDPhidget
+ * Method: setLEDOn
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_RFIDPhidget_setLEDOn
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_RFIDPhidget
+ * Method: getLastTag
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_phidgets_RFIDPhidget_getLastTag
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_RFIDPhidget
+ * Method: getTagStatus
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_RFIDPhidget_getTagStatus
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_RFIDPhidget
+ * Method: enableTagGainEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_RFIDPhidget_enableTagGainEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_RFIDPhidget
+ * Method: enableTagLossEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_RFIDPhidget_enableTagLossEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_RFIDPhidget
+ * Method: enableOutputChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_RFIDPhidget_enableOutputChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_ServoPhidget.c b/Java/com_phidgets_ServoPhidget.c
new file mode 100644
index 0000000..f016002
--- /dev/null
+++ b/Java/com_phidgets_ServoPhidget.c
@@ -0,0 +1,47 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_ServoPhidget.h"
+#include "../cphidgetservo.h"
+
+EVENT_VARS(servoPositionChange, ServoPositionChange)
+
+JNI_LOAD(servo, Servo)
+ EVENT_VAR_SETUP(servo, servoPositionChange, ServoPositionChange, ID, V)
+}
+
+EVENT_HANDLER_INDEXED(Servo, servoPositionChange, ServoPositionChange,
+ CPhidgetServo_set_OnPositionChange_Handler, double)
+
+JNI_CREATE(Servo)
+JNI_INDEXED_GETFUNC(Servo, Position, Position, jdouble)
+JNI_INDEXED_SETFUNC(Servo, Position, Position, jdouble)
+JNI_INDEXED_GETFUNC(Servo, PositionMin, PositionMin, jdouble)
+JNI_INDEXED_GETFUNC(Servo, PositionMax, PositionMax, jdouble)
+JNI_INDEXED_GETFUNCBOOL(Servo, Engaged, Engaged)
+JNI_INDEXED_SETFUNC(Servo, Engaged, Engaged, jboolean)
+JNI_GETFUNC(Servo, MotorCount, MotorCount, jint)
+JNIEXPORT jint JNICALL
+Java_com_phidgets_ServoPhidget_getServoType(JNIEnv *env, jobject obj, jint index)
+{
+ CPhidgetServoHandle h = (CPhidgetServoHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+ int error;
+ CPhidget_ServoType v;
+ if ((error = CPhidgetServo_getServoType(h, index, &v)))
+ PH_THROW(error);
+ return (jint)v;
+}
+JNI_INDEXED_SETFUNC(Servo, ServoType, ServoType, jint)
+JNIEXPORT void JNICALL
+Java_com_phidgets_ServoPhidget_setServoParameters(JNIEnv *env, jobject obj, jint index, jdouble minUs, jdouble maxUs, jdouble degrees)
+{
+ CPhidgetServoHandle h = (CPhidgetServoHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+ int error;
+ if ((error = CPhidgetServo_setServoParameters(h, index, minUs, maxUs, degrees)))
+ PH_THROW(error);
+}
+
+//Deprecated
+JNI_INDEXED_GETFUNCBOOL(Servo, MotorOn, Engaged)
+JNI_INDEXED_SETFUNC(Servo, MotorOn, Engaged, jboolean)
diff --git a/Java/com_phidgets_ServoPhidget.h b/Java/com_phidgets_ServoPhidget.h
new file mode 100644
index 0000000..17a7fc6
--- /dev/null
+++ b/Java/com_phidgets_ServoPhidget.h
@@ -0,0 +1,319 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_ServoPhidget */
+
+#ifndef _Included_com_phidgets_ServoPhidget
+#define _Included_com_phidgets_ServoPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_ServoPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_ServoPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_ServoPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_ServoPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_ServoPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_ServoPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_ServoPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_ServoPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_ServoPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_ServoPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_ServoPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_ServoPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_ServoPhidget_PHIDID_NOTHING
+#define com_phidgets_ServoPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_ServoPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_ServoPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_ServoPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_ServoPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_ServoPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_ServoPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_ServoPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_ServoPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_ServoPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_ServoPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_ServoPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_ServoPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_ServoPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_ServoPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_ServoPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_ServoPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_ServoPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_ServoPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_ServoPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_ServoPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_ServoPhidget_PHIDID_GPS
+#define com_phidgets_ServoPhidget_PHIDID_GPS 121L
+#undef com_phidgets_ServoPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_ServoPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_ServoPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_ServoPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_ServoPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_ServoPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_ServoPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_ServoPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_ServoPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_ServoPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_ServoPhidget_PHIDID_IR
+#define com_phidgets_ServoPhidget_PHIDID_IR 77L
+#undef com_phidgets_ServoPhidget_PHIDID_LED_64
+#define com_phidgets_ServoPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_ServoPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_ServoPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_ServoPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_ServoPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_ServoPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_ServoPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_ServoPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_ServoPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_ServoPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_ServoPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_ServoPhidget_PHIDID_PHSENSOR
+#define com_phidgets_ServoPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_ServoPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_ServoPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_ServoPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_ServoPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_ServoPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_ServoPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_ServoPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_ServoPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_ServoPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_ServoPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_ServoPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_ServoPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_ServoPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_ServoPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_ServoPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_ServoPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_ServoPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_ServoPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_ServoPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_ServoPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_ServoPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_ServoPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_ServoPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_ServoPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_ServoPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_ServoPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_ServoPhidget_PHIDID_RFID
+#define com_phidgets_ServoPhidget_PHIDID_RFID 48L
+#undef com_phidgets_ServoPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_ServoPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_ServoPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_ServoPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_ServoPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_ServoPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_ServoPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_ServoPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_ServoPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_ServoPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_ServoPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_ServoPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_ServoPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_ServoPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_ServoPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_ServoPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_ServoPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_ServoPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_ServoPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_ServoPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_ServoPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_ServoPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_ServoPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_GPS
+#define com_phidgets_ServoPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_ServoPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_LED
+#define com_phidgets_ServoPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_ServoPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_ServoPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_RFID
+#define com_phidgets_ServoPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_SERVO
+#define com_phidgets_ServoPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_ServoPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_ServoPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_ServoPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_ServoPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_ServoPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_ServoPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_DEFAULT
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_DEFAULT 1L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_RAW_us_MODE
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_RAW_us_MODE 2L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_HS322HD
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_HS322HD 3L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_HS5245MG
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_HS5245MG 4L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_805BB
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_805BB 5L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_HS422
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_HS422 6L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_TOWERPRO_MG90
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_TOWERPRO_MG90 7L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_HSR1425CR
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_HSR1425CR 8L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_HS785HB
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_HS785HB 9L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_HS485HB
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_HS485HB 10L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_HS645MG
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_HS645MG 11L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_815BB
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_HITEC_815BB 12L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_30_50_06_R
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_30_50_06_R 13L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_50_100_06_R
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_50_100_06_R 14L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_50_210_06_R
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_50_210_06_R 15L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_100_50_06_R
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_100_50_06_R 16L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_100_100_06_R
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_FIRGELLI_L12_100_100_06_R 17L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S2313M
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S2313M 18L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S3317M
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S3317M 19L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S3317SR
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S3317SR 20L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S4303R
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S4303R 21L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S4315M
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S4315M 22L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S4315R
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S4315R 23L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S4505B
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_SPRINGRC_SM_S4505B 24L
+#undef com_phidgets_ServoPhidget_PHIDGET_SERVO_USER_DEFINED
+#define com_phidgets_ServoPhidget_PHIDGET_SERVO_USER_DEFINED 25L
+/*
+ * Class: com_phidgets_ServoPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_ServoPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_ServoPhidget
+ * Method: getMotorCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_ServoPhidget_getMotorCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_ServoPhidget
+ * Method: getPosition
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_ServoPhidget_getPosition
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_ServoPhidget
+ * Method: getPositionMax
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_ServoPhidget_getPositionMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_ServoPhidget
+ * Method: getPositionMin
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_ServoPhidget_getPositionMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_ServoPhidget
+ * Method: setPosition
+ * Signature: (ID)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_ServoPhidget_setPosition
+ (JNIEnv *, jobject, jint, jdouble);
+
+/*
+ * Class: com_phidgets_ServoPhidget
+ * Method: setEngaged
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_ServoPhidget_setEngaged
+ (JNIEnv *, jobject, jint, jboolean);
+
+/*
+ * Class: com_phidgets_ServoPhidget
+ * Method: setMotorOn
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_ServoPhidget_setMotorOn
+ (JNIEnv *, jobject, jint, jboolean);
+
+/*
+ * Class: com_phidgets_ServoPhidget
+ * Method: getEngaged
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_ServoPhidget_getEngaged
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_ServoPhidget
+ * Method: getMotorOn
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_ServoPhidget_getMotorOn
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_ServoPhidget
+ * Method: getServoType
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_ServoPhidget_getServoType
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_ServoPhidget
+ * Method: setServoType
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_ServoPhidget_setServoType
+ (JNIEnv *, jobject, jint, jint);
+
+/*
+ * Class: com_phidgets_ServoPhidget
+ * Method: setServoParameters
+ * Signature: (IDDD)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_ServoPhidget_setServoParameters
+ (JNIEnv *, jobject, jint, jdouble, jdouble, jdouble);
+
+/*
+ * Class: com_phidgets_ServoPhidget
+ * Method: enableServoPositionChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_ServoPhidget_enableServoPositionChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_SpatialPhidget.c b/Java/com_phidgets_SpatialPhidget.c
new file mode 100644
index 0000000..361b989
--- /dev/null
+++ b/Java/com_phidgets_SpatialPhidget.c
@@ -0,0 +1,166 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_SpatialPhidget.h"
+#include "../cphidgetspatial.h"
+
+EVENT_VARS(spatialData, SpatialData)
+
+static jclass spatialEventData_class; //class
+static jmethodID spatialEventData_cons; //constructor
+
+JNI_LOAD(spatial, Spatial)
+ EVENT_VAR_SETUP(spatial, spatialData, SpatialData, [Lcom/phidgets/SpatialEventData;, V)
+
+ if (!(spatialEventData_class = (*env)->FindClass(env,"com/phidgets/SpatialEventData")))
+ JNI_ABORT_STDERR("Couldn't FindClass com/phidgets/SpatialEventData");
+ if (!(spatialEventData_class = (jclass)(*env)->NewGlobalRef(env, spatialEventData_class)))
+ JNI_ABORT_STDERR("Couldn't create global ref spatialEventData_class");
+ if (!(spatialEventData_cons = (*env)->GetMethodID(env, spatialEventData_class, "<init>", "([D[D[DII)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID <init> from spatialEventData_class");
+}
+
+//SpatialData event
+static int CCONV spatialData_handler(CPhidgetSpatialHandle h, void *arg, CPhidgetSpatial_SpatialEventDataHandle *, int);
+JNIEXPORT void JNICALL
+Java_com_phidgets_SpatialPhidget_enableSpatialDataEvents(JNIEnv *env, jobject obj, jboolean b)
+{
+ jlong gr = updateGlobalRef(env, obj, nativeSpatialDataHandler_fid, b);
+ CPhidgetSpatialHandle h = (CPhidgetSpatialHandle)(uintptr_t)(*env)->GetLongField(env, obj, handle_fid);
+ CPhidgetSpatial_set_OnSpatialData_Handler(h, b ? spatialData_handler : 0, (void *)(uintptr_t)gr);
+}
+static int CCONV
+spatialData_handler(CPhidgetSpatialHandle h, void *arg, CPhidgetSpatial_SpatialEventDataHandle *data, int dataLength)
+{
+ JNIEnv *env;
+ jobject obj;
+ jobject spatialDataEv;
+ jobjectArray jo;
+ int i, j;
+
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL))
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread");
+
+ obj = (jobject)arg;
+
+ //create and fill in short array
+ jo = (*env)->NewObjectArray(env, dataLength, spatialEventData_class, NULL);
+ if (!jo)
+ return -1;
+
+ for (i=0; i<dataLength; i++)
+ {
+ jdoubleArray accel, gyro, mag;
+ jdouble *datas;
+
+ //create and fill in data arrays
+ accel = (*env)->NewDoubleArray(env, h->phid.attr.spatial.numAccelAxes);
+ gyro = (*env)->NewDoubleArray(env, h->phid.attr.spatial.numGyroAxes);
+ mag = (*env)->NewDoubleArray(env, data[i]->magneticField[0]==PUNK_DBL?0:h->phid.attr.spatial.numCompassAxes);
+ if (!accel || !gyro || !mag)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return -1;
+ }
+ if(h->phid.attr.spatial.numAccelAxes)
+ {
+ datas = (*env)->GetDoubleArrayElements(env, accel, 0);
+ if (!datas)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return -1;
+ }
+ for (j=0; j<h->phid.attr.spatial.numAccelAxes; j++)
+ datas[j] = (jdouble)data[i]->acceleration[j];
+ (*env)->ReleaseDoubleArrayElements(env, accel, datas, 0);
+ }
+ if(h->phid.attr.spatial.numGyroAxes)
+ {
+ datas = (*env)->GetDoubleArrayElements(env, gyro, 0);
+ if (!datas)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return -1;
+ }
+ for (j=0; j<h->phid.attr.spatial.numGyroAxes; j++)
+ datas[j] = (jdouble)data[i]->angularRate[j];
+ (*env)->ReleaseDoubleArrayElements(env, gyro, datas, 0);
+ }
+ if(data[i]->magneticField[0]==PUNK_DBL?0:h->phid.attr.spatial.numCompassAxes)
+ {
+ datas = (*env)->GetDoubleArrayElements(env, mag, 0);
+ if (!datas)
+ {
+ PH_THROW(EPHIDGET_UNEXPECTED);
+ return -1;
+ }
+ for (j=0; j<h->phid.attr.spatial.numCompassAxes; j++)
+ datas[j] = (jdouble)data[i]->magneticField[j];
+ (*env)->ReleaseDoubleArrayElements(env, mag, datas, 0);
+ }
+
+ //create and add the SpatialEventData object to its array
+ (*env)->SetObjectArrayElement(env,jo,i,(*env)->NewObject(env, spatialEventData_class, spatialEventData_cons, accel, gyro, mag, data[i]->timestamp.seconds, data[i]->timestamp.microseconds));
+ }
+
+ if (!(spatialDataEv = (*env)->NewObject(env, spatialDataEvent_class, spatialDataEvent_cons, obj, jo)))
+ {
+ return -1;
+ }
+
+ (*env)->CallVoidMethod(env, obj, fireSpatialData_mid, spatialDataEv);
+
+ (*env)->DeleteLocalRef(env, spatialDataEv);
+ (*ph_vm)->DetachCurrentThread(ph_vm);
+
+ return 0;
+}
+
+JNI_CREATE(Spatial)
+
+JNI_INDEXED_GETFUNC(Spatial, AccelerationMax, AccelerationMax, jdouble)
+JNI_INDEXED_GETFUNC(Spatial, AccelerationMin, AccelerationMin, jdouble)
+JNI_INDEXED_GETFUNC(Spatial, Acceleration, Acceleration, jdouble)
+JNI_GETFUNC(Spatial, AccelerationAxisCount, AccelerationAxisCount, jint)
+
+JNI_INDEXED_GETFUNC(Spatial, AngularRateMax, AngularRateMax, jdouble)
+JNI_INDEXED_GETFUNC(Spatial, AngularRateMin, AngularRateMin, jdouble)
+JNI_INDEXED_GETFUNC(Spatial, AngularRate, AngularRate, jdouble)
+JNI_GETFUNC(Spatial, GyroAxisCount, GyroAxisCount, jint)
+
+JNI_INDEXED_GETFUNC(Spatial, MagneticFieldMax, MagneticFieldMax, jdouble)
+JNI_INDEXED_GETFUNC(Spatial, MagneticFieldMin, MagneticFieldMin, jdouble)
+JNI_INDEXED_GETFUNC(Spatial, MagneticField, MagneticField, jdouble)
+JNI_GETFUNC(Spatial, CompassAxisCount, CompassAxisCount, jint)
+
+JNI_GETFUNC(Spatial, DataRateMin, DataRateMin, jint)
+JNI_GETFUNC(Spatial, DataRateMax, DataRateMax, jint)
+JNI_GETFUNC(Spatial, DataRate, DataRate, jint)
+JNI_SETFUNC(Spatial, DataRate, DataRate, jint)
+
+JNIEXPORT void JNICALL Java_com_phidgets_SpatialPhidget_zeroGyro (JNIEnv *env, jobject obj)
+{
+ CPhidgetSpatialHandle h = (CPhidgetSpatialHandle)(uintptr_t)(*env)->GetLongField( env, obj, handle_fid);
+ int error;
+ if ((error = CPhidgetSpatial_zeroGyro(h)))
+ PH_THROW(error);
+}
+
+JNIEXPORT void JNICALL Java_com_phidgets_SpatialPhidget_setCompassCorrectionParameters (JNIEnv *env, jobject obj,
+ jdouble magField,
+ jdouble offset0, jdouble offset1, jdouble offset2,
+ jdouble gain0, jdouble gain1, jdouble gain2,
+ jdouble T0, jdouble T1, jdouble T2, jdouble T3, jdouble T4, jdouble T5)
+{
+ CPhidgetSpatialHandle h = (CPhidgetSpatialHandle)(uintptr_t)(*env)->GetLongField( env, obj, handle_fid);
+ int error;
+ if ((error = CPhidgetSpatial_setCompassCorrectionParameters(h, magField, offset0, offset1, offset2, gain0, gain1, gain2, T0, T1, T2, T3, T4, T5)))
+ PH_THROW(error);
+}
+
+JNIEXPORT void JNICALL Java_com_phidgets_SpatialPhidget_resetCompassCorrectionParameters (JNIEnv *env, jobject obj)
+{
+ CPhidgetSpatialHandle h = (CPhidgetSpatialHandle)(uintptr_t)(*env)->GetLongField( env, obj, handle_fid);
+ int error;
+ if ((error = CPhidgetSpatial_resetCompassCorrectionParameters(h)))
+ PH_THROW(error);
+}
diff --git a/Java/com_phidgets_SpatialPhidget.h b/Java/com_phidgets_SpatialPhidget.h
new file mode 100644
index 0000000..ef1ba3e
--- /dev/null
+++ b/Java/com_phidgets_SpatialPhidget.h
@@ -0,0 +1,325 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_SpatialPhidget */
+
+#ifndef _Included_com_phidgets_SpatialPhidget
+#define _Included_com_phidgets_SpatialPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_SpatialPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_SpatialPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_SpatialPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_SpatialPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_SpatialPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_SpatialPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_SpatialPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_SpatialPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_SpatialPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_SpatialPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_SpatialPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_SpatialPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_SpatialPhidget_PHIDID_NOTHING
+#define com_phidgets_SpatialPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_SpatialPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_SpatialPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_SpatialPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_SpatialPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_SpatialPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_SpatialPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_SpatialPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_SpatialPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_SpatialPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_SpatialPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_SpatialPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_SpatialPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_SpatialPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_SpatialPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_SpatialPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_SpatialPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_SpatialPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_SpatialPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_SpatialPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_SpatialPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_SpatialPhidget_PHIDID_GPS
+#define com_phidgets_SpatialPhidget_PHIDID_GPS 121L
+#undef com_phidgets_SpatialPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_SpatialPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_SpatialPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_SpatialPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_SpatialPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_SpatialPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_SpatialPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_SpatialPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_SpatialPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_SpatialPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_SpatialPhidget_PHIDID_IR
+#define com_phidgets_SpatialPhidget_PHIDID_IR 77L
+#undef com_phidgets_SpatialPhidget_PHIDID_LED_64
+#define com_phidgets_SpatialPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_SpatialPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_SpatialPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_SpatialPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_SpatialPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_SpatialPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_SpatialPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_SpatialPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_SpatialPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_SpatialPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_SpatialPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_SpatialPhidget_PHIDID_PHSENSOR
+#define com_phidgets_SpatialPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_SpatialPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_SpatialPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_SpatialPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_SpatialPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_SpatialPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_SpatialPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_SpatialPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_SpatialPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_SpatialPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_SpatialPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_SpatialPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_SpatialPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_SpatialPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_SpatialPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_SpatialPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_SpatialPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_SpatialPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_SpatialPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_SpatialPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_SpatialPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_SpatialPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_SpatialPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_SpatialPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_SpatialPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_SpatialPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_SpatialPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_SpatialPhidget_PHIDID_RFID
+#define com_phidgets_SpatialPhidget_PHIDID_RFID 48L
+#undef com_phidgets_SpatialPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_SpatialPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_SpatialPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_SpatialPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_SpatialPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_SpatialPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_SpatialPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_SpatialPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_SpatialPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_SpatialPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_SpatialPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_SpatialPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_SpatialPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_SpatialPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_SpatialPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_SpatialPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_SpatialPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_SpatialPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_SpatialPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_SpatialPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_SpatialPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_SpatialPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_SpatialPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_GPS
+#define com_phidgets_SpatialPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_SpatialPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_LED
+#define com_phidgets_SpatialPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_SpatialPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_SpatialPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_RFID
+#define com_phidgets_SpatialPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_SERVO
+#define com_phidgets_SpatialPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_SpatialPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_SpatialPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_SpatialPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_SpatialPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_SpatialPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_SpatialPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_SpatialPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: getAccelerationAxisCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_SpatialPhidget_getAccelerationAxisCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: getAcceleration
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_SpatialPhidget_getAcceleration
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: getAccelerationMax
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_SpatialPhidget_getAccelerationMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: getAccelerationMin
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_SpatialPhidget_getAccelerationMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: getGyroAxisCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_SpatialPhidget_getGyroAxisCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: getAngularRate
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_SpatialPhidget_getAngularRate
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: getAngularRateMax
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_SpatialPhidget_getAngularRateMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: getAngularRateMin
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_SpatialPhidget_getAngularRateMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: getCompassAxisCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_SpatialPhidget_getCompassAxisCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: getMagneticField
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_SpatialPhidget_getMagneticField
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: getMagneticFieldMax
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_SpatialPhidget_getMagneticFieldMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: getMagneticFieldMin
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_SpatialPhidget_getMagneticFieldMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: getDataRate
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_SpatialPhidget_getDataRate
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: setDataRate
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_SpatialPhidget_setDataRate
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: getDataRateMin
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_SpatialPhidget_getDataRateMin
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: getDataRateMax
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_SpatialPhidget_getDataRateMax
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: zeroGyro
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_SpatialPhidget_zeroGyro
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: setCompassCorrectionParameters
+ * Signature: (DDDDDDDDDDDDD)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_SpatialPhidget_setCompassCorrectionParameters
+ (JNIEnv *, jobject, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: resetCompassCorrectionParameters
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_SpatialPhidget_resetCompassCorrectionParameters
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_SpatialPhidget
+ * Method: enableSpatialDataEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_SpatialPhidget_enableSpatialDataEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_StepperPhidget.c b/Java/com_phidgets_StepperPhidget.c
new file mode 100644
index 0000000..bdc12a6
--- /dev/null
+++ b/Java/com_phidgets_StepperPhidget.c
@@ -0,0 +1,53 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_StepperPhidget.h"
+#include "../cphidgetstepper.h"
+
+EVENT_VARS(stepperPositionChange, StepperPositionChange)
+EVENT_VARS(inputChange, InputChange)
+EVENT_VARS(stepperVelocityChange, StepperVelocityChange)
+EVENT_VARS(currentChange, CurrentChange)
+
+JNI_LOAD(stepper, Stepper)
+ EVENT_VAR_SETUP(stepper, stepperPositionChange, StepperPositionChange, IJ, V)
+ EVENT_VAR_SETUP(stepper, inputChange, InputChange, IZ, V)
+ EVENT_VAR_SETUP(stepper, stepperVelocityChange, StepperVelocityChange, ID, V)
+ EVENT_VAR_SETUP(stepper, currentChange, CurrentChange, ID, V)
+}
+
+EVENT_HANDLER_INDEXED(Stepper, stepperPositionChange, StepperPositionChange,
+ CPhidgetStepper_set_OnPositionChange_Handler, long long)
+EVENT_HANDLER_INDEXED(Stepper, inputChange, InputChange,
+ CPhidgetStepper_set_OnInputChange_Handler, int)
+EVENT_HANDLER_INDEXED(Stepper, stepperVelocityChange, StepperVelocityChange,
+ CPhidgetStepper_set_OnVelocityChange_Handler, double)
+EVENT_HANDLER_INDEXED(Stepper, currentChange, CurrentChange,
+ CPhidgetStepper_set_OnCurrentChange_Handler, double)
+
+JNI_CREATE(Stepper)
+JNI_INDEXED_GETFUNC(Stepper, Acceleration, Acceleration, jdouble)
+JNI_INDEXED_SETFUNC(Stepper, Acceleration, Acceleration, jdouble)
+JNI_INDEXED_GETFUNC(Stepper, AccelerationMin, AccelerationMin, jdouble)
+JNI_INDEXED_GETFUNC(Stepper, AccelerationMax, AccelerationMax, jdouble)
+JNI_INDEXED_GETFUNC(Stepper, Velocity, Velocity, jdouble)
+JNI_INDEXED_SETFUNC(Stepper, VelocityLimit, VelocityLimit, jdouble)
+JNI_INDEXED_GETFUNC(Stepper, VelocityLimit, VelocityLimit, jdouble)
+JNI_INDEXED_GETFUNC(Stepper, VelocityMin, VelocityMin, jdouble)
+JNI_INDEXED_GETFUNC(Stepper, VelocityMax, VelocityMax, jdouble)
+JNI_INDEXED_GETFUNC(Stepper, TargetPosition, TargetPosition, jlong)
+JNI_INDEXED_SETFUNC(Stepper, TargetPosition, TargetPosition, jlong)
+JNI_INDEXED_GETFUNC(Stepper, CurrentPosition, CurrentPosition, jlong)
+JNI_INDEXED_SETFUNC(Stepper, CurrentPosition, CurrentPosition, jlong)
+JNI_INDEXED_GETFUNC(Stepper, PositionMin, PositionMin, jlong)
+JNI_INDEXED_GETFUNC(Stepper, PositionMax, PositionMax, jlong)
+JNI_INDEXED_GETFUNC(Stepper, Current, Current, jdouble)
+JNI_INDEXED_SETFUNC(Stepper, CurrentLimit, CurrentLimit, jdouble)
+JNI_INDEXED_GETFUNC(Stepper, CurrentLimit, CurrentLimit, jdouble)
+JNI_INDEXED_GETFUNC(Stepper, CurrentMin, CurrentMin, jdouble)
+JNI_INDEXED_GETFUNC(Stepper, CurrentMax, CurrentMax, jdouble)
+JNI_INDEXED_GETFUNCBOOL(Stepper, Stopped, Stopped)
+JNI_INDEXED_GETFUNCBOOL(Stepper, Engaged, Engaged)
+JNI_INDEXED_SETFUNC(Stepper, Engaged, Engaged, jboolean)
+JNI_INDEXED_GETFUNCBOOL(Stepper, InputState, InputState)
+JNI_GETFUNC(Stepper, MotorCount, MotorCount, jint)
+JNI_GETFUNC(Stepper, InputCount, InputCount, jint)
diff --git a/Java/com_phidgets_StepperPhidget.h b/Java/com_phidgets_StepperPhidget.h
new file mode 100644
index 0000000..a3fbfdd
--- /dev/null
+++ b/Java/com_phidgets_StepperPhidget.h
@@ -0,0 +1,405 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_StepperPhidget */
+
+#ifndef _Included_com_phidgets_StepperPhidget
+#define _Included_com_phidgets_StepperPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_StepperPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_StepperPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_StepperPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_StepperPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_StepperPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_StepperPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_StepperPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_StepperPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_StepperPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_StepperPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_StepperPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_StepperPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_StepperPhidget_PHIDID_NOTHING
+#define com_phidgets_StepperPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_StepperPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_StepperPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_StepperPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_StepperPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_StepperPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_StepperPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_StepperPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_StepperPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_StepperPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_StepperPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_StepperPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_StepperPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_StepperPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_StepperPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_StepperPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_StepperPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_StepperPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_StepperPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_StepperPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_StepperPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_StepperPhidget_PHIDID_GPS
+#define com_phidgets_StepperPhidget_PHIDID_GPS 121L
+#undef com_phidgets_StepperPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_StepperPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_StepperPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_StepperPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_StepperPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_StepperPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_StepperPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_StepperPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_StepperPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_StepperPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_StepperPhidget_PHIDID_IR
+#define com_phidgets_StepperPhidget_PHIDID_IR 77L
+#undef com_phidgets_StepperPhidget_PHIDID_LED_64
+#define com_phidgets_StepperPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_StepperPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_StepperPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_StepperPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_StepperPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_StepperPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_StepperPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_StepperPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_StepperPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_StepperPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_StepperPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_StepperPhidget_PHIDID_PHSENSOR
+#define com_phidgets_StepperPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_StepperPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_StepperPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_StepperPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_StepperPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_StepperPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_StepperPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_StepperPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_StepperPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_StepperPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_StepperPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_StepperPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_StepperPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_StepperPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_StepperPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_StepperPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_StepperPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_StepperPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_StepperPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_StepperPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_StepperPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_StepperPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_StepperPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_StepperPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_StepperPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_StepperPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_StepperPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_StepperPhidget_PHIDID_RFID
+#define com_phidgets_StepperPhidget_PHIDID_RFID 48L
+#undef com_phidgets_StepperPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_StepperPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_StepperPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_StepperPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_StepperPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_StepperPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_StepperPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_StepperPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_StepperPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_StepperPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_StepperPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_StepperPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_StepperPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_StepperPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_StepperPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_StepperPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_StepperPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_StepperPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_StepperPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_StepperPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_StepperPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_StepperPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_StepperPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_GPS
+#define com_phidgets_StepperPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_StepperPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_LED
+#define com_phidgets_StepperPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_StepperPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_StepperPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_RFID
+#define com_phidgets_StepperPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_SERVO
+#define com_phidgets_StepperPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_StepperPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_StepperPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_StepperPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_StepperPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_StepperPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_StepperPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_StepperPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getMotorCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_StepperPhidget_getMotorCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getInputCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_StepperPhidget_getInputCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getInputState
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_StepperPhidget_getInputState
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getAcceleration
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_StepperPhidget_getAcceleration
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getAccelerationMax
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_StepperPhidget_getAccelerationMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getAccelerationMin
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_StepperPhidget_getAccelerationMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: setAcceleration
+ * Signature: (ID)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_StepperPhidget_setAcceleration
+ (JNIEnv *, jobject, jint, jdouble);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getVelocity
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_StepperPhidget_getVelocity
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getVelocityMax
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_StepperPhidget_getVelocityMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getVelocityMin
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_StepperPhidget_getVelocityMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: setVelocityLimit
+ * Signature: (ID)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_StepperPhidget_setVelocityLimit
+ (JNIEnv *, jobject, jint, jdouble);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getVelocityLimit
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_StepperPhidget_getVelocityLimit
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getPositionMax
+ * Signature: (I)J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_StepperPhidget_getPositionMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getPositionMin
+ * Signature: (I)J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_StepperPhidget_getPositionMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: setCurrentPosition
+ * Signature: (IJ)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_StepperPhidget_setCurrentPosition
+ (JNIEnv *, jobject, jint, jlong);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getCurrentPosition
+ * Signature: (I)J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_StepperPhidget_getCurrentPosition
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: setTargetPosition
+ * Signature: (IJ)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_StepperPhidget_setTargetPosition
+ (JNIEnv *, jobject, jint, jlong);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getTargetPosition
+ * Signature: (I)J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_StepperPhidget_getTargetPosition
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getCurrent
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_StepperPhidget_getCurrent
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getCurrentLimit
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_StepperPhidget_getCurrentLimit
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: setCurrentLimit
+ * Signature: (ID)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_StepperPhidget_setCurrentLimit
+ (JNIEnv *, jobject, jint, jdouble);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getCurrentMax
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_StepperPhidget_getCurrentMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getCurrentMin
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_StepperPhidget_getCurrentMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: setEngaged
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_StepperPhidget_setEngaged
+ (JNIEnv *, jobject, jint, jboolean);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getEngaged
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_StepperPhidget_getEngaged
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: getStopped
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_StepperPhidget_getStopped
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: enableStepperPositionChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_StepperPhidget_enableStepperPositionChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: enableStepperVelocityChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_StepperPhidget_enableStepperVelocityChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: enableCurrentChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_StepperPhidget_enableCurrentChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_StepperPhidget
+ * Method: enableInputChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_StepperPhidget_enableInputChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_TemperatureSensorPhidget.c b/Java/com_phidgets_TemperatureSensorPhidget.c
new file mode 100644
index 0000000..233826b
--- /dev/null
+++ b/Java/com_phidgets_TemperatureSensorPhidget.c
@@ -0,0 +1,42 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_TemperatureSensorPhidget.h"
+#include "../cphidgettemperaturesensor.h"
+
+EVENT_VARS(temperatureChange, TemperatureChange)
+
+JNI_LOAD(temp, TemperatureSensor)
+ EVENT_VAR_SETUP(temp, temperatureChange, TemperatureChange, ID, V)
+}
+
+EVENT_HANDLER_INDEXED(TemperatureSensor, temperatureChange, TemperatureChange,
+ CPhidgetTemperatureSensor_set_OnTemperatureChange_Handler, double)
+
+JNI_CREATE(TemperatureSensor)
+JNI_INDEXED_GETFUNC(TemperatureSensor, TemperatureChangeTrigger, TemperatureChangeTrigger, jdouble)
+JNI_INDEXED_SETFUNC(TemperatureSensor, TemperatureChangeTrigger, TemperatureChangeTrigger, jdouble)
+JNIEXPORT jint JNICALL
+Java_com_phidgets_TemperatureSensorPhidget_getThermocoupleType(JNIEnv *env, jobject obj, jint index)
+{
+ CPhidgetTemperatureSensorHandle h = (CPhidgetTemperatureSensorHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+ int error;
+ CPhidgetTemperatureSensor_ThermocoupleType v;
+ if ((error = CPhidgetTemperatureSensor_getThermocoupleType(h, index, &v)))
+ PH_THROW(error);
+ return (jint)v;
+}
+JNI_INDEXED_SETFUNC(TemperatureSensor, ThermocoupleType, ThermocoupleType, jint)
+JNI_INDEXED_GETFUNC(TemperatureSensor, Temperature, Temperature, jdouble)
+JNI_INDEXED_GETFUNC(TemperatureSensor, TemperatureMin, TemperatureMin, jdouble)
+JNI_INDEXED_GETFUNC(TemperatureSensor, TemperatureMax, TemperatureMax, jdouble)
+JNI_INDEXED_GETFUNC(TemperatureSensor, Potential, Potential, jdouble)
+JNI_INDEXED_GETFUNC(TemperatureSensor, PotentialMin, PotentialMin, jdouble)
+JNI_INDEXED_GETFUNC(TemperatureSensor, PotentialMax, PotentialMax, jdouble)
+JNI_GETFUNC(TemperatureSensor, AmbientTemperature, AmbientTemperature, jdouble)
+JNI_GETFUNC(TemperatureSensor, AmbientTemperatureMin, AmbientTemperatureMin, jdouble)
+JNI_GETFUNC(TemperatureSensor, AmbientTemperatureMax, AmbientTemperatureMax, jdouble)
+JNI_GETFUNC(TemperatureSensor, TemperatureInputCount, TemperatureInputCount, jint)
+
+//Deprecated
+JNI_GETFUNC(TemperatureSensor, SensorCount, TemperatureInputCount, jint)
diff --git a/Java/com_phidgets_TemperatureSensorPhidget.h b/Java/com_phidgets_TemperatureSensorPhidget.h
new file mode 100644
index 0000000..dba8b34
--- /dev/null
+++ b/Java/com_phidgets_TemperatureSensorPhidget.h
@@ -0,0 +1,301 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_TemperatureSensorPhidget */
+
+#ifndef _Included_com_phidgets_TemperatureSensorPhidget
+#define _Included_com_phidgets_TemperatureSensorPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_TemperatureSensorPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_TemperatureSensorPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_TemperatureSensorPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_TemperatureSensorPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_TemperatureSensorPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_TemperatureSensorPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_TemperatureSensorPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_NOTHING
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_GPS
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_GPS 121L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_IR
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_IR 77L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_LED_64
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_PHSENSOR
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_RFID
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_RFID 48L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_TemperatureSensorPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_GPS
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_LED
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_RFID
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_SERVO
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_TemperatureSensorPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDGET_TEMPERATURE_SENSOR_K_TYPE
+#define com_phidgets_TemperatureSensorPhidget_PHIDGET_TEMPERATURE_SENSOR_K_TYPE 1L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDGET_TEMPERATURE_SENSOR_J_TYPE
+#define com_phidgets_TemperatureSensorPhidget_PHIDGET_TEMPERATURE_SENSOR_J_TYPE 2L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDGET_TEMPERATURE_SENSOR_E_TYPE
+#define com_phidgets_TemperatureSensorPhidget_PHIDGET_TEMPERATURE_SENSOR_E_TYPE 3L
+#undef com_phidgets_TemperatureSensorPhidget_PHIDGET_TEMPERATURE_SENSOR_T_TYPE
+#define com_phidgets_TemperatureSensorPhidget_PHIDGET_TEMPERATURE_SENSOR_T_TYPE 4L
+/*
+ * Class: com_phidgets_TemperatureSensorPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_TemperatureSensorPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_TemperatureSensorPhidget
+ * Method: getTemperatureInputCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_TemperatureSensorPhidget_getTemperatureInputCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TemperatureSensorPhidget
+ * Method: getSensorCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_TemperatureSensorPhidget_getSensorCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TemperatureSensorPhidget
+ * Method: getTemperature
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_TemperatureSensorPhidget_getTemperature
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_TemperatureSensorPhidget
+ * Method: getTemperatureMax
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_TemperatureSensorPhidget_getTemperatureMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_TemperatureSensorPhidget
+ * Method: getTemperatureMin
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_TemperatureSensorPhidget_getTemperatureMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_TemperatureSensorPhidget
+ * Method: getAmbientTemperature
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_TemperatureSensorPhidget_getAmbientTemperature
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TemperatureSensorPhidget
+ * Method: getAmbientTemperatureMax
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_TemperatureSensorPhidget_getAmbientTemperatureMax
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TemperatureSensorPhidget
+ * Method: getAmbientTemperatureMin
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_TemperatureSensorPhidget_getAmbientTemperatureMin
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TemperatureSensorPhidget
+ * Method: getPotential
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_TemperatureSensorPhidget_getPotential
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_TemperatureSensorPhidget
+ * Method: getPotentialMax
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_TemperatureSensorPhidget_getPotentialMax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_TemperatureSensorPhidget
+ * Method: getPotentialMin
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_TemperatureSensorPhidget_getPotentialMin
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_TemperatureSensorPhidget
+ * Method: setTemperatureChangeTrigger
+ * Signature: (ID)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_TemperatureSensorPhidget_setTemperatureChangeTrigger
+ (JNIEnv *, jobject, jint, jdouble);
+
+/*
+ * Class: com_phidgets_TemperatureSensorPhidget
+ * Method: getTemperatureChangeTrigger
+ * Signature: (I)D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_TemperatureSensorPhidget_getTemperatureChangeTrigger
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_TemperatureSensorPhidget
+ * Method: getThermocoupleType
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_TemperatureSensorPhidget_getThermocoupleType
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_TemperatureSensorPhidget
+ * Method: setThermocoupleType
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_TemperatureSensorPhidget_setThermocoupleType
+ (JNIEnv *, jobject, jint, jint);
+
+/*
+ * Class: com_phidgets_TemperatureSensorPhidget
+ * Method: enableTemperatureChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_TemperatureSensorPhidget_enableTemperatureChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_TextLCDPhidget.c b/Java/com_phidgets_TextLCDPhidget.c
new file mode 100644
index 0000000..a917bfd
--- /dev/null
+++ b/Java/com_phidgets_TextLCDPhidget.c
@@ -0,0 +1,97 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_TextLCDPhidget.h"
+#include "../cphidgettextlcd.h"
+
+JNI_LOAD(lcd, TextLCD)
+}
+
+JNI_CREATE(TextLCD)
+JNI_GETFUNCBOOL(TextLCD, Backlight, Backlight)
+JNI_SETFUNC(TextLCD, Backlight, Backlight, jboolean)
+JNI_GETFUNC(TextLCD, Contrast, Contrast, jint)
+JNI_SETFUNC(TextLCD, Contrast, Contrast, jint)
+JNI_GETFUNC(TextLCD, Brightness, Brightness, jint)
+JNI_SETFUNC(TextLCD, Brightness, Brightness, jint)
+JNI_GETFUNCBOOL(TextLCD, Cursor, CursorOn)
+JNI_SETFUNC(TextLCD, Cursor, CursorOn, jboolean)
+JNI_GETFUNCBOOL(TextLCD, CursorBlink, CursorBlink)
+JNI_SETFUNC(TextLCD, CursorBlink, CursorBlink, jboolean)
+JNI_GETFUNC(TextLCD, RowCount, RowCount, jint)
+JNI_GETFUNC(TextLCD, ColumnCount, ColumnCount, jint)
+JNI_GETFUNC(TextLCD, ScreenCount, ScreenCount, jint)
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_TextLCDPhidget_setDisplayString(JNIEnv *env, jobject obj, jint index, jstring v)
+{
+ CPhidgetTextLCDHandle h = (CPhidgetTextLCDHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+ int error, i;
+ jboolean iscopy;
+ char string[TEXTLCD_MAXCOLS+2];
+
+ //we can't use GetStringUTFChars here because it converts the UTF-16 to UTF-8 and this screws up the 0x80-0xFF characters
+ const jchar *textString = (*env)->GetStringChars(env, v, &iscopy);
+
+ for(i=0;i<TEXTLCD_MAXCOLS+2;i++)
+ {
+ string[i] = (char)textString[i];
+ if(!textString[i])
+ break;
+ }
+ string[TEXTLCD_MAXCOLS+1] = '\0';
+
+ if ((error = CPhidgetTextLCD_setDisplayString(h, index, (char *)string)))
+ PH_THROW(error);
+
+ (*env)->ReleaseStringChars(env, v, textString);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_TextLCDPhidget_setDisplayCharacter(JNIEnv *env, jobject obj, jint row, jint column, jchar v)
+{
+ CPhidgetTextLCDHandle h = (CPhidgetTextLCDHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+ int error;
+
+ if ((error = CPhidgetTextLCD_setDisplayCharacter(h, row, column, (char)v)))
+ PH_THROW(error);
+}
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_TextLCDPhidget_setCustomCharacter(JNIEnv *env, jobject obj, jint index, jint v, jint v2)
+{
+ CPhidgetTextLCDHandle h = (CPhidgetTextLCDHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+ int error;
+ if ((error = CPhidgetTextLCD_setCustomCharacter(h, index, v, v2)))
+ PH_THROW(error);
+}
+
+JNI_GETFUNC(TextLCD, Screen, Screen, jint)
+JNI_SETFUNC(TextLCD, Screen, Screen, jint)
+
+JNIEXPORT jint JNICALL
+Java_com_phidgets_TextLCDPhidget_getScreenSize(JNIEnv *env, jobject obj)
+{
+ CPhidgetTextLCDHandle h = (CPhidgetTextLCDHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+ int error;
+ CPhidgetTextLCD_ScreenSize v;
+ if ((error = CPhidgetTextLCD_getScreenSize(h, &v)))
+ PH_THROW(error);
+ return (jint)v;
+}
+
+JNI_SETFUNC(TextLCD, ScreenSize, ScreenSize, jint)
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_TextLCDPhidget_initialize(JNIEnv *env, jobject obj)
+{
+ CPhidgetTextLCDHandle h = (CPhidgetTextLCDHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+ int error;
+
+ if ((error = CPhidgetTextLCD_initialize(h)))
+ PH_THROW(error);
+}
diff --git a/Java/com_phidgets_TextLCDPhidget.h b/Java/com_phidgets_TextLCDPhidget.h
new file mode 100644
index 0000000..d96d7b1
--- /dev/null
+++ b/Java/com_phidgets_TextLCDPhidget.h
@@ -0,0 +1,359 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_TextLCDPhidget */
+
+#ifndef _Included_com_phidgets_TextLCDPhidget
+#define _Included_com_phidgets_TextLCDPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_TextLCDPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_TextLCDPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_TextLCDPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_TextLCDPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_TextLCDPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_TextLCDPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_TextLCDPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_TextLCDPhidget_PHIDID_NOTHING
+#define com_phidgets_TextLCDPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_TextLCDPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_TextLCDPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_TextLCDPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_TextLCDPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_TextLCDPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_TextLCDPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_TextLCDPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_TextLCDPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_TextLCDPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_TextLCDPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_TextLCDPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_TextLCDPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_TextLCDPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_TextLCDPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_TextLCDPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_TextLCDPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_TextLCDPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_TextLCDPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_TextLCDPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_TextLCDPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_TextLCDPhidget_PHIDID_GPS
+#define com_phidgets_TextLCDPhidget_PHIDID_GPS 121L
+#undef com_phidgets_TextLCDPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_TextLCDPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_TextLCDPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_TextLCDPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_TextLCDPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_TextLCDPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_TextLCDPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_TextLCDPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_TextLCDPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_TextLCDPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_TextLCDPhidget_PHIDID_IR
+#define com_phidgets_TextLCDPhidget_PHIDID_IR 77L
+#undef com_phidgets_TextLCDPhidget_PHIDID_LED_64
+#define com_phidgets_TextLCDPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_TextLCDPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_TextLCDPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_TextLCDPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_TextLCDPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_TextLCDPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_TextLCDPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_TextLCDPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_TextLCDPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_TextLCDPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_TextLCDPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_TextLCDPhidget_PHIDID_PHSENSOR
+#define com_phidgets_TextLCDPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_TextLCDPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_TextLCDPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_TextLCDPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_TextLCDPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_TextLCDPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_TextLCDPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_TextLCDPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_TextLCDPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_TextLCDPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_TextLCDPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_TextLCDPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_TextLCDPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_TextLCDPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_TextLCDPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_TextLCDPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_TextLCDPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_TextLCDPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_TextLCDPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_TextLCDPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_TextLCDPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_TextLCDPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_TextLCDPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_TextLCDPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_TextLCDPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_TextLCDPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_TextLCDPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_TextLCDPhidget_PHIDID_RFID
+#define com_phidgets_TextLCDPhidget_PHIDID_RFID 48L
+#undef com_phidgets_TextLCDPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_TextLCDPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_TextLCDPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_TextLCDPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_TextLCDPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_TextLCDPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_TextLCDPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_TextLCDPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_TextLCDPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_TextLCDPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_TextLCDPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_TextLCDPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_TextLCDPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_TextLCDPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_TextLCDPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_TextLCDPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_GPS
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_LED
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_RFID
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_SERVO
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_TextLCDPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_TextLCDPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_NONE
+#define com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_NONE 1L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_1x8
+#define com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_1x8 2L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_2x8
+#define com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_2x8 3L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_1x16
+#define com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_1x16 4L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_2x16
+#define com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_2x16 5L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_4x16
+#define com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_4x16 6L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_2x20
+#define com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_2x20 7L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_4x20
+#define com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_4x20 8L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_2x24
+#define com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_2x24 9L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_1x40
+#define com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_1x40 10L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_2x40
+#define com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_2x40 11L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_4x40
+#define com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_4x40 12L
+#undef com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_UNKNOWN
+#define com_phidgets_TextLCDPhidget_PHIDGET_TEXTLCD_SCREEN_UNKNOWN 13L
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_TextLCDPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: getRowCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_TextLCDPhidget_getRowCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: getColumnCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_TextLCDPhidget_getColumnCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: getScreenCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_TextLCDPhidget_getScreenCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: getScreen
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_TextLCDPhidget_getScreen
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: setScreen
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_TextLCDPhidget_setScreen
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: getScreenSize
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_TextLCDPhidget_getScreenSize
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: setScreenSize
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_TextLCDPhidget_setScreenSize
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: getContrast
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_TextLCDPhidget_getContrast
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: setContrast
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_TextLCDPhidget_setContrast
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: getBrightness
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_TextLCDPhidget_getBrightness
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: setBrightness
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_TextLCDPhidget_setBrightness
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: getBacklight
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_TextLCDPhidget_getBacklight
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: setBacklight
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_TextLCDPhidget_setBacklight
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: getCursor
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_TextLCDPhidget_getCursor
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: setCursor
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_TextLCDPhidget_setCursor
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: getCursorBlink
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_phidgets_TextLCDPhidget_getCursorBlink
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: setCursorBlink
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_TextLCDPhidget_setCursorBlink
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: setDisplayString
+ * Signature: (ILjava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_TextLCDPhidget_setDisplayString
+ (JNIEnv *, jobject, jint, jstring);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: setDisplayCharacter
+ * Signature: (IIC)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_TextLCDPhidget_setDisplayCharacter
+ (JNIEnv *, jobject, jint, jint, jchar);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: setCustomCharacter
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_TextLCDPhidget_setCustomCharacter
+ (JNIEnv *, jobject, jint, jint, jint);
+
+/*
+ * Class: com_phidgets_TextLCDPhidget
+ * Method: initialize
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_TextLCDPhidget_initialize
+ (JNIEnv *, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_TextLEDPhidget.c b/Java/com_phidgets_TextLEDPhidget.c
new file mode 100644
index 0000000..f6f139c
--- /dev/null
+++ b/Java/com_phidgets_TextLEDPhidget.c
@@ -0,0 +1,29 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_TextLEDPhidget.h"
+#include "../cphidgettextled.h"
+
+JNI_LOAD(led, TextLED)
+}
+
+JNI_CREATE(TextLED)
+JNI_GETFUNC(TextLED, Brightness, Brightness, jint)
+JNI_SETFUNC(TextLED, Brightness, Brightness, jint)
+JNI_GETFUNC(TextLED, RowCount, RowCount, jint)
+JNI_GETFUNC(TextLED, ColumnCount, ColumnCount, jint)
+
+JNIEXPORT void JNICALL
+Java_com_phidgets_TextLEDPhidget_setDisplayString(JNIEnv *env, jobject obj, jint index, jstring v)
+{
+ CPhidgetTextLEDHandle h = (CPhidgetTextLEDHandle)(uintptr_t)
+ (*env)->GetLongField(env, obj, handle_fid);
+ int error;
+ jboolean iscopy;
+ const char *textString = (*env)->GetStringUTFChars(
+ env, v, &iscopy);
+
+ if ((error = CPhidgetTextLED_setDisplayString(h, index, (char *)textString)))
+ PH_THROW(error);
+
+ (*env)->ReleaseStringUTFChars(env, v, textString);
+}
diff --git a/Java/com_phidgets_TextLEDPhidget.h b/Java/com_phidgets_TextLEDPhidget.h
new file mode 100644
index 0000000..b62ffa1
--- /dev/null
+++ b/Java/com_phidgets_TextLEDPhidget.h
@@ -0,0 +1,205 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_TextLEDPhidget */
+
+#ifndef _Included_com_phidgets_TextLEDPhidget
+#define _Included_com_phidgets_TextLEDPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_TextLEDPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_TextLEDPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_TextLEDPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_TextLEDPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_TextLEDPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_TextLEDPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_TextLEDPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_TextLEDPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_TextLEDPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_TextLEDPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_TextLEDPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_TextLEDPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_TextLEDPhidget_PHIDID_NOTHING
+#define com_phidgets_TextLEDPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_TextLEDPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_TextLEDPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_TextLEDPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_TextLEDPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_TextLEDPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_TextLEDPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_TextLEDPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_TextLEDPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_TextLEDPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_TextLEDPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_TextLEDPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_TextLEDPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_TextLEDPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_TextLEDPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_TextLEDPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_TextLEDPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_TextLEDPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_TextLEDPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_TextLEDPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_TextLEDPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_TextLEDPhidget_PHIDID_GPS
+#define com_phidgets_TextLEDPhidget_PHIDID_GPS 121L
+#undef com_phidgets_TextLEDPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_TextLEDPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_TextLEDPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_TextLEDPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_TextLEDPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_TextLEDPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_TextLEDPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_TextLEDPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_TextLEDPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_TextLEDPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_TextLEDPhidget_PHIDID_IR
+#define com_phidgets_TextLEDPhidget_PHIDID_IR 77L
+#undef com_phidgets_TextLEDPhidget_PHIDID_LED_64
+#define com_phidgets_TextLEDPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_TextLEDPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_TextLEDPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_TextLEDPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_TextLEDPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_TextLEDPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_TextLEDPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_TextLEDPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_TextLEDPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_TextLEDPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_TextLEDPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_TextLEDPhidget_PHIDID_PHSENSOR
+#define com_phidgets_TextLEDPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_TextLEDPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_TextLEDPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_TextLEDPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_TextLEDPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_TextLEDPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_TextLEDPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_TextLEDPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_TextLEDPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_TextLEDPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_TextLEDPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_TextLEDPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_TextLEDPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_TextLEDPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_TextLEDPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_TextLEDPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_TextLEDPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_TextLEDPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_TextLEDPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_TextLEDPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_TextLEDPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_TextLEDPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_TextLEDPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_TextLEDPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_TextLEDPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_TextLEDPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_TextLEDPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_TextLEDPhidget_PHIDID_RFID
+#define com_phidgets_TextLEDPhidget_PHIDID_RFID 48L
+#undef com_phidgets_TextLEDPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_TextLEDPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_TextLEDPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_TextLEDPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_TextLEDPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_TextLEDPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_TextLEDPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_TextLEDPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_TextLEDPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_TextLEDPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_TextLEDPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_TextLEDPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_TextLEDPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_TextLEDPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_TextLEDPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_TextLEDPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_GPS
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_LED
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_RFID
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_SERVO
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_TextLEDPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_TextLEDPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+/*
+ * Class: com_phidgets_TextLEDPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_TextLEDPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_TextLEDPhidget
+ * Method: getRowCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_TextLEDPhidget_getRowCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TextLEDPhidget
+ * Method: getColumnCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_TextLEDPhidget_getColumnCount
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TextLEDPhidget
+ * Method: getBrightness
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_phidgets_TextLEDPhidget_getBrightness
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_TextLEDPhidget
+ * Method: setBrightness
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_TextLEDPhidget_setBrightness
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_phidgets_TextLEDPhidget
+ * Method: setDisplayString
+ * Signature: (ILjava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_TextLEDPhidget_setDisplayString
+ (JNIEnv *, jobject, jint, jstring);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/com_phidgets_WeightSensorPhidget.c b/Java/com_phidgets_WeightSensorPhidget.c
new file mode 100644
index 0000000..59a88bd
--- /dev/null
+++ b/Java/com_phidgets_WeightSensorPhidget.c
@@ -0,0 +1,18 @@
+#include "../stdafx.h"
+#include "phidget_jni.h"
+#include "com_phidgets_WeightSensorPhidget.h"
+#include "../cphidgetweightsensor.h"
+
+EVENT_VARS(weightChange, WeightChange)
+
+JNI_LOAD(weight, WeightSensor)
+ EVENT_VAR_SETUP(weight, weightChange, WeightChange, D, V)
+}
+
+EVENT_HANDLER(WeightSensor, weightChange, WeightChange,
+ CPhidgetWeightSensor_set_OnWeightChange_Handler, double)
+
+JNI_CREATE(WeightSensor)
+JNI_GETFUNC(WeightSensor, WeightChangeTrigger, WeightChangeTrigger, jdouble)
+JNI_SETFUNC(WeightSensor, WeightChangeTrigger, WeightChangeTrigger, jdouble)
+JNI_GETFUNC(WeightSensor, Weight, Weight, jdouble)
diff --git a/Java/com_phidgets_WeightSensorPhidget.h b/Java/com_phidgets_WeightSensorPhidget.h
new file mode 100644
index 0000000..2de6bde
--- /dev/null
+++ b/Java/com_phidgets_WeightSensorPhidget.h
@@ -0,0 +1,197 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_phidgets_WeightSensorPhidget */
+
+#ifndef _Included_com_phidgets_WeightSensorPhidget
+#define _Included_com_phidgets_WeightSensorPhidget
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_phidgets_WeightSensorPhidget_PHIDGET_LOG_CRITICAL
+#define com_phidgets_WeightSensorPhidget_PHIDGET_LOG_CRITICAL 1L
+#undef com_phidgets_WeightSensorPhidget_PHIDGET_LOG_ERROR
+#define com_phidgets_WeightSensorPhidget_PHIDGET_LOG_ERROR 2L
+#undef com_phidgets_WeightSensorPhidget_PHIDGET_LOG_WARNING
+#define com_phidgets_WeightSensorPhidget_PHIDGET_LOG_WARNING 3L
+#undef com_phidgets_WeightSensorPhidget_PHIDGET_LOG_DEBUG
+#define com_phidgets_WeightSensorPhidget_PHIDGET_LOG_DEBUG 4L
+#undef com_phidgets_WeightSensorPhidget_PHIDGET_LOG_INFO
+#define com_phidgets_WeightSensorPhidget_PHIDGET_LOG_INFO 5L
+#undef com_phidgets_WeightSensorPhidget_PHIDGET_LOG_VERBOSE
+#define com_phidgets_WeightSensorPhidget_PHIDGET_LOG_VERBOSE 6L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_NOTHING
+#define com_phidgets_WeightSensorPhidget_PHIDID_NOTHING 1L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_ACCELEROMETER_3AXIS
+#define com_phidgets_WeightSensorPhidget_PHIDID_ACCELEROMETER_3AXIS 126L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_ADVANCEDSERVO_1MOTOR
+#define com_phidgets_WeightSensorPhidget_PHIDID_ADVANCEDSERVO_1MOTOR 130L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_ANALOG_4OUTPUT
+#define com_phidgets_WeightSensorPhidget_PHIDID_ANALOG_4OUTPUT 55L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_ADVANCEDSERVO_8MOTOR
+#define com_phidgets_WeightSensorPhidget_PHIDID_ADVANCEDSERVO_8MOTOR 58L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR
+#define com_phidgets_WeightSensorPhidget_PHIDID_BIPOLAR_STEPPER_1MOTOR 123L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_BRIDGE_4INPUT
+#define com_phidgets_WeightSensorPhidget_PHIDID_BRIDGE_4INPUT 59L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_ENCODER_1ENCODER_1INPUT
+#define com_phidgets_WeightSensorPhidget_PHIDID_ENCODER_1ENCODER_1INPUT 75L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_ENCODER_HS_1ENCODER
+#define com_phidgets_WeightSensorPhidget_PHIDID_ENCODER_HS_1ENCODER 128L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT
+#define com_phidgets_WeightSensorPhidget_PHIDID_ENCODER_HS_4ENCODER_4INPUT 79L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT
+#define com_phidgets_WeightSensorPhidget_PHIDID_FREQUENCYCOUNTER_2INPUT 53L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_GPS
+#define com_phidgets_WeightSensorPhidget_PHIDID_GPS 121L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_INTERFACEKIT_0_0_4
+#define com_phidgets_WeightSensorPhidget_PHIDID_INTERFACEKIT_0_0_4 64L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_INTERFACEKIT_0_0_8
+#define com_phidgets_WeightSensorPhidget_PHIDID_INTERFACEKIT_0_0_8 129L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_INTERFACEKIT_0_16_16
+#define com_phidgets_WeightSensorPhidget_PHIDID_INTERFACEKIT_0_16_16 68L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_INTERFACEKIT_8_8_8
+#define com_phidgets_WeightSensorPhidget_PHIDID_INTERFACEKIT_8_8_8 69L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD
+#define com_phidgets_WeightSensorPhidget_PHIDID_INTERFACEKIT_8_8_8_w_LCD 125L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_IR
+#define com_phidgets_WeightSensorPhidget_PHIDID_IR 77L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_LED_64
+#define com_phidgets_WeightSensorPhidget_PHIDID_LED_64 74L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_LED_64_ADV
+#define com_phidgets_WeightSensorPhidget_PHIDID_LED_64_ADV 76L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_LINEAR_TOUCH
+#define com_phidgets_WeightSensorPhidget_PHIDID_LINEAR_TOUCH 118L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR
+#define com_phidgets_WeightSensorPhidget_PHIDID_MOTORCONTROL_HC_2MOTOR 89L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
+#define com_phidgets_WeightSensorPhidget_PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT 88L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_MOTORCONTROL_1MOTOR
+#define com_phidgets_WeightSensorPhidget_PHIDID_MOTORCONTROL_1MOTOR 62L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_PHSENSOR
+#define com_phidgets_WeightSensorPhidget_PHIDID_PHSENSOR 116L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_RFID_2OUTPUT
+#define com_phidgets_WeightSensorPhidget_PHIDID_RFID_2OUTPUT 49L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_ROTARY_TOUCH
+#define com_phidgets_WeightSensorPhidget_PHIDID_ROTARY_TOUCH 119L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_SERVO_1MOTOR
+#define com_phidgets_WeightSensorPhidget_PHIDID_SERVO_1MOTOR 57L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_SPATIAL_ACCEL_3AXIS
+#define com_phidgets_WeightSensorPhidget_PHIDID_SPATIAL_ACCEL_3AXIS 127L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
+#define com_phidgets_WeightSensorPhidget_PHIDID_SPATIAL_ACCEL_GYRO_COMPASS 51L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_TEMPERATURESENSOR
+#define com_phidgets_WeightSensorPhidget_PHIDID_TEMPERATURESENSOR 112L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_TEMPERATURESENSOR_4
+#define com_phidgets_WeightSensorPhidget_PHIDID_TEMPERATURESENSOR_4 50L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8
+#define com_phidgets_WeightSensorPhidget_PHIDID_TEXTLCD_2x20_w_8_8_8 381L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_TEXTLCD_ADAPTER
+#define com_phidgets_WeightSensorPhidget_PHIDID_TEXTLCD_ADAPTER 61L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR
+#define com_phidgets_WeightSensorPhidget_PHIDID_UNIPOLAR_STEPPER_4MOTOR 122L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_ACCELEROMETER_2AXIS
+#define com_phidgets_WeightSensorPhidget_PHIDID_ACCELEROMETER_2AXIS 113L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD
+#define com_phidgets_WeightSensorPhidget_PHIDID_INTERFACEKIT_0_8_8_w_LCD 83L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_INTERFACEKIT_4_8_8
+#define com_phidgets_WeightSensorPhidget_PHIDID_INTERFACEKIT_4_8_8 4L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_RFID
+#define com_phidgets_WeightSensorPhidget_PHIDID_RFID 48L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_SERVO_1MOTOR_OLD
+#define com_phidgets_WeightSensorPhidget_PHIDID_SERVO_1MOTOR_OLD 2L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_SERVO_4MOTOR
+#define com_phidgets_WeightSensorPhidget_PHIDID_SERVO_4MOTOR 56L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_SERVO_4MOTOR_OLD
+#define com_phidgets_WeightSensorPhidget_PHIDID_SERVO_4MOTOR_OLD 3L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_TEXTLCD_2x20
+#define com_phidgets_WeightSensorPhidget_PHIDID_TEXTLCD_2x20 82L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8
+#define com_phidgets_WeightSensorPhidget_PHIDID_TEXTLCD_2x20_w_0_8_8 339L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_TEXTLED_1x8
+#define com_phidgets_WeightSensorPhidget_PHIDID_TEXTLED_1x8 73L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_TEXTLED_4x8
+#define com_phidgets_WeightSensorPhidget_PHIDID_TEXTLED_4x8 72L
+#undef com_phidgets_WeightSensorPhidget_PHIDID_WEIGHTSENSOR
+#define com_phidgets_WeightSensorPhidget_PHIDID_WEIGHTSENSOR 114L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_NOTHING
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_NOTHING 1L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_ACCELEROMETER
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_ACCELEROMETER 2L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_ADVANCEDSERVO
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_ADVANCEDSERVO 3L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_ANALOG
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_ANALOG 22L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_BRIDGE
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_BRIDGE 23L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_ENCODER
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_ENCODER 4L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_FREQUENCYCOUNTER
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_FREQUENCYCOUNTER 21L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_GPS
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_GPS 5L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_INTERFACEKIT
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_INTERFACEKIT 7L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_LED
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_LED 8L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_MOTORCONTROL
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_MOTORCONTROL 9L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_PHSENSOR
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_PHSENSOR 10L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_RFID
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_RFID 11L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_SERVO
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_SERVO 12L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_STEPPER
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_STEPPER 13L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_TEMPERATURESENSOR
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_TEMPERATURESENSOR 14L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_TEXTLCD
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_TEXTLCD 15L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_TEXTLED
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_TEXTLED 16L
+#undef com_phidgets_WeightSensorPhidget_PHIDCLASS_WEIGHTSENSOR
+#define com_phidgets_WeightSensorPhidget_PHIDCLASS_WEIGHTSENSOR 17L
+/*
+ * Class: com_phidgets_WeightSensorPhidget
+ * Method: create
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_phidgets_WeightSensorPhidget_create
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_phidgets_WeightSensorPhidget
+ * Method: getWeight
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_WeightSensorPhidget_getWeight
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_WeightSensorPhidget
+ * Method: setWeightChangeTrigger
+ * Signature: (D)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_WeightSensorPhidget_setWeightChangeTrigger
+ (JNIEnv *, jobject, jdouble);
+
+/*
+ * Class: com_phidgets_WeightSensorPhidget
+ * Method: getWeightChangeTrigger
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_phidgets_WeightSensorPhidget_getWeightChangeTrigger
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_phidgets_WeightSensorPhidget
+ * Method: enableWeightChangeEvents
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_phidgets_WeightSensorPhidget_enableWeightChangeEvents
+ (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Java/phidget_jni.c b/Java/phidget_jni.c
new file mode 100644
index 0000000..1ec7ca6
--- /dev/null
+++ b/Java/phidget_jni.c
@@ -0,0 +1,156 @@
+#include "../stdafx.h"
+#include <stdlib.h>
+#include "../cphidget.h"
+#include "phidget_jni.h"
+#include <stdio.h>
+
+JavaVM *ph_vm = 0;
+
+jclass phidget_class;
+jmethodID phidget_cons;
+
+jclass ph_exception_class;
+jmethodID ph_exception_cons;
+
+jclass attachEvent_class;
+jmethodID attachEvent_cons;
+
+jclass detachEvent_class;
+jmethodID detachEvent_cons;
+
+jclass errorEvent_class;
+jmethodID errorEvent_cons;
+
+jclass serverConnectEvent_class;
+jmethodID serverConnectEvent_cons;
+
+jclass serverDisconnectEvent_class;
+jmethodID serverDisconnectEvent_cons;
+
+jint JNICALL
+JNI_OnLoad(JavaVM *vm, void *reserved)
+{
+ JNIEnv *env;
+ jint version = 0;
+ jint result;
+
+ ph_vm = vm;
+
+ result = (*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_4);
+
+ if(result == JNI_EDETACHED)
+ if ((*vm)->AttachCurrentThread(vm, (JNIEnvPtr)&env, NULL))
+ JNI_ABORT_STDERR("Couldn't Attach Thread");
+
+ if(!(version = (*env)->GetVersion(env)))
+ JNI_ABORT_STDERR("Couldn't get version");
+ LOG(PHIDGET_LOG_DEBUG,"JNI Version: %08x",version);
+
+ //Load all Phidget classes, and needed methods and fields...
+ //Phidget
+ if (!(phidget_class = (*env)->FindClass(env, "com/phidgets/Phidget")))
+ JNI_ABORT_STDERR("");
+ if (!(phidget_class = (jclass)(*env)->NewGlobalRef(env, phidget_class)))
+ JNI_ABORT_STDERR("");
+ if (!(phidget_cons = (*env)->GetMethodID(env, phidget_class, "<init>", "(J)V")))
+ JNI_ABORT_STDERR("");
+
+ //PhidgetException
+ if (!(ph_exception_class = (*env)->FindClass(env, "com/phidgets/PhidgetException")))
+ JNI_ABORT_STDERR("Coulnd't FindClass com/phidgets/PhidgetException");
+ if (!(ph_exception_class = (jclass)(*env)->NewGlobalRef(env, ph_exception_class)))
+ JNI_ABORT_STDERR("Couldn't create global ref ph_exception_class");
+ if (!(ph_exception_cons = (*env)->GetMethodID(env, ph_exception_class, "<init>", "(ILjava/lang/String;)V")))
+ JNI_ABORT_STDERR("Couldn't get Method ID <init> from ph_exception_class");
+
+ //AttachEvent
+ if (!(attachEvent_class = (*env)->FindClass(env, "com/phidgets/event/AttachEvent")))
+ JNI_ABORT_STDERR("Coulnd't FindClass com/phidgets/AttachEvent");
+ if (!(attachEvent_class = (jclass)(*env)->NewGlobalRef(env, attachEvent_class)))
+ JNI_ABORT_STDERR("Couldn't create global ref attachEvent_class");
+ if (!(attachEvent_cons = (*env)->GetMethodID(env, attachEvent_class, "<init>", "(Lcom/phidgets/Phidget;)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID <init> from attachEvent_class");
+
+ //DetachEvent
+ if (!(detachEvent_class = (*env)->FindClass(env, "com/phidgets/event/DetachEvent")))
+ JNI_ABORT_STDERR("Coulnd't FindClass com/phidgets/DetachEvent");
+ if (!(detachEvent_class = (jclass)(*env)->NewGlobalRef(env, detachEvent_class)))
+ JNI_ABORT_STDERR("Couldn't create global ref detachEvent_class");
+ if (!(detachEvent_cons = (*env)->GetMethodID(env, detachEvent_class, "<init>", "(Lcom/phidgets/Phidget;)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID <init> from detachEvent_class");
+
+ //ErrorEvent
+ if (!(errorEvent_class = (*env)->FindClass(env, "com/phidgets/event/ErrorEvent")))
+ JNI_ABORT_STDERR("Coulnd't FindClass com/phidgets/ErrorEvent");
+ if (!(errorEvent_class = (jclass)(*env)->NewGlobalRef(env, errorEvent_class)))
+ JNI_ABORT_STDERR("Couldn't create global ref errorEvent_class");
+ if (!(errorEvent_cons = (*env)->GetMethodID(env, errorEvent_class, "<init>", "(Lcom/phidgets/Phidget;Lcom/phidgets/PhidgetException;)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID <init> from errorEvent_class");
+
+ //ServerConnectEvent
+ if (!(serverConnectEvent_class = (*env)->FindClass(env, "com/phidgets/event/ServerConnectEvent")))
+ JNI_ABORT_STDERR("Couldn't FindClass com/phidgets/ServerConnectEvent");
+ if (!(serverConnectEvent_class = (jclass)(*env)->NewGlobalRef(env, serverConnectEvent_class)))
+ JNI_ABORT_STDERR("Couldn't create global ref serverConnectEvent_class");
+ if (!(serverConnectEvent_cons = (*env)->GetMethodID(env, serverConnectEvent_class, "<init>", "(Ljava/lang/Object;)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID <init> from serverConnectEvent_class");
+
+ //ServerDisconnectEvent
+ if (!(serverDisconnectEvent_class = (*env)->FindClass(env, "com/phidgets/event/ServerDisconnectEvent")))
+ JNI_ABORT_STDERR("Couldn't FindClass com/phidgets/ServerDisconnectEvent");
+ if (!(serverDisconnectEvent_class = (jclass)(*env)->NewGlobalRef(env, serverDisconnectEvent_class)))
+ JNI_ABORT_STDERR("Couldn't create global ref serverDisconnectEvent_class");
+ if (!(serverDisconnectEvent_cons = (*env)->GetMethodID(env, serverDisconnectEvent_class, "<init>", "(Ljava/lang/Object;)V")))
+ JNI_ABORT_STDERR("Couldn't get method ID <init> from serverDisconnectEvent_class");
+
+ com_phidgets_Phidget_OnLoad(env);
+ com_phidgets_Manager_OnLoad(env);
+ com_phidgets_Dictionary_OnLoad(env);
+ com_phidgets_DictionaryKeyListener_OnLoad(env);
+ com_phidgets_AccelerometerPhidget_OnLoad(env);
+ com_phidgets_AdvancedServoPhidget_OnLoad(env);
+ com_phidgets_AnalogPhidget_OnLoad(env);
+ com_phidgets_BridgePhidget_OnLoad(env);
+ com_phidgets_EncoderPhidget_OnLoad(env);
+ com_phidgets_FrequencyCounterPhidget_OnLoad(env);
+ com_phidgets_GPSPhidget_OnLoad(env);
+ com_phidgets_InterfaceKitPhidget_OnLoad(env);
+ com_phidgets_IRPhidget_OnLoad(env);
+ com_phidgets_LEDPhidget_OnLoad(env);
+ com_phidgets_MotorControlPhidget_OnLoad(env);
+ com_phidgets_PHSensorPhidget_OnLoad(env);
+ com_phidgets_RFIDPhidget_OnLoad(env);
+ com_phidgets_ServoPhidget_OnLoad(env);
+ com_phidgets_SpatialPhidget_OnLoad(env);
+ com_phidgets_StepperPhidget_OnLoad(env);
+ com_phidgets_TemperatureSensorPhidget_OnLoad(env);
+ com_phidgets_TextLCDPhidget_OnLoad(env);
+ com_phidgets_TextLEDPhidget_OnLoad(env);
+ com_phidgets_WeightSensorPhidget_OnLoad(env);
+
+#ifdef _ANDROID
+ if(com_phidgets_usb_Phidget_OnLoad(env) && com_phidgets_usb_Manager_OnLoad(env))
+ AndroidUsbJarAvailable = PTRUE;
+ else
+ AndroidUsbJarAvailable = PFALSE;
+#endif
+
+ return JNI_VERSION_1_4;
+}
+
+jlong
+updateGlobalRef(JNIEnv *env, jobject obj, jfieldID fid, jboolean b)
+{
+ /*
+ * Manages the global reference held by phidget21 to the handler
+ * target.
+ */
+ jlong gr;
+
+ if ((gr = (*env)->GetLongField(env, obj, fid)) != 0)
+ (*env)->DeleteGlobalRef(env, (jobject)(uintptr_t)gr);
+ gr = b ? (jlong)(uintptr_t)(*env)->NewGlobalRef(env, obj) : 0;
+ (*env)->SetLongField(env, obj, fid, gr);
+
+ return gr;
+}
diff --git a/Java/phidget_jni.h b/Java/phidget_jni.h
new file mode 100644
index 0000000..2325fd0
--- /dev/null
+++ b/Java/phidget_jni.h
@@ -0,0 +1,322 @@
+#ifndef PHIDGET_JNI_H
+#define PHIDGET_JNI_H
+
+#include <jni.h>
+
+#ifdef _ANDROID
+#define JNIEnvPtr const struct JNINativeInterface ***
+#else
+#define JNIEnvPtr void **
+#endif
+
+extern JavaVM *ph_vm;
+
+extern jclass phidget_class;
+extern jmethodID phidget_cons;
+
+extern jclass ph_exception_class;
+extern jmethodID ph_exception_cons;
+
+extern jclass attachEvent_class;
+extern jmethodID attachEvent_cons;
+
+extern jclass detachEvent_class;
+extern jmethodID detachEvent_cons;
+
+extern jclass errorEvent_class;
+extern jmethodID errorEvent_cons;
+
+extern jclass serverConnectEvent_class;
+extern jmethodID serverConnectEvent_cons;
+
+extern jclass serverDisconnectEvent_class;
+extern jmethodID serverDisconnectEvent_cons;
+
+void com_phidgets_Phidget_OnLoad(JNIEnv *);
+void com_phidgets_AccelerometerPhidget_OnLoad(JNIEnv *);
+void com_phidgets_AdvancedServoPhidget_OnLoad(JNIEnv *);
+void com_phidgets_AnalogPhidget_OnLoad(JNIEnv *);
+void com_phidgets_BridgePhidget_OnLoad(JNIEnv *);
+void com_phidgets_EncoderPhidget_OnLoad(JNIEnv *);
+void com_phidgets_FrequencyCounterPhidget_OnLoad(JNIEnv *);
+void com_phidgets_GPSPhidget_OnLoad(JNIEnv *);
+void com_phidgets_InterfaceKitPhidget_OnLoad(JNIEnv *);
+void com_phidgets_IRPhidget_OnLoad(JNIEnv *);
+void com_phidgets_LEDPhidget_OnLoad(JNIEnv *);
+void com_phidgets_MotorControlPhidget_OnLoad(JNIEnv *);
+void com_phidgets_PHSensorPhidget_OnLoad(JNIEnv *);
+void com_phidgets_RFIDPhidget_OnLoad(JNIEnv *);
+void com_phidgets_ServoPhidget_OnLoad(JNIEnv *);
+void com_phidgets_SpatialPhidget_OnLoad(JNIEnv *);
+void com_phidgets_StepperPhidget_OnLoad(JNIEnv *);
+void com_phidgets_TemperatureSensorPhidget_OnLoad(JNIEnv *);
+void com_phidgets_TextLCDPhidget_OnLoad(JNIEnv *);
+void com_phidgets_TextLEDPhidget_OnLoad(JNIEnv *);
+void com_phidgets_WeightSensorPhidget_OnLoad(JNIEnv *);
+void com_phidgets_Manager_OnLoad(JNIEnv *);
+void com_phidgets_Dictionary_OnLoad(JNIEnv *);
+void com_phidgets_DictionaryKeyListener_OnLoad(JNIEnv *);
+
+#ifdef _ANDROID
+extern int AndroidUsbJarAvailable;
+int com_phidgets_usb_Manager_OnLoad(JNIEnv *);
+int com_phidgets_usb_Phidget_OnLoad(JNIEnv *);
+#endif
+
+jlong updateGlobalRef(JNIEnv *env, jobject obj, jfieldID fid, jboolean b);
+
+#define JNI_ABORT_STDERR(...) \
+do { \
+ LOG_STDERR(PHIDGET_LOG_CRITICAL, __VA_ARGS__); \
+ (*env)->ExceptionDescribe(env); \
+ (*env)->ExceptionClear(env); \
+ abort(); \
+} while(0)
+
+#define EVENT_VARS(event, Event) static jmethodID event##Event_cons; \
+static jmethodID fire##Event##_mid; \
+static jclass event##Event_class; \
+static jfieldID native##Event##Handler_fid;
+
+#define JNI_LOAD(name, Pname) \
+extern jfieldID handle_fid; \
+static jclass name##_class; \
+void com_phidgets_##Pname##Phidget_OnLoad(JNIEnv *env) \
+{ \
+ if (!(name##_class = (*env)->FindClass(env, "com/phidgets/" #Pname "Phidget"))) \
+ JNI_ABORT_STDERR("Couldn't FindClass com/phidgets/" #Pname "Phidget"); \
+ if (!(name##_class = (jclass)(*env)->NewGlobalRef(env, name##_class))) \
+ JNI_ABORT_STDERR("Couldn't create NewGlobalRef " #name "_class"); \
+
+#define EVENT_VAR_SETUP(name, event, Event, parameters, returntype) \
+ if (!(event##Event_class = (*env)->FindClass(env, "com/phidgets/event/" #Event "Event"))) \
+ JNI_ABORT_STDERR("Couldn't FindClass com/phidgets/event/" #Event "Event"); \
+ if (!(event##Event_class = (jclass)(*env)->NewGlobalRef(env, event##Event_class))) \
+ JNI_ABORT_STDERR("Couldn't create global ref " #event "Event_class"); \
+ if (!(fire##Event##_mid = (*env)->GetMethodID(env, name##_class, "fire" #Event , "(Lcom/phidgets/event/" #Event "Event;)" #returntype ))) \
+ JNI_ABORT_STDERR("Please install the latest Phidget Library. Couldn't get method ID fire" #Event); \
+ if (!(event##Event_cons = (*env)->GetMethodID(env, event##Event_class, "<init>", "(Lcom/phidgets/Phidget;" #parameters ")" #returntype ))) \
+ JNI_ABORT_STDERR("Couldn't get method ID <init> from " #event "Event_class"); \
+ if (!(native##Event##Handler_fid = (*env)->GetFieldID(env, name##_class, "native" #Event "Handler", "J"))) \
+ JNI_ABORT_STDERR("Couldn't get Field ID native" #Event "Handler from " #name "_class");
+
+#define PH_THROW(errno) { \
+ jobject eobj; \
+ jstring edesc; \
+ \
+ if (!(edesc = (*env)->NewStringUTF(env, CPhidget_strerror(errno)))) \
+ JNI_ABORT_STDERR("Couldn't get NewStringUTF"); \
+ if (!(eobj = (*env)->NewObject(env, ph_exception_class, ph_exception_cons, errno, edesc))) \
+ JNI_ABORT_STDERR("Couldn't get NewObject ph_exception_class"); \
+ (*env)->Throw(env, (jthrowable)eobj); \
+}
+
+#define JNI_INDEXED_SETFUNC(pname, fname, lfname, type) \
+JNIEXPORT void JNICALL Java_com_phidgets_##pname##Phidget_set##fname(JNIEnv *env, jobject obj, jint index, type v) \
+{ \
+ CPhidget##pname##Handle h = (CPhidget##pname##Handle)(uintptr_t)(*env)->GetLongField(env, obj, handle_fid); \
+ int error; \
+ if ((error = CPhidget##pname##_set##lfname(h, index, v))) \
+ PH_THROW(error); \
+}
+
+#define JNI_SETFUNC(pname, fname, lfname, type) \
+JNIEXPORT void JNICALL Java_com_phidgets_##pname##Phidget_set##fname(JNIEnv *env, jobject obj, type v) \
+{ \
+ CPhidget##pname##Handle h = (CPhidget##pname##Handle)(uintptr_t) \
+ (*env)->GetLongField(env, obj, handle_fid); \
+ int error; \
+ if ((error = CPhidget##pname##_set##lfname(h, v))) \
+ PH_THROW(error); \
+}
+
+#define JNI_INDEXED_GETFUNC(pname, fname, lfname, type) \
+JNIEXPORT type JNICALL Java_com_phidgets_##pname##Phidget_get##fname(JNIEnv *env, jobject obj, jint index) \
+{ \
+ CPhidget##pname##Handle h = (CPhidget##pname##Handle)(uintptr_t) \
+ (*env)->GetLongField(env, obj, handle_fid); \
+ int error; \
+ type v; \
+ if ((error = CPhidget##pname##_get##lfname(h, index, &v))) \
+ PH_THROW(error); \
+ return v; \
+}
+
+#define JNI_INDEXED_GETFUNCBOOL(pname, fname, lfname) \
+JNIEXPORT jboolean JNICALL Java_com_phidgets_##pname##Phidget_get##fname(JNIEnv *env, jobject obj, jint index) \
+{ \
+ CPhidget##pname##Handle h = (CPhidget##pname##Handle)(uintptr_t) \
+ (*env)->GetLongField(env, obj, handle_fid); \
+ int error; \
+ int v; \
+ if ((error = CPhidget##pname##_get##lfname(h, index, &v))) \
+ PH_THROW(error); \
+ if (v) return 1; \
+ return 0; \
+}
+
+#define JNI_GETFUNC(pname, fname, lfname, type) \
+JNIEXPORT type JNICALL Java_com_phidgets_##pname##Phidget_get##fname (JNIEnv *env, jobject obj) \
+{ \
+ CPhidget##pname##Handle h = (CPhidget##pname##Handle)(uintptr_t) \
+ (*env)->GetLongField( env, obj, handle_fid); \
+ int error; \
+ type no; \
+ if ((error = CPhidget##pname##_get##lfname(h, &no))) \
+ PH_THROW(error); \
+ return no; \
+}
+
+#define JNI_GETFUNCBOOL(pname, fname, lfname) \
+JNIEXPORT jboolean JNICALL Java_com_phidgets_##pname##Phidget_get##fname (JNIEnv *env, jobject obj) \
+{ \
+ CPhidget##pname##Handle h = (CPhidget##pname##Handle)(uintptr_t) \
+ (*env)->GetLongField( env, obj, handle_fid); \
+ int error; \
+ int no; \
+ if ((error = CPhidget##pname##_get##lfname(h, &no))) \
+ PH_THROW(error); \
+ if(no) return 1; \
+ return 0; \
+}
+
+#define JNI_CREATE(Pname) \
+JNIEXPORT jlong JNICALL Java_com_phidgets_##Pname##Phidget_create(JNIEnv *env, jclass cls) \
+{ \
+ CPhidget##Pname##Handle phid; \
+ int error; \
+ if ((error = CPhidget##Pname##_create(&phid)) != EPHIDGET_OK) { \
+ PH_THROW(error); \
+ return 0; \
+ } \
+ return (jlong)(uintptr_t)phid; \
+}
+
+#define EVENT_HANDLER(pname, event, Event, cphidgetSetHandlerFunc, type) \
+static int CCONV event##_handler(CPhidget##pname##Handle h, void *arg, type); \
+JNIEXPORT void JNICALL Java_com_phidgets_##pname##Phidget_enable##Event##Events(JNIEnv *env, jobject obj, jboolean b) \
+{ \
+ jlong gr = updateGlobalRef(env, obj, native##Event##Handler_fid, b); \
+ CPhidget##pname##Handle h = (CPhidget##pname##Handle)(uintptr_t) \
+ (*env)->GetLongField(env, obj, handle_fid); \
+ cphidgetSetHandlerFunc(h, b ? event##_handler : 0, \
+ (void *)(uintptr_t)gr); \
+} \
+\
+static int CCONV event##_handler(CPhidget##pname##Handle h, void *arg, type v) \
+{ \
+ JNIEnv *env; \
+ jobject obj; \
+ jobject event##Ev; \
+\
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL)) \
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread"); \
+\
+ obj = (jobject)arg; \
+\
+ if (!(event##Ev = (*env)->NewObject(env, event##Event_class, event##Event_cons, obj, v))) \
+ return -1; \
+ (*env)->CallVoidMethod(env, obj, fire##Event##_mid, event##Ev); \
+ (*env)->DeleteLocalRef(env, event##Ev); \
+ (*ph_vm)->DetachCurrentThread(ph_vm); \
+\
+ return 0; \
+}
+
+#define EVENT_HANDLER_INDEXED(pname, event, Event, cphidgetSetHandlerFunc, type) \
+static int CCONV event##_handler(CPhidget##pname##Handle h, void *arg, int, type); \
+JNIEXPORT void JNICALL Java_com_phidgets_##pname##Phidget_enable##Event##Events(JNIEnv *env, jobject obj, jboolean b) \
+{ \
+ jlong gr = updateGlobalRef(env, obj, native##Event##Handler_fid, b); \
+ CPhidget##pname##Handle h = (CPhidget##pname##Handle)(uintptr_t) \
+ (*env)->GetLongField(env, obj, handle_fid); \
+ cphidgetSetHandlerFunc(h, b ? event##_handler : 0, \
+ (void *)(uintptr_t)gr); \
+} \
+\
+static int CCONV event##_handler(CPhidget##pname##Handle h, void *arg, int index, type v) \
+{ \
+ JNIEnv *env; \
+ jobject obj; \
+ jobject event##Ev; \
+\
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL)) \
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread"); \
+\
+ obj = (jobject)arg; \
+\
+ if (!(event##Ev = (*env)->NewObject(env, event##Event_class, event##Event_cons, obj, index, v))) \
+ return -1; \
+ (*env)->CallVoidMethod(env, obj, fire##Event##_mid, event##Ev); \
+ (*env)->DeleteLocalRef(env, event##Ev); \
+ (*ph_vm)->DetachCurrentThread(ph_vm); \
+\
+ return 0; \
+}
+
+#define EVENT_HANDLER_INDEXED2(pname, event, Event, cphidgetSetHandlerFunc, type, type2) \
+static int CCONV event##_handler(CPhidget##pname##Handle h, void *arg, int, type, type2); \
+JNIEXPORT void JNICALL Java_com_phidgets_##pname##Phidget_enable##Event##Events(JNIEnv *env, jobject obj, jboolean b) \
+{ \
+ jlong gr = updateGlobalRef(env, obj, native##Event##Handler_fid, b); \
+ CPhidget##pname##Handle h = (CPhidget##pname##Handle)(uintptr_t) \
+ (*env)->GetLongField(env, obj, handle_fid); \
+ cphidgetSetHandlerFunc(h, b ? event##_handler : 0, \
+ (void *)(uintptr_t)gr); \
+} \
+\
+static int CCONV event##_handler(CPhidget##pname##Handle h, void *arg, int index, type v, type2 w) \
+{ \
+ JNIEnv *env; \
+ jobject obj; \
+ jobject event##Ev; \
+\
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL)) \
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread"); \
+\
+ obj = (jobject)arg; \
+\
+ if (!(event##Ev = (*env)->NewObject(env, event##Event_class, \
+ event##Event_cons, obj, index, v, w))) \
+ return -1; \
+ (*env)->CallVoidMethod(env, obj, fire##Event##_mid, event##Ev); \
+ (*env)->DeleteLocalRef(env, event##Ev); \
+ (*ph_vm)->DetachCurrentThread(ph_vm); \
+\
+ return 0; \
+}
+
+#define EVENT_HANDLER_3(pname, event, Event, cphidgetSetHandlerFunc, type, type2, type3) \
+static int CCONV event##_handler(CPhidget##pname##Handle h, void *arg, type, type2, type3); \
+JNIEXPORT void JNICALL Java_com_phidgets_##pname##Phidget_enable##Event##Events(JNIEnv *env, jobject obj, jboolean b) \
+{ \
+ jlong gr = updateGlobalRef(env, obj, native##Event##Handler_fid, b); \
+ CPhidget##pname##Handle h = (CPhidget##pname##Handle)(uintptr_t) \
+ (*env)->GetLongField(env, obj, handle_fid); \
+ cphidgetSetHandlerFunc(h, b ? event##_handler : 0, \
+ (void *)(uintptr_t)gr); \
+} \
+\
+static int CCONV event##_handler(CPhidget##pname##Handle h, void *arg, type v, type2 w, type3 x) \
+{ \
+ JNIEnv *env; \
+ jobject obj; \
+ jobject event##Ev; \
+\
+ if ((*ph_vm)->AttachCurrentThread(ph_vm, (JNIEnvPtr)&env, NULL)) \
+ JNI_ABORT_STDERR("Couldn't AttachCurrentThread"); \
+\
+ obj = (jobject)arg; \
+\
+ if (!(event##Ev = (*env)->NewObject(env, event##Event_class, \
+ event##Event_cons, obj, v, w, x))) \
+ return -1; \
+ (*env)->CallVoidMethod(env, obj, fire##Event##_mid, event##Ev); \
+ (*env)->DeleteLocalRef(env, event##Ev); \
+ (*ph_vm)->DetachCurrentThread(ph_vm); \
+\
+ return 0; \
+}
+
+
+#endif