Class Scenario
Packages an on-line model scenario, including accelerator node proxy manager, lattice, probe, and synchronization manager.
It is not necessary for the Scenario
object to maintain a back
reference to the original AcceleratorSeq
object that it models.
In fact it is undesirable since this represents a dependency of the online
model with the SMF hardware representation component of Open XAL. Its current
uses here are not so requirements, typically used to lookup hardware nodes
from their IDs. This can be done directly on the hardware sequence itself
without using this class as a proxy.
- Author:
- Craig McChesney, Christopher K. Allen
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Synchronization manager constant for design parameter synchronizationstatic final String
Synchronization manager constant for live machine synchronizationstatic final String
Synchronization manager constant for synchronization only to live magnet values -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Scenario
(AcceleratorSeq smfSeq, Lattice mdlLattice, SynchronizationManager mgrSync) Constructor -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkSynchronization
(AcceleratorNode aNode, Map<String, Double> values) Testing SupportReturns a List of components mapped to the specified node.Returns the lattice.getModelInput
(AcceleratorNode aNode, 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.Return the string identifier of the modeling element where propagation starts.Return the string identifier of the modeling element where propagation stops.get the synchronization mode<S extends ProbeState<S>>
Trajectory<S>NOTEstatic Scenario
newScenarioFor
(AcceleratorSeq smfSeq) Creates a new Scenario for the supplied accelerator sequence.static Scenario
newScenarioFor
(AcceleratorSeq smfSeq, ElementMapping mapNodeToElem) Creates a new Scenario for the supplied accelerator sequence and element mapping.static Scenario
newScenarioFor
(Ring smfRing) Creates a newScenario
object for the explicit case where theAcceleratorSeq
object is of typexal.smf.Ring
.nodeWithId
(String id) Returns the accelerator node with the specified id, or null if there is none.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, String property) Removes the model input for the specified property on the specified node, if there is one.void
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
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) setModelInput
(AcceleratorNode aNode, String propName, double val) Sets the specified node's property to the specified value.void
Sets the supplied probe for this scenario.void
setStartComponent
(IComponent start) Sets the model to start propagation from the specified IComponent.void
setStartElementId
(String elemId) Set the "start" element by String idvoid
setStartNode
(String nodeId) Sets the model to start propagation from the AcceleratorNode with the specified id.void
setStopComponent
(IComponent stop) Sets the model to stop propagation (by default) after the specified IComponent.void
setStopElementId
(String elemId) Set the "stop" element by String idvoid
setStopNode
(String nodeId) Sets the model to stop propagation the AcceleratorNode with the specified id.void
setSynchronizationMode
(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.List<? extends ProbeState<?>>
Returns an array of the trajectory states for the specified element id.void
remove previously set Start pointvoid
remove previously set Stop point
-
Field Details
-
SYNC_MODE_LIVE
Synchronization manager constant for live machine synchronization- See Also:
-
SYNC_MODE_DESIGN
Synchronization manager constant for design parameter synchronization- See Also:
-
SYNC_MODE_RF_DESIGN
Synchronization manager constant for synchronization only to live magnet values- See Also:
-
-
Constructor Details
-
Scenario
Constructor
-
-
Method Details
-
newScenarioFor
Creates a new Scenario for the supplied accelerator sequence.- Parameters:
smfSeq
- the accelerator sequence to build a scenario for- Returns:
- a new Scenario for the supplied accelerator sequence
- Throws:
ModelException
- error building Scenario
-
newScenarioFor
public static Scenario newScenarioFor(AcceleratorSeq smfSeq, ElementMapping mapNodeToElem) throws ModelException Creates a new Scenario for the supplied accelerator sequence and element mapping.- Parameters:
smfSeq
- the accelerator sequence to build a scenario formapNodeToElem
- the element mapping to build a scenario with- Returns:
- a new model
Scenario
for the supplied accelerator sequence - Throws:
ModelException
- general error building model lattice
-
newScenarioFor
Creates a newScenario
object for the explicit case where theAcceleratorSeq
object is of typexal.smf.Ring
.- Parameters:
smfRing
- target hardware (SMF) ring object- Returns:
Scenario
object encapsulating ring- Throws:
ModelException
- unable to build modeling scenario
-
setSynchronizationMode
Sets the synchronization mode for the sync manager to a known sync mode, such as SynchronizationManager.SYNC_MODE_LIVE or SYNC_MODE_DESIGN.- Parameters:
newMode
- String specifying mode to set to- Throws:
IllegalArgumentException
- if the specified mode is unknown
-
getSynchronizationMode
get the synchronization mode -
resync
Synchronizes each lattice element to the appropriate data source.- Throws:
SynchronizationException
- if an error is encountered reading a data source
-
resyncFromCache
Synchronizes each lattice element from the cache and applies the whatif model inputs.- Throws:
SynchronizationException
- if an error is encountered reading a data source
-
setStartNode
Sets the model to start propagation from the AcceleratorNode with the specified id. First get the AcceleratorNode for the id, find the first element mapped to it, and then set it as the starting element in the lattice.- Parameters:
nodeId
- ID of AcceleratorNode to start from- Throws:
ModelException
- if the node is not found, or no elements are mapped to it
-
setStopNode
Sets the model to stop propagation the AcceleratorNode with the specified id. By default the model will stop propagation AFTER this node. This behavior can be changed in the Tracker ( see setStopNodeInclusive(boolean) method.- Parameters:
nodeId
- ID of the AcceleratorNode to stop after- Throws:
ModelException
- if the node is not found, or no elements are mapped to it
-
setStartComponent
Sets the model to start propagation from the specified IComponent. If you don't have a reference to a component but do have an AcceleratorNode, use setStartNode(String).- Parameters:
start
- Component to start propagation from
-
setStopComponent
Sets the model to stop propagation (by default) after the specified IComponent. If you don't have a reference to a component but do have an AcceleratorNode, use setStopNode(String). This "stop after" behavior can be changed in the Tracker ( see setStopNodeInclusive(boolean) method.- Parameters:
stop
- Component to stop propagation after
-
setIncludeStopElement
public 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. The later case is the default.- Parameters:
bolInclStopElem
- propagation stops after stop element iftrue
, before the stop element iffalse
- Since:
- Oct 20, 2014
-
getPositionRelativeToStart
public 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.- Parameters:
positionInSequence
- The position of a location in this scenario's sequence- Returns:
- the corresponding position relative to this scenario's starting element
-
run
Runs the model (propagate probe through lattice).- Throws:
ModelException
- if there is an error propagating the probeIllegalStateException
- if the lattice or probe is not properly initialized
-
getLattice
Returns the lattice. NOTE: I (Craig M) don't like this here. I only added it so that I could keep ModelProxy working as it presently does. Let's figure out a way to change it. It seems that the only thing that gets the Lattice from ModelProxy is OrbitDisplay2. If it were changed to use Scenario, then this method could be removed!- Returns:
- the Lattice
-
setLattice
-
getTrajectory
NOTE
Returns the trajectory obtained by running the model. · The type of the object returned is actually
Trajectory<?>
since the actual type of the trajectory is not known. Any type of probe may be used to run the scenario.
· This is simply a convenient way to avoid the clumsy Java type casting, however, it is essentially the same thing.
· A runtime cast exception will be thrown if the trajectory does not match the probe type currently run.- Returns:
- the Trajectory obtained by running the model
- Throws:
IllegalStateException
- if the probe or trajectory is null
-
propertiesForNode
Returns a map of property values (key = String property name, value = double property value) for the supplied node.- Parameters:
aNode
- AcceleratorNode whose properties to get- Returns:
- a Map of property values for the supplied node
- Throws:
IllegalArgumentException
- if aNode is null
-
nodeWithId
Returns the accelerator node with the specified id, or null if there is none.- Parameters:
id
- String id of the node to return- Returns:
- AcceleratorNode with specified id
-
componentsMappedTo
Returns a List of components mapped to the specified node.- Parameters:
aNode
- node to get components mapped to- Returns:
- a List of Components mapped to the specified node
-
trajectoryStatesForElement
Returns an array of the trajectory states for the specified element id.- Parameters:
id
- element id to find states for- Returns:
- array of trajectory states for specified element id
- Throws:
ModelException
- if the probe is not yet propagated
-
getStartElementId
Return the string identifier of the modeling element where propagation starts.- Returns:
- modeling element string identifier
-
setStartElementId
Set the "start" element by String id- Parameters:
elemId
- Start element Id
-
getStopElementId
Return the string identifier of the modeling element where propagation stops.- Returns:
- modeling element string identifier
-
setStopElementId
Set the "stop" element by String id- Parameters:
elemId
- Stop element Id
-
setModelInput
Sets the specified node's property to the specified value. Replaces the existing value if there is one.- Parameters:
aNode
- node whose property to setpropName
- name of property to setval
- double value for property
-
getModelInput
Returns the ModelInput for the specified node's property.- Parameters:
aNode
- node whose property to get a ModelInput forpropName
- name of property to get a ModelInput for
-
removeModelInput
Removes the model input for the specified property on the specified node, if there is one.- Parameters:
aNode
- node whose input to removeproperty
- name of property whose input to remove
-
setProbe
Sets the supplied probe for this scenario.- Parameters:
aProbe
- the probe to be used by the scenario
-
getProbe
Returns the scenario's current probe, or null if there is none.- Returns:
- the scenario's current probe or null
-
resetProbe
public void resetProbe()Resets the probe to its initial state - before propagation (e.g., the state specified in the probe xml file). -
checkSynchronization
public boolean checkSynchronization(AcceleratorNode aNode, Map<String, Double> values) throws SynchronizationExceptionTesting Support- Throws:
SynchronizationException
-
unsetStartNode
public void unsetStartNode()remove previously set Start point -
unsetStopNode
public void unsetStopNode()remove previously set Stop point -
getSequence
-