From 0b624384cd52be20e61284551d832b499d7b7707 Mon Sep 17 00:00:00 2001 From: Jonathan McCrohan Date: Sat, 14 Apr 2012 12:56:48 +0100 Subject: Imported Upstream version 2.1.8.20120216 --- Java/com/phidgets/macros/BridgePhidget.jm | 171 ++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 Java/com/phidgets/macros/BridgePhidget.jm (limited to 'Java/com/phidgets/macros/BridgePhidget.jm') 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. + *

+ * + * @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} + *

+ * @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. + *

+ * 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} + *

+ * @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. + *

+ * Data rate must be a multiple of 8ms. Trying to set something between multiplies of 8 will cause an EPHIDGET_INVALIDARG exception. + *

+ * @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. + *

+ * Data rate must be a multiple of 8ms. Trying to set something between multiplies of 8 will cause an EPHIDGET_INVALIDARG exception. + *

+ * @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. + *

+ * 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 -- cgit v1.2.3