Package com.cosylab.epics.caj.cas.util
Class DefaultServerImpl
- java.lang.Object
-
- com.cosylab.epics.caj.cas.util.DefaultServerImpl
-
- All Implemented Interfaces:
Server
public class DefaultServerImpl extends Object implements Server
Default server implementation. Implementation keeps a hash-map of all registered PVs. WhenprocessVariableExistanceTestis called existance test is made on the hash-map.processVariableAttachmetod simply retrieves PV from the hash-map.
-
-
Constructor Summary
Constructors Constructor Description DefaultServerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MemoryProcessVariablecreateMemoryProcessVariable(String name, DBRType type, Object initialValue)Convenience method to create and register new in-memory process variables.ProcessVariableprocessVariableAttach(String aliasName, ProcessVariableEventCallback eventCallback, ProcessVariableAttachCallback asyncCompletionCallback)This function is called every time that a client attaches to the PV.ProcessVariableExistanceCompletionprocessVariableExistanceTest(String aliasName, InetSocketAddress clientAddress, ProcessVariableExistanceCallback asyncCompletionCallback)This function is called by the server library when it needs to determine if a named process variable (PV) exists (or could be created) in the server tool.voidregisterProcessVariable(ProcessVariable pv)Register process variable.voidregisterProcessVariable(String aliasName, ProcessVariable pv)Register process variable.ProcessVariableunregisterProcessVariable(String aliasName)Unregister process variable.
-
-
-
Field Detail
-
pvs
protected Map pvs
Map of PVs.
-
-
Method Detail
-
createMemoryProcessVariable
public MemoryProcessVariable createMemoryProcessVariable(String name, DBRType type, Object initialValue)
Convenience method to create and register new in-memory process variables.- Parameters:
name- process variable name.type- process variable native type.initialValue- process variable initial value (array expected).- Returns:
- created and registered process variable.
-
registerProcessVariable
public void registerProcessVariable(String aliasName, ProcessVariable pv)
Register process variable. Note: if process variable withaliasNameis already registered this will override it.- Parameters:
aliasName- process variable name.pv- process variable instance.
-
registerProcessVariable
public void registerProcessVariable(ProcessVariable pv)
Register process variable. Note: if process variable with the same name is already registered this will override it.- Parameters:
pv- process variable instance.
-
unregisterProcessVariable
public ProcessVariable unregisterProcessVariable(String aliasName)
Unregister process variable.- Parameters:
aliasName- process variable name- Returns:
- unregistered process variable,
nullif non unregistered.
-
processVariableAttach
public ProcessVariable processVariableAttach(String aliasName, ProcessVariableEventCallback eventCallback, ProcessVariableAttachCallback asyncCompletionCallback) throws CAStatusException, IllegalArgumentException, IllegalStateException
Description copied from interface:ServerThis function is called every time that a client attaches to the PV. The name supplied here will be either a canonical PV name or an alias PV name. The request is allowed to complete asynchronously. It is a responsibility of the server tool to detect attempts by the server library to attach to an existing PV. If the PV does not exist then the server tool should create it. Otherwise, the server tool typically will return a pointer to the preexisting PV. The server tool is encouraged to accept multiple PV name aliases for the same PV here. In most situations the server tool should avoid PV duplication by returning a pointer to an existing PV if the PV alias name matches a preexisting PV's name or any of its aliases. In certain specialized rare situations the server tool may choose to create client private process variables that are not shared between clients. In this situation there might be several process variables with the same name. One for each client. For example, a server tool might be written that provides access to archival storage of the historic values of a set of process variables. Each client would specify its date of interest by writing into a client private process variable. Next the client would determine the current value of its subset of named process variables at its privately specified date by attaching to additional client private process variables.- Specified by:
processVariableAttachin interfaceServer- Parameters:
aliasName- the process variable alias name.eventCallback- the process variable event callback (where PV reports value changes ifinterestistrue).asyncCompletionCallback- if asynchronous completion is required method should returnnulland callProcessVariableExistanceCompletionCallback.processVariableAttachCompleted()method.- Returns:
- requested
ProcessVariableinstance,nullif operation is to be done asynchronously or exception is thrown in case of an error (non-existant PV, etc.). - Throws:
CAStatusException- is thrown if a Channel Access error occured while creating the channel.IllegalArgumentException- is thrown if the channel's name is null or empty.IllegalStateException- if the context has been destroyed.- See Also:
Server.processVariableAttach(java.lang.String, gov.aps.jca.cas.ProcessVariableEventCallback, gov.aps.jca.cas.ProcessVariableAttachCallback)
-
processVariableExistanceTest
public ProcessVariableExistanceCompletion processVariableExistanceTest(String aliasName, InetSocketAddress clientAddress, ProcessVariableExistanceCallback asyncCompletionCallback) throws CAException, IllegalArgumentException, IllegalStateException
Description copied from interface:ServerThis function is called by the server library when it needs to determine if a named process variable (PV) exists (or could be created) in the server tool. The request is allowed to complete asynchronously. The server tool is encouraged to accept multiple PV name aliases for the same PV here. NOTE: returnProcessVariableExistanceCompletion.DOES_NOT_EXIST_HEREif too many simultaneous asynchronous operations are pending against the server. The client library will retry the request at some time in the future.- Specified by:
processVariableExistanceTestin interfaceServer- Parameters:
aliasName- the process variable alias name.clientAddress- the client which requested test.asyncCompletionCallback- if asynchronous completion is required method should returnProcessVariableExistanceCompletion.ASYNC_COMPLETIONand callProcessVariableExistanceCompletionCallback.processVariableExistanceTestCompleted()method.- Returns:
- process variable existance status.
- Throws:
IllegalArgumentException- is thrown if the process variable name is invalid.IllegalStateException- if the context has been destroyed.CAException- See Also:
Server.processVariableExistanceTest(java.lang.String, java.net.InetSocketAddress, gov.aps.jca.cas.ProcessVariableExistanceCallback)
-
-