gov.aps.epics.jca
Class Context

java.lang.Object
  |
  +--gov.aps.epics.jca.Context
All Implemented Interfaces:
CaConstants
Direct Known Subclasses:
JNIContext

public abstract class Context
extends java.lang.Object
implements CaConstants

The class representing a CA Context.

A Context controls all IO operations and the circuits thru which Channels will be created and connected. Since CA 3.14 an application can create more than one context, thus ehancing IO control and Channels managment. It is also possible for the application to specify how asynchronous callbacks will be provided by a context.

 Two differents mode are possible:
   ENABLE_PREEMPTIVE_CALLBACK : The callbacks are controled by independant threads. The application 
                                does not need to call pendEvent() to process pending event.
   DISABLE_PREEMPTIVE_CALLBACK: The callbacks are controled by the application itself which
                                need to call pendEvent() to process pending events.
 
 
In earlier CA version, only on context using the DISABLE_PREEMPTIVE_CALLBACK mode is allowed. The Context class also offers two different thread control mode.
   THREAD_CTRL_EXTERNAL: in this mode only the thread that created the Context (and all 
                         others that have registered with the Context) are allowed to perform
                         operations.
   THREAD_CTRL_INTERNAL: in this mode the Context uses its own internal thread to perform
                         operations, thus allowing any thread in the application to access the Context.

 
For complexity reasons uses THREAD_CTRL_EXTERNAL mode in simple application or in application where you want to control which threads will access the Context.

See Also:
Ca, CaConstants

Field Summary
protected static java.util.HashMap _contextMap
           
 
Fields inherited from interface gov.aps.epics.jca.CaConstants
CA_K_ERROR, CA_K_FATAL, CA_K_INFO, CA_K_SEVERE, CA_K_SUCCESS, CA_K_WARNING, CA_M_ERROR, CA_M_LEVEL, CA_M_MSG_NO, CA_M_SEVERE, CA_M_SEVERITY, CA_M_SUCCESS, CA_OP_ADD_MONITOR, CA_OP_CLEAR_MONITOR, CA_OP_CONN_DOWN, CA_OP_CONN_UP, CA_OP_FIRST, CA_OP_GET, CA_OP_LAST, CA_OP_OTHER, CA_OP_PUT, CA_OP_SEARCH, CA_OP_STRING, CA_V_MSG_NO, CA_V_SEVERITY, CA_V_SUCCESS, CALLBACK_MODE_FIRST, CALLBACK_MODE_LAST, CALLBACK_MODE_STRING, CS_CLOSED, CS_CONN, CS_FIRST, CS_LAST, CS_NEVER_CONN, CS_PREV_CONN, CS_STRING, DBE_ALARM, DBE_LOG, DBE_VALUE, DBR_BYTE, DBR_CTRL_BYTE, DBR_CTRL_DOUBLE, DBR_CTRL_ENUM, DBR_CTRL_FLOAT, DBR_CTRL_INT, DBR_CTRL_SHORT, DBR_CTRL_STRING, DBR_DOUBLE, DBR_ENUM, DBR_FIRST, DBR_FLOAT, DBR_GR_BYTE, DBR_GR_DOUBLE, DBR_GR_FLOAT, DBR_GR_INT, DBR_GR_SHORT, DBR_GR_STRING, DBR_INT, DBR_LABELS_ENUM, DBR_LAST, DBR_PUT_ACKS, DBR_PUT_ACKT, DBR_SHORT, DBR_STRING, DBR_STS_BYTE, DBR_STS_DOUBLE, DBR_STS_ENUM, DBR_STS_FLOAT, DBR_STS_INT, DBR_STS_SHORT, DBR_STS_STRING, DBR_STSACK_STRING, DBR_TIME_BYTE, DBR_TIME_DOUBLE, DBR_TIME_ENUM, DBR_TIME_FLOAT, DBR_TIME_INT, DBR_TIME_SHORT, DBR_TIME_STRING, DBR_TYPE_STRING, DISABLE_PREEMPTIVE_CALLBACK, ECA_ADDFAIL, ECA_ALLOCMEM, ECA_ANACHRONISM, ECA_BADCHID, ECA_BADCOUNT, ECA_BADFUNCPTR, ECA_BADMASK, ECA_BADMONID, ECA_BADPRIORITY, ECA_BADSTR, ECA_BADSYNCGRP, ECA_BADTYPE, ECA_BUILDGET, ECA_CHANDESTROY, ECA_CHIDNOTFND, ECA_CHIDRETRY, ECA_CONN, ECA_DBLCHNL, ECA_DBLCLFAIL, ECA_DEFUNCT, ECA_DISCONN, ECA_DISCONNCHID, ECA_DLCKREST, ECA_EMPTYSTR, ECA_EVDISALLOW, ECA_FIRST, ECA_GETFAIL, ECA_INTERNAL, ECA_IODONE, ECA_IOINPROGRESS, ECA_ISATTACHED, ECA_LAST, ECA_MAXIOC, ECA_MESSAGE_STRING, ECA_NEEDSFP, ECA_NEWADDR, ECA_NEWCONN, ECA_NOCACTX, ECA_NOCAST, ECA_NOCHANMSG, ECA_NOCONVERT, ECA_NORDACCESS, ECA_NOREPEATER, ECA_NORMAL, ECA_NOSEARCHADDR, ECA_NOSUPPORT, ECA_NOTINSERVICE, ECA_NOTTHREADED, ECA_NOWTACCESS, ECA_OVEVFAIL, ECA_PUTCBINPROG, ECA_PUTFAIL, ECA_SERVBEHIND, ECA_SOCK, ECA_STRTOBIG, ECA_TIMEOUT, ECA_TOLARGE, ECA_UKNCHAN, ECA_UKNFIELD, ECA_UKNHOST, ECA_UKNSERV, ENABLE_PREEMPTIVE_CALLBACK, THREAD_CTRL_EXTERNAL, THREAD_CTRL_FIRST, THREAD_CTRL_INTERNAL, THREAD_CTRL_LAST, THREAD_CTRL_STRING
 
