public class Scenario
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SYNC_MODE_DESIGN |
static java.lang.String |
SYNC_MODE_LIVE |
static java.lang.String |
SYNC_MODE_RF_DESIGN |
Modifier | Constructor and Description |
---|---|
protected |
Scenario(AcceleratorSeq aSeq,
Lattice aLattice,
SynchronizationManager aSyncMgr)
Constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkSynchronization(AcceleratorNode aNode,
java.util.Map<java.lang.String,java.lang.Double> values)
Testing Support
|
java.util.List<IElement> |
elementsMappedTo(AcceleratorNode aNode)
Returns a List of elements mapped to the specified node.
|
Lattice |
getLattice()
Returns the lattice.
|
ModelInput |
getModelInput(AcceleratorNode aNode,
java.lang.String propName)
Returns the ModelInput for the specified node's property.
|
double |
getPositionRelativeToStart(double positionInSequence)
Convert the position of a location in the sequence to a position in a trajectory due to
a start element offset specified in the scenario.
|
Probe<?> |
getProbe()
Returns the scenario's current probe, or null if there is none.
|
java.lang.String |
getStartElementId()
Return the string identifier of the modeling element where propagation
starts.
|
java.lang.String |
getStopElementId()
Return the string identifier of the modeling element where propagation
stops.
|
java.lang.String |
getSynchronizationMode()
get the synchronization mode
|
<S extends ProbeState<S>> |
getTrajectory()
Returns the trajectory obtained by running the model.
|
static Scenario |
newScenarioFor(AcceleratorSeq smfSeq)
Creates a new Scenario for the supplied accelerator sequence.
|
static Scenario |
newScenarioFor(AcceleratorSeq smfSeq,
ElementMapping elementMapping)
Creates a new Scenario for the supplied accelerator sequence and element mapping.
|
static Scenario |
newScenarioFor(Ring smfRing)
Creates a new
Scenario object for the explicit case where
the AcceleratorSeq object is of type
gov.sns.xal.smf.Ring . |
AcceleratorNode |
nodeWithId(java.lang.String id)
Returns the accelerator node with the specified id, or null if there is
none.
|
java.util.Map<java.lang.String,java.lang.Double> |
propertiesForNode(AcceleratorNode aNode)
Returns a map of property values (key = String property name, value =
double property value) for the supplied node.
|
void |
removeModelInput(AcceleratorNode aNode,
java.lang.String property)
Removes the model input for the specified property on the specified node,
if there is one.
|
void |
resetProbe()
Resets the probe to its initial state - before propagation (e.g., the
state specified in the probe xml file).
|
void |
resync()
Synchronizes each lattice element to the appropriate data source.
|
void |
resyncFromCache()
Synchronizes each lattice element from the cache and applies the whatif model inputs.
|
void |
run()
Runs the model (propagate probe through lattice).
|
void |
setIncludeStopElement(boolean bolInclStopElem)
Sets the flag that determines whether or not the
propagation stops at the entrance of the stop element (if set),
or at the exit of the stop node.
|
void |
setLattice(Lattice aLattice) |
ModelInput |
setModelInput(AcceleratorNode aNode,
java.lang.String propName,
double val)
Sets the specified node's property to the specified value.
|
void |
setProbe(Probe<?> aProbe)
Sets the supplied probe for this scenario.
|
void |
setStartElement(IElement start)
Sets the model to start propagation from the specified IElement.
|
void |
setStartElementId(java.lang.String elemId)
Set the "start" element by String id
|
void |
setStartNode(java.lang.String nodeId)
Sets the model to start propagation from the AcceleratorNode with the
specified id.
|
void |
setStopElement(IElement stop)
Sets the model to stop propagation (by default) after the specified IElement.
|
void |
setStopElementId(java.lang.String elemId)
Set the "stop" element by String id
|
void |
setStopNode(java.lang.String nodeId)
Sets the model to stop propagation the AcceleratorNode
with the specified id.
|
void |
setSynchronizationMode(java.lang.String newMode)
Sets the synchronization mode for the sync manager to a known sync mode,
such as SynchronizationManager.SYNC_MODE_LIVE or SYNC_MODE_DESIGN.
|
java.util.List<? extends ProbeState<?>> |
trajectoryStatesForElement(java.lang.String id)
Returns an array of the trajectory states for the specified element id.
|
void |
unsetStartNode()
remove previously set Start point
|
void |
unsetStopNode()
remove previously set Stop point
|
public static final java.lang.String SYNC_MODE_LIVE
public static final java.lang.String SYNC_MODE_DESIGN
public static final java.lang.String SYNC_MODE_RF_DESIGN
protected Scenario(AcceleratorSeq aSeq, Lattice aLattice, SynchronizationManager aSyncMgr)
public static Scenario newScenarioFor(AcceleratorSeq smfSeq) throws ModelException
smfSeq
- the accelerator sequence to build a scenario forModelException
- error building Scenariopublic static Scenario newScenarioFor(AcceleratorSeq smfSeq, ElementMapping elementMapping) throws ModelException
smfSeq
- the accelerator sequence to build a scenario forelementMapping
- the element mapping to build a scenario withModelException
- error building Scenariopublic static Scenario newScenarioFor(Ring smfRing) throws ModelException
Scenario
object for the explicit case where
the AcceleratorSeq
object is of type
gov.sns.xal.smf.Ring
.smfRing
- target hardware (SMF) ring objectScenario
object encapsulating ringModelException
- unable to build modeling scenariopublic void setSynchronizationMode(java.lang.String newMode)
newMode
- String specifying mode to set tojava.lang.IllegalArgumentException
- if the specified mode is unknownpublic java.lang.String getSynchronizationMode()
public void resync() throws SynchronizationException
SynchronizationException
- if an error is encountered reading a data sourcepublic void resyncFromCache() throws SynchronizationException
SynchronizationException
- if an error is encountered reading a data sourcepublic void setStartNode(java.lang.String nodeId) throws ModelException
nodeId
- ID of AcceleratorNode to start fromModelException
- if the node is not found, or no elements are mapped to itpublic void setStopNode(java.lang.String nodeId) throws ModelException
nodeId
- ID of the AcceleratorNode to stop afterModelException
- if the node is not found, or no elements are mapped to itpublic void setStartElement(IElement start)
start
- Element to start propagation frompublic void setStopElement(IElement stop)
stop
- Element to stop propagation afterpublic void setIncludeStopElement(boolean bolInclStopElem)
bolInclStopElem
- propagation stops after stop element if true
,
before the stop element if false
public double getPositionRelativeToStart(double positionInSequence)
positionInSequence
- The position of a location in this scenario's sequencepublic void run() throws ModelException
ModelException
- if there is an error propagating the probejava.lang.IllegalStateException
- if the lattice or probe is not properly initializedpublic Lattice getLattice()
public void setLattice(Lattice aLattice)
public <S extends ProbeState<S>> Trajectory<S> getTrajectory()
Returns the trajectory obtained by running the model.
Trajectory>
since the actual type of the trajectory is not known. Any type of probe
may be used to run the scenario.
java.lang.IllegalStateException
- if the probe or trajectory is nullpublic java.util.Map<java.lang.String,java.lang.Double> propertiesForNode(AcceleratorNode aNode) throws SynchronizationException
aNode
- AcceleratorNode whose properties to getSynchronizationException
- if error getting propertiesjava.lang.IllegalArgumentException
- if aNode is nullpublic AcceleratorNode nodeWithId(java.lang.String id)
id
- String id of the node to returnpublic java.util.List<IElement> elementsMappedTo(AcceleratorNode aNode)
aNode
- node to get elements mapped topublic java.util.List<? extends ProbeState<?>> trajectoryStatesForElement(java.lang.String id) throws ModelException
id
- element id to find states forModelException
- if the probe is not yet propagatedpublic java.lang.String getStartElementId()
public void setStartElementId(java.lang.String elemId)
elemId
- Start element Idpublic java.lang.String getStopElementId()
public void setStopElementId(java.lang.String elemId)
elemId
- Stop element Idpublic ModelInput setModelInput(AcceleratorNode aNode, java.lang.String propName, double val)
aNode
- node whose property to setpropName
- name of property to setval
- double value for propertypublic ModelInput getModelInput(AcceleratorNode aNode, java.lang.String propName)
aNode
- node whose property to get a ModelInput forpropName
- name of property to get a ModelInput forpublic void removeModelInput(AcceleratorNode aNode, java.lang.String property)
aNode
- node whose input to removeproperty
- name of property whose input to removepublic void setProbe(Probe<?> aProbe)
aProbe
- the probe to be used by the scenariopublic Probe<?> getProbe()
public void resetProbe()
public boolean checkSynchronization(AcceleratorNode aNode, java.util.Map<java.lang.String,java.lang.Double> values) throws SynchronizationException
SynchronizationException
public void unsetStartNode()
public void unsetStopNode()