FourMS
Class FourMSParameterConverter

java.lang.Object
  extended by FourMS.FourMSParameterConverter

public class FourMSParameterConverter
extends java.lang.Object

This class contains the methods necessary to perform conversion for the parameters associated with different mechanisms and message types between engineering and logical units. For example, a filter specified by a user for the MFW mechanism in the PFIP may be specified by the user as the filterName. However this filter name must be converted to a filter position in the filter wheel before being passed onto the 4MS module. The converse is true also, filter positions coming back from the 4MS must be converted back to their filter name before being stored. It is also responsible for pushing out changes that are coming in from the 4MS out to the notice board and the CORBA event channel. When we are talking about output parameters, we talk about parameters going out to the 4MS and conversely input parameters are parameters coming from the 4MS to the software system. Each of the conversions are stored in a hash which will be indexed by the using the Mechanism name, the message number and the parameter position in that message (i.e. MechanismName + MessageType + ParameterPosition). The class uses the java reflection interface to examine the conversion class to establish whether or not the registered conversion exists in the intrument specific conversion class and then that will be used to convert the input data into logical or engineering units as specified.

Version:
$Id: FourMSParameterConverter.java,v 1.7 2006/01/31 09:04:45 cb Exp $
Author:
Craige Bevil

Field Summary
private  java.util.Hashtable<java.lang.String,java.lang.reflect.Method> ConversionMethodHash
          This is an array of the methods which are included in the parameter conversion object
private  boolean Initialised
          Flag to indicate whether or not we are initialised or not
private  java.util.Hashtable<java.lang.String,java.lang.String> ParameterConversionMappingHash
          This is a hash table which will be used to store the details of the conversion routines which will be used when converting engineering units to logical units and vice-versa.
 MessageHandler SyslogMessageHandler
          This is a syslog object which will be used to report errors etc
private  FourMSConversions TypeConverter
          This object will be used to affect the type conversions which will be necessary, normally it will be specific to the instrument which is being controlled and the methods will be accessed through the reflection interface
 
Constructor Summary
FourMSParameterConverter(MessageHandler SyslogMessageHandler)
          The constructor for the class
 
Method Summary
 boolean initialiseConverter(FourMSConversions TypeConverter)
          The purpose of this method is to initialise the convertor such that it is set up for this 4MS instrument.
static void main(java.lang.String[] args)
          This is a main routine which can be used to test the class should we need to
 java.lang.String performConversion(int ConversionType, java.lang.String[] InputParameters, java.lang.String MechanismName)
          This method will be used to convert the input parameters into either engineering or logical units depending on what is required.
 java.lang.String performConversion(int ConversionType, java.lang.String[] InputParameters, java.lang.String MechanismName, int MessageNumber, int ParameterPosition)
          This method will be used to convert the input parameters into either engineering or logical units depending on what is required.
 boolean registerParameterConversion(java.lang.String MechanismName, int MessageNumber, int ParameterPosition, java.lang.String ConversionMethod)
          This method will be used to register a parameter for conversion prior to being submitted to the 4MS or transfer back to the OCS.
 boolean registerParameterConversion(java.lang.String MechanismName, java.lang.String ConversionMethod)
          This method will be used to register a parameter for conversion prior to being submitted to the 4MS or transfer back to the OCS.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ParameterConversionMappingHash

private java.util.Hashtable<java.lang.String,java.lang.String> ParameterConversionMappingHash
This is a hash table which will be used to store the details of the conversion routines which will be used when converting engineering units to logical units and vice-versa. It will be accessed using the mechanism name, the message number and the parameter position


ConversionMethodHash

private java.util.Hashtable<java.lang.String,java.lang.reflect.Method> ConversionMethodHash
This is an array of the methods which are included in the parameter conversion object


Initialised

private boolean Initialised
Flag to indicate whether or not we are initialised or not


TypeConverter

private FourMSConversions TypeConverter
This object will be used to affect the type conversions which will be necessary, normally it will be specific to the instrument which is being controlled and the methods will be accessed through the reflection interface


SyslogMessageHandler

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

Constructor Detail

FourMSParameterConverter

public FourMSParameterConverter(MessageHandler SyslogMessageHandler)
The constructor for the class

Parameters:
SyslogMessageHandler -
Method Detail

initialiseConverter

public boolean initialiseConverter(FourMSConversions TypeConverter)
The purpose of this method is to initialise the convertor such that it is set up for this 4MS instrument. Based on the instrument to be used, the necessary information is extracted from the WHT ICS database and then used to set up the conversion data structure will allow the quick look up of which conversion method to use in order to convert input and output parameters.

Parameters:
TypeConverter - - This is an object that will be used to perform the conversions expected of the input and output parameters to the 4MS.
Returns:
boolean

performConversion

public java.lang.String performConversion(int ConversionType,
                                          java.lang.String[] InputParameters,
                                          java.lang.String MechanismName,
                                          int MessageNumber,
                                          int ParameterPosition)
                                   throws ConversionFailedException
This method will be used to convert the input parameters into either engineering or logical units depending on what is required. It takes the input parameters and uses them to index the conversion routine (if any specified) in order to convert each of the values specified in the input parameter list. The output is provided in an ArrayList which is provided as the output of the method. If the conversion fails, a ConversionFailedException is raised by the method. If there is no conversion routine available, it simply returns the input value

Parameters:
ConversionType - - This is the type of the conversion to be performed, it should one of the following;
  • FourMSConstants.ENGINEERINGTOLOGICAL
  • FourMSConstants.LOGICALTOENGINEERING
This specifies in the first case the input parameter is to be converted to logical units and the second from logical units to engineering units.
InputParameters - - This is a list of the input parameters to the conversion routine. For example, each message coming or going from the 4MS might contain a number of parameters which may or may not all need converting before they are suitable for transmission to the 4MS or be returned to the OCS for futher processing.
MechanismName - - This is the name of the mechanism such as MFW, it used to index the correct conversion routine.
MessageNumber - - This is the message type (e.g. 800). It used to index the correct conversion routine.
ParameterPosition - - This is the parameter number in the dialogue.It will be used to index the correct conversion routine.
Returns:
String
Throws:
ConversionFailedException
ConversionFailedException

performConversion

public java.lang.String performConversion(int ConversionType,
                                          java.lang.String[] InputParameters,
                                          java.lang.String MechanismName)
                                   throws ConversionFailedException
This method will be used to convert the input parameters into either engineering or logical units depending on what is required. It takes the input parameters and uses them to index the conversion routine (if any specified) in order to convert each of the values specified in the input parameter list. The output is provided in an ArrayList which is provided as the output of the method. If the conversion fails, a ConversionFailedException is raised by the method. If there is no conversion routine available, it simply returns the input value

Parameters:
ConversionType - - This is the type of the conversion to be performed, it should one of the following;
  • FourMSConstants.ENGINEERINGTOLOGICAL
  • FourMSConstants.LOGICALTOENGINEERING
This specifies in the first case the input parameter is to be converted to logical units and the second from logical units to engineering units.
InputParameters - - This is a list of the input parameters to the conversion routine. For example, each message coming or going from the 4MS might contain a number of parameters which may or may not all need converting before they are suitable for transmission to the 4MS or be returned to the OCS for futher processing.
MechanismName - - This is the name of the mechanism such as MFW, it used to index the correct conversion routine.
Returns:
String
Throws:
ConversionFailedException
ConversionFailedException

registerParameterConversion

public boolean registerParameterConversion(java.lang.String MechanismName,
                                           int MessageNumber,
                                           int ParameterPosition,
                                           java.lang.String ConversionMethod)
                                    throws ConversionAlreadyRegisteredException
This method will be used to register a parameter for conversion prior to being submitted to the 4MS or transfer back to the OCS. The message type, the mechanism and the parameter number in the 4MS message should be specified. Any attempt to specify more than one conversion for a specific parameter will result in a ConversionAlreadyRegisteredException being raised.

Parameters:
MechanismName - - This is the name of the mechanism which this conversion is to be associated with. For instance in the case of the PFIP 4MS system this might be MFW.
MessageNumber - - This is the message type of the 4MS message that this conversion is associated with. For instance this could be message type 101. There may be several conversions to be performed on parameters associated with a specific message type.
ParameterPosition - - This is the position of the parameter in the message that is to be sent or received from the 4MS system. There may be only one conversion for a specific parameter associated with a given message number on a specific mechanism. If there is an attempt to register a multiple conversions for the same parameter, an ConversionAlreadyRegisteredException will be raised. The position of the parameter in the message is an index into looking up the conversion to be applied to the parameter. The parameter position should be specified as a positive integer, 0 indicates the first parameter.
ConversionMethod - - This is the name of the conversion method which will be used by the class when converting backwards and forwards between engineering units and logical units. Implementation note : as the name of the method that is to perform the conversion is not available at compile time, we need to use the Reflection facility of Java in order to call random methods at runtime. This facility provides exactly that functionality. The class will have a built in number of conversion routines and also as part of it's initialisation it will read a dynamic package which will have further conversion routines specific to this 4MS. For instance in the case of the PFIP system, the conversion routine to convert between the filter positions and the filter names associated with the MFW will need to access the filter database in order to establish the filter name.
Returns:
boolean
Throws:
ConversionAlreadyRegisteredException
ConversionAlreadyRegisteredException

registerParameterConversion

public boolean registerParameterConversion(java.lang.String MechanismName,
                                           java.lang.String ConversionMethod)
                                    throws ConversionAlreadyRegisteredException
This method will be used to register a parameter for conversion prior to being submitted to the 4MS or transfer back to the OCS. The mechanism Any attempt to specify more than one conversion of the same type parameter will result in a ConversionAlreadyRegisteredException being raised.

Parameters:
MechanismName - - This is the name of the mechanism which this conversion is to be associated with. For instance in the case of the PFIP 4MS system this might be MFW.
ConversionMethod - - This is the name of the conversion method which will be used by the class when converting backwards and forwards between engineering units and logical units. Implementation note : as the name of the method that is to perform the conversion is not available at compile time, we need to use the Reflection facility of Java in order to call random methods at runtime. This facility provides exactly that functionality. The class will have a built in number of conversion routines and also as part of it's initialisation it will read a dynamic package which will have further conversion routines specific to this 4MS. For instance in the case of the PFIP system, the conversion routine to convert between the filter positions and the filter names associated with the MFW will need to access the filter database in order to establish the filter name.
Returns:
boolean
Throws:
ConversionAlreadyRegisteredException
ConversionAlreadyRegisteredException

main

public static void main(java.lang.String[] args)
This is a main routine which can be used to test the class should we need to

Parameters:
args - The arguments to run the application