Class CoupledConverterHolder<S extends javax.measure.Quantity<S>,T extends javax.measure.Quantity<T>,I extends javax.measure.Quantity<I>>

java.lang.Object
gda.factory.FindableBase
gda.util.converters.CoupledConverterHolder<S,T,I>
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 CoupledConverterHolder<S extends javax.measure.Quantity<S>,T extends javax.measure.Quantity<T>,I extends javax.measure.Quantity<I>> extends FindableBase implements IReloadableQuantitiesConverter<S,T>
Class that can be used to create a converter made up of two other converters in series. An occasion where this is useful is if one can convert from a value of Source to Target using a combination of a conversion using a Java Expression Parser representing the conversion expected from geometric design of a piece of equipment followed by a conversion using a lookup table to correct for manufacturing errors.

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:

<CoupledConverter name="BeamLineEnergy_DCM_Perp_converter" sourceConverterName="BeamLineEnergy_DCM_Perp_converter1" targetConverterName="BeamLineEnergy_DCM_Perp_converter2" />

The sourceConverterName value is the name of a findable implementor of IReloadableQuantitiesConverter to be used to perform the first conversion between the Source and an intermediate quantity.

The targetConverterName value is the name of a findable implementor of IReloadableQuantitiesConverter to be used to convert between the intermediate quantity and the Target.

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

converter = finder.find("BeamLineEnergy_DCM_Perp_converter")

The object implements IReloadableQuantitiesConverter so that the dependent converters can be re-loaded using the command:

finder.find("BeamLineEnergy_DCM_Perp_converter").ReloadConverter

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

  • Constructor Details

    • CoupledConverterHolder

      public CoupledConverterHolder(String name, String sourceConverterName, String targetConverterName)
      Parameters:
      name - The name of the converter by which the object can be found using the Finder
      sourceConverterName - The name of a findable implementor of IReloadableQuantitiesConverter to be used to perform the first conversion between the Source and an intermediate quantity.
      targetConverterName - The name of a findable implementor of IReloadableQuantitiesConverter to be used to convert between the intermediate quantity and the Target.
    • CoupledConverterHolder

      public CoupledConverterHolder(String name, IReloadableQuantitiesConverter<S,I> sourceConverter, IReloadableQuantitiesConverter<I,T> targetConverter)
      Creates a coupled converter holder which uses the specified source and target converters.
      Parameters:
      name - the converter name
      sourceConverter - the source converter
      targetConverter - the target converter
  • Method Details

    • getSourceConverterName

      public String getSourceConverterName()
      Returns:
      sourceConverterName
    • getTargetConverterName

      public String getTargetConverterName()
      Returns:
      targetConverterName
    • setName

      public void setName(String name)
      Description copied from interface: Findable
      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
    • reloadConverter

      public void reloadConverter()
      Description copied from interface: IReloadableQuantitiesConverter
      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>>
    • calculateMoveables

      public javax.measure.Quantity<T>[] calculateMoveables(javax.measure.Quantity<S>[] sources, Object[] moveables) throws Exception
      Description copied from interface: IQuantitiesConverter
      Calculates an array of values in units of the source given an array of quantities in units of the source
      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
    • toSource

      public javax.measure.Quantity<S>[] toSource(javax.measure.Quantity<T>[] targets, Object[] moveables) throws Exception
      Description copied from interface: IQuantitiesConverter
      Calculates an array of values in units of the source given an array of quantities in units of the moveables
      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
    • 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
    • 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
    • FindReloadableQuantitiesConverter

      public static <Q extends javax.measure.Quantity<Q>, R extends javax.measure.Quantity<R>> IReloadableQuantitiesConverter<Q,R> FindReloadableQuantitiesConverter(String converterName)
      Parameters:
      converterName -
      Returns:
      IReloadableQuantitiesConverter
    • FindQuantitiesConverter

      public static <Q extends javax.measure.Quantity<Q>, R extends javax.measure.Quantity<R>> IQuantitiesConverter<Q,R> FindQuantitiesConverter(String converterName)
      Parameters:
      converterName -
      Returns:
      IQuantitiesConverter
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getIQuantityConverter

      public static <Q extends javax.measure.Quantity<Q>, R extends javax.measure.Quantity<R>> IQuantityConverter<Q,R> getIQuantityConverter(Object obj)
      Parameters:
      obj -
      Returns:
      IQuantityConverter
    • 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
    • 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
    • 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.
    • 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