Class LookupTableConverterHolder<S extends javax.measure.Quantity<S>,T extends javax.measure.Quantity<T>>

java.lang.Object
gda.factory.FindableBase
gda.util.converters.LookupTableConverterHolder<S,T>
All Implemented Interfaces:
Findable, IConverter<javax.measure.Quantity<S>,javax.measure.Quantity<T>>, IQuantitiesConverter<S,T>, IQuantityConverter<S,T>, IReloadableQuantitiesConverter<S,T>

public final class LookupTableConverterHolder<S extends javax.measure.Quantity<S>,T extends javax.measure.Quantity<T>> extends FindableBase implements IReloadableQuantitiesConverter<S,T>
class to be generated by the Castor on the ObjectServer to allow conversion between two DOFs using a lookup table.

An instance of this object is to be created by the Castor system within the ObjectServer due to presence in the main xml file of content of the from:

<LookupTableConverter name="dcm_energy_perp_converter" columnDataFileName="dcm_energy_perp.txt" sColumn="0" tColumn="1" mode="StoT"/>

name The text by which the object can be located using the Finder

columnDataFileName The name of the lookup file. This can be an absolute filename, or a relative filename (in which case gda.function.columnDataFile.lookupDir will be prepended to the filename).

The lookup table is to be found in the folder pointed to be LocalProperties.get("gda.function.columnDataFile.lookupDir").

The lookup table is read by the class ColumnDataFile and so must conform to the format that that class requires.

sColumn Zero based index to identify the column that contains the values for the Source

tColumn Zero based index to identify the column that contains the values for the Target

mode Indicates the direction in which the conversion is valid

The object implements findable so it can be found via the Jython script using the command

converter = finder.find("dcm_energy_perp_converter")

The object implements IReloadableQuantitiesConverter so that the lookup table can be re-read using the command:

finder.find("dcm_energy_perp_converter").ReloadConverter

The object implements IQuantitiesConverter so that the object can be referenced by CombinedDOF.

The object implements IQuantityConverter to allow the conversion to be easily tested using the commands:

      converter = finder.find("dcm_energy_perp_converter")
      import  org.jscience.physics.quantities.Quantity as Quantity
      q = Quantity.valueOf(-200, converter.AcceptableTargetUnits().get(0))
      converter.ToSource(q)
 
