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 interface
SweepAction.ActionGenerator<T>
static interface
SweepAction.Formatter<T>
static class
SweepAction.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)
void
addActions(java.util.Collection<Action> actions)
<R extends Action>
RaddFinalAction(R action)
void
addFinalActions(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.void
addTag(java.lang.String tag)
void
clearActions()
void
clearFinalActions()
void
clearTags()
SweepAction<T>
copy()
Creates a deep copy of this action.java.lang.String
format(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.String
getCurrentSweepString()
Returns the string representation of the current value of the swept variable.T
getCurrentSweepValue()
Returns the current value of the swept variable.java.lang.Void
getData()
Returns whatever data this action generates.SweepActionDisplay<T>
getDisplay()
Returns the JavaFX node used to display this action in an ActionQueueDisplay object.java.lang.Exception
getError()
Returns the exception that caused the the action to result in failure.java.util.List<Action>
getFinalActions()
Measurement
getMeasurement()
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.boolean
isRunning()
Returns whether the action is currently running or not.protected void
regenerateActions()
Regenerates all the sub-actions for this sweep.void
removeAction(Action action)
void
removeActions(java.util.Collection<Action> actions)
void
removeFinalAction(Action action)
void
removeSweepValueListener(Listener listener)
Removes the specified listener from this action - if it was added to begin with.void
removeTag(java.lang.String tag)
void
reset()
Resets the action to the state it was in before being run.void
resume()
Resumes the action from where it was last interruptedprotected void
runFinalActions()
void
setAttribute(java.lang.String key, java.lang.String value)
Sets the value of the specified attribute for this action.void
setFormatter(SweepAction.Formatter<T> formatter)
Specifies how the sweep variable should be converted to a string.void
setMeasurement(Measurement measure)
void
setSweepValues(java.lang.Iterable<T> values)
Sets the values for this action to sweep over.void
setSweepValues(T... values)
Sets the values for this action to sweep over.void
skip()
Marks the action to be skipped next time it is run, or immediately if it is currently running.void
start()
Runs the action.protected void
start(boolean resume)
void
stop()
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:Action
Resets the action to the state it was in before being run.- Specified by:
reset
in interfaceAction<T>
- Specified by:
reset
in 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:Action
Sets the value of the specified attribute for this action.- Specified by:
setAttribute
in interfaceAction<T>
- Overrides:
setAttribute
in classAbstractAction<java.lang.Void>
- Parameters:
key
- Attribute keyvalue
- Attribute value
-
addTag
public void addTag(java.lang.String tag)
- Specified by:
addTag
in interfaceAction<T>
- Overrides:
addTag
in classAbstractAction<java.lang.Void>
-
removeTag
public void removeTag(java.lang.String tag)
- Specified by:
removeTag
in interfaceAction<T>
- Overrides:
removeTag
in classAbstractAction<java.lang.Void>
-
clearTags
public void clearTags()
- Specified by:
clearTags
in interfaceAction<T>
- Overrides:
clearTags
in 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:Action
Resumes the action from where it was last interrupted
-
start
public void start()
Description copied from interface:Action
Runs the action. Should only return once the action is complete/interrupted/failed.- Specified by:
start
in interfaceAction<T>
- Specified by:
start
in classAbstractAction<java.lang.Void>
-
start
protected void start(boolean resume)
-
stop
public void stop()
Description copied from interface:Action
Interrupts and stops the action.- Specified by:
stop
in interfaceAction<T>
- Specified by:
stop
in classAbstractAction<java.lang.Void>
-
skip
public void skip()
Description copied from interface:Action
Marks the action to be skipped next time it is run, or immediately if it is currently running.- Specified by:
skip
in interfaceAction<T>
- Specified by:
skip
in classAbstractAction<java.lang.Void>
-
runFinalActions
protected void runFinalActions()
-
getError
public java.lang.Exception getError()
Description copied from interface:Action
Returns the exception that caused the the action to result in failure.- Returns:
- Exception
-
isRunning
public boolean isRunning()
Description copied from interface:Action
Returns whether the action is currently running or not.- Specified by:
isRunning
in interfaceAction<T>
- Specified by:
isRunning
in classAbstractAction<java.lang.Void>
- Returns:
- Is it running?
-
getData
public java.lang.Void getData()
Description copied from interface:Action
Returns whatever data this action generates.- Specified by:
getData
in interfaceAction<T>
- Specified by:
getData
in 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:Action
Returns 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:
getChildren
in interfaceAction<T>
- Specified by:
getChildren
in 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:Action
Returns 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:Action
Creates a deep copy of this action.- Returns:
- Deep copy of this action
-
-