|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--Phidgets.Phidget
This is the base class from which all Phidget Devices derive. Don't cerate phidget devices directly using this class. Use the specific class for the device that you wish to access.
General usage of the java Phidget library is as follows:
Support for Phidgets in java is provided by way of the Phidget Server, a TCP/IP based socket server that is run on the pc with the attached phidget. Because of this, java doesn't need to talk to the hardware direcly, and so a JNI is not needed. Also, both local and remote Phidgets can be opened and controlled.
To open a Phidget:
First, create an instance of the device you wish to open:
ie: PhidgetInterfaceKit ifkit = new PhidgetInterfaceKit();
Second, choose a open type:
There are two ways to open Phidgets: OpenRemote and OpenRemoteIP
OpenRemote uses UDP broadcast to find a server by its registered serial number but only works
on internal networks
OpenRemoteIP takes in a regular IP address or hostname for opening Phidgets across networks, or over the internet -
wherever broadcast can't be used.
Both methods require the port that the server is running on and the password that it's running with, as well as the serial number of the Phidget you wish to open.
ie: ifkit.OpenRemoteIP("localhost",5001,-1,"pass");
To read from or control a Phidget:
Each Phidget class has it's own methods for controlling the device and reading data from it. Data is polled automatically from the Phidget devices and so it always up to date and accesible using the Get methods. Also, event handlers can be registered that will recieve notification on data changes.
To set up Events:
Each phidget has two methods for events:
add_IPhidgetEventsListener(_IPhidgetEvents l)
and remove_IPhidgetEventsListener()
for adding and removing event handlers.
The easiest way to set up event support is to create a class that implements the events interface for that device and write your events handlers there, then pass that class to the add event listener method.
Each device has it's own set of events, but every Phidget supports three basic event types:
OnDetach
, OnAttach
and OnError
which can be used for basic monitoring.
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
Phidget()
|
Method Summary | |
void |
Close()
Closes the device. |
boolean |
equals(java.lang.Object comp)
|
java.lang.String |
GetDeviceType()
Gets the device type. |
int |
GetDeviceVersion()
Gets the Device Version. |
boolean |
GetIsAttached()
Gets the connection status. |
int |
GetSerialNumber()
Gets the Serial Number. |
java.lang.String |
GetServerAddress()
Gets the IP address of the Phidget WebService |
int |
GetServerID()
Gets the Server ID of the Phidget WebService |
int |
GetServerPort()
Gets the Port of the Phidget WebService |
void |
run()
Polls for phidget data on an open socket. |
void |
setDeviceType(java.lang.String string)
Sets the device name. |
void |
setDeviceVersion(int i)
Sets teh device version. |
void |
setSerialNumber(int i)
Sets the serial number. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Phidget()
Method Detail |
public int GetSerialNumber()
public int GetDeviceVersion()
public boolean GetIsAttached()
public java.lang.String GetDeviceType()
public void Close()
public void run()
run
in class java.lang.Thread
public void setDeviceType(java.lang.String string)
string
- Device Namepublic void setDeviceVersion(int i)
i
- Versionpublic void setSerialNumber(int i)
i
- Serial Numberpublic boolean equals(java.lang.Object comp)
equals
in class java.lang.Object
public java.lang.String GetServerAddress()
public int GetServerPort()
public int GetServerID()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |