00001 00002 /* 00003 * Copyright 2012 Phidgets Inc. All rights reserved. 00004 */ 00005 00006 package com.phidgets; 00007 import java.util.Iterator; 00008 import java.util.LinkedList; 00009 import com.phidgets.event.*; 00020 public final class BridgePhidget extends Phidget 00021 { 00022 public BridgePhidget () throws PhidgetException 00023 { 00024 super (create ()); 00025 } 00026 private static native long create () throws PhidgetException; 00030 public static final int PHIDGET_BRIDGE_GAIN_1 = 1; 00034 public static final int PHIDGET_BRIDGE_GAIN_8 = 2; 00038 public static final int PHIDGET_BRIDGE_GAIN_16 = 3; 00042 public static final int PHIDGET_BRIDGE_GAIN_32 = 4; 00046 public static final int PHIDGET_BRIDGE_GAIN_64 = 5; 00050 public static final int PHIDGET_BRIDGE_GAIN_128 = 6; 00054 public static final int PHIDGET_BRIDGE_GAIN_UNKNOWN = 7; 00059 public native int getInputCount () throws PhidgetException; 00068 public native double getBridgeValue (int index) throws PhidgetException; 00076 public native double getBridgeMin (int index) throws PhidgetException; 00084 public native double getBridgeMax (int index) throws PhidgetException; 00093 public native boolean getEnabled (int index) throws PhidgetException; 00102 public native void setEnabled (int index, boolean state) throws PhidgetException; 00116 public native int getGain (int index) throws PhidgetException; 00131 public native void setGain (int index, int gain) throws PhidgetException; 00143 public native int getDataRate () throws PhidgetException; 00155 public native void setDataRate (int rate) throws PhidgetException; 00162 public native int getDataRateMin () throws PhidgetException; 00169 public native int getDataRateMax () throws PhidgetException; 00170 00171 private final void enableDeviceSpecificEvents (boolean b) 00172 { 00173 enableBridgeDataEvents (b && bridgeDataListeners.size () > 0); 00174 } 00182 public final void addBridgeDataListener (BridgeDataListener l) 00183 { 00184 synchronized (bridgeDataListeners) 00185 { 00186 bridgeDataListeners.add (l); 00187 enableBridgeDataEvents (true); 00188 }} private LinkedList bridgeDataListeners = new LinkedList (); 00189 private long nativeBridgeDataHandler = 0; 00190 public final void removeBridgeDataListener (BridgeDataListener l) 00191 { 00192 synchronized (bridgeDataListeners) 00193 { 00194 bridgeDataListeners.remove (l); 00195 enableBridgeDataEvents (bridgeDataListeners.size () > 0); 00196 }} private void fireBridgeData (BridgeDataEvent e) 00197 { 00198 synchronized (bridgeDataListeners) 00199 { 00200 for (Iterator it = bridgeDataListeners.iterator (); it.hasNext ();) 00201 ((BridgeDataListener) it.next ()).bridgeData (e); 00202 } 00203 } 00204 private native void enableBridgeDataEvents (boolean b); 00205 }