com.phidgets
Class Manager

java.lang.Object
  extended bycom.phidgets.Manager

public class Manager
extends java.lang.Object

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.

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.

Constructor Summary
Manager()
          The default constructor.
 
Method Summary
 void addAttachListener(AttachListener l)
          Adds an attach listener.
 void addDetachListener(DetachListener l)
          Adds a detach listener.
 void addServerConnectListener(ServerConnectListener l)
          Adds an serverConnect listener.
 void addServerDisconnectListener(ServerDisconnectListener l)
          Adds an serverDisconnect listener.
 void close()
          Shuts down the Phidget Manager.
 java.util.Vector getPhidgets()
          Returns a list of Phidgets attached to the host computer.
 java.lang.String getServerAddress()
          Returns the Address of a Phidget Webservice when this Manager was opened as remote.
 java.lang.String getServerID()
          Returns the Server ID of a Phidget Webservice when this Manager was opened as remote.
 int getServerPort()
          Returns the Port of a Phidget Webservice when this Manager was opened as remote.
 boolean isAttached()
          Returns the attached status of this Manager.
 boolean isAttachedToServer()
          Returns the network attached status for remotely opened Phidgets.
 void open()
          Starts the PhidgetManager.
 void open(java.lang.String serverID)
          Open this Manager remotely using a Server ID.
 void open(java.lang.String ipAddress, int port)
          Open this Manager remotely using an IP Address.
 void open(java.lang.String ipAddress, int port, java.lang.String password)
          Open this Manager remotely and securely, using an IP Address.
 void open(java.lang.String serverID, java.lang.String password)
          Open this Manager remotely and securely, using a Server ID.
 void removeAttachListener(AttachListener l)
          Removes an attach listener.
 void removeDetachListener(DetachListener l)
          Removes a detach listener.
 void removeServerConnectListener(ServerConnectListener l)
          Removes an serverConnect listener.
 void removeServerDisconnectListener(ServerDisconnectListener l)
          Removes an serverDisconnect listener.
 java.lang.String toString()
          Return a Sring describing this manager.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Manager

public Manager()
        throws PhidgetException
The default constructor. Creating a Phidget Manager object will initialize the attach and detach handlers internally, but open still needs to be called to actually receive event notifications.

Method Detail

getServerAddress

public final java.lang.String getServerAddress()
                                        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.

Returns:
Server Address
Throws:
PhidgetException - if this Manager was not opened.

getServerID

public final java.lang.String getServerID()
                                   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.

Returns:
Server ID
Throws:
PhidgetException - if this Manager was not opened.

getServerPort

public final int getServerPort()
                        throws PhidgetException
Returns the Port of a Phidget Webservice when this Manager was opened as remote.

Returns:
Server Port
Throws:
PhidgetException - if this Manager was not opened.

isAttached

public final boolean isAttached()
                         throws PhidgetException
Returns the attached status of this Manager.

Returns:
Status
Throws:
PhidgetException - If this Manager is not opened.

isAttachedToServer

public final boolean isAttachedToServer()
                                 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.

Returns:
Status
Throws:
PhidgetException - If this Phidget is not opened.

open

public final void open()
                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 close is called.

Throws:
PhidgetException

open

public final void open(java.lang.String ipAddress,
                       int port,
                       java.lang.String password)
                throws PhidgetException
Open this Manager remotely and securely, using an IP Address.

This method is the same as open(String ipAddress, int port), except that it specifies a password. This password can be set as a parameter when starting the Phidget Webservice.

Throws:
PhidgetException

open

public final void open(java.lang.String ipAddress,
                       int port)
                throws PhidgetException
Open this Manager remotely using an IP Address.

This version of open is network based.

Parameters:
ipAddress - IP Address or hostname of the Phidget Webservice
port - Port of the Phidget Webservice
Throws:
PhidgetException - if the Phidget Webservice cannot be contacted

open

public final void open(java.lang.String serverID,
                       java.lang.String password)
                throws PhidgetException
Open this Manager remotely and securely, using a Server ID.

This method is the same as open(String serverID), except that it specifies a password. This password can be set as a parameter when starting the Phidget Webservice.

Throws:
PhidgetException

open

public final void open(java.lang.String serverID)
                throws PhidgetException
Open this Manager remotely using a Server ID.

This version of open is network based.

ServerID can be NULL to get a listing of all Phidgets on all Servers

Parameters:
serverID - ServerID of the Phidget Webservice
Throws:
PhidgetException

close

public final void close()
                 throws PhidgetException
Shuts down the Phidget Manager. This method should be called to close down the Phidget Manager. Events will no longer be received. This method gets called automatically when the class is destroyed so calling it is not required.

Throws:
PhidgetException

addAttachListener

public final void addAttachListener(AttachListener l)
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.

There is no limit on the number of attach handlers that can be registered for a particular Phidget.

Parameters:
l - An implemetation of the AttachListener interface

removeAttachListener

public final void removeAttachListener(AttachListener l)
Removes an attach listener. This will remove a previously added attach listener.


addDetachListener

public final void addDetachListener(DetachListener l)
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.

There is no limit on the number of detach handlers that can be registered for a particular Phidget.

Parameters:
l - An implemetation of the DetachListener interface

removeDetachListener

public final void removeDetachListener(DetachListener l)
Removes a detach listener. This will remove a previously added detach listener.


addServerConnectListener

public final void addServerConnectListener(ServerConnectListener l)
Adds an serverConnect listener. The serverConnect handler is a method that will be called when a connection to a server is made

There is no limit on the number of serverConnect handlers that can be registered for a particular Manager.

Parameters:
l - An implemetation of the ServerConnectListener interface

removeServerConnectListener

public final void removeServerConnectListener(ServerConnectListener l)
Removes an serverConnect listener. This will remove a previously added serverConnect listener.


addServerDisconnectListener

public final void addServerDisconnectListener(ServerDisconnectListener l)
Adds an serverDisconnect listener. The serverDisconnect handler is a method that will be called when a connection to a server is terminated.

There is no limit on the number of serverDisconnect handlers that can be registered for a particular Manager.

Parameters:
l - An implemetation of the ServerDisconnectListener interface

removeServerDisconnectListener

public final void removeServerDisconnectListener(ServerDisconnectListener l)
Removes an serverDisconnect listener. This will remove a previously added serverDisconnect listener.


toString

public java.lang.String toString()
Return a Sring describing this manager.


getPhidgets

public java.util.Vector getPhidgets()
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.

Returns:
list of attached Phidgets