charly.client
Class ChGpibClient

java.lang.Object
  extended bycharly.client.ChGpibClient
All Implemented Interfaces:
ChGpibClientIntern

public class ChGpibClient
extends java.lang.Object
implements ChGpibClientIntern

This class represents the GPIB-bus. This class will in the future be deprecated. Please use ChGpibUnit and ChGpibSrq instead. ChGpibClient offers the methods provided by the Keithley CEC.488 API to each client. Before calling these methods a ChTask with the appropriate resources (the GPIB-devices or the whole GPIB-bus) has to be started.


Field Summary
protected  ChGpibDevice gpibDvc
           
protected  java.util.LinkedList gpibListeners
          elems are of type ChGpibListener.
protected  ChGpibClientRepresentation representation
           
protected  ChTask task
           
 
Constructor Summary
ChGpibClient()
          Konstruktor, der ChGpibClient(ChConnect) mittels new ChConnect() aufruft und daher eine Verbindung mit dem voreingestellten Server aufbaut
ChGpibClient(ChConnect conn)
          Konstruktor
 
Method Summary
 void addGpibListener(ChGpibListener l)
          adds a ChGpibListener for SRQ-Events.
 void checkSrq(int dvcAddr)
          causes the server to check the given device on srq and to send an event to the ChGpibListener.
 byte[] enter(int dvcAddr)
          receives from a given device on the gpib-bus.
 void fireSRQEvent(int dvcAddr)
          for internal use only.
static java.lang.String getResourceName(int dvcAddr)
          returns the name to be allocated on a server for a specified GPIB-device.
 ChTask getTask()
           
 void initialize(int addr, int level)
          usually does not need to be called.
 int isGpibBoardPresent()
          tests if gpibboard is present.
 int isListenerPresent(int dvcAddr)
          tests if listener with specified address is present.
 int ppoll()
          Deprecated. Please use new event listener model.
 byte[] rarray()
          receives binary and non-binary data from the gpib-bus.
 byte[] rarray(int dvcAddr)
          receives binary and non-binary data from a specified device of the gpib-bus.
 byte[] receive()
          receives non-binary data from the gpib-bus.
 byte[] receive(int dvcAddr)
          receives non-binary data from the gpib-bus.
 void removeGpibListener(ChGpibListener l)
           
 void send(int dvcAddr, byte[] data, int length)
          sends a specified string to a given device on the gpib-bus.
 void send(int dvcAddr, java.lang.String data)
          sends a specified string to a given device on the gpib-bus.
 void setTask(ChTask task)
          This method must be called to be able to use the other methods.
 void setTimeOut(int msec)
          sets timeout-time of the GPIB-Bus in msec.
 int spoll(int dvcAddr)
          Deprecated. Please use new event listener model.
 int srq()
          Deprecated. Please use new event listener model.
 void tarray(byte[] data, int length, byte eoi)
          sends data to the gpib-bus.
 void tarray(int dvcAddr, byte[] data, int length, byte eoi)
          sends data to a given device of the gpib-bus.
 void transmit(byte[] data, int length)
          sends commands and data to the gpib-bus.
 void uncheckSrq(int dvcAddr)
          This method should be used to inform the server that he does not have to check the device on an SRQ.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gpibDvc

protected ChGpibDevice gpibDvc

task

protected ChTask task

representation

protected ChGpibClientRepresentation representation

gpibListeners

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

Constructor Detail

ChGpibClient

public ChGpibClient()
             throws java.rmi.RemoteException,
                    java.net.MalformedURLException,
                    java.rmi.NotBoundException
Konstruktor, der ChGpibClient(ChConnect) mittels new ChConnect() aufruft und daher eine Verbindung mit dem voreingestellten Server aufbaut

See Also:
ChGpibClient(ChConnect), ChConnect

ChGpibClient

public ChGpibClient(ChConnect conn)
             throws java.rmi.RemoteException,
                    java.net.MalformedURLException,
                    java.rmi.NotBoundException
Konstruktor

Method Detail

fireSRQEvent

public void fireSRQEvent(int dvcAddr)
for internal use only.

Specified by:
fireSRQEvent in interface ChGpibClientIntern
See Also:
ChGpibClientRepresentation, ChGpibClientIntern

addGpibListener

public void addGpibListener(ChGpibListener l)
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.

See Also:
checkSrq(int)

removeGpibListener

public void removeGpibListener(ChGpibListener l)

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.


getTask

public ChTask getTask()

initialize

public void initialize(int addr,
                       int level)
                throws java.rmi.RemoteException,
                       ChTaskNotStartedException,
                       ChAccessDeniedException
usually does not need to be called. The Gpib-bus is initialized by default by ChGpib. The resource "GPIB" has to be reserved.

Parameters:
addr - the device-nr, the present GPIB-Board should have as GPIB-address (0-32)
level - 0 means the GPIB-board is controller of the GPIB-bus
Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException

checkSrq

public void checkSrq(int dvcAddr)
              throws java.rmi.RemoteException,
                     ChTaskNotStartedException,
                     ChAccessDeniedException
causes the server to check the given 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(int) has to be reserved.

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

uncheckSrq

public void uncheckSrq(int dvcAddr)
                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 an SRQ. A call of this method is not necessary if after the call of checkSrq(int) an SRQ on the specified device occurred. The device resource getResourceName(int) has to be reserved before calling this method.

Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException

send

public void send(int dvcAddr,
                 byte[] data,
                 int length)
          throws java.rmi.RemoteException,
                 ChTaskNotStartedException,
                 ChAccessDeniedException,
                 ChGpibTimeOutException,
                 ChGpibStateException
sends a specified string to a given device on the gpib-bus. The device resource getResourceName(int) has to be reserved before calling this method.

Parameters:
dvcAddr - the device-nr of the receiving device on the gpib-bus (0-32)
data - the bytes to be sent. The data has to be in non-binary form.
length - amount of bytes to be sent
Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
See Also:
String.getBytes()

send

public void send(int dvcAddr,
                 java.lang.String data)
          throws java.rmi.RemoteException,
                 ChTaskNotStartedException,
                 ChAccessDeniedException,
                 ChGpibTimeOutException,
                 ChGpibStateException
sends a specified string to a given device on the gpib-bus. The device resource getResourceName(int) has to be reserved before calling this method.

Parameters:
dvcAddr - the device-nr of the receiving device on the gpib-bus (0-32)
data - the string to be sent. The data has to be in non-binary form.
Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException

enter

public byte[] enter(int dvcAddr)
             throws java.rmi.RemoteException,
                    ChTaskNotStartedException,
                    ChAccessDeniedException,
                    ChGpibTimeOutException,
                    ChGpibStateException
receives from a given device on the gpib-bus. This method can only handle data in non-binary form. The device resource getResourceName(int) has to be reserved before calling this method.

Parameters:
dvcAddr - the device-nr of the receiving device on the gpib-bus (0-32)
Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
See Also:
String.String(byte[])

spoll

public int spoll(int dvcAddr)
          throws java.rmi.RemoteException,
                 ChTaskNotStartedException,
                 ChAccessDeniedException,
                 ChGpibTimeOutException,
                 ChGpibStateException
Deprecated. Please use new event listener model.

Please use the direct support for srq through ChGpibListener. The device resource getResourceName(int) has to be reserved before calling this method.

Parameters:
dvcAddr - the device-nr of the receiving device on the gpib-bus (0-32)
Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
See Also:
srq()

ppoll

public int ppoll()
          throws java.rmi.RemoteException,
                 ChTaskNotStartedException,
                 ChAccessDeniedException,
                 ChGpibTimeOutException,
                 ChGpibStateException
Deprecated. Please use new event listener model.

Please use the direct support for srq through ChGpibListener. The resource "GPIB" has to be reserved before calling this method.

Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
See Also:
srq()

transmit

public void transmit(byte[] data,
                     int length)
              throws java.rmi.RemoteException,
                     ChTaskNotStartedException,
                     ChAccessDeniedException,
                     ChGpibTimeOutException,
                     ChGpibStateException
sends commands and data to the gpib-bus. The resource "GPIB" has to be reserved before calling this method.

Parameters:
data - the bytes to be sent. The data cannot be in binary form.
length - amount of bytes to be sent
Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
See Also:
String.getBytes()

receive

public byte[] receive()
               throws java.rmi.RemoteException,
                      ChTaskNotStartedException,
                      ChAccessDeniedException,
                      ChGpibTimeOutException,
                      ChGpibStateException
receives non-binary data from the gpib-bus. The resource "GPIB" has to be reserved before calling this method.

Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
See Also:
receive(int), rarray(), rarray(int)

receive

public byte[] receive(int dvcAddr)
               throws java.rmi.RemoteException,
                      ChTaskNotStartedException,
                      ChAccessDeniedException,
                      ChGpibTimeOutException,
                      ChGpibStateException
receives non-binary data from the gpib-bus. The device resource getResourceName(int) has to be reserved before calling this method.

Parameters:
dvcAddr - the device-nr of the sending device on the gpib-bus (0-32)
Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
Since:
Charly V0.3.0
See Also:
receive(), rarray(), rarray(int)

tarray

public void tarray(byte[] data,
                   int length,
                   byte eoi)
            throws java.rmi.RemoteException,
                   ChTaskNotStartedException,
                   ChAccessDeniedException,
                   ChGpibTimeOutException,
                   ChGpibStateException
sends data to the gpib-bus. The data can be in binary form. The resource "GPIB" has to be reserved before calling this method.

Parameters:
data - the bytes to be sent
length - amount of bytes to be sent
eoi - EOI-Byte
Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
See Also:
String.getBytes()

tarray

public void tarray(int dvcAddr,
                   byte[] data,
                   int length,
                   byte eoi)
            throws java.rmi.RemoteException,
                   ChTaskNotStartedException,
                   ChAccessDeniedException,
                   ChGpibTimeOutException,
                   ChGpibStateException
sends data to a given device of the gpib-bus. The data can be in binary form. The device resource getResourceName(int) has to be reserved before calling this method.

Parameters:
dvcAddr - the device-nr of the receiving device on the gpib-bus (0-32)
data - the bytes to be sent
length - amount of bytes to be sent
eoi - EOI-Byte
Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
Since:
Charly V0.3.0
See Also:
String.getBytes()

rarray

public byte[] rarray()
              throws java.rmi.RemoteException,
                     ChTaskNotStartedException,
                     ChAccessDeniedException,
                     ChGpibTimeOutException,
                     ChGpibStateException
receives binary and non-binary data from the gpib-bus. The resource "GPIB" has to be reserved before calling this method.

Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
See Also:
rarray(int)

rarray

public byte[] rarray(int dvcAddr)
              throws java.rmi.RemoteException,
                     ChTaskNotStartedException,
                     ChAccessDeniedException,
                     ChGpibTimeOutException,
                     ChGpibStateException
receives binary and non-binary data from a specified device of the gpib-bus. The device resource getResourceName(int) has to be reserved before calling this method.

Parameters:
dvcAddr - the device-nr of the sending device on the gpib-bus (0-32)
Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
Since:
Charly V0.3.0
See Also:
rarray(int)

srq

public int srq()
        throws java.rmi.RemoteException,
               ChTaskNotStartedException,
               ChAccessDeniedException
Deprecated. Please use new event listener model.

Please use the direct support for srq through ChGpibListener. The resource "GPIB" has to be reserved before calling this method.

Returns:
status
Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException
See Also:
spoll(int), ppoll()

setTimeOut

public void setTimeOut(int msec)
                throws java.rmi.RemoteException,
                       ChTaskNotStartedException,
                       ChAccessDeniedException
sets timeout-time of the GPIB-Bus in msec. The resource "GPIB" has to be reserved before calling this method.

Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException

isListenerPresent

public int isListenerPresent(int dvcAddr)
                      throws java.rmi.RemoteException,
                             ChTaskNotStartedException,
                             ChAccessDeniedException
tests if listener with specified address is present. The device resource getResourceName(int) has to be reserved before calling this method.

Parameters:
dvcAddr - the device-nr of the checked device on the gpib-bus (0-32)
Returns:
status ???
Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException

isGpibBoardPresent

public int isGpibBoardPresent()
                       throws java.rmi.RemoteException
tests if gpibboard is present. It is not necessary to reserve a resource before calling this method.

Returns:
status.
Throws:
java.rmi.RemoteException

getResourceName

public static java.lang.String getResourceName(int dvcAddr)
returns the name to be allocated on a server for a specified GPIB-device.

Example:

   ChTask task=new ChTask("ATask");
   task.addRsrc(conn,gpibClient.getRsrcName(7));
 

Since:
V0.3.6 - static version