Package org.yamcs.algorithms
Class AbstractAlgorithmExecutor
- java.lang.Object
-
- org.yamcs.algorithms.AbstractAlgorithmExecutor
-
- All Implemented Interfaces:
AlgorithmExecutor
- Direct Known Subclasses:
MathAlgorithmExecutor,ScriptAlgorithmExecutor
public abstract class AbstractAlgorithmExecutor extends Object implements AlgorithmExecutor
Skeleton implementation for algorithms conforming to the XTCEAlgorithmdefinition.It collects all the inputs into an inputList and implements the triggering based on the mandatory parameters.
-
-
Field Summary
Fields Modifier and Type Field Description protected AlgorithmalgorithmDefprotected AlgorithmExecutionContextexecCtxprotected CopyOnWriteArrayList<AlgorithmExecListener>execListenersprotected List<ParameterValue>inputValuesprotected static org.slf4j.Loggerlog
-
Constructor Summary
Constructors Constructor Description AbstractAlgorithmExecutor(Algorithm algorithmDef, AlgorithmExecutionContext execCtx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddExecListener(AlgorithmExecListener listener)Add a listener to be called each time the algorithm has runAlgorithmgetAlgorithm()AlgorithmExecutionContextgetExecutionContext()protected ParametergetOutputParameter(int idx)Returns the output parameter with the given index.protected voidpropagateToListeners(Object returnValue, List<ParameterValue> outputValues)protected voidupdateInput(int idx, InputParameter inputParameter, ParameterValue newValue)Called when the given inputParameter receives a value. idx is the index of the inputParameter in the algorithm definition input list.booleanupdateParameters(List<ParameterValue> items)update the parameters and return true if the algorithm should run-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.yamcs.algorithms.AlgorithmExecutor
getLookbackSize, runAlgorithm
-
-
-
-
Field Detail
-
execCtx
protected final AlgorithmExecutionContext execCtx
-
algorithmDef
protected final Algorithm algorithmDef
-
execListeners
protected final CopyOnWriteArrayList<AlgorithmExecListener> execListeners
-
log
protected static final org.slf4j.Logger log
-
inputValues
protected final List<ParameterValue> inputValues
-
-
Constructor Detail
-
AbstractAlgorithmExecutor
public AbstractAlgorithmExecutor(Algorithm algorithmDef, AlgorithmExecutionContext execCtx)
-
-
Method Detail
-
updateParameters
public boolean updateParameters(List<ParameterValue> items)
update the parameters and return true if the algorithm should run- Specified by:
updateParametersin interfaceAlgorithmExecutor- Parameters:
items-- Returns:
- true if the algorithm should run
-
updateInput
protected void updateInput(int idx, InputParameter inputParameter, ParameterValue newValue)Called when the given inputParameter receives a value. idx is the index of the inputParameter in the algorithm definition input list.Can be used by subclasses to perform specific actions;
Note that all values are also collected in the inputList
- Parameters:
inputParameter-newValue-
-
getOutputParameter
protected Parameter getOutputParameter(int idx)
Returns the output parameter with the given index.- Parameters:
idx-- Returns:
-
propagateToListeners
protected void propagateToListeners(Object returnValue, List<ParameterValue> outputValues)
-
addExecListener
public void addExecListener(AlgorithmExecListener listener)
Description copied from interface:AlgorithmExecutorAdd a listener to be called each time the algorithm has run- Specified by:
addExecListenerin interfaceAlgorithmExecutor
-
getExecutionContext
public AlgorithmExecutionContext getExecutionContext()
- Specified by:
getExecutionContextin interfaceAlgorithmExecutor- Returns:
- the execution context in which the executor activates
-
getAlgorithm
public Algorithm getAlgorithm()
- Specified by:
getAlgorithmin interfaceAlgorithmExecutor
-
-