gov.sns.jca
Class JcaChannel

java.lang.Object
  |
  +--gov.sns.ca.Channel
        |
        +--gov.sns.jca.JcaChannel

public class JcaChannel
extends Channel

Objectizes the Java Channel Access (jca) library by Boucher. In particular, the jca.PV object and static jca.Ca are encapsulated. The the jca.PV and jca.Ca operations are collected and exposed as necessary to perform rudimentary process variable puts, gets, and monitors. The user may request a reference to the associated PV object to perform more complicated operations as appropriate.


Field Summary
protected  gov.aps.jca.Channel _jcaChannel
          JCA Channel
protected  gov.aps.jca.Context _jcaContext
          JCA Context
static int BYTE
           
static double c_dblDefTimeEvent
           
static double c_dblDefTimeIO
           
static int DOUBLE
           
static int ENUM
           
static int FLOAT
           
protected  boolean hasInitializedCa
          indicates whether this channel ever initialized CA
static int INT
           
protected static boolean s_bolCaInit
           
protected static boolean s_bolCaLock
           
protected static boolean s_bolDebug
           
protected static long s_lngCntRef
           
static int SHORT
           
static int STRING
           
 
Fields inherited from class gov.sns.ca.Channel
channelSystem, connectionFlag, connectionProxy, m_dblTmEvt, m_dblTmIO, m_strId, messageCenter
 
Method Summary
 Monitor addMonitorValStatus(IEventSinkValStatus ifcSink, int intMaskFire)
          Setup a monitor on this channel
 Monitor addMonitorValTime(IEventSinkValTime ifcSink, int intMaskFire)
          Setup a monitor on this channel
 Monitor addMonitorValue(IEventSinkValue ifcSink, int intMaskFire)
          Setup a monitor on this channel
static void caLock()
          Channel access library lock.
static void caUnlock()
          Unlock the Channel Access library.
 boolean connect_async()
          Open and secure channel across network, setup a connection monitor.
 boolean connect()
          Open and secure channel across network
 void disconnect()
          Terminate the network channel connection and clear all events associated with process variable
 int elementCount()
          Return size of value array associated with process variable
 java.lang.Class elementType()
          get the Java class associated with the native type of this channel
protected  void finalize()
          Check if Channel Access library can be released
protected  gov.aps.jca.dbr.CTRL getCtrlInfo()
          Returns a DBR_CTRL instance of the appropriate for this channel.
 double getEventTimeout()
          Get the channel access Pend Event timeout
 double getIoTimeout()
          Get the channel access Pend IO timeout
 ChannelStatusRecord getRawStatusRecord()
          Return a ChannelStatusRecord representing the fetched record for the native type of this channel.
 ChannelTimeRecord getRawTimeRecord()
          Return a ChannelTimeRecord representing the fetched record for the native type of this channel.
 void getRawValueCallback(IEventSinkValue listener)
          Get value of process variable asynchronously with a "get monitor" object.
 ChannelRecord getRawValueRecord()
          Return a ChannelRecord representing the fetched record for the native type of this channel.
protected  int getStatusType()
          Get the native value-status DBR type of this channel.
protected  int getTimeType()
          Get the native DBR value-status-timestamp type of this channel.
 java.lang.String getUnits()
          Convenience method which returns the units for this channel.
 java.lang.Object getValue()
          5/6/2002 -tap This convenience method returns a data value object for a general data type.
 java.lang.String hostName()
          Get the IOC host name which supports the process variable
