cern.cmw.rda.server
Class DeviceServerBase

java.lang.Object
  extended by cern.cmw.rda.server.DeviceServerBase
Direct Known Subclasses:
DeviceServer

public abstract class DeviceServerBase
extends Object

An abstract class that provides the RDA connectivity for device servers implemented as its derived classes. Device server developers must at least provide implementations for the four basic device access methods: get(), set(), monitorOn(), monitorOff(). These methods are called whenever a corresponding method is called on an associated DeviceHandle in a remote client.

The device access calls can throw the following two exceptions:

Throwing any other exceptions then the above two is considered as a bug in the device server implementation. All such "unchecked" exceptions will be caught by the server side RDA and reported to clients by throwing an InternalException.

See Also:
"DeviceHandle for the description of the client side device access methods."

Field Summary
static int STATUS_GREEN
          Everything is fine.
static int STATUS_RED
          A serious problem with the server.
static int STATUS_YELLOW
          Something went wrong, but the server is still operational.
 
Constructor Summary
DeviceServerBase(String serverName)
          Constructs a device server with the specified name.
 
Method Summary
 Data get(IOPoint iop, Data context)
          Returns the value at the specified I/O point.
static Logger getCallsLogger()
          Returns the logger that is used by RDA to trace device calls.
 String getClassName(String deviceName)
           
static Logger getGlobalLogger()
          Returns the logger that is used by RDA to trace general activities in the server (initialization, fatal errors, shutdown, ...).
static String getServerName()
          Returns the Corba name of the server (or null if server has not yet been instantiated)
 Data getState()
          This method gets called when an administration client invokes the getState method of the admin::ServerAdmin interface.
 int getStatus()
          This method gets called when an administration client invokes the getStatus method of the admin::ServerAdmin interface.
static Logger getSubscriptionsLogger()
          Returns the logger that is used by RDA to trace subscription reports.
 int getVersion(String component)
          Gets the version number of a specified software component.
 void monitorOff(IOPoint iop, ValueChangeListener listener)
          Cancels the subscription identified by the I/O point and listener.
 void monitorOn(IOPoint iop, ValueChangeListener listener)
          Starts a subscription to value at the specified I/O point.
 void runServer()
          Makes the server available for clients.
 void set(IOPoint iop, Data value, Data context)
          Changes the value at the specified I/O point.
 void shutDown()
          Deactivates the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUS_GREEN

public static final int STATUS_GREEN
Everything is fine.

See Also:
Constant Field Values

STATUS_YELLOW

public static final int STATUS_YELLOW
Something went wrong, but the server is still operational.

See Also:
Constant Field Values

STATUS_RED

public static final int STATUS_RED
A serious problem with the server.

See Also:
Constant Field Values
Constructor Detail

DeviceServerBase

public DeviceServerBase(String serverName)
                 throws InternalException
Constructs a device server with the specified name. The constructor prepares all the facilities required to make the server available for clients over the network, but does not activate the communications. Access to the server can be enabled when it is fully constructed (all subclass constructors successfully completed) using the runServer method of the class.

Parameters:
serverName - the name under which the new server will be registered with the naming service when activated by the #runServer call.
Throws:
InternalException
Method Detail

get

public Data get(IOPoint iop,
                Data context)
         throws BadParameter,
                IOError
Returns the value at the specified I/O point.

Parameters:
iop - the I/O point identifier
context - the operation context, if specified in the client call, or an empty Data object otherwise.
Throws:
BadParameter
IOError

set

public void set(IOPoint iop,
                Data value,
                Data context)
         throws BadParameter,
                IOError
Changes the value at the specified I/O point.

Parameters:
iop - the I/O point identifier
value - the value to set
context - the operation context, if specified in the client call, or an empty Data object otherwise.
Throws:
BadParameter
IOError

monitorOn

public void monitorOn(IOPoint iop,
                      ValueChangeListener listener)
               throws BadParameter,
                      IOError
Starts a subscription to value at the specified I/O point.

Parameters:
iop - the I/O point identifier
listener - the callback object where to deliver subscription results.
Throws:
BadParameter
IOError

monitorOff

public void monitorOff(IOPoint iop,
                       ValueChangeListener listener)
Cancels the subscription identified by the I/O point and listener.


runServer

public void runServer()
               throws InternalException
Makes the server available for clients.

Each device server must call this method when it is ready to accept client requests. The method registers the server with the naming service and enters event loop to receive incoming requests. The method only returns if shutDown is called on the server.

Throws:
InternalException - thrown if the call fails due to some internal error.

shutDown

public void shutDown()
Deactivates the server. This method causes runServer() to return.


getClassName

public String getClassName(String deviceName)
                    throws BadParameter
Throws:
BadParameter

getVersion

public int getVersion(String component)
               throws BadParameter
Gets the version number of a specified software component. The component name 'rda' is reserved by the cmw-rda library.

Parameters:
component - The component name.
Returns:
The version number of the component.
Throws:
BadParameter - If the component is unknown.

getStatus

public int getStatus()
This method gets called when an administration client invokes the getStatus method of the admin::ServerAdmin interface. The default implementation of the method in this class returns

getState

public Data getState()
This method gets called when an administration client invokes the getState method of the admin::ServerAdmin interface. The default implementation of the method in this class returns a Data object which contains state variables of the RDA server. If you want to add some information to the state data, first get the RDA server state by calling the superclass' method, then add to it your state variables. For example:

class MyServer extends DeviceServerBase
{
   ...
   private double delay;
   private long counter;
   public Data getState()
   {
      //
      // Get the RDA server state
      //
      Data state = super.getState();
      //
      // Add MyServer variables to the state data
      //
      state.insert("my.delay", delay);
      state.insert("my.counter", counter);
      return state;
   }
   ...
};


getServerName

public static String getServerName()
Returns the Corba name of the server (or null if server has not yet been instantiated)


getGlobalLogger

public static Logger getGlobalLogger()
Returns the logger that is used by RDA to trace general activities in the server (initialization, fatal errors, shutdown, ...).


getCallsLogger

public static Logger getCallsLogger()
Returns the logger that is used by RDA to trace device calls.


getSubscriptionsLogger

public static Logger getSubscriptionsLogger()
Returns the logger that is used by RDA to trace subscription reports.



Copyright © 2007 CERN. All Rights Reserved.