Constructor Summary
Context()
           
 
Method Summary
abstract  void attachCurrentThread()
           
 gov.aps.epics.jca.Channel createChannel(java.lang.String name)
          Create a new Channel using this context to access a process variable.
abstract  gov.aps.epics.jca.Channel createChannel(java.lang.String name, gov.aps.epics.jca.ConnectionListener l)
          Create a new Channel using this context to access a process variable with a ConnectionListener to receive ConnectionEvent from the newly created Channel.
abstract  void destroy()
          Destroys the Context and clear all associated ressources.
 void dispose()
           
abstract  void flushIO()
           
abstract  int getCallbackMode()
          Returns the Context's callback mode.
 java.lang.String getCallbackModeString()
          Returns a String representing the Context's callback mode.
abstract  gov.aps.epics.jca.ContextExceptionListener getContextExceptionListener()
          Returns the ContextExceptionListener registered with the Context.
static gov.aps.epics.jca.Context[] getContextList()
          Returns all created Contexts.
abstract  gov.aps.epics.jca.ContextMessageListener getContextMessageListener()
          Returns the ContextMessageListener registered with the Context.
abstract  java.lang.String getName()
          Returns the name of the Context.
abstract  int getThreadCtrlMode()
          Returns the Context's thread control mode.
 java.lang.String getThreadCtrlModeString()
          Returns a String representing the Context's thread control mode.
protected static gov.aps.epics.jca.Context lookupContext(java.lang.String name)
           
abstract  void pendEvent(double time)
          Process all pending events.
abstract  void pendIO(double timeout)
          Process all pending IO operations.
abstract  void poll()
           
 void printInfo()
          Prints detailed information about the Context to the standard output stream.
 void printInfo(java.io.PrintStream out)
          Prints detailed information about the Context to the specified output stream.
protected static void registerContext(gov.aps.epics.jca.Context c)
           
abstract  void setContextExceptionListener(gov.aps.epics.jca.ContextExceptionListener l)
          Sets the ContextExceptionListener which will receive ContextExceptionEvents from this Context.
abstract  void setContextMessageListener(gov.aps.epics.jca.ContextMessageListener l)
          Sets the ContextMessageListener which will receive ContextMessageEvents from this Context.
abstract  boolean testIO()
          Tests if there are some pending IO requests.
protected static void unregisterContext(gov.aps.epics.jca.Context c)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_contextMap

protected static java.util.HashMap _contextMap
Constructor Detail

Context

public Context()
Method Detail

printInfo

public void printInfo()
Prints detailed information about the Context to the standard output stream.


printInfo

public void printInfo(java.io.PrintStream out)
Prints detailed information about the Context to the specified output stream.

Parameters:
out - the output stream.

registerContext

protected static void registerContext(gov.aps.epics.jca.Context c)

unregisterContext

protected static void unregisterContext(gov.aps.epics.jca.Context c)

lookupContext

protected static gov.aps.epics.jca.Context lookupContext(java.lang.String name)

getContextList

public static gov.aps.epics.jca.Context[] getContextList()
Returns all created Contexts.


dispose

public void dispose()

getName

public abstract java.lang.String getName()
Returns the name of the Context.


getThreadCtrlMode

public abstract int getThreadCtrlMode()
Returns the Context's thread control mode.

See Also:
CaConstants

getThreadCtrlModeString

public java.lang.String getThreadCtrlModeString()
Returns a String representing the Context's thread control mode.

See Also:
CaConstants

getCallbackMode

public abstract int getCallbackMode()
Returns the Context's callback mode.

See Also:
CaConstants

getCallbackModeString

public java.lang.String getCallbackModeString()
Returns a String representing the Context's callback mode.

See Also:
CaConstants

getContextMessageListener

public abstract gov.aps.epics.jca.ContextMessageListener getContextMessageListener()
Returns the ContextMessageListener registered with the Context.


setContextMessageListener

public abstract void setContextMessageListener(gov.aps.epics.jca.ContextMessageListener l)
                                        throws CaException
Sets the ContextMessageListener which will receive ContextMessageEvents from this Context.

Parameters:
l - the ContextMessageListener.
CaException

getContextExceptionListener

public abstract gov.aps.epics.jca.ContextExceptionListener getContextExceptionListener()
Returns the ContextExceptionListener registered with the Context.


setContextExceptionListener

public abstract void setContextExceptionListener(gov.aps.epics.jca.ContextExceptionListener l)
                                          throws CaException
Sets the ContextExceptionListener which will receive ContextExceptionEvents from this Context.

Parameters:
l - the ContextExceptionListener.
CaException

destroy

public abstract void destroy()
                      throws CaException
Destroys the Context and clear all associated ressources.

CaException

createChannel

public gov.aps.epics.jca.Channel createChannel(java.lang.String name)
                                        throws CaException
Create a new Channel using this context to access a process variable.

Parameters:
name - the process variable to connect to.
Returns:
the new Channel.
CaException

createChannel

public abstract gov.aps.epics.jca.Channel createChannel(java.lang.String name,
                                                        gov.aps.epics.jca.ConnectionListener l)
                                                 throws CaException
Create a new Channel using this context to access a process variable with a ConnectionListener to receive ConnectionEvent from the newly created Channel.

Parameters:
name - the process variable to connect to.
l - the ConnectionListener.
Returns:
the new Channel.
Throws:
CaException - is thrown if the Context has been destroyed.

pendIO

public abstract void pendIO(double timeout)
                     throws CaException
Process all pending IO operations.

Parameters:
timeout - the timeout limit.
Throws:
CaException - is thrown if all the IO couldn't be processed.
CaException - is thrown if the Context has been destroyed.

testIO

public abstract boolean testIO()
                        throws CaException
Tests if there are some pending IO requests.

CaException

pendEvent

public abstract void pendEvent(double time)
                        throws CaException
Process all pending events.

Parameters:
time - the time during which the Context will process events.
CaException

poll

public abstract void poll()
                   throws CaException
CaException

flushIO

public abstract void flushIO()
                      throws CaException
CaException

attachCurrentThread

public abstract void attachCurrentThread()
                                  throws CaException
CaException