Package jisa.experiment.queue
Class SweepAction<T>
- java.lang.Object
-
- jisa.experiment.queue.AbstractAction<java.lang.Void>
-
- jisa.experiment.queue.SweepAction<T>
-
- All Implemented Interfaces:
java.io.Serializable,Action<java.lang.Void>
public class SweepAction<T> extends AbstractAction<java.lang.Void>
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSweepAction.ActionGenerator<T>static interfaceSweepAction.Formatter<T>static classSweepAction.MultiException-
Nested classes/interfaces inherited from interface jisa.experiment.queue.Action
Action.Status
-
-
Constructor Summary
Constructors Constructor Description SweepAction(java.lang.String name, java.lang.Iterable<T> sweepValues, SweepAction.ActionGenerator<T> generator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R extends Action>
RaddAction(R action)voidaddActions(java.util.Collection<Action> actions)<R extends Action>
RaddFinalAction(R action)voidaddFinalActions(java.util.Collection<Action> actions)Listener<T>addSweepValueListener(Listener<T> listener)Adds a listener that is triggered every time the current sweep value is changed.voidaddTag(java.lang.String tag)voidclearActions()voidclearFinalActions()voidclearTags()SweepAction<T>copy()Creates a deep copy of this action.java.lang.Stringformat(T value)java.util.List<Action>generateActionsForValue(T value)Generates the set of actions for the iteration of the sweep with the given value.java.util.List<Action>getActions()java.util.List<Action>getChildren()Returns an unmodifiable list of sub-actions that this action contains.java.util.List<Action>getChildrenByValue(T value)Returns an unmodifiable list of the actions in the iteration of the sweep with the given value.java.lang.StringgetCurrentSweepString()Returns the string representation of the current value of the swept variable.TgetCurrentSweepValue()Returns the current value of the swept variable.java.lang.VoidgetData()Returns whatever data this action generates.SweepActionDisplay<T>getDisplay()Returns the JavaFX node used to display this action in an ActionQueueDisplay object.java.lang.ExceptiongetError()Returns the exception that caused the the action to result in failure.java.util.List<Action>getFinalActions()MeasurementgetMeasurement()java.util.List<java.lang.String>getSweepStrings()Returns an unmodifiable list of the string representations of the values this action will sweep over.java.util.List<T>getSweepValues()Returns an unmodifiable list of values that this action will sweep over.booleanisRunning()Returns whether the action is currently running or not.protected voidregenerateActions()Regenerates all the sub-actions for this sweep.voidremoveAction(Action action)voidremoveActions(java.util.Collection<Action> actions)voidremoveFinalAction(Action action)voidremoveSweepValueListener(Listener listener)Removes the specified listener from this action - if it was added to begin with.voidremoveTag(java.lang.String tag)voidreset()Resets the action to the state it was in before being run.voidresume()Resumes the action from where it was last interruptedprotected voidrunFinalActions()voidsetAttribute(java.lang.String key, java.lang.String value)Sets the value of the specified attribute for this action.voidsetFormatter(SweepAction.Formatter<T> formatter)Specifies how the sweep variable should be converted to a string.voidsetMeasurement(Measurement measure)voidsetSweepValues(java.lang.Iterable<T> values)Sets the values for this action to sweep over.voidsetSweepValues(T... values)Sets the values for this action to sweep over.voidskip()Marks the action to be skipped next time it is run, or immediately if it is currently running.voidstart()Runs the action.protected voidstart(boolean resume)voidstop()Interrupts and stops the action.-
Methods inherited from class jisa.experiment.queue.AbstractAction
addAttributeListener, addChildrenListener, addNameListener, addStatusListener, childrenChanged, copyBasicParametersTo, getAttribute, getAttributes, getName, getStatus, getStatusListeners, getTags, hasAttribute, isCritical, onFinish, onStart, removeAttribute, removeListener, setCritical, setName, setOnEdit, setOnFinish, setOnStart, setStatus, userEdit
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jisa.experiment.queue.Action
addListener, getAttributeString, getAttributeString
-
-
-
-
Constructor Detail
-
SweepAction
public SweepAction(java.lang.String name, java.lang.Iterable<T> sweepValues, SweepAction.ActionGenerator<T> generator)
-
-
Method Detail
-
addSweepValueListener
public Listener<T> addSweepValueListener(Listener<T> listener)
Adds a listener that is triggered every time the current sweep value is changed.- Parameters:
listener- Listener to add- Returns:
- The listener that was added
-
removeSweepValueListener
public void removeSweepValueListener(Listener listener)
Removes the specified listener from this action - if it was added to begin with.- Parameters:
listener- The listener to remove
-
reset
public void reset()
Description copied from interface:ActionResets the action to the state it was in before being run.- Specified by:
resetin interfaceAction<T>- Specified by:
resetin classAbstractAction<java.lang.Void>
-
getSweepValues
public java.util.List<T> getSweepValues()
Returns an unmodifiable list of values that this action will sweep over.- Returns:
- Sweep values
-
getSweepStrings
public java.util.List<java.lang.String> getSweepStrings()
Returns an unmodifiable list of the string representations of the values this action will sweep over.- Returns:
- String representation of sweep values
-
setSweepValues
public void setSweepValues(T... values)
Sets the values for this action to sweep over.- Parameters:
values- Sweep values to use
-
setSweepValues
public void setSweepValues(java.lang.Iterable<T> values)
Sets the values for this action to sweep over.- Parameters:
values- Sweep values to use
-
generateActionsForValue
public java.util.List<Action> generateActionsForValue(T value)
Generates the set of actions for the iteration of the sweep with the given value.- Parameters:
value- Value of iteration- Returns:
- List of actions
-
getCurrentSweepValue
public T getCurrentSweepValue()
Returns the current value of the swept variable.- Returns:
- Current sweep value
-
getCurrentSweepString
public java.lang.String getCurrentSweepString()
Returns the string representation of the current value of the swept variable.- Returns:
- String representation of current sweep value
-
setAttribute
public void setAttribute(java.lang.String key, java.lang.String value)Description copied from interface:ActionSets the value of the specified attribute for this action.- Specified by:
setAttributein interfaceAction<T>- Overrides:
setAttributein classAbstractAction<java.lang.Void>- Parameters:
key- Attribute keyvalue- Attribute value
-
addTag
public void addTag(java.lang.String tag)
- Specified by:
addTagin interfaceAction<T>- Overrides:
addTagin classAbstractAction<java.lang.Void>
-
removeTag
public void removeTag(java.lang.String tag)
- Specified by:
removeTagin interfaceAction<T>- Overrides:
removeTagin classAbstractAction<java.lang.Void>
-
clearTags
public void clearTags()
- Specified by:
clearTagsin interfaceAction<T>- Overrides:
clearTagsin classAbstractAction<java.lang.Void>
-
setFormatter
public void setFormatter(SweepAction.Formatter<T> formatter)
Specifies how the sweep variable should be converted to a string.- Parameters:
formatter- Formatter to use
-
format
public java.lang.String format(T value)
-
regenerateActions
protected void regenerateActions()
Regenerates all the sub-actions for this sweep.
-
resume
public void resume()
Description copied from interface:ActionResumes the action from where it was last interrupted
-
start
public void start()
Description copied from interface:ActionRuns the action. Should only return once the action is complete/interrupted/failed.- Specified by:
startin interfaceAction<T>- Specified by:
startin classAbstractAction<java.lang.Void>
-
start
protected void start(boolean resume)
-
stop
public void stop()
Description copied from interface:ActionInterrupts and stops the action.- Specified by:
stopin interfaceAction<T>- Specified by:
stopin classAbstractAction<java.lang.Void>
-
skip
public void skip()
Description copied from interface:ActionMarks the action to be skipped next time it is run, or immediately if it is currently running.- Specified by:
skipin interfaceAction<T>- Specified by:
skipin classAbstractAction<java.lang.Void>
-
runFinalActions
protected void runFinalActions()
-
getError
public java.lang.Exception getError()
Description copied from interface:ActionReturns the exception that caused the the action to result in failure.- Returns:
- Exception
-
isRunning
public boolean isRunning()
Description copied from interface:ActionReturns whether the action is currently running or not.- Specified by:
isRunningin interfaceAction<T>- Specified by:
isRunningin classAbstractAction<java.lang.Void>- Returns:
- Is it running?
-
getData
public java.lang.Void getData()
Description copied from interface:ActionReturns whatever data this action generates.- Specified by:
getDatain interfaceAction<T>- Specified by:
getDatain classAbstractAction<java.lang.Void>- Returns:
- Generated data
-
addAction
public <R extends Action> R addAction(R action)
-
addActions
public void addActions(java.util.Collection<Action> actions)
-
removeAction
public void removeAction(Action action)
-
removeActions
public void removeActions(java.util.Collection<Action> actions)
-
clearActions
public void clearActions()
-
getActions
public java.util.List<Action> getActions()
-
getChildren
public java.util.List<Action> getChildren()
Description copied from interface:ActionReturns an unmodifiable list of sub-actions that this action contains. The exact meaning of a sub-action and how it relates to the running of this action depends on the type of action this is.- Specified by:
getChildrenin interfaceAction<T>- Specified by:
getChildrenin classAbstractAction<java.lang.Void>- Returns:
- List of sub-actions
-
getChildrenByValue
public java.util.List<Action> getChildrenByValue(T value)
Returns an unmodifiable list of the actions in the iteration of the sweep with the given value.- Parameters:
value- Value- Returns:
- List of actions
-
getFinalActions
public java.util.List<Action> getFinalActions()
-
addFinalAction
public <R extends Action> R addFinalAction(R action)
-
addFinalActions
public void addFinalActions(java.util.Collection<Action> actions)
-
removeFinalAction
public void removeFinalAction(Action action)
-
clearFinalActions
public void clearFinalActions()
-
getDisplay
public SweepActionDisplay<T> getDisplay()
Description copied from interface:ActionReturns the JavaFX node used to display this action in an ActionQueueDisplay object.- Returns:
- Node
-
setMeasurement
public void setMeasurement(Measurement measure)
-
getMeasurement
public Measurement getMeasurement()
-
copy
public SweepAction<T> copy()
Description copied from interface:ActionCreates a deep copy of this action.- Returns:
- Deep copy of this action
-
-