charly.client
Class ChGpibUnit

java.lang.Object
  extended bycharly.client.ChGpibUnit
All Implemented Interfaces:
ChResource

public class ChGpibUnit
extends java.lang.Object
implements ChResource

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)

Field Summary
protected  ChConnect conn
           
(package private)  int dvcAddr
           
protected  ChGpibDevice gpibDvc
           
(package private)  java.lang.String suffix
           
protected  ChTask task
           
 
Constructor Summary
ChGpibUnit(ChConnect conn, int dvcAddr)
          Konstruktor
ChGpibUnit(ChConnect conn, int dvcAddr, java.lang.String suffix)
          Konstruktor
 
Method Summary
 byte[] enter()
          receives from the device on the gpib-bus.
 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()
           
 int isListenerPresent()
          tests if listener with specified address is present.
 byte[] rarray()
          receives binary and non-binary data from the device of the gpib-bus.
 byte[] receive()
          receives non-binary data from the gpib-bus.
 void send(byte[] data, int length)
          sends a specified string to the device on the gpib-bus.
 void send(java.lang.String data)
          sends a specified string to the device on the gpib-bus.
 byte[] sendAndEnter(byte[] data, int length)
          sends a string to the device on the gpib-bus and enters a string from this device.
 byte[] sendAndEnter(java.lang.String data)
          sends a string to the device on the gpib-bus and enters a string from this device.
 void setTask(ChTask task)
          This method must be called to be able to use the other methods.
 void tarray(int dvcAddr, byte[] data, int length, byte eoi)
          sends data to a given device of the gpib-bus.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dvcAddr

int dvcAddr

suffix

java.lang.String suffix

gpibDvc

protected ChGpibDevice gpibDvc

conn

protected ChConnect conn

task

protected ChTask task
Constructor Detail

ChGpibUnit

public ChGpibUnit(ChConnect conn,
                  int dvcAddr,
                  java.lang.String suffix)
           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)
suffix - - the name of the channel, e.g. CHANNEL0; can be null.
Throws:
ChNestedException - - Nested exception can be RemoteException, MalformedURLException, NotBoundException

ChGpibUnit

public ChGpibUnit(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)
Method Detail

getResourceName

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

Specified by:
getResourceName in interface ChResource

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.

Specified by:
setTask in interface ChResource

getTask

public ChTask getTask()

send

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

Parameters:
data - the bytes to be sent. The data has to be in non-binary form.
length - amount of bytes to be sent
Throws:
ChNestedException - - nested exception can be RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
See Also:
String.getBytes()

send

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

Parameters:
data - the string to be sent. The data has to be in non-binary form.
Throws:
ChNestedException - - nested exception can be RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException

sendAndEnter

public byte[] sendAndEnter(byte[] data,
                           int length)
                    throws ChNestedException,
                           ChTaskNotStartedException,
                           ChAccessDeniedException,
                           ChGpibTimeOutException,
                           ChGpibStateException
sends a string to the device on the gpib-bus and enters a string from this device. The device resource getResourceName() has to be reserved before calling this method.

Parameters:
data - the bytes to be sent. The data has to be in non-binary form.
length - amount of bytes to be sent
Throws:
ChNestedException - - nested exception can be RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
See Also:
String.getBytes()

sendAndEnter

public byte[] sendAndEnter(java.lang.String data)
                    throws ChNestedException,
                           ChTaskNotStartedException,
                           ChAccessDeniedException,
                           ChGpibTimeOutException,
                           ChGpibStateException
sends a string to the device on the gpib-bus and enters a string from this device. The device resource getResourceName() has to be reserved before calling this method.

Parameters:
data - the string to be sent. The data has to be in non-binary form.
Throws:
ChNestedException - - nested exception can be RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
See Also:
String.getBytes()

enter

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

Throws:
ChNestedException - - nested exception can be RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
See Also:
String.String(byte[])

receive

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

Throws:
ChNestedException - - nested exception can be RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
Since:
Charly V0.3.6
See Also:
rarray()

tarray

public void tarray(int dvcAddr,
                   byte[] data,
                   int length,
                   byte eoi)
            throws ChNestedException,
                   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() 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:
ChNestedException - - nested exception can be RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
Since:
Charly V0.3.6
See Also:
String.getBytes()

rarray

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

Throws:
ChNestedException - - nested exception can be RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
Since:
Charly V0.3.0
See Also:
receive()

isListenerPresent

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

Returns:
status ???
Throws:
ChNestedException - - nested exception can be RemoteException
ChTaskNotStartedException
ChAccessDeniedException