Package org.yamcs.algorithms
Class ScriptAlgorithmExecutorFactory
- java.lang.Object
-
- org.yamcs.algorithms.ScriptAlgorithmExecutorFactory
-
- All Implemented Interfaces:
AlgorithmExecutorFactory
public class ScriptAlgorithmExecutorFactory extends Object implements AlgorithmExecutorFactory
Handles the creation of algorithm executors for script algorithms for a given language and scriptEngine (currently javascript or python are supported). Each algorithm is created as a function in the scriptEngine. There might be multiple executors for the same algorithm: for example in the command verifier there will be one algorithm executor for each command. However there will be only one function created in the script engine.
-
-
Constructor Summary
Constructors Constructor Description ScriptAlgorithmExecutorFactory(ScriptEngineManager scriptEngineManager, String language, List<String> libraryNames)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
generateFunctionCode(String functionName, CustomAlgorithm algorithmDef)
List<String>
getLanguages()
Returns all the languages supported by this factory.ScriptAlgorithmExecutor
makeExecutor(CustomAlgorithm calg, AlgorithmExecutionContext execCtx)
Creates a new executor for the algorithm running in the execution context
-
-
-
Constructor Detail
-
ScriptAlgorithmExecutorFactory
public ScriptAlgorithmExecutorFactory(ScriptEngineManager scriptEngineManager, String language, List<String> libraryNames)
-
-
Method Detail
-
makeExecutor
public ScriptAlgorithmExecutor makeExecutor(CustomAlgorithm calg, AlgorithmExecutionContext execCtx)
Description copied from interface:AlgorithmExecutorFactory
Creates a new executor for the algorithm running in the execution context- Specified by:
makeExecutor
in interfaceAlgorithmExecutorFactory
- Parameters:
calg
- - the algorithm definitionexecCtx
- - the algorithm execution context- Returns:
-
generateFunctionCode
public static String generateFunctionCode(String functionName, CustomAlgorithm algorithmDef)
-
getLanguages
public List<String> getLanguages()
Description copied from interface:AlgorithmExecutorFactory
Returns all the languages supported by this factory. Used in order to not create new factories for the same language with different names (e.g. JavaScript and ECMAScript)- Specified by:
getLanguages
in interfaceAlgorithmExecutorFactory
- Returns:
-
-