charly.server.devices
Class ChGpibDeviceImpl

java.lang.Object
  extended byjava.rmi.server.RemoteObject
      extended byjava.rmi.server.RemoteServer
          extended byjava.rmi.server.UnicastRemoteObject
              extended bycharly.server.devices.ChGpibDeviceImpl
All Implemented Interfaces:
ChDevice, ChGpibDevice, java.rmi.Remote, java.io.Serializable

public class ChGpibDeviceImpl
extends java.rmi.server.UnicastRemoteObject
implements ChDevice, ChGpibDevice

This class is the bridge between the functionality of the GPIB-bus, that is concentrated in ChGpib, and the network. Its methods are mostly called by the client via RMI.
If synchronization on the GPIB-bus is necessary, it is synchronized on gpib.

See Also:
Serialized Form

Nested Class Summary
(package private) static class ChGpibDeviceImpl.ChClientGpibInfo
           
(package private) static class ChGpibDeviceImpl.ChSrqInitiator
           
(package private)  class ChGpibDeviceImpl.ChSrqService
           
 
Field Summary
(package private)  ChGpib gpib
           
(package private)  ChRsrcManagerImpl rsrcMgr
           
(package private)  ChGpibDeviceImpl.ChSrqService srqService
           
static java.lang.String srqSuffix
           
 
Fields inherited from class java.rmi.server.UnicastRemoteObject
 
Fields inherited from class java.rmi.server.RemoteServer
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Fields inherited from interface charly.server.devices.ChGpibDevice
NAME
 
Constructor Summary
ChGpibDeviceImpl()
           
 
Method Summary
 void checkSrq(java.lang.String taskID, int dvcAddr, ChClientGpib clientGpib)
          This method asks the server to notify the specified client, when an SRQ on the specified device occured.
 byte[] enter(java.lang.String taskID, int dvcAddr)
          receives from a given device on the gpib-bus.
 byte[] enter(java.lang.String taskID, int dvcAddr, java.lang.String suffix)
          receives from a given device on the gpib-bus.
 java.lang.String getName()
           
protected  java.lang.String getRsrcName(int dvcAddr)
          returns a string-description for a specified device on the GPIB-Bus.
protected  java.lang.String getRsrcName(int dvcAddr, java.lang.String suffix)
          returns a string-description for a specified device on the GPIB-Bus.
 void initialize(java.lang.String taskID, int addr, int level)
          usually does not need to be called.
 int isGpibBoardPresent()
          tests if gpibboard is present.
 int isListenerPresent(java.lang.String taskID, int dvcAddr)
          tests if listener with specified address is present.
 int isListenerPresent(java.lang.String taskID, int dvcAddr, java.lang.String suffix)
          tests if listener with specified address is present.
 int ppoll(java.lang.String taskID)
          This function will be replaced by an event-listener-model.
 byte[] rarray(java.lang.String taskID)
          receives binary and non-binary data from the gpib-bus.
 byte[] rarray(java.lang.String taskID, int dvcAddr)
          receives binary and non-binary data from a given device of the gpib-bus.
 byte[] rarray(java.lang.String taskID, int dvcAddr, java.lang.String suffix)
          receives binary and non-binary data from a given device of the gpib-bus.
 byte[] receive(java.lang.String taskID)
          receives non-binary data from the gpib-bus.
 byte[] receive(java.lang.String taskID, int dvcAddr)
          receives non-binary data from a device of the gpib-bus.
 byte[] receive(java.lang.String taskID, int dvcAddr, java.lang.String suffix)
          receives non-binary data from a device of the gpib-bus.
 void send(java.lang.String taskID, int dvcAddr, byte[] data, int length)
          sends a specified string to a given device on the gpib-bus.
 void send(java.lang.String taskID, int dvcAddr, java.lang.String suffix, byte[] data, int length)
          sends a specified string to a given device on the gpib-bus.
 byte[] sendAndEnter(java.lang.String taskID, int dvcAddr, java.lang.String suffix, byte[] data, int length)
          sends a specified string to a device on the gpib-bus and enters the result from this device.
 void setRsrcMgr(ChRsrcManagerImpl rsrcMgr)
          is called immediately after the constructor
 void setTimeOut(java.lang.String taskID, int msec)
          sets timeout-time of the GPIB-Bus in msec.
 int spoll(java.lang.String taskID, int dvcAddr)
          This function will be replaced by an event-listener-model.
 int srq(java.lang.String taskID)
          This function will be replaced by an event-listener-model.
 void tarray(java.lang.String taskID, byte[] data, int length, byte eoi)
          sends data to the gpib-bus.
 void tarray(java.lang.String taskID, int dvcAddr, byte[] data, int length, byte eoi)
          sends data to a given device of the gpib-bus.
 void tarray(java.lang.String taskID, int dvcAddr, java.lang.String suffix, byte[] data, int length, byte eoi)
          sends data to a given device of the gpib-bus.
 void transmit(java.lang.String taskID, byte[] data, int length)
          sends data to a the gpib-bus.
 void uncheckSrq(java.lang.String taskID, int dvcAddr, ChClientGpib clientGpib)
          This method tells the server to stop notifying the specified client, when an SRQ on the specified device occured.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

gpib

ChGpib gpib

rsrcMgr

ChRsrcManagerImpl rsrcMgr

srqService

ChGpibDeviceImpl.ChSrqService srqService

srqSuffix

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

ChGpibDeviceImpl

public ChGpibDeviceImpl()
                 throws java.rmi.RemoteException
Method Detail

setRsrcMgr

public void setRsrcMgr(ChRsrcManagerImpl rsrcMgr)
Description copied from interface: ChDevice
is called immediately after the constructor

Specified by:
setRsrcMgr in interface ChDevice

getName

public java.lang.String getName()
Specified by:
getName in interface ChDevice
Returns:
"GPIB"
See Also:
ChGpibDevice.NAME

getRsrcName

protected java.lang.String getRsrcName(int dvcAddr)
returns a string-description for a specified device on the GPIB-Bus.

Returns:
a string built of getName()+ slash + dvcAddr, e.g. "GPIB/7"

getRsrcName

protected java.lang.String getRsrcName(int dvcAddr,
                                       java.lang.String suffix)
returns a string-description for a specified device on the GPIB-Bus.

Parameters:
dvcAddr - (0-31)
suffix - - e.g. "CHANNEL2"; can be null
Returns:
a string built of getName()+ slash + dvcAddr +slash+ suffix, e.g. "GPIB/7/CHANNEL2"

initialize

public void initialize(java.lang.String taskID,
                       int addr,
                       int level)
                throws ChTaskNotStartedException,
                       ChAccessDeniedException
usually does not need to be called. The Gpib-bus is initialized by default by ChGpib.

Specified by:
initialize in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
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:
ChAccessDeniedException - if access to resource "GPIB" is denied
ChTaskNotStartedException

send

public void send(java.lang.String taskID,
                 int dvcAddr,
                 java.lang.String suffix,
                 byte[] data,
                 int length)
          throws ChTaskNotStartedException,
                 ChAccessDeniedException,
                 ChGpibTimeOutException,
                 ChGpibStateException
sends a specified string to a given device on the gpib-bus.

Specified by:
send in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
dvcAddr - the device-nr of the receiving device on the gpib-bus (0-32)
suffix - - e.g. "CHANNEL2"; can be null
data - the bytes to be sent
length - amount of bytes to be sent
Throws:
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException

send

public void send(java.lang.String taskID,
                 int dvcAddr,
                 byte[] data,
                 int length)
          throws ChTaskNotStartedException,
                 ChAccessDeniedException,
                 ChGpibTimeOutException,
                 ChGpibStateException
sends a specified string to a given device on the gpib-bus.

Specified by:
send in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
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
Throws:
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException

sendAndEnter

public byte[] sendAndEnter(java.lang.String taskID,
                           int dvcAddr,
                           java.lang.String suffix,
                           byte[] data,
                           int length)
                    throws java.rmi.RemoteException,
                           ChTaskNotStartedException,
                           ChAccessDeniedException,
                           ChGpibTimeOutException,
                           ChGpibStateException
sends a specified string to a device on the gpib-bus and enters the result from this device. It is a combination of send(String, int, String, byte[], int) and enter(String, int, String). This method synchronizes on gpib.

Specified by:
sendAndEnter in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
dvcAddr - the device-nr of the receiving device on the gpib-bus (0-32)
suffix - - e.g. "CHANNEL2"; can be null
data - the bytes to be sent
length - amount of bytes to be sent
Throws:
java.rmi.RemoteException
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException

enter

public byte[] enter(java.lang.String taskID,
                    int dvcAddr,
                    java.lang.String suffix)
             throws ChTaskNotStartedException,
                    ChAccessDeniedException,
                    ChGpibTimeOutException,
                    ChGpibStateException
receives from a given device on the gpib-bus.

Specified by:
enter in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
dvcAddr - the device-nr of the receiving device on the gpib-bus (0-32)
suffix - - e.g. "CHANNEL2"; can be null
Throws:
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException

enter

public byte[] enter(java.lang.String taskID,
                    int dvcAddr)
             throws ChTaskNotStartedException,
                    ChAccessDeniedException,
                    ChGpibTimeOutException,
                    ChGpibStateException
receives from a given device on the gpib-bus.

Specified by:
enter in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
dvcAddr - the device-nr of the receiving device on the gpib-bus (0-32)
Throws:
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException

checkSrq

public void checkSrq(java.lang.String taskID,
                     int dvcAddr,
                     ChClientGpib clientGpib)
              throws ChTaskNotStartedException,
                     ChAccessDeniedException
This method asks the server to notify the specified client, when an SRQ on the specified device occured.

Specified by:
checkSrq in interface ChGpibDevice
Throws:
ChTaskNotStartedException
ChAccessDeniedException

uncheckSrq

public void uncheckSrq(java.lang.String taskID,
                       int dvcAddr,
                       ChClientGpib clientGpib)
                throws ChTaskNotStartedException,
                       ChAccessDeniedException
This method tells the server to stop notifying the specified client, when an SRQ on the specified device occured.

Specified by:
uncheckSrq in interface ChGpibDevice
Throws:
ChTaskNotStartedException
ChAccessDeniedException

spoll

public int spoll(java.lang.String taskID,
                 int dvcAddr)
          throws ChTaskNotStartedException,
                 ChAccessDeniedException,
                 ChGpibTimeOutException,
                 ChGpibStateException
This function will be replaced by an event-listener-model.

Specified by:
spoll in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
dvcAddr - the device-nr of the receiving device on the gpib-bus (0-32)
Returns:
Spoll-Result, which is not the status of spoll
Throws:
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
See Also:
srq(String)

ppoll

public int ppoll(java.lang.String taskID)
          throws ChTaskNotStartedException,
                 ChAccessDeniedException
This function will be replaced by an event-listener-model.

Specified by:
ppoll in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
Throws:
ChAccessDeniedException - if access to resource "GPIB" is denied
ChTaskNotStartedException
See Also:
srq(String)

transmit

public void transmit(java.lang.String taskID,
                     byte[] data,
                     int length)
              throws ChTaskNotStartedException,
                     ChAccessDeniedException,
                     ChGpibTimeOutException,
                     ChGpibStateException
sends data to a the gpib-bus.

Specified by:
transmit in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
data - the bytes to be sent
length - amount of bytes to be sent
Throws:
ChAccessDeniedException - if access to resource "GPIB" is denied
ChTaskNotStartedException
ChGpibTimeOutException
ChGpibStateException

receive

public byte[] receive(java.lang.String taskID)
               throws ChTaskNotStartedException,
                      ChAccessDeniedException,
                      ChGpibTimeOutException,
                      ChGpibStateException
receives non-binary data from the gpib-bus.

Specified by:
receive in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
Throws:
ChAccessDeniedException - if access to resource "GPIB" is denied.
ChTaskNotStartedException
ChGpibTimeOutException
ChGpibStateException

receive

public byte[] receive(java.lang.String taskID,
                      int dvcAddr,
                      java.lang.String suffix)
               throws ChTaskNotStartedException,
                      ChAccessDeniedException,
                      ChGpibTimeOutException,
                      ChGpibStateException
receives non-binary data from a device of the gpib-bus. This implementation first transmits the String "UNL UNT MLA TALK "+dvcAddr and then calls ChGpib.receive()

Specified by:
receive in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
dvcAddr - the device-nr of the receiving device on the gpib-bus (0-32)
suffix - - e.g. "CHANNEL2"; can be null
Throws:
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
Since:
Charly V0.3.6

receive

public byte[] receive(java.lang.String taskID,
                      int dvcAddr)
               throws ChTaskNotStartedException,
                      ChAccessDeniedException,
                      ChGpibTimeOutException,
                      ChGpibStateException
receives non-binary data from a device of the gpib-bus. This implementation first transmits the String "UNL UNT MLA TALK "+dvcAddr and then calls ChGpib.receive()

Specified by:
receive in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
dvcAddr - the device-nr of the receiving device on the gpib-bus (0-32)
Throws:
ChTaskNotStartedException
ChAccessDeniedException
ChGpibTimeOutException
ChGpibStateException
Since:
Charly V0.3.0

tarray

public void tarray(java.lang.String taskID,
                   byte[] data,
                   int length,
                   byte eoi)
            throws ChTaskNotStartedException,
                   ChAccessDeniedException,
                   ChGpibTimeOutException,
                   ChGpibStateException
sends data to the gpib-bus. The data can be in binary form.

Specified by:
tarray in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
data - the bytes to be sent
length - amount of bytes to be sent
eoi - EOI-Byte
Throws:
ChAccessDeniedException - if access to resource "GPIB" is denied.
ChTaskNotStartedException
ChGpibTimeOutException
ChGpibStateException

tarray

public void tarray(java.lang.String taskID,
                   int dvcAddr,
                   java.lang.String suffix,
                   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. This implementation first transmits the String "UNL UNT MTA LISTEN "+dvcAddr and then calls ChGpib.tarray(byte[], int, byte).

Specified by:
tarray in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
dvcAddr - the device-nr of the receiving device on the gpib-bus (0-32)
suffix - - e.g. "CHANNEL2"; can be null
data - the bytes to be sent
length - amount of bytes to be sent
eoi - EOI-Byte
Throws:
ChAccessDeniedException - if access to the receiving device is denied.
java.rmi.RemoteException
ChTaskNotStartedException
ChGpibTimeOutException
ChGpibStateException
Since:
Charly V0.3.0

tarray

public void tarray(java.lang.String taskID,
                   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. This implementation first transmits the String "UNL UNT MTA LISTEN "+dvcAddr and then calls ChGpib.tarray(byte[], int, byte).

Specified by:
tarray in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
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:
ChAccessDeniedException - if access to the receiving device is denied.
java.rmi.RemoteException
ChTaskNotStartedException
ChGpibTimeOutException
ChGpibStateException
Since:
Charly V0.3.0

rarray

public byte[] rarray(java.lang.String taskID)
              throws ChTaskNotStartedException,
                     ChAccessDeniedException,
                     ChGpibTimeOutException,
                     ChGpibStateException
receives binary and non-binary data from the gpib-bus.

Specified by:
rarray in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
Throws:
ChAccessDeniedException - if access to resource "GPIB" is denied.
ChTaskNotStartedException
ChGpibTimeOutException
ChGpibStateException

rarray

public byte[] rarray(java.lang.String taskID,
                     int dvcAddr,
                     java.lang.String suffix)
              throws ChTaskNotStartedException,
                     ChAccessDeniedException,
                     ChGpibTimeOutException,
                     ChGpibStateException
receives binary and non-binary data from a given device of the gpib-bus. This implementation first transmits the String "UNL UNT MLA TALK "+dvcAddr and then calls ChGpib.rarray()

Specified by:
rarray in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
dvcAddr - (0-31)
suffix - - e.g. "CHANNEL2"; can be null
Throws:
ChAccessDeniedException - if access to the gpib device is denied.
ChTaskNotStartedException
ChGpibTimeOutException
ChGpibStateException
Since:
Charly V0.3.0

rarray

public byte[] rarray(java.lang.String taskID,
                     int dvcAddr)
              throws ChTaskNotStartedException,
                     ChAccessDeniedException,
                     ChGpibTimeOutException,
                     ChGpibStateException
receives binary and non-binary data from a given device of the gpib-bus. This implementation first transmits the String "UNL UNT MLA TALK "+dvcAddr and then calls ChGpib.rarray()

Specified by:
rarray in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
dvcAddr - the device-nr of the receiving device on the gpib-bus (0-32)
Throws:
ChAccessDeniedException - if access to the gpib device is denied.
ChTaskNotStartedException
ChGpibTimeOutException
ChGpibStateException
Since:
Charly V0.3.0

srq

public int srq(java.lang.String taskID)
        throws ChTaskNotStartedException,
               ChAccessDeniedException
This function will be replaced by an event-listener-model.

Specified by:
srq in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
Returns:
status
Throws:
ChAccessDeniedException - if access to resource "GPIB" is denied
ChTaskNotStartedException
See Also:
spoll(String,int), ppoll(String)

setTimeOut

public void setTimeOut(java.lang.String taskID,
                       int msec)
                throws ChTaskNotStartedException,
                       ChAccessDeniedException
sets timeout-time of the GPIB-Bus in msec.

Specified by:
setTimeOut in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
Throws:
ChAccessDeniedException - if access to resource "GPIB" is denied
ChTaskNotStartedException

isListenerPresent

public int isListenerPresent(java.lang.String taskID,
                             int dvcAddr,
                             java.lang.String suffix)
                      throws ChTaskNotStartedException,
                             ChAccessDeniedException
tests if listener with specified address is present.

Specified by:
isListenerPresent in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
dvcAddr - the device-nr of the checked device on the gpib-bus (0-32)
suffix - - e.g. "CHANNEL2"; can be null
Returns:
status ???
Throws:
ChTaskNotStartedException
ChAccessDeniedException

isListenerPresent

public int isListenerPresent(java.lang.String taskID,
                             int dvcAddr)
                      throws ChTaskNotStartedException,
                             ChAccessDeniedException
tests if listener with specified address is present.

Specified by:
isListenerPresent in interface ChGpibDevice
Parameters:
taskID - is the string returned by ChRsrcManager.startTask( ChClientTask, String, java.util.Set)
dvcAddr - the device-nr of the checked device on the gpib-bus (0-32)
Returns:
status ???
Throws:
ChTaskNotStartedException
ChAccessDeniedException

isGpibBoardPresent

public int isGpibBoardPresent()
tests if gpibboard is present.

Specified by:
isGpibBoardPresent in interface ChGpibDevice
Returns:
status.