public class Trajectory<S extends ProbeState<S>> extends java.lang.Object implements IArchive, java.lang.Iterable<S>
ProbeState
objects,
each of which reflects the state of the Probe
at a particular
point in time.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
TRAJ_LABEL
XML element tag for trajectory
|
Constructor and Description |
---|
Trajectory(java.lang.Class<S> clsStates)
Creates a new
Trajectory given the Class<S>
object of the underlying ProbeState type, S . |
Modifier and Type | Method and Description |
---|---|
protected void |
addPropertiesTo(DataAdaptor container)
Override this method in subclasses to add subclass-specific properties to
the output.
|
S |
finalState()
Returns the probe's final state or null if there is none.
|
java.lang.String |
getDescription()
Return the user comment associated with this trajectory.
|
java.lang.Class<S> |
getStateClass()
Gets the
Class<S> object of the generic type S . |
java.util.List<S> |
getStatesViaIndexer()
Returns a list of all the states in this trajectory managed by
the state numeric (position) indexer.
|
java.util.List<S> |
getStatesViaStateMap()
Get the list of all states in this trajectory managed by the
state map.
|
java.util.Date |
getTimestamp()
Return the time stamp of the trajectory object
|
int[] |
indicesForElement(java.lang.String element)
Returns an array of the state indices corresponding to the specified element.
|
S |
initialState()
Returns the probe's initial state or null if there is none.
|
java.util.Iterator<S> |
iterator()
Returns an iterator over all the probe states in the trajectory.
|
void |
load(DataAdaptor container)
Load the current
Trajectory object with the state history
information in the DataAdaptor object. |
int |
numStates()
Return the number of states in the trajectory.
|
S |
popLastState()
Remove the last state from the trajectory and return it.
|
static Trajectory<? extends ProbeState<?>> |
readFrom(DataAdaptor container)
Read the contents of the supplied
DataAdaptor and return
an instance of the appropriate Trajectory species. |
protected void |
readPropertiesFrom(DataAdaptor container)
Allow subclasses to read subclass-specific properties from the
DataAdaptor . |
void |
save(DataAdaptor container)
Adds a representation of this Trajectory and its state history to the supplied
DataAdaptor . |
void |
saveState(S state)
Save the
ProbeState object directly to the trajectory at the tail. |
void |
setDescription(java.lang.String strDescr)
Set the user comment string
|
void |
setTimestamp(long lngTimeStamp)
Set the time stamp of the trajectory.
|
S |
stateAtPosition(double pos)
Returns the probe state at the specified position.
|
S |
stateForElement(java.lang.String strSmfNodeId)
The old comment read
"Get the probe state for the specified element ID." which is now inaccurate. |
java.util.Iterator<S> |
stateIterator()
Return an Iterator over the iterator's states.
|
S |
stateNearestPosition(double position)
Get the state that is closest to the specified position
|
ProbeState[] |
statesForElement_OLD(java.lang.String strElemId)
Deprecated.
|
java.util.List<S> |
statesForElement(java.lang.String strSmfNodeId)
Revised version of state lookup method for an element ID
class, which now corresponds to a hardware node
ID lookup.
|
java.util.List<S> |
statesInPositionRange(double low,
double high)
Returns the states that fall within the specified position range, inclusive.
|
S |
stateWithIndex(int i)
Returns the state corresponding to the specified index, or null if there is none.
|
Trajectory<S> |
subTrajectory(java.lang.String strSmfNodeId1,
java.lang.String strSmfNodeId2)
Creates and returns a "sub-trajectory" object built from the contiguous
state objects of this trajectory between the start node
strSmfNodeId1
and the stop node strSmfNodeId2 . |
Trajectory<S> |
subTrajectoryInclusive(java.lang.String strSmfNodeId1,
java.lang.String strSmfNodeId2)
Creates and returns a "sub-trajectory" object built from the contiguous
state objects of this trajectory between the start node
strSmfNodeId1
and the stop node strSmfNodeId2 . |
java.lang.String |
toString()
Store a textual representation of the trajectory to a string
|
void |
update(Probe<S> probe)
Captures the specified probe's current state to a
ProbeState object
then saves it to the trajectory. |
public static final java.lang.String TRAJ_LABEL
public Trajectory(java.lang.Class<S> clsStates)
Trajectory
given the Class<S>
object of the underlying ProbeState
type, S
.clsStates
- - the Class<S>
object of the underlying
ProbeState
typepublic static Trajectory<? extends ProbeState<?>> readFrom(DataAdaptor container) throws ParsingException
DataAdaptor
and return
an instance of the appropriate Trajectory species.container
- DataAdaptor
to read a Trajectory fromParsingException
- error encountered reading the DataAdaptorprotected void addPropertiesTo(DataAdaptor container)
container
- the DataAdaptor
to add properties toprotected void readPropertiesFrom(DataAdaptor container) throws ParsingException
DataAdaptor
. Implementations should call super.readPropertiesFrom
to ensure that superclass implementations are executed.container
- DataAdaptor
to read properties fromParsingException
public void setDescription(java.lang.String strDescr)
strDescr
- user comment stringpublic void setTimestamp(long lngTimeStamp)
lngTimeStamp
- number of milliseconds since January 1, 1970 GMTpublic java.lang.Class<S> getStateClass()
Class<S>
object of the generic type S
.Class<S>
object for the class S
public void update(Probe<S> probe)
ProbeState
object
then saves it to the trajectory. State goes at the tail of the trajectory list.probe
- target probe objectpublic void saveState(S state)
ProbeState
object directly to the trajectory at the tail.state
- new addition to trajectorypublic S popLastState()
ProbeState
in the historypublic java.lang.String getDescription()
public java.util.Date getTimestamp()
public java.util.Iterator<S> stateIterator()
public int numStates()
public S initialState()
public S finalState()
public java.util.List<S> getStatesViaStateMap()
public java.util.List<S> getStatesViaIndexer()
public Trajectory<S> subTrajectory(java.lang.String strSmfNodeId1, java.lang.String strSmfNodeId2)
strSmfNodeId1
and the stop node strSmfNodeId2
. The returned trajectory contains
references to the same states contained in this trajectory, they are not
duplicates. So any modifications made on the returned object will
be reflected here. Also, it is important to note that the returned sub-trajectory
excludes all states belonging to the stop hardware node
strSmfNodeId2
. That is, the returned value contains states from,
and including, node 1 up to, but not including, state 2. If you wish to include
the states of both hardware nodes see
subTrajectoryInclusive(String, String)
.strSmfNodeId1
- hardware node ID defining the first state object in sub-trajectorystrSmfNodeId2
- hardware node ID defining the last state object in sub-trajectorysubTrajectoryInclusive(String, String)
public Trajectory<S> subTrajectoryInclusive(java.lang.String strSmfNodeId1, java.lang.String strSmfNodeId2)
strSmfNodeId1
and the stop node strSmfNodeId2
. The returned trajectory contains
references to the same states contained in this trajectory, they are not
duplicates. So any modifications made on the returned object will
be reflected here. Also, it is important to note that the returned sub-trajectory
includes all states belonging to the stop hardware node
strSmfNodeId2
. That is, the returned value contains states from,
and including, node 1 up to and including state 2. If you wish to exclude
the states of both hardware nodes see
subTrajectory(String, String)
.strSmfNodeId1
- hardware node ID defining the first state object in sub-trajectorystrSmfNodeId2
- hardware node ID defining the last state object in sub-trajectorysubTrajectory(String, String)
public S stateAtPosition(double pos)
public S stateNearestPosition(double position)
position
- the position for which to find a statepublic java.util.List<S> statesInPositionRange(double low, double high)
low
- lower bound on position rangehigh
- upper bound on position rangeProbeState
objects whose position falls
within the specified rangepublic S stateForElement(java.lang.String strSmfNodeId)
The old comment read
"Get the probe state for the specified element ID."
which is now inaccurate. The returned state is actual the first
state for the given identifier which is treated as that for an
SMF hardware node. The "first state" is the state with the smallest
upstream position, that which the probe encounters first in an
forward propagation.
strSmfNodeId
- hardware node ID of the desired state@Deprecated public ProbeState[] statesForElement_OLD(java.lang.String strElemId)
strElemId
- the name of the element to search forProbeState
objects for that elementpublic java.util.List<S> statesForElement(java.lang.String strSmfNodeId)
Revised version of state lookup method for an element ID class, which now corresponds to a hardware node ID lookup. Since the lattice generator creates element IDs by prefixing and suffixing hardware node IDs, the actual hardware node ID must be used to get all the states corresponding to a given hardware node.
The revised part comes from the fact that the states are now stored and retrieved by
hashing or a tree lookup, rather that by a linear search.
Specifically, a map of probe
states for every hardware node ID is maintained, along with an ordered
list of states arranged according to their position along the
beamline (for iterations, e.g., see ).
strSmfNodeId
- identifier for the SMF hardware nodepublic int[] indicesForElement(java.lang.String element)
element
- name of element to search forpublic S stateWithIndex(int i)
i
- index of state to returnpublic java.util.Iterator<S> iterator()
Iterable
interface which facilitates
the "for each" statement. States are traversed in their order along the
beamline.iterator
in interface java.lang.Iterable<S extends ProbeState<S>>
(T X : Container<T>)
statementpublic java.lang.String toString()
toString
in class java.lang.Object
public void save(DataAdaptor container)
DataAdaptor
.public void load(DataAdaptor container) throws DataFormatException
Trajectory
object with the state history
information in the DataAdaptor
object.load
in interface IArchive
container
- DataAdaptor
from which state history is extractedDataFormatException
- malformated data in DataAdaptor