FourMS
Class FourMSController

java.lang.Object
  extended by FourMS.FourMSController
All Implemented Interfaces:
iInstrumentController.InstrumentControllerOperations

public abstract class FourMSController
extends java.lang.Object
implements iInstrumentController.InstrumentControllerOperations

This class describes the main 4MS class which will be used to control a 4MS microprocessor. This is the boundary class for the package through which all control of the 4MS will be affected. It allows subactions to be started on the mechanism and then subsequently cancelled if necessary. Controlling objects will be informed of the progress of the actions upon the 4MS via the implemenation of interfaces provided by the package.

This class provides a base set of functionality for the control of 4MS based instruments. This class should be extended by classes more specific to the instrument to be controlled in order to fine tune control.

This class creates the software representations of the mechanisms and the actions which can be performed on them mechanisms. Each action is a CORBA operation which can be invoked from external clients (or internal ones also). Irrespective of the function of the action, it posseses the same interface and behaviour to an external client. See SubAction for the details of this interface.

This class implements the CORBA interface InstrumentControllerOperations which allows third party applications to shut down the instrument controller, change it's trace level, enable and disable debug and also handshake with the application.

Version:
$Id: FourMSController.java,v 1.16 2006/04/07 08:02:10 cb Exp $
Author:
Craige Bevil


Field Summary
protected  FourMSCommsMonitor CommunicationsMonitor
          A communications monitor on the 4MS which will report if the communications timeout
private  org.omg.CosNaming.NamingContextExt ControllerNameServiceContext
          This is the context in the COS naming service into which we should store the details of mechanisms and the subactions which are associated with them
protected  java.sql.Connection DBConnection
          This is used to hold a database connection to the WHT OCS postgres database where the configuration data for the mechanisms which are to be simulated is held
protected  FourMSParameterConverter ER412FourMSParameterConverter
          This will be used to convert parameters backwards and forewards from engineering units and back again
protected  FourMSMessageHandler ER412MessageHandler
          This is the message handler which will be responisble for sending the messages out to the 4MS and receiving incoming messages coming back from the 4MS
protected  MessageListener ER412MessageListener
          This will be used for listening to messages coming in from the 4MS microprocessor and then handing them over to the ER412 message handler for processing.
protected  java.lang.String InstrumentName
          This is the name of the instrument associated with the 4MS.
protected  java.util.Hashtable<java.lang.String,Mechanism> Mechanisms
          Holds the details of all of the mechanisms which are to be found on this 4MS microprocessor.
private  boolean MechanismsCreated
          Flag which indicates if the mechanisms have already been created
protected  FourMSControllerMessageDispatcher MessageDispatcher
          This will be used to dispatch messages to the appropriate object in order to be processed
protected  org.omg.CORBA.ORB Orb
          The CORBA request broker or ORB which will be used for handling CORBA requests
protected  iParameterNoticeBoard.ParameterNoticeBoardSupplier ParameterNoticeBoard
          This is reference to the remote proxy CORBA object which will be used to access the parameter noticeboard
protected  org.omg.PortableServer.POA Poa
          The portable object adapter which will be used by this class
private  java.lang.String PortServerDevice
          This is the name of device which we need to open in order to communicate with the port server and ultimately the 4MS.
protected  org.omg.CosNaming.NamingContextExt RootNamingServiceContext
          This is a reference to the COS naming service
private  int SimulationPort
          This is the simulation port number which is used for communicating with the simulator if we are starting in simulation mode
 MessageHandler SyslogMessageHandler
          This is a syslog object which will be used to report errors etc
 
Constructor Summary
FourMSController(java.lang.String[] args, java.lang.String ER412SourceName, java.lang.String ER412DestinationName, MessageHandler SyslogMessageHandler, FourMSParameterConverter ER412FourMSParameterConverter, java.lang.String ORBPersistentPort, java.lang.String ORBServerID, java.lang.String InstrumentName, java.lang.String dbHost)
          This is the constructor for this class
 
Method Summary
 void closeDown(java.lang.String CloseDownMessage)
          This is an obligation to the CORBA instrument controller interface which permits the application to be closed down in a controlled manner.
protected  boolean createMechanisms()
          This method will be called to create the mechanisms objects which are associated with the 4MS module.
 boolean handshake()
          This is an obligation to the CORBA instrument controller interface which permits a third party to ascertain if the instrument controller is responding.
 boolean listenForFourMSController(boolean SimulationMode)
          This method will be called and will result in the application starting up a listening thread which will be responsible for listening for input coming back from the 4MS which is attached to this controller.
 void setDebugState(boolean DebugState)
          This is an obligation to the CORBA instrument controller interface which permits the debug of the application to be enabled or disabled.
 void setTraceLevel(double TraceLevel)
          This is an obligation to the CORBA instrument controller interface which permits the trace level of the application to be set, in this application there is no different trace levels enabled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CommunicationsMonitor

protected FourMSCommsMonitor CommunicationsMonitor
A communications monitor on the 4MS which will report if the communications timeout


ParameterNoticeBoard

protected iParameterNoticeBoard.ParameterNoticeBoardSupplier ParameterNoticeBoard
This is reference to the remote proxy CORBA object which will be used to access the parameter noticeboard


InstrumentName

protected java.lang.String InstrumentName
This is the name of the instrument associated with the 4MS. Normally it will be called the accepted name of the instrument such as PFIP or ISIS. This will be used to uniquely index the 4MS database in order to establish the information for all of the mechanisms which are associated with this 4MS microprocessor.


SimulationPort

private int SimulationPort
This is the simulation port number which is used for communicating with the simulator if we are starting in simulation mode


PortServerDevice

private java.lang.String PortServerDevice
This is the name of device which we need to open in order to communicate with the port server and ultimately the 4MS. This value will be read from the ICS database.


MechanismsCreated

private boolean MechanismsCreated
Flag which indicates if the mechanisms have already been created


Mechanisms

protected java.util.Hashtable<java.lang.String,Mechanism> Mechanisms
Holds the details of all of the mechanisms which are to be found on this 4MS microprocessor. These will be created by this class


ER412MessageHandler

protected FourMSMessageHandler ER412MessageHandler
This is the message handler which will be responisble for sending the messages out to the 4MS and receiving incoming messages coming back from the 4MS


ER412MessageListener

protected MessageListener ER412MessageListener
This will be used for listening to messages coming in from the 4MS microprocessor and then handing them over to the ER412 message handler for processing. This object runs in a separate thread to everything else in order to ensure that it can respond to input from the 4MS at any time.


SyslogMessageHandler

public MessageHandler SyslogMessageHandler
This is a syslog object which will be used to report errors etc


MessageDispatcher

protected FourMSControllerMessageDispatcher MessageDispatcher
This will be used to dispatch messages to the appropriate object in order to be processed


ER412FourMSParameterConverter

protected FourMSParameterConverter ER412FourMSParameterConverter
This will be used to convert parameters backwards and forewards from engineering units and back again


DBConnection

protected java.sql.Connection DBConnection
This is used to hold a database connection to the WHT OCS postgres database where the configuration data for the mechanisms which are to be simulated is held


Orb

protected org.omg.CORBA.ORB Orb
The CORBA request broker or ORB which will be used for handling CORBA requests


Poa

protected org.omg.PortableServer.POA Poa
The portable object adapter which will be used by this class


ControllerNameServiceContext

private org.omg.CosNaming.NamingContextExt ControllerNameServiceContext
This is the context in the COS naming service into which we should store the details of mechanisms and the subactions which are associated with them


RootNamingServiceContext

protected org.omg.CosNaming.NamingContextExt RootNamingServiceContext
This is a reference to the COS naming service

Constructor Detail

FourMSController

public FourMSController(java.lang.String[] args,
                        java.lang.String ER412SourceName,
                        java.lang.String ER412DestinationName,
                        MessageHandler SyslogMessageHandler,
                        FourMSParameterConverter ER412FourMSParameterConverter,
                        java.lang.String ORBPersistentPort,
                        java.lang.String ORBServerID,
                        java.lang.String InstrumentName,
                        java.lang.String dbHost)
This is the constructor for this class

Parameters:
ER412FourMSParameterConverter - - When this object is created it should be provided with a 4MS parameter convertor. This will subsequently used to convert micro units to logical units and vice versa. Note that the object is not typed and that the creator should ensure that the for the given instrument that is to be controlled by the 4MS controller class, the object that is provided here has ALL of the conversion operations required by the 4MS instrument controller.
args - These are the command line arguments which were passed into the application on startup.
SyslogMessageHandler - This will be used for syslog error handling
ER412SourceName - - This is the value which is expected to be expressed in the source name of messages coming into the simulator.
ER412DestinationName - - This is the expected value of the destination field in the messages that are sent to this process from a 4MS transmitter.
ORBPersistentPort - This is the number of a port which will be used to access persistent objects
ORBServerID - This is an integer string which indicates the ID associated with the ORB server and will be used for persistence
InstrumentName - This is the name of the instrument which is being controlled.
dbHost - This is the name of the machine which is hosting the database.
Method Detail

listenForFourMSController

public boolean listenForFourMSController(boolean SimulationMode)
This method will be called and will result in the application starting up a listening thread which will be responsible for listening for input coming back from the 4MS which is attached to this controller. We read out the device which we will use to communicate with the port server from the database from the instrument table. We will use the instrument name as the key to find this database

Parameters:
SimulationMode - Set to true if we are to be running in simulation mode
Returns:
boolean

createMechanisms

protected boolean createMechanisms()
This method will be called to create the mechanisms objects which are associated with the 4MS module. The configuration is read from the WHTOCS database

Returns:
boolean

setDebugState

public void setDebugState(boolean DebugState)
This is an obligation to the CORBA instrument controller interface which permits the debug of the application to be enabled or disabled.

Specified by:
setDebugState in interface iInstrumentController.InstrumentControllerOperations
Parameters:
DebugState - Whether or not debug should be enabled or disabled.

setTraceLevel

public void setTraceLevel(double TraceLevel)
This is an obligation to the CORBA instrument controller interface which permits the trace level of the application to be set, in this application there is no different trace levels enabled.

Specified by:
setTraceLevel in interface iInstrumentController.InstrumentControllerOperations
Parameters:
TraceLevel - The expected trace level of the application when debug is enabled.

closeDown

public void closeDown(java.lang.String CloseDownMessage)
This is an obligation to the CORBA instrument controller interface which permits the application to be closed down in a controlled manner.

Specified by:
closeDown in interface iInstrumentController.InstrumentControllerOperations
Parameters:
CloseDownMessage - The text of a message which is to be put into the syslog when the application closes down

handshake

public boolean handshake()
This is an obligation to the CORBA instrument controller interface which permits a third party to ascertain if the instrument controller is responding. The application should return true in the case that the application is working fine

Specified by:
handshake in interface iInstrumentController.InstrumentControllerOperations
Returns:
boolean true if the application is responding