See Also:
  • Constructor Details

    • LookupTableConverterHolder

      public LookupTableConverterHolder(String name, String columnDataFileName, int sColumn, int tColumn, String modeString)
      Parameters:
      name - The name of the object. This is required to allow the object to be found via the Finder.
      columnDataFileName - Lookup table filename. The lookup table is to be found in the folder pointed to be LocalProperties.get("gda.function.columnDataFile.lookupDir"). The lookup table is read by the class ColumnDataFile and so must conform to the format that that class requires.
      sColumn - The column of the lookup table that contains the source values. First column is 0.
      tColumn - The column of the lookup table that contains the target values. First column is 0.
      modeString - If not null this is a String that indicates the direction for which the conversion is valid In some circumstances the lookup table is only valid for conversion in one direction e.g. The xvalues all increase but the yvalues show a change in direction.
      See Also:
  • Method Details

    • getColumnDataFileName

      public String getColumnDataFileName()
      Castor function. - I am using the constructor mapping option for set-methods so that members can be final
      Returns:
      Lookup table filename. The lookup table is to be found in the folder pointed to be LocalProperties.get("gda.function.columnDataFile.lookupDir")
    • getSColumn

      public int getSColumn()
      Castor function. - I am using the constructor mapping option for set-methods so that members can be final
      Returns:
      The column of the lookup table that contains the source values. First column is 0.
    • getTColumn

      public int getTColumn()
      Castor function. - I am using the constructor mapping option for set-methods so that members can be final
      Returns:
      The column of the lookup table that contains the target values. First column is 0.
    • getMode

      public String getMode()
      Castor function. - I am using the constructor mapping option for set-methods so that members can be final
      Returns:
      The column of the lookup table that contains the target values. First column is 0.
    • isInterpolateNotExtrapolate

      public boolean isInterpolateNotExtrapolate()
    • setInterpolateNotExtrapolate

      public void setInterpolateNotExtrapolate(boolean interpolateNotExtrapolate)
    • setName

      public void setName(String name) throws IllegalArgumentException
      Castor function. - This should never be called and will throw an exception if it is. Set or change the name of the object (as defined in XML).
      Specified by:
      setName in interface Findable
      Overrides:
      setName in class FindableBase
      Parameters:
      name - the object name
      Throws:
      IllegalArgumentException
      See Also:
    • reloadConverter

      public void reloadConverter()
      Re-reads the lookup table. Note that the units of the lookup must not change. Reload its state from any resource on which it may depend e.g. re-read a lookup table.
      Specified by:
      reloadConverter in interface IReloadableQuantitiesConverter<S extends javax.measure.Quantity<S>,T extends javax.measure.Quantity<T>>
      See Also:
    • getAcceptableMoveableUnits

      public List<List<String>> getAcceptableMoveableUnits()
      Description copied from interface: IQuantitiesConverter
      Returns the units in which the targets quantities passed into ToSource can be expressed
      Specified by:
      getAcceptableMoveableUnits in interface IQuantitiesConverter<S extends javax.measure.Quantity<S>,T extends javax.measure.Quantity<T>>
      Returns:
      Each element of the array is an array of units that is acceptable for the corresponding target in calls to ToSource
      See Also:
    • getAcceptableUnits

      public List<List<String>> getAcceptableUnits()
      Description copied from interface: IQuantitiesConverter
      Returns the units in which the sources quantities passed into calculateMoveables can be expressed
      Specified by:
      getAcceptableUnits in interface IQuantitiesConverter<S extends javax.measure.Quantity<S>,T extends javax.measure.Quantity<T>>
      Returns:
      Each element of the array is an array of units that is acceptable for the corresponding source in calls to calculateMoveables
      See Also:
    • calculateMoveables

      public javax.measure.Quantity<T>[] calculateMoveables(javax.measure.Quantity<S>[] sources, Object[] moveables) throws Exception
      Uses the lookup table to calculate values for the moveables given the values in sources.
      Specified by:
      calculateMoveables in interface IQuantitiesConverter<S extends javax.measure.Quantity<S>,T extends javax.measure.Quantity<T>>
      Parameters:
      sources - Array of values in units of the sources to be converted.
      moveables - Array of Moveable
      Returns:
      Array of calculated values in units of the moveables
      Throws:
      Exception
      See Also:
    • toSource

      public javax.measure.Quantity<S>[] toSource(javax.measure.Quantity<T>[] targets, Object[] moveables) throws Exception
      Uses the lookup table to calculate values for the sources given the values in targets.
      Specified by:
      toSource in interface IQuantitiesConverter<S extends javax.measure.Quantity<S>,T extends javax.measure.Quantity<T>>
      Parameters:
      targets - Array of values in units of the moveables to be converted.
      moveables - Array of Moveable
      Returns:
      Array of calculated values in units of the source
      Throws:
      Exception
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • getAcceptableSourceUnits

      public List<String> getAcceptableSourceUnits()
      Specified by:
      getAcceptableSourceUnits in interface IQuantityConverter<S extends javax.measure.Quantity<S>,T extends javax.measure.Quantity<T>>
      Returns:
      AcceptableSourceUnits
      See Also:
    • getAcceptableTargetUnits

      public List<String> getAcceptableTargetUnits()
      Specified by:
      getAcceptableTargetUnits in interface IQuantityConverter<S extends javax.measure.Quantity<S>,T extends javax.measure.Quantity<T>>
      Returns:
      AcceptableTargetUnits
      See Also:
    • toSource

      public javax.measure.Quantity<S> toSource(javax.measure.Quantity<T> target) throws Exception
      Description copied from interface: IConverter
      Calculates a value for Source given the value of the target
      Specified by:
      toSource in interface IConverter<S extends javax.measure.Quantity<S>,T extends javax.measure.Quantity<T>>
      Parameters:
      target -
      Returns:
      The value calculated from the value of the target *
      Throws:
      Exception
    • toTarget

      public javax.measure.Quantity<T> toTarget(javax.measure.Quantity<S> source) throws Exception
      Description copied from interface: IConverter
      Calculates a value for Target given the value of the source
      Specified by:
      toTarget in interface IConverter<S extends javax.measure.Quantity<S>,T extends javax.measure.Quantity<T>>
      Parameters:
      source -
      Returns:
      The value calculated from the value of the source
      Throws:
      Exception
    • sourceMinIsTargetMax

      public boolean sourceMinIsTargetMax()
      Description copied from interface: IConverter
      Returns true is the conversion reverses the sense. So that to get the max of the source you convert the min of the target and vice versa
      Specified by:
      sourceMinIsTargetMax in interface IConverter<S extends javax.measure.Quantity<S>,T extends javax.measure.Quantity<T>>
      Returns:
      true is the conversion reverses the sense.
      See Also:
    • handlesStoT

      public boolean handlesStoT()
      Specified by:
      handlesStoT in interface IQuantityConverter<S extends javax.measure.Quantity<S>,T extends javax.measure.Quantity<T>>
      Returns:
      true if the converter converts from S to T
    • handlesTtoS

      public boolean handlesTtoS()
      Specified by:
      handlesTtoS in interface IQuantityConverter<S extends javax.measure.Quantity<S>,T extends javax.measure.Quantity<T>>
      Returns:
      true if the converter converts from T to S