Class LatticeElement

java.lang.Object
xal.sim.scenario.LatticeElement
All Implemented Interfaces:
Comparable<LatticeElement>
Direct Known Subclasses:
LatticeSequence

public class LatticeElement extends Object implements Comparable<LatticeElement>

CKA NOTES:

This class is essentially an association class between accelerator hardware nodes and modeling elements of the XAL online model.

This can also be a proxy for SMF hardware nodes and can generates its modeling element counterpart. Currently it represents one atomic hardware node, but I believe it can represent many modeling elements (see #getParts()).

· I have modified this objects so it carries the additional attribute of the modeling element identifier. This is in contrast to the hardware node identifier from which it maps.

· The idea is that probes states produced by simulation will carry this attribute if it has been set. If not, then the probe state will have the same attribute ID as the hardware node.

· Note that probe states now carry two identifier attributes, one for the modeling element, and one for the SMF hardware node from which it came.

· The modeling element parameter initialization is done by calling the IComponent.initializeFrom(LatticeElement). This design effectively couples the xal.model online model subsystem to the xal.smf hardware representation subsystem. These systems should be independent, able to function without each other.

· I cannot really tell exactly what is happening as there was no commenting. I have added some comments wherever I have gone over the code, hopefully they are in the ball park.

Since:
Oct 3, 2013
Version:
Sep 5, 2014
Author:
Ivo List, Christopher K. Allen
  • Field Details

    • dblElemLen

      protected double dblElemLen
      length of the modeling element
    • dblElemCntrPos

      protected double dblElemCntrPos
      center position of the modeling element within its parent sequence
    • dblElemEntrPos

      protected double dblElemEntrPos
      axial position of the modeling element entrance
    • dblElemExitPos

      protected double dblElemExitPos
      axial position of the modeling element exit
  • Constructor Details

    • LatticeElement

      public LatticeElement(AcceleratorNode smfNode, double dblPosCtr, Class<? extends IComponent> clsModElemType, int originalPosition)
      Initializing constructor for LatticeElement. The hardware node entrance and exit positions are initialized using the given center position and length attribute.
      Parameters:
      smfNode - associated hardware node
      dblPosCtr - center position of hardware node within accelerator sequence
      clsModElemType - class type of the modeling element for associated hardware
      originalPosition - index position of the hardware node within its sequence (used to sort elements)
      Since:
      Dec 8, 2014
  • Method Details

    • setModelingElementId

      public void setModelingElementId(String strElemId)
      Sets the (optional) string identifier for the modeling element that this object will create. Typically used when splitting up modeling elements associated with the proxied hardware node.
      Parameters:
      strElemId - identifier for the modeling element to be created
      Since:
      Sep 5, 2014
    • getHardwareNode

      public AcceleratorNode getHardwareNode()
      Returns the hardware node associated with this lattice element proxy.
      Returns:
      accelerator hardware node proxied by this lattice element
      Since:
      Dec 9, 2014
    • getModelingElementId

      public String getModelingElementId()
      Returns the identifier string to be used for the modeling element created by this object.
      Returns:
      the element ID of the created object
      Since:
      Sep 5, 2014
    • getModelingClass

      public Class<? extends IComponent> getModelingClass()
      Returns the class type of the modeling element used to represent the associated hardware node.
      Returns:
      class type of the modeling element to be created
      Since:
      Dec 9, 2014
    • getLength

      public double getLength()

      Returns the length associated with the hardware node. This length depends upon the length of the hardware node and how many times it has been split to create the appropriate modeling element.

      Note that the effective length of the associated hardware node is used. If the hardware is a bending magnet then this is the path length. If the hardware node is not a magnet then the physical length is returned. These values are determined in the LatticeElement constructor.

      Returns:
      length of this lattice element based upon hardware length and splitting
      Since:
      Dec 9, 2014
    • getStartPosition

      public double getStartPosition()
      Returns the entrance location within its parent element sequence of the modeling element to be created. This value is derived from the associated hardware position and the splitting of the representative lattice elements.
      Returns:
      entrance position of the modeling element w.r.t. the parent sequence
      Since:
      Dec 9, 2014
    • getCenterPosition

      public double getCenterPosition()
      Returns the center location of the modeling element to be created. This value is derived from the associated hardware position and the splitting of the representative lattice elements.
      Returns:
      axial center position within the parent sequence
      Since:
      Dec 9, 2014
    • getEndPosition

      public double getEndPosition()
      Returns the exit location of the modeling element to be created within its parent accelerator sequence.
      Returns:
      exit position of the modeling element w.r.t. the parent sequence
      Since:
      Dec 9, 2014
    • isThin

      public boolean isThin()
      Determines whether or not the hardware accelerator node will be represented with a thin modeling element. Looks at both the effective length of the hardware node and the class type of the modeling element used to represent it.
      Returns:
      true if a modeling element derived from ThinElement will be returned, false otherwise
      Since:
      Dec 4, 2014
    • isArtificial

      public boolean isArtificial()
      Indicates whether or not this lattice element is artificial or not. An element is artificial if there is no hardware representation for it in the XDXF file. It was probably created as a placeholder within the lattice generation process.
      Returns:
      true if this element has no corresponding SMF hardware node, false if this element is artificial
      Since:
      Jan 30, 2015 by Christopher K. Allen
    • isContainedIn

      public boolean isContainedIn(LatticeElement lem)
      Determines whether or not the given lattice element contains this element with respect to the axial positions. Specifically, if the entrance location of this element is greater than or equal to the entrance location of the given element, and the exit location of this element is less than or equal to the exit location of the given element, this method returns true.
      Parameters:
      lem - lattice element to compare against
      Returns:
      true if this element is contained within the axial position occupied by the given element, false otherwise
      Since:
      Jan 28, 2015 by Christopher K. Allen
    • axialTranslation

      public void axialTranslation(double dblOffset)
      Translates the element by the given amount along the beamline axis (of which sequence it belongs).
      Parameters:
      dblOffset - distance by which this element is translated (either positive or negative)
      Since:
      Jan 29, 2015 by Christopher K. Allen
    • splitElementAt

      public LatticeElement splitElementAt(LatticeElement elemSplitPos)

      Appears to split this lattice element into two parts, presumably at the center position of the given element, returning the second part.

      The number of parts is doubled and I can't figure this out?? I assume "parts" is the number of modeling elements used to represent the hardware.

      In any event, this lattice element is modified, its position now lives only up to the center position of the given element.

      I am guessing that the given lattice element should be a proxy for a thin element, but it is not enforced here.

      Parameters:
      elemSplitPos - the lattice element defining the splitting position
      Returns:
      a new lattice element which is the second part of this original lattice element
      Since:
      Dec 4, 2014
    • splitElementAt

      public LatticeElement splitElementAt(double splitPos)
    • createModelingElement

      public IComponent createModelingElement() throws ModelException

      Creates and initializes a new modeling element represented by this object. Java reflection is used to create a new instance from the element's class type. There must be a zero constructor for the element.

      CKA Notes

      · The parameter initialization is done by calling the IComponent.initializeFrom(LatticeElement). This design effectively couples the xal.model online model subsystem to the xal.smf hardware representation subsystem. These systems should be independent, able to function without each other.

      Returns:
      a new modeling element for the hardware proxied by this object
      Throws:
      ModelException - Java reflection threw an InstantiationException
      Since:
      Dec 4, 2014
    • compareTo

      public int compareTo(LatticeElement e2)
      Compare by looking at hardware node positions. If the positions are equal and the elements are both thin then we look at the position index within the sequence.
      Specified by:
      compareTo in interface Comparable<LatticeElement>
      Since:
      Dec 4, 2014
      See Also:
    • toString

      public String toString()
      Writes out entrance position, exit position, center position, and length.
      Overrides:
      toString in class Object
      Since:
      Dec 4, 2014
      See Also:
    • getFirstSlice

      public LatticeElement getFirstSlice()
    • getNextSlice

      public LatticeElement getNextSlice()
    • isFirstSlice

      public boolean isFirstSlice()
    • isLastSlice

      public boolean isLastSlice()