Class ElementSeq
- All Implemented Interfaces:
Iterable<IComponent>,IComponent,IComposite
- Direct Known Subclasses:
ElectromagnetSeq,IdealRfCavity,Lattice,LineModel,RingModel,Sector
Convenience abstract base class for a composite modeling element. The composite is represented as a sequence of modeling elements, perhaps other composites. Specifically we have an ordered list of child modeling elements.
Propagation of probes (objects exposing the IProbe interface) is
done by passing it sequentially to each child. Of course if a child is also a
composite the same is done there.
- Version:
- 2.0 February, 2009
- Author:
- Christopher K. Allen
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intdefault number of element positions to reserve in list array -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedElementSeq(String strType) Creates a new instance ofElementSeqwithout of the given soft type but without a sequence identifier.protectedElementSeq(String strType, String strId) Creates a new instance ofElementSeqwith the given soft type and sequence identifier.protectedElementSeq(String strType, String strId, int szReserve) Creates a new instance ofElementSeqwith the given soft type and sequence identifier. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(IComponent iComp) Add a component object at the tail of the sequence list and at the head of the reverse sequence list.voidbackPropagate(IProbe probe) Backward propagation of probe through sequence.voidbackPropagate(IProbe probe, double pos) Override ofIComponent.propagate(xal.model.IProbe, double)Return anIteratorobject that cycles through all the direct children of the sequence.protected voidRecompute all the dependent parameters.voidConcatenate the indicatedElementSeqobject to the tail of this sequence.doubleGet the horizontal misalignmentdoubleGet the vertical misalignmentdoubleGet the longitudinal misalignmentReturns a list of all elements contained in this sequence, more specifically, all leaf elements.getChild(int indChild) Get the child IComponent interface at location specified by index.intGet the number of direct children in this sequence.Get any user comments regarding this sequence.Return the list ofIElementobjects contained in this sequence.protected List<IComponent>Return the internal list of componentsReturns the string identifier of the hardware node which this element models.getId()Get the sequence identifierdoubleReturn the (center) position of this component within the global lattice structure to which it belongs.intGet the number ofIElementderived objects contained in this sequence.doubleReturn the length of the sequence.Returns the composite structure (if any) that owns this component.doublegetPhiX()doublegetPhiY()doublegetPhiZ()doubleReturn the center position of this component within the immediate parent composite element.protected List<IComponent>Return the reverse component list (downstream to upstream)getType()Get the type identifier for the composite element.Return anIteratorobject that iterates over everyIComponentobject in this composite.Return anIteratorobject that iterates over everyIComponentobject in this composite.voidinitializeFrom(LatticeElement latticeElement) Initialization method to be provided by the useriterator()Returns a shallow iterator for the direct descendants of this composite modeling element.Return anIteratorobject that iterates over the direct descendants only of this composite element, in reverse order.Return anIteratorobject that iterates over the direct descendants only of this composite element, in order.voidprint(PrintWriter os) Dump contents to a text stream.voidPropagate probe through sequencevoidOverride ofIComponent.propagate(xal.model.IProbe, double)booleanremove(IComponent iCmp) Remove an element from the entire tree.voidSet the alignment parameters all at once.voidsetAlignX(double x) Set the horizontal misalignmentvoidsetAlignY(double y) Set the vertical misalignmentvoidsetAlignZ(double z) Set the longitudinal misalignmentvoidsetComments(String strComment) Sets any user comment associated with this sequence.protected voidsetCompList(List<? extends IComponent> elements) Set the comp list to the new list of elements.voidsetDirty(IComponent cmpCaller) voidsetHardwareNodeId(String strSmfId) Sets the string identifier of the hardware node which this element models.voidSet the string identifier for the element.voidsetParent(IComposite cpsParent) Sets the parent structure containing this composite structure.voidsetPhiX(double phix) voidsetPhiY(double phiy) voidsetPhiZ(double phiz) toString()Writes out the modeling elements in this element sequence structure.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
SIZE_DEF_RESERVE
public static final int SIZE_DEF_RESERVEdefault number of element positions to reserve in list array- See Also:
-
-
Constructor Details
-
ElementSeq
Creates a new instance ofElementSeqwithout of the given soft type but without a sequence identifier.- Parameters:
strType- soft type of the sequence (defined by the child class)
-
ElementSeq
Creates a new instance ofElementSeqwith the given soft type and sequence identifier.- Parameters:
strType- soft type of the sequence (defined by the child class)strId- identifier of the sequence
-
ElementSeq
Creates a new instance ofElementSeqwith the given soft type and sequence identifier. Also reserves space for a the sequence elements. This saves a little CPU time if the relative size of the sequence is known a priori.- Parameters:
strType- soft type of the sequence (defined by the child class)strId- identifier of the sequenceszReserve- number of Element spaces to reserve
-
-
Method Details
-
setId
Set the string identifier for the element.- Parameters:
strId- new string identifier for element
-
setHardwareNodeId
Sets the string identifier of the hardware node which this element models. Node that this sequence probably models an accelerator sector, or logical unit. Thus, this ID is likely of the type "HEBT", "RING", "DTL", etc.- Parameters:
strSmfId- identifier for the modeled hardware node (SMF object)- Since:
- Sep 2, 2014
-
setComments
Sets any user comment associated with this sequence.- Parameters:
strComment- string containing user comments
-
getComments
Get any user comments regarding this sequence. Returns the null string if none.- Returns:
- string containing user comments
-
getLeafCount
public int getLeafCount()Get the number ofIElementderived objects contained in this sequence.- Returns:
- number of
Elementobject w/in sequence
-
getElementList
Return the list ofIElementobjects contained in this sequence.- Returns:
- list of elements composing this sequence
-
getAllElements
Returns a list of all elements contained in this sequence, more specifically, all leaf elements.- Returns:
- list containing all
IComponentclass elements in this sequence - Since:
- Sep 11, 2014
-
setAlign
Set the alignment parameters all at once.- Parameters:
vecAlign- (dx,dy,dz)
-
setAlignX
public void setAlignX(double x) Set the horizontal misalignment- Parameters:
x- misalignment (in m)- Since:
- Dec 17, 2014 by Christopher K. Allen
-
setAlignY
public void setAlignY(double y) Set the vertical misalignment- Parameters:
y- misalignment (in m)- Since:
- Dec 17, 2014 by Christopher K. Allen
-
setAlignZ
public void setAlignZ(double z) Set the longitudinal misalignment- Parameters:
z- misalignment (in m)- Since:
- Dec 17, 2014 by Christopher K. Allen
-
getAlignX
public double getAlignX()Get the horizontal misalignment- Returns:
- the misalignment (in meters)
- Since:
- Dec 17, 2014 by Christopher K. Allen
-
getAlignY
public double getAlignY()Get the vertical misalignment- Returns:
- the misalignment (in meters)
- Since:
- Dec 17, 2014 by Christopher K. Allen
-
getAlignZ
public double getAlignZ()Get the longitudinal misalignment- Returns:
- the misalignment (in meters)
- Since:
- Dec 17, 2014 by Christopher K. Allen
-
getPhiX
public double getPhiX() -
getPhiY
public double getPhiY() -
getPhiZ
public double getPhiZ() -
setPhiX
public void setPhiX(double phix) -
setPhiY
public void setPhiY(double phiy) -
setPhiZ
public void setPhiZ(double phiz) -
localBackIterator
Return anIteratorobject that iterates over the direct descendants only of this composite element, in reverse order.- Returns:
- interface to iterator object
- Since:
- Feb 27, 2009
- See Also:
-
globalBackIterator
Return anIteratorobject that iterates over everyIComponentobject in this composite. ForIComponentwhich are also composite the parent is returned first, then all its children. This would be in reverse order.- Returns:
Iteratorinterface to iterator object- See Also:
-
childIterator
Return anIteratorobject that cycles through all the direct children of the sequence. Note that any child may have children itself.- Returns:
- iterator of
IElementinterfaces
-
concatenateEquals
Concatenate the indicatedElementSeqobject to the tail of this sequence.- Parameters:
seq- object to append to this one
-
initializeFrom
Initialization method to be provided by the user- Specified by:
initializeFromin interfaceIComponent- Parameters:
latticeElement- the SMF node to convert
-
getType
Get the type identifier for the composite element.- Specified by:
getTypein interfaceIComponent- Returns:
- type identifier for ElementSeq
-
getId
Get the sequence identifier- Specified by:
getIdin interfaceIComponent- Returns:
- sequence identifier
-
getHardwareNodeId
Returns the string identifier of the hardware node which this element models. This value is likely a sector of an accelerator structure, such as "HEBT", "RING", "MEBT", etc.- Specified by:
getHardwareNodeIdin interfaceIComponent- Returns:
- the identifier string of the hardware this element models
- Since:
- Sep 2, 2014
-
getLength
public double getLength()Return the length of the sequence. The length of the sequence is determined but summing the lengths of all the contained
IComponentobjects.- Specified by:
getLengthin interfaceIComponent- Returns:
- total length of the sequence (in meters)
-
getPosition
public double getPosition()Description copied from interface:IComponentReturn the center position of this component within the immediate parent composite element. If there is no parent then this method should return zero.
This value is typically a "hardware property," especially if this element models a hardware node. That is, the value is specified in the description of the hardware node and, thus, carries through to the modeling element. The situation is different than the property
where the position is completely dependent upon where the modeling element lies within the overall lattice structure.IComponent.getLatticePosition()- Specified by:
getPositionin interfaceIComponent- Returns:
- center position of this element within the immediate parent container (meters)
- Since:
- Dec 3, 2015, Christopher K. Allen
- See Also:
-
getLatticePosition
public double getLatticePosition()Description copied from interface:IComponentReturn the (center) position of this component within the global lattice structure to which it belongs. Note the difference between this parameter and that returned by
IComponentwhich returns the position with respect to the direct parent.IComponent.getLength()The returned value is not usually a design parameter, in particular if composites are pasted together or otherwise form a larger tree structure. It should be computed according to the current structure of the global composite structure. Thus, moving this element in the lattice should change this value.
- Specified by:
getLatticePositionin interfaceIComponent- Returns:
- the center position of this component within the entire lattice containing this element (not just the parent)
- Since:
- Dec 3, 2015, Christopher K. Allen
- See Also:
-
getParent
Description copied from interface:IComponentReturns the composite structure (if any) that owns this component.- Specified by:
getParentin interfaceIComponent- Returns:
- returns the composite structure owning this composite structure,
or
nullif this structure is top level - Since:
- Jan 22, 2015 by Christopher K. Allen
- See Also:
-
setParent
Sets the parent structure containing this composite structure. The parent is assumed to be a composite structure built from component elements.- Specified by:
setParentin interfaceIComponent- Parameters:
cpsParent- the composite structure built from this component- Since:
- Jan 22, 2015 by Christopher K. Allen
- See Also:
-
propagate
Override of
IComponent.propagate(xal.model.IProbe, double)- Specified by:
propagatein interfaceIComponent- Throws:
ModelException- Since:
- Feb 27, 2009
- See Also:
-
propagate
Propagate probe through sequence- Specified by:
propagatein interfaceIComponent- Specified by:
propagatein interfaceIComposite- Parameters:
probe- the state of the probe will be advance using the elements dynamics- Throws:
ModelException- an error occurred while advancing the probe state- See Also:
-
backPropagate
Override of
IComponent.propagate(xal.model.IProbe, double)NOTES: CKA
· Support for backward propagation February, 2009.
· You must use the proper algorithm object for this method to work correctly!- Specified by:
backPropagatein interfaceIComponent- Parameters:
probe- probe to be propagate - its state is advancedpos- position within element- Throws:
ModelException- error advancing the probe state- Since:
- Feb 27, 2009
- See Also:
-
backPropagate
Backward propagation of probe through sequence.
NOTES: CKA
· Support for backward propagation February, 2009.
· You must use the proper algorithm object for this method to work correctly!- Specified by:
backPropagatein interfaceIComponent- Parameters:
probe- the state of the probe will be advance using the elements dynamics- Throws:
ModelException- an error occurred while advancing the probe state
-
localIterator
Return anIteratorobject that iterates over the direct descendants only of this composite element, in order.- Specified by:
localIteratorin interfaceIComposite- Returns:
- interface to iterator object
- See Also:
-
globalIterator
Return anIteratorobject that iterates over everyIComponentobject in this composite. ForIComponentwhich are also composite the parent is returned first, then all its children. This would be in reverse order.- Specified by:
globalIteratorin interfaceIComposite- Returns:
Iteratorinterface to iterator object- See Also:
-
getChildCount
public int getChildCount()Get the number of direct children in this sequence. Note that this is not the number of leaves in the sequence.- Specified by:
getChildCountin interfaceIComposite- Returns:
- number of direct descendants
-
getChild
Get the child IComponent interface at location specified by index.- Specified by:
getChildin interfaceIComposite- Parameters:
indChild- position index within the sequence list- Returns:
- child at position indChild
-
addChild
Add a component object at the tail of the sequence list and at the head of the reverse sequence list.
NOTES: CKA
· Added support for backward propagation February, 2009- Specified by:
addChildin interfaceIComposite- Parameters:
iComp- new component object
-
remove
Remove an element from the entire tree. The element can be a single leaf node or a composite node.- Specified by:
removein interfaceIComposite- Parameters:
iCmp- IComponent object to be removed- Returns:
- return true if element was found and removed, false otherwise
-
setDirty
Description copied from interface:ICompositeNeed only be called by implementing classes
Indicates internally that the composite structure has been modified and any dependent parameters must be recomputed. This is needed if these parameters must be computed upon demand due to dynamic changes in the composite. In order to avoid expensive re-iteration through large composite structures, by employing this method a state condition can be set up so that the dependent parameters are only recomputed when the composite changes.- Implementing classes should call this method whenever the composite
changes, in particular whenever
andIComposite.addChild(IComponent)are called.IComposite.remove(IComponent) - They respond to this call by setting a dirty flag and calls the same method on their parent object.
- If the dirty flag is set then all dependent parameters should be recomputed whenever one is requested (after which the flag can be cleared).
- Specified by:
setDirtyin interfaceIComposite- Parameters:
cmpCaller- theIComponentobject calling this method, ornullif the object is not a component- Since:
- Dec 3, 2015, Christopher K. Allen
- See Also:
-
xal.model.IComposite#setDirty()
- Implementing classes should call this method whenever the composite
changes, in particular whenever
-
iterator
Returns a shallow iterator for the direct descendants of this composite modeling element. This is the same iterator returned by. This method is needed by thelocalIterator()Iterableinterface to satisfyforeachlanguage constructions.- Specified by:
iteratorin interfaceIterable<IComponent>- Returns:
- a shallow iterator traversing the direct descendants of this container
- Since:
- Dec 2, 2015, Christopher K. Allen
-
toString
Writes out the modeling elements in this element sequence structure. -
toStringLegacy
- Since:
- Feb 3, 2015 by Christopher K. Allen
- See Also:
-
print
Dump contents to a text stream.- Parameters:
os- output stream
-
getForwardCompList
Return the internal list of components -
getReverseCompList
Return the reverse component list (downstream to upstream)
NOTES: CKA
· Added support for backward propagation February, 2009- Returns:
Listof sequence components in reverse order- Since:
- Feb 27, 2009
-
setCompList
Set the comp list to the new list of elements.
NOTES: CKA
· Added support for backward propagation February, 2009- Parameters:
elements- the new list of elements
-
compDependParams
protected void compDependParams()Recompute all the dependent parameters. Right now that is the sequence length and the position of this sequence within the parent sequence. The dirty flag is cleared once it's all done.- Since:
- Dec 3, 2015, Christopher K. Allen
-