charly.client
Class ChGpibSrq

java.lang.Object
  extended bycharly.client.ChGpibSrq
All Implemented Interfaces:
ChGpibClientIntern, ChResource

public class ChGpibSrq
extends java.lang.Object
implements ChResource, ChGpibClientIntern

This class represents a device or a channel of a device on the GPIB-bus. Before calling the methods of an instance of this class a ChTask with the appropriate resources (the GPIB bus, or the single GPIB-device) has to be started.

See Also:
setTask(ChTask)

Nested Class Summary
(package private)  class ChGpibSrq.ChCheckSrqTaskListener
           
 
Field Summary
protected  ChGpibSrq.ChCheckSrqTaskListener checkSrqTaskListener
           
protected  ChConnect conn
           
(package private)  int dvcAddr
           
protected  ChGpibDevice gpibDvc
           
protected  java.util.LinkedList gpibListeners
          elems are of type ChGpibListener.
protected  ChGpibClientRepresentation representation
           
static java.lang.String srqSuffix
           
protected  ChTask task
           
 
Constructor Summary
ChGpibSrq(ChConnect conn, int dvcAddr)
          Konstruktor
 
Method Summary
 void addGpibListener(ChGpibListener l)
          adds a ChGpibListener for SRQ-Events.
 void checkSrq()
          causes the server to check the device on srq and to send an event to the ChGpibListener.
 void fireSRQEvent(int dvcAddr)
          notifies each GpibListener and calls checkSrq(), if there are GpibListeners left.
 ChConnect getConnection()
          Implementations should return the connection to the server where the resource can be found.
 java.lang.String getResourceName()
          returns the resource name, e.g.
 ChTask getTask()
           
 void listenForSrq()
          waits until a SRQ on this device occured.
 void removeGpibListener(ChGpibListener l)
          If no listeners are left, the server is notified that it needn't check the SRQ any more.
 void setTask(ChTask task)
          This method must be called to be able to use the other methods.
static void showException(java.lang.Exception e)
          prints the stack trace of the exception to system.out.
 void uncheckSrq()
          This method should be used to inform the server that he does not have to check the device on SRQ.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dvcAddr

int dvcAddr

srqSuffix

public static final java.lang.String srqSuffix
See Also:
Constant Field Values

gpibDvc

protected ChGpibDevice gpibDvc

conn

protected ChConnect conn

task

protected ChTask task

checkSrqTaskListener

protected ChGpibSrq.ChCheckSrqTaskListener checkSrqTaskListener

representation

protected ChGpibClientRepresentation representation

gpibListeners

protected java.util.LinkedList gpibListeners
elems are of type ChGpibListener.

Constructor Detail

ChGpibSrq

public ChGpibSrq(ChConnect conn,
                 int dvcAddr)
          throws ChNestedException
Konstruktor

Parameters:
conn - - the server to connect to; on this server, charlyServer must have been started
dvcAddr - - the number of the device on the GPIB bus (0-31)
Throws:
ChNestedException - - Nested exception can be RemoteException, MalformedURLException, NotBoundException
Method Detail

getResourceName

public java.lang.String getResourceName()
returns the resource name, e.g. "GPIB/7/SRQ".

Specified by:
getResourceName in interface ChResource
See Also:
srqSuffix

getConnection

public ChConnect getConnection()
Description copied from interface: ChResource
Implementations should return the connection to the server where the resource can be found.

Specified by:
getConnection in interface ChResource

setTask

public void setTask(ChTask task)
This method must be called to be able to use the other methods. The task must be started before calling the other methods. This method asks for an SRQ-check, if task has been started.

Specified by:
setTask in interface ChResource
See Also:
ChTask.addResource(ChResource), checkSrq()

getTask

public ChTask getTask()

fireSRQEvent

public void fireSRQEvent(int dvcAddr)
                  throws java.rmi.RemoteException,
                         ChAccessDeniedException
notifies each GpibListener and calls checkSrq(), if there are GpibListeners left.

Specified by:
fireSRQEvent in interface ChGpibClientIntern
Throws:
java.rmi.RemoteException
ChAccessDeniedException

addGpibListener

public void addGpibListener(ChGpibListener l)
                     throws ChNestedException,
                            ChTaskNotStartedException,
                            ChAccessDeniedException
adds a ChGpibListener for SRQ-Events. The gpib listeners are called after a SRQEvent occured in the order they were added. There is only one thread for a SRQ-Event. Thus, the second listener is called when the first listener returns. But be aware that different SRQ-Events can occur in different threads. Implicitly calls checkSrq(), if task is started.

Throws:
ChNestedException - - nested exception can be RemoteException
ChTaskNotStartedException
ChAccessDeniedException

removeGpibListener

public void removeGpibListener(ChGpibListener l)
                        throws ChNestedException,
                               ChTaskNotStartedException,
                               ChAccessDeniedException
If no listeners are left, the server is notified that it needn't check the SRQ any more.

Throws:
ChNestedException - - nested exception can be RemoteException
ChTaskNotStartedException
ChAccessDeniedException
See Also:
uncheckSrq()

checkSrq

public void checkSrq()
              throws java.rmi.RemoteException,
                     ChTaskNotStartedException,
                     ChAccessDeniedException
causes the server to check the device on srq and to send an event to the ChGpibListener. After an SRQ of the device, this method has to be called again to check for SRQ. The device resource getResourceName() has to be reserved.

Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException
See Also:
addGpibListener(ChGpibListener), uncheckSrq()

listenForSrq

public void listenForSrq()
                  throws ChNestedException,
                         ChTaskNotStartedException,
                         ChAccessDeniedException
waits until a SRQ on this device occured. Implicitly calls checkSrq().

Throws:
ChNestedException - - nested exception can be InterruptedException
ChTaskNotStartedException
ChAccessDeniedException

uncheckSrq

public void uncheckSrq()
                throws java.rmi.RemoteException,
                       ChTaskNotStartedException,
                       ChAccessDeniedException
This method should be used to inform the server that he does not have to check the device on SRQ. A call of this method is not necessary if after the call of checkSrq() an SRQ on the device occurred. The device resource getResourceName() has to be reserved before calling this method.

Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException

showException

public static void showException(java.lang.Exception e)
prints the stack trace of the exception to system.out.