protected  void initChannelAccess()
          Initialize channel access and increment instance count
 int nativeType()
          Return native type of process variable associated with channel
 void putRawValCallback(byte[] newVal, PutListener listener)
          Asynchronously put a raw value to the channel process variable.
 void putRawValCallback(byte newVal, PutListener listener)
          Asynchronously put a raw value to the channel process variable.
 void putRawValCallback(double[] newVal, PutListener listener)
          Asynchronously put a raw value to the channel process variable.
 void putRawValCallback(double newVal, PutListener listener)
          Asynchronously put a raw value to the channel process variable.
 void putRawValCallback(float[] newVal, PutListener listener)
          Asynchronously put a raw value to the channel process variable.
 void putRawValCallback(float newVal, PutListener listener)
          Asynchronously put a raw value to the channel process variable.
 void putRawValCallback(int[] newVal, PutListener listener)
          Asynchronously put a raw value to the channel process variable.
 void putRawValCallback(int newVal, PutListener listener)
          Asynchronously put a raw value to the channel process variable.
 void putRawValCallback(short[] newVal, PutListener listener)
          Asynchronously put a raw value to the channel process variable.
 void putRawValCallback(short newVal, PutListener listener)
          Asynchronously put a raw value to the channel process variable.
 void putRawValCallback(java.lang.String newVal, PutListener listener)
          Asynchronously put a raw value to the channel process variable.
 java.lang.Number rawLowerAlarmLimit()
          Convenience method which returns the lower alarm limit.
 java.lang.Number rawLowerControlLimit()
          Convenience method which returns the lower control limit.
 java.lang.Number rawLowerDisplayLimit()
          Convenience method which returns the lower display limit.
 java.lang.Number rawLowerWarningLimit()
          Convenience method which returns the lower warning limit.
 java.lang.Number rawUpperAlarmLimit()
          Convenience method which returns the upper alarm limit.
 java.lang.Number rawUpperControlLimit()
          Convenience method which returns the upper control limit.
 java.lang.Number rawUpperDisplayLimit()
          Convenience method which returns the upper display limit.
 java.lang.Number rawUpperWarningLimit()
          Convenience method which returns the upper warning limit.
 boolean readAccess()
          Determine if channel has read access to process variable
static void setDebugMode(boolean bDebug)
          Set Forte debug mode.
 void setEventTimeout(double dblTm)
          Set the channel access Pend Event timeout
 void setIoTimeout(double dblTm)
          Set the channel access Pend IO timeout
 int state()
          Get state of current process variable connection
 boolean writeAccess()
          Determine if channel has write access to process variable
 
Methods inherited from class gov.sns.ca.Channel
addConnectionListener, channelName, checkConnection, checkConnection, getArrayValue, getArrByte, getArrByteCallback, getArrDbl, getArrDblCallback, getArrFlt, getArrFltCallback, getArrInt, getArrIntCallback, getId, getStatusRecord, getSyncRequest, getTimeRecord, getValByte, getValByteCallback, getValDbl, getValDblCallback, getValEnum, getValFlt, getValFltCallback, getValInt, getValIntCallback, getValueRecord, getValueTransform, isConnected, lowerAlarmLimit, lowerControlLimit, lowerDisplayLimit, lowerWarningLimit, pendEvent, pendIO, putVal, putVal, putVal, putVal, putVal, putVal, putVal, putVal, putVal, putVal, putVal, putValCallback, putValCallback, putValCallback, putValCallback, putValCallback, putValCallback, putValCallback, putValCallback, putValCallback, putValCallback, putValCallback, removeConnectionListener, setChannelName, setSyncRequest, upperAlarmLimit, upperControlLimit, upperDisplayLimit, upperWarningLimit
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s_bolCaInit

protected static boolean s_bolCaInit

s_bolCaLock

protected static boolean s_bolCaLock

s_lngCntRef

protected static long s_lngCntRef

s_bolDebug

protected static boolean s_bolDebug

c_dblDefTimeIO

public static final double c_dblDefTimeIO
See Also:
Constant Field Values

c_dblDefTimeEvent

public static final double c_dblDefTimeEvent
See Also:
Constant Field Values

STRING

public static final int STRING

SHORT

public static final int SHORT

FLOAT

public static final int FLOAT

ENUM

public static final int ENUM

BYTE

public static final int BYTE

INT

public static final int INT

DOUBLE

public static final int DOUBLE

_jcaChannel

protected gov.aps.jca.Channel _jcaChannel
JCA Channel


_jcaContext

protected gov.aps.jca.Context _jcaContext
JCA Context


hasInitializedCa

protected boolean hasInitializedCa
indicates whether this channel ever initialized CA

Method Detail

caLock

public static void caLock()
Channel access library lock. Locks CA library into memory once it is initialized. CA library will not release until Java virtual machine terminates.


caUnlock

public static void caUnlock()
Unlock the Channel Access library. CA library may be released if there are no Channel instances in the Java virtual machine.


setDebugMode

public static void setDebugMode(boolean bDebug)
Set Forte debug mode. The jca shared library (jca.dll on Windows) is normally loaded whenever the first Channel object is instantiated. This is done with a call to jca.Ca.init() with the Channel.caAddRef() method. Loading the jca shared library seems to confuse the Forte debugger. Use this method to set the Channel Forte debug mode to true. When in debug mode the jca shared library is never loaded. Thus, Channel objects may be instatiated, but they cannot be used to connect to EPICS channel access.

Parameters:
bDebug - debug flag (on or off)

finalize

protected void finalize()
                 throws java.lang.Throwable
Check if Channel Access library can be released

Overrides:
finalize in class java.lang.Object
java.lang.Throwable

setIoTimeout

public void setIoTimeout(double dblTm)
Set the channel access Pend IO timeout

Overrides:
setIoTimeout in class Channel
Parameters:
dblTm - I/O timeout

setEventTimeout

public void setEventTimeout(double dblTm)
Set the channel access Pend Event timeout

Overrides:
setEventTimeout in class Channel
Parameters:
dblTm - event timeout

getIoTimeout

public double getIoTimeout()
Get the channel access Pend IO timeout

Overrides:
getIoTimeout in class Channel
Returns:
I/O timeout

getEventTimeout

public double getEventTimeout()
Get the channel access Pend Event timeout

Overrides:
getEventTimeout in class Channel
Returns:
event timeout

initChannelAccess

protected void initChannelAccess()
Initialize channel access and increment instance count


connect

public boolean connect()
Open and secure channel across network

Specified by:
connect in class Channel
Returns:
false if connection could not be established

connect_async

public boolean connect_async()
Open and secure channel across network, setup a connection monitor. Warning! This method is not thread safe.

Specified by:
connect_async in class Channel
Returns:
false if connection could not be established

disconnect

public void disconnect()
Terminate the network channel connection and clear all events associated with process variable

Specified by:
disconnect in class Channel

state

public int state()
          throws ConnectionException
Get state of current process variable connection

Returns:
EPICS channel access state code
ConnectionException

elementType

public java.lang.Class elementType()
                            throws ConnectionException
get the Java class associated with the native type of this channel

Specified by:
elementType in class Channel
ConnectionException

nativeType

public int nativeType()
               throws ConnectionException
Return native type of process variable associated with channel

Returns:
jca.DBR type code of process variable
ConnectionException

elementCount

public int elementCount()
                 throws ConnectionException
Return size of value array associated with process variable

Specified by:
elementCount in class Channel
Returns:
number of values in process variable
ConnectionException

readAccess

public boolean readAccess()
                   throws ConnectionException
Determine if channel has read access to process variable

Specified by:
readAccess in class Channel
Returns:
true if channel has read access
Throws:
ConnectionException - channel not connected

writeAccess

public boolean writeAccess()
                    throws ConnectionException
Determine if channel has write access to process variable

Specified by:
writeAccess in class Channel
Returns:
true if channel has write access
Throws:
ConnectionException - channel not connected

hostName

public java.lang.String hostName()
                          throws ConnectionException
Get the IOC host name which supports the process variable

Returns:
string containing network name of host
ConnectionException

getStatusType

protected int getStatusType()
                     throws ConnectionException,
                            GetException
Get the native value-status DBR type of this channel.

Returns:
The native DBR type of this channel.
ConnectionException
GetException

getTimeType

protected int getTimeType()
                   throws ConnectionException,
                          GetException
Get the native DBR value-status-timestamp type of this channel.

Returns:
The native DBR type of this channel.
ConnectionException
GetException

getUnits

public java.lang.String getUnits()
                          throws ConnectionException,
                                 GetException
Convenience method which returns the units for this channel.

Specified by:
getUnits in class Channel
ConnectionException
GetException

rawUpperDisplayLimit

public java.lang.Number rawUpperDisplayLimit()
                                      throws ConnectionException,
                                             GetException
Convenience method which returns the upper display limit.

Specified by:
rawUpperDisplayLimit in class Channel
ConnectionException
GetException

rawLowerDisplayLimit

public java.lang.Number rawLowerDisplayLimit()
                                      throws ConnectionException,
                                             GetException
Convenience method which returns the lower display limit.

Specified by:
rawLowerDisplayLimit in class Channel
ConnectionException
GetException

rawUpperAlarmLimit

public java.lang.Number rawUpperAlarmLimit()
                                    throws ConnectionException,
                                           GetException
Convenience method which returns the upper alarm limit.

Specified by:
rawUpperAlarmLimit in class Channel
ConnectionException
GetException

rawLowerAlarmLimit

public java.lang.Number rawLowerAlarmLimit()
                                    throws ConnectionException,
                                           GetException
Convenience method which returns the lower alarm limit.

Specified by:
rawLowerAlarmLimit in class Channel
ConnectionException
GetException

rawUpperWarningLimit

public java.lang.Number rawUpperWarningLimit()
                                      throws ConnectionException,
                                             GetException
Convenience method which returns the upper warning limit.

Specified by:
rawUpperWarningLimit in class Channel
ConnectionException
GetException

rawLowerWarningLimit

public java.lang.Number rawLowerWarningLimit()
                                      throws ConnectionException,
                                             GetException
Convenience method which returns the lower warning limit.

Specified by:
rawLowerWarningLimit in class Channel
ConnectionException
GetException

rawUpperControlLimit

public java.lang.Number rawUpperControlLimit()
                                      throws ConnectionException,
                                             GetException
Convenience method which returns the upper control limit.

Specified by:
rawUpperControlLimit in class Channel
ConnectionException
GetException

rawLowerControlLimit

public java.lang.Number rawLowerControlLimit()
                                      throws ConnectionException,
                                             GetException
Convenience method which returns the lower control limit.

Specified by:
rawLowerControlLimit in class Channel
ConnectionException
GetException

getCtrlInfo

protected gov.aps.jca.dbr.CTRL getCtrlInfo()
                                    throws ConnectionException,
                                           GetException
Returns a DBR_CTRL instance of the appropriate for this channel. The DBR_CTRL record contains valuable information about the channel such as the units and upper and lower limits for alarm, display, warning and control. All of these items are returned as a DBData instance. Examples: String units = channel.getCtrlInfo().units(); double upperDisplayLimit = channel.getCtrlInfo().upperDispLimit().doubleValue();

ConnectionException
GetException

getValue

public java.lang.Object getValue()
                          throws ConnectionException,
                                 GetException
5/6/2002 -tap This convenience method returns a data value object for a general data type. It always attempts a connect before fetching data. For primitive data types, it returns an array of values.

ConnectionException
GetException

getRawValueRecord

public ChannelRecord getRawValueRecord()
                                throws ConnectionException,
                                       GetException
Return a ChannelRecord representing the fetched record for the native type of this channel. This is a convenient way to get the value of the PV.

Specified by:
getRawValueRecord in class Channel
ConnectionException
GetException

getRawStatusRecord

public ChannelStatusRecord getRawStatusRecord()
                                       throws ConnectionException,
                                              GetException
Return a ChannelStatusRecord representing the fetched record for the native type of this channel. This is a convenient way to get the value of the PV along with status.

Specified by:
getRawStatusRecord in class Channel
ConnectionException
GetException

getRawTimeRecord

public ChannelTimeRecord getRawTimeRecord()
                                   throws ConnectionException,
                                          GetException
Return a ChannelTimeRecord representing the fetched record for the native type of this channel. This is a convenient way to get the value of the PV along with status and timestamp.

Specified by:
getRawTimeRecord in class Channel
ConnectionException
GetException

getRawValueCallback

public void getRawValueCallback(IEventSinkValue listener)
                         throws ConnectionException,
                                GetException
Get value of process variable asynchronously with a "get monitor" object. Value of process variable is sent to the event listener indicated by IEventSinkValue.

Specified by:
getRawValueCallback in class Channel
Parameters:
listener - Listener of the callback event.
Throws:
ConnectionException - channel is not connected
GetException - general channel access failure

putRawValCallback

public void putRawValCallback(java.lang.String newVal,
                              PutListener listener)
                       throws ConnectionException,
                              PutException
Asynchronously put a raw value to the channel process variable. Fire the specified callback when put is complete.

Specified by:
putRawValCallback in class Channel
Parameters:
newVal - value sent to process variable
listener - The receiver of the callback event
Throws:
ConnectionException - channel is not connected
PutException - general put failure

putRawValCallback

public void putRawValCallback(byte newVal,
                              PutListener listener)
                       throws ConnectionException,
                              PutException
Asynchronously put a raw value to the channel process variable. Fire the specified callback when put is complete.

Specified by:
putRawValCallback in class Channel
Parameters:
newVal - value sent to process variable
listener - The receiver of the callback event
Throws:
ConnectionException - channel is not connected
PutException - general put failure

putRawValCallback

public void putRawValCallback(short newVal,
                              PutListener listener)
                       throws ConnectionException,
                              PutException
Asynchronously put a raw value to the channel process variable. Fire the specified callback when put is complete.

Specified by:
putRawValCallback in class Channel
Parameters:
newVal - value sent to process variable
listener - The receiver of the callback event
Throws:
ConnectionException - channel is not connected
PutException - general put failure

putRawValCallback

public void putRawValCallback(int newVal,
                              PutListener listener)
                       throws ConnectionException,
                              PutException
Asynchronously put a raw value to the channel process variable. Fire the specified callback when put is complete.

Specified by:
putRawValCallback in class Channel
Parameters:
newVal - value sent to process variable
listener - The receiver of the callback event
Throws:
ConnectionException - channel is not connected
PutException - general put failure

putRawValCallback

public void putRawValCallback(float newVal,
                              PutListener listener)
                       throws ConnectionException,
                              PutException
Asynchronously put a raw value to the channel process variable. Fire the specified callback when put is complete.

Specified by:
putRawValCallback in class Channel
Parameters:
newVal - value sent to process variable
listener - The receiver of the callback event
Throws:
ConnectionException - channel is not connected
PutException - general put failure

putRawValCallback

public void putRawValCallback(double newVal,
                              PutListener listener)
                       throws ConnectionException,
                              PutException
Asynchronously put a raw value to the channel process variable. Fire the specified callback when put is complete.

Specified by:
putRawValCallback in class Channel
Parameters:
newVal - value sent to process variable
listener - The receiver of the callback event
Throws:
ConnectionException - channel is not connected
PutException - general put failure

putRawValCallback

public void putRawValCallback(byte[] newVal,
                              PutListener listener)
                       throws ConnectionException,
                              PutException
Asynchronously put a raw value to the channel process variable. Fire the specified callback when put is complete.

Specified by:
putRawValCallback in class Channel
Parameters:
newVal - value sent to process variable
listener - The receiver of the callback event
Throws:
ConnectionException - channel is not connected
PutException - general put failure

putRawValCallback

public void putRawValCallback(short[] newVal,
                              PutListener listener)
                       throws ConnectionException,
                              PutException
Asynchronously put a raw value to the channel process variable. Fire the specified callback when put is complete.

Specified by:
putRawValCallback in class Channel
Parameters:
newVal - value sent to process variable
listener - The receiver of the callback event
Throws:
ConnectionException - channel is not connected
PutException - general put failure

putRawValCallback

public void putRawValCallback(int[] newVal,
                              PutListener listener)
                       throws ConnectionException,
                              PutException
Asynchronously put a raw value to the channel process variable. Fire the specified callback when put is complete.

Specified by:
putRawValCallback in class Channel
Parameters:
newVal - value sent to process variable
listener - The receiver of the callback event
Throws:
ConnectionException - channel is not connected
PutException - general put failure

putRawValCallback

public void putRawValCallback(float[] newVal,
                              PutListener listener)
                       throws ConnectionException,
                              PutException
Asynchronously put a raw value to the channel process variable. Fire the specified callback when put is complete.

Specified by:
putRawValCallback in class Channel
Parameters:
newVal - value sent to process variable
listener - The receiver of the callback event
Throws:
ConnectionException - channel is not connected
PutException - general put failure

putRawValCallback

public void putRawValCallback(double[] newVal,
                              PutListener listener)
                       throws ConnectionException,
                              PutException
Asynchronously put a raw value to the channel process variable. Fire the specified callback when put is complete.

Specified by:
putRawValCallback in class Channel
Parameters:
newVal - value sent to process variable
listener - The receiver of the callback event
Throws:
ConnectionException - channel is not connected
PutException - general put failure

addMonitorValTime

public Monitor addMonitorValTime(IEventSinkValTime ifcSink,
                                 int intMaskFire)
                          throws ConnectionException,
                                 MonitorException
Setup a monitor on this channel

Specified by:
addMonitorValTime in class Channel
Parameters:
ifcSink - interface to data sink
intMaskFire - code specifying when the monitor is fired or'ed combination of {Monitor.VALUE, Monitor.LOG, Monitor.ALARM}
Returns:
MonitorSrc object associated with this event
Throws:
MonitorException - general monitor failure
ConnectionException - channel is not connected

addMonitorValStatus

public Monitor addMonitorValStatus(IEventSinkValStatus ifcSink,
                                   int intMaskFire)
                            throws ConnectionException,
                                   MonitorException
Setup a monitor on this channel

Specified by:
addMonitorValStatus in class Channel
Parameters:
ifcSink - interface to data sink
intMaskFire - code specifying when the monitor is fired or'ed combination of {Monitor.VALUE, Monitor.LOG, Monitor.ALARM}
Returns:
MonitorSrc object associated with this event
Throws:
ConnectionException - channel is not connected
MonitorException - general monitor failure

addMonitorValue

public Monitor addMonitorValue(IEventSinkValue ifcSink,
                               int intMaskFire)
                        throws ConnectionException,
                               MonitorException
Setup a monitor on this channel

Specified by:
addMonitorValue in class Channel
Parameters:
ifcSink - interface to data sink
intMaskFire - code specifying when the monitor is fired or'ed combination of {Monitor.VALUE, Monitor.LOG, Monitor.ALARM}
Returns:
MonitorSrc object associated with this event
Throws:
MonitorException - general monitor failure
ConnectionException - channel is not connected