gov.sns.xal.model.mpx
Class ModelProxy

java.lang.Object
  |
  +--gov.sns.xal.model.mpx.ModelProxy

public class ModelProxy
extends java.lang.Object

This class provides an API to the on-line model. It features convienience methods to input data to the model, to generate the lattice from an accelerator sequence, to run the model, to synchronize the model with the real accelerator, and to extract results from a model run.


Field Summary
protected  AcceleratorSeq acceleratorSequence
           
static int DIAGNOSTIC_PROBE
          Probe type indicating a diagnostic probe.
static int ENSEMBLE_PROBE
          Probe type indicating an ensemble probe.
static int ENVELOPE_PROBE
          Probe type indicating an envelope probe.
static java.lang.String PARAMSRC_DESIGN
           
static java.lang.String PARAMSRC_LIVE
           
static java.lang.String PARAMSRC_RF_DESIGN
           
static int PARTICLE_PROBE
          Probe type indicating a particle probe.
protected  Probe probe
           
protected  Scenario scenario
           
 
Constructor Summary
ModelProxy()
          Create a new (empty) model proxy.
ModelProxy(java.lang.String paramSrc)
          Create a new (empty) model proxy.
 
Method Summary
 void addModelProxyListener(ModelProxyListener listener)
          Add a ModelProxyListener to the internal list of event listeners.
 void checkLattice()
          Check wether the model proxy has a valid lattice and take actions.
 void checkProbe()
          Check wether the model proxy has a valid probe and take actions.
 AcceleratorSeq getAcceleratorSequence()
          Returns last selected sequence.
 java.lang.String getChannelSource()
          Getter for the channel source flag
protected  ModelProxyListener[] getModelProxyListeners()
          Getter for the ModelProxyListener event list property.
 Lattice getOnLineModelLattice()
          Getter for the on-line-model lattice property.
 org.w3c.dom.Document getOnLineModelLatticeAsDocument()
          Getter for the on-line-model lattice property.
 Probe getProbe()
          Getter for the on-line-model probe property.
 org.w3c.dom.Document getProbeAsDocument()
          Getter for the probe DOM property.
 java.io.File getProbeMasterFile()
          Getter for the xml-file defining the probe.
 int getProbeType()
          Getter for the probe type.
 boolean hasLattice()
          Test the model proxy for a valid lattice.
 boolean hasProbe()
          Test the model proxy for a valid probe.
protected  boolean isProbePropagated()
          Returns true if the probe has been propagated, false otherwise.
protected  void notifyListeners(int cause)
          Notify registered ModelProxyListeners.
 void removeModelProxyListener(ModelProxyListener listener)
          Remove a ModelProxyListener from the internal list of event listeners.
 void resetProbe()
          Reset the probe to its initial values.
 void runModel()
          Run the model.
 void setAcceleratorSeq(AcceleratorSeq seq)
          Setter for the accelerator sequence property.
 boolean setChannelSource(java.lang.String src)
          Setter for the data source flag.
 void setNewProbe(java.io.File probeFile)
          Setter for the probe property.
 void setNewProbe(Probe aProbe)
          Setter for a new probe.
 ProbeState stateForElement(java.lang.String id)
          Find the probe's state for a given accelerator node.
 ProbeState[] statesForElement(java.lang.String id)
          Find all probe states for a given accelerator node.
 void synchronizeAcceleratorSeq()
          Synchronize the model with according to current sync mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

acceleratorSequence

protected AcceleratorSeq acceleratorSequence

scenario

protected Scenario scenario

probe

protected Probe probe

PARAMSRC_DESIGN

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

PARAMSRC_RF_DESIGN

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

PARAMSRC_LIVE

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

DIAGNOSTIC_PROBE

public static final int DIAGNOSTIC_PROBE
Probe type indicating a diagnostic probe.

See Also:
Constant Field Values

ENSEMBLE_PROBE

public static final int ENSEMBLE_PROBE
Probe type indicating an ensemble probe.

See Also:
Constant Field Values

ENVELOPE_PROBE

public static final int ENVELOPE_PROBE
Probe type indicating an envelope probe.

See Also:
Constant Field Values

PARTICLE_PROBE

public static final int PARTICLE_PROBE
Probe type indicating a particle probe.

See Also:
Constant Field Values
Constructor Detail

ModelProxy

public ModelProxy()
Create a new (empty) model proxy. Per default this proxy will be synchronized by channel access.


ModelProxy

public ModelProxy(java.lang.String paramSrc)
Create a new (empty) model proxy.

Parameters:
paramSrc - an integer to indicate where to synchronize from. If true the proxy will use channel access to read settings of lattice elements, if false the element settings will be taken from design values defined in the accelerator database.
Method Detail

addModelProxyListener

public void addModelProxyListener(ModelProxyListener listener)
Add a ModelProxyListener to the internal list of event listeners.

Parameters:
listener - the listener.

removeModelProxyListener

public void removeModelProxyListener(ModelProxyListener listener)
Remove a ModelProxyListener from the internal list of event listeners.

Parameters:
listener - the listener.

getModelProxyListeners

protected ModelProxyListener[] getModelProxyListeners()
Getter for the ModelProxyListener event list property.


runModel

public void runModel()
              throws ModelException
Run the model. The probe will be propagated through the lattice. All registered ModelProxyListeners will be notified by calling modelResultsChanged.

Throws:
ModelException

notifyListeners

protected void notifyListeners(int cause)
Notify registered ModelProxyListeners.

Parameters:
cause - what to notify. Cause can be either of: ModelProxyListener.ACCEL_CHANGED, ModelProxyListener.PROBE_CHANGED, ModelProxyListener.SEQUENCE_CHANGED, ModelProxyListener.RESULTS_CHANGED, ModelProxyListener.MISSING_INPUT. If neither of these values no notification is issued.

synchronizeAcceleratorSeq

public void synchronizeAcceleratorSeq()
                               throws LatticeError
Synchronize the model with according to current sync mode. This operation resets the probe to its initial values. All registered ModelProxyListeners will be notified by: probeMasterChanged and accelSequenceChanged.

Throws:
LatticeError
ParsingException
java.lang.Exception

resetProbe

public void resetProbe()
Reset the probe to its initial values.

Throws:
ParsingException

setAcceleratorSeq

public void setAcceleratorSeq(AcceleratorSeq seq)
                       throws LatticeError
Setter for the accelerator sequence property. As a result of calling this member a new Scenario will be generated. In Addition all registered ModelproxyListeners will be notified by accelSequenceChanged.

Parameters:
seq - the accelerator sequence.
Throws:
LatticeError
ParsingException
java.lang.Exception

setNewProbe

public void setNewProbe(java.io.File probeFile)
                 throws LatticeError
Setter for the probe property. All registered ModleProxyListeners will be notified by probeMasterChanged.

Parameters:
probeFile - the file for the probe definition in XML.
Throws:
ParsingException
java.lang.ClassNotFoundException
java.net.MalformedURLException
LatticeError

setNewProbe

public void setNewProbe(Probe aProbe)
Setter for a new probe.

Parameters:
aProbe - the new probe object.

setChannelSource

public boolean setChannelSource(java.lang.String src)
Setter for the data source flag.

Parameters:
src - a constant to indicate the channel source. May be one of Synchronization.PARAMSRC_DESIGN Synchronization.PARAMSRC_LIVE
Returns:
true on succes, false if failed.

getAcceleratorSequence

public AcceleratorSeq getAcceleratorSequence()
Returns last selected sequence.

Returns:
selectet sequence. If not set null is returned.

getChannelSource

public java.lang.String getChannelSource()
Getter for the channel source flag


getOnLineModelLattice

public Lattice getOnLineModelLattice()
Getter for the on-line-model lattice property.

Returns:
the on-line-model lattice.

getProbeType

public int getProbeType()
Getter for the probe type. The type is either of: DIAGNOSTIC_PROBE, ENSEMBLE_PROBE, ENVELOPE_PROBE, PARTICLE_PROBE

Returns:
the probe type. If probe is not set yet a -1 is returned.

getProbe

public Probe getProbe()
Getter for the on-line-model probe property.

Returns:
the on-line-model probe. If probe is not set yet null is retuned.

getProbeMasterFile

public java.io.File getProbeMasterFile()
Getter for the xml-file defining the probe.

Returns:
the opened probe file. If file is not set yet null is returned.

getOnLineModelLatticeAsDocument

public org.w3c.dom.Document getOnLineModelLatticeAsDocument()
Getter for the on-line-model lattice property.

Returns:
the on-line-model lattice. If lattice is not set yet null is returned.

getProbeAsDocument

public org.w3c.dom.Document getProbeAsDocument()
Getter for the probe DOM property.

Returns:
the DOM of the probe. If not set yet null is returned.

stateForElement

public ProbeState stateForElement(java.lang.String id)
                           throws ModelException
Find the probe's state for a given accelerator node.

Parameters:
id - the identifier of the given accelerator node.
Returns:
the probe state for the center of that node.
Throws:
ModelException

statesForElement

public ProbeState[] statesForElement(java.lang.String id)
                              throws ModelException
Find all probe states for a given accelerator node.

Parameters:
id - the identifier of the given accelerator node.
Returns:
an array probe states for the given element.
Throws:
ModelException

checkLattice

public void checkLattice()
                  throws LatticeError
Check wether the model proxy has a valid lattice and take actions. If the lattice is not valid all ModelProxyListeners will be notified by calling missingInputToRunModel and and an Error will be thrown.

Throws:
java.lang.Error
LatticeError

checkProbe

public void checkProbe()
                throws LatticeError
Check wether the model proxy has a valid probe and take actions. If the probe is not valid all ModelProxyListeners will be notified by calling missingInputToRunModel and and an Error will be thrown.

Throws:
java.lang.Error
LatticeError

hasLattice

public boolean hasLattice()
Test the model proxy for a valid lattice.

Returns:
true if the model has a valid lattice , false if not.

hasProbe

public boolean hasProbe()
Test the model proxy for a valid probe.

Returns:
true if the model has a valid probe , false if not.

isProbePropagated

protected boolean isProbePropagated()
Returns true if the probe has been propagated, false otherwise.

Returns:
ture if the probe has been propagated, false otherwise