gov.sns.xal.model.scenario
Class Scenario

java.lang.Object
  |
  +--gov.sns.xal.model.scenario.Scenario

public class Scenario
extends java.lang.Object

Packages an on-line model scenario, including accelerator node proxy manager, lattice, probe, and synchronization manager.


Field Summary
static java.lang.String SYNC_MODE_DESIGN
           
static java.lang.String SYNC_MODE_LIVE
           
static java.lang.String SYNC_MODE_RF_DESIGN
           
 
Constructor Summary
protected Scenario(AcceleratorSeq aSeq, Lattice aLattice, SynchronizationManager aSyncMgr)
           
 
Method Summary
 boolean checkSynchronization(AcceleratorNode aNode, java.util.Map values)
           
 java.util.List 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.
 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.
 Trajectory getTrajectory()
          Returns the trajectory obtained by running the model.
static Scenario newAndImprovedScenarioFor(AcceleratorSeq aSeq)
           
static Scenario newScenarioFor(AcceleratorSeq smfSeq)
          Creates a new Scenario for the supplied accelerator sequence.
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 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 run()
          Runs the model (propagate probe through lattice).
 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 before 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 before 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.
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYNC_MODE_LIVE

public static final java.lang.String SYNC_MODE_LIVE
See Also:
Constant Field Values

SYNC_MODE_DESIGN

public static final java.lang.String SYNC_MODE_DESIGN
See Also:
Constant Field Values

SYNC_MODE_RF_DESIGN

public static final java.lang.String SYNC_MODE_RF_DESIGN
See Also:
Constant Field Values
Constructor Detail

Scenario

protected Scenario(AcceleratorSeq aSeq,
                   Lattice aLattice,
                   SynchronizationManager aSyncMgr)
Method Detail

newScenarioFor

public static Scenario newScenarioFor(AcceleratorSeq smfSeq)
                               throws ModelException
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(Ring smfRing)
                               throws ModelException
Creates a new Scenario object for the explicit case where the AcceleratorSeq object is of type gov.sns.xal.smf.Ring.

Parameters:
smfRing - target hardware (SMF) ring object
Returns:
Scenario object encapsulating ring
Throws:
ModelException - unable to build modeling scenario

newAndImprovedScenarioFor

public static Scenario newAndImprovedScenarioFor(AcceleratorSeq aSeq)
                                          throws ModelException
ModelException

setSynchronizationMode

public 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.

Parameters:
newMode - String specifying mode to set to
Throws:
java.lang.IllegalArgumentException - if the specified mode is unknown

resync

public void resync()
            throws SynchronizationException
Synchronizes each lattice element to the appropriate data source.

Throws:
SynchronizationException - if an error is encountered reading a data source

setStartNode

public void setStartNode(java.lang.String nodeId)
                  throws ModelException
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

public void setStopNode(java.lang.String nodeId)
                 throws ModelException
Sets the model to stop propagation before the AcceleratorNode with the specified id.

Parameters:
nodeId - ID of the AcceleratorNode to stop after
Throws:
ModelException - if the node is not found, or no elements are mapped to it

setStartElement

public void setStartElement(IElement start)
Sets the model to start propagation from the specified IElement. If you don't have a reference to an element but do have an AcceleratorNode, use setStartNode(String).

Parameters:
start - Element to start propagation from

setStopElement

public void setStopElement(IElement stop)
Sets the model to stop propagation before the specified IElement. If you don't have a reference to an element but do have an AcceleratorNode, use setStopNode(String).

Parameters:
stop - Element to stop propagation after

run

public void run()
         throws ModelException
Runs the model (propagate probe through lattice).

Throws:
ModelException - if there is an error propagating the probe
java.lang.IllegalStateException - if the lattice or probe is not properly initialized

getLattice

public Lattice 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

getTrajectory

public Trajectory getTrajectory()
Returns the trajectory obtained by running the model.

Returns:
the Trajectory obtained by running the model
Throws:
java.lang.IllegalStateException - if the probe or trajectory is null

propertiesForNode

public java.util.Map propertiesForNode(AcceleratorNode aNode)
                                throws SynchronizationException
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:
ModelException - if error getting properties
java.lang.IllegalArgumentException - if aNode is null
SynchronizationException

nodeWithId

public AcceleratorNode nodeWithId(java.lang.String id)
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

elementsMappedTo

public java.util.List elementsMappedTo(AcceleratorNode aNode)
Returns a List of elements mapped to the specified node.

Parameters:
aNode - node to get elements mapped to
Returns:
a List of Elements mapped to the specified node

trajectoryStatesForElement

public ProbeState[] trajectoryStatesForElement(java.lang.String id)
                                        throws ModelException
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

public java.lang.String getStartElementId()
Return the string identifier of the modeling element where propagation starts.

Returns:
modeling element string identifier

setStartElementId

public void setStartElementId(java.lang.String elemId)
Set the "start" element by String id

Parameters:
elemId - Start element Id

getStopElementId

public java.lang.String getStopElementId()
Return the string identifier of the modeling element where propagation stops.

Returns:
modeling element string identifier

setStopElementId

public void setStopElementId(java.lang.String elemId)
Set the "stop" element by String id

Parameters:
elemId - Stop element Id

setModelInput

public ModelInput setModelInput(AcceleratorNode aNode,
                                java.lang.String propName,
                                double val)
Sets the specified node's property to the specified value. Replaces the existing value if there is one.

Parameters:
aNode - node whose property to set
propName - name of property to set
val - double value for property

getModelInput

public ModelInput getModelInput(AcceleratorNode aNode,
                                java.lang.String propName)
Returns the ModelInput for the specified node's property.

Parameters:
aNode - node whose property to get a ModelInput for
propName - name of property to get a ModelInput for

removeModelInput

public void removeModelInput(AcceleratorNode aNode,
                             java.lang.String property)
Removes the model input for the specified property on the specified node, if there is one.

Parameters:
aNode - node whose input to remove
property - name of property whose input to remove

setProbe

public void setProbe(Probe aProbe)
Sets the supplied probe for this scenario.

Parameters:
aProbe - the probe to be used by the scenario

getProbe

public Probe 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,
                                    java.util.Map values)
                             throws SynchronizationException
SynchronizationException

unsetStartNode

public void unsetStartNode()
remove previously set Start point


unsetStopNode

public void unsetStopNode()
remove previously set Stop point