Class AlgorithmManager
- All Implemented Interfaces:
com.google.common.util.concurrent.Service
,ParameterProcessor
,ParameterProvider
,ProcessorService
Upon initialization it will scan all algorithms, and schedule any that are to be triggered periodically. OutputParameters of all algorithms will be indexed, so that AlgorithmManager knows what parameters it can provide to the ParameterRequestManager.
Algorithms and any needed algorithms that require earlier execution, will be activated as soon as a request for one of its output parameters is registered.
Algorithm executors are created by AlgorithmExecutorFactory
which themselves are created by the
AlgorithmEngine
. The algorithm engines are registered at server startup using the
registerAlgorithmEngine(String, AlgorithmEngine)
method.
javascript will be automatically registered as well as python if available.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.common.util.concurrent.Service
com.google.common.util.concurrent.Service.Listener, com.google.common.util.concurrent.Service.State
-
Field Summary
Fields inherited from class org.yamcs.AbstractProcessorService
config, log, processor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionactivateAlgorithm
(Algorithm algorithm, AlgorithmExecutionContext execCtx) Activate an algorithm in a context.void
boolean
canProvide
(Yamcs.NamedObjectId itemId) Returns whether or not a given parameter can be provided by this providerboolean
void
createContext
(String name) Create a new algorithm execution context.void
disableTracing
(Algorithm algo) protected void
doStart()
protected void
doStop()
void
enableTracing
(Algorithm algo) getAlgorithmStatus
(Algorithm algo) getParameter
(Yamcs.NamedObjectId paraId) Returns the parameterDefinition corresponding to the parameter idgetSpec()
Returns the valid configuration of the input args of this service.void
init
(Processor processor, YConfiguration config, Object spec) void
overrideAlgorithm
(CustomAlgorithm calg, String text) Override the algorithmvoid
process
(ProcessingData data) Called by PRM when new parameters are received.static void
registerAlgorithmEngine
(String name, AlgorithmEngine eng) void
void
void
setParameterProcessor
(ParameterProcessor parameterRequestManager) Send parameters to this processor.void
startProviding
(Parameter paramDef) Adds a new parameter to the list of parameters that have to providedvoid
start providing all known parametersvoid
stopProviding
(Parameter paramDef) Removes a parameter from the list of parameters that have to be providedMethods inherited from class org.yamcs.AbstractProcessorService
getConfig, getYamcsInstance
Methods inherited from class com.google.common.util.concurrent.AbstractService
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, doCancelStart, failureCause, isRunning, notifyFailed, notifyStarted, notifyStopped, startAsync, state, stopAsync, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.google.common.util.concurrent.Service
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, failureCause, isRunning, startAsync, state, stopAsync
-
Constructor Details
-
AlgorithmManager
public AlgorithmManager()
-
-
Method Details
-
getSpec
Description copied from interface:ProcessorService
Returns the valid configuration of the input args of this service.- Specified by:
getSpec
in interfaceProcessorService
- Returns:
- the argument specification, or
null
if the args should not be validated.
-
registerAlgorithmEngine
-
init
- Specified by:
init
in interfaceProcessorService
- Overrides:
init
in classAbstractProcessorService
config
- service configuration as specified in processor.yamlspec
- passed by the user when creating the processor (for instance via the REST API)
-
startProviding
Description copied from interface:ParameterProvider
Adds a new parameter to the list of parameters that have to provided- Specified by:
startProviding
in interfaceParameterProvider
-
createContext
Create a new algorithm execution context.- Parameters:
name
- - name of the context- Returns:
- the newly created context
-
removeContext
-
activateAlgorithm
public ActiveAlgorithm activateAlgorithm(Algorithm algorithm, AlgorithmExecutionContext execCtx) throws AlgorithmException Activate an algorithm in a context.If the algorithm cannot be activated (e.g. error compiling) returns null.
- Throws:
AlgorithmException
-
startProvidingAll
public void startProvidingAll()Description copied from interface:ParameterProvider
start providing all known parameters- Specified by:
startProvidingAll
in interfaceParameterProvider
-
stopProviding
Description copied from interface:ParameterProvider
Removes a parameter from the list of parameters that have to be provided- Specified by:
stopProviding
in interfaceParameterProvider
-
canProvide
- Specified by:
canProvide
in interfaceParameterProvider
-
canProvide
Description copied from interface:ParameterProvider
Returns whether or not a given parameter can be provided by this provider- Specified by:
canProvide
in interfaceParameterProvider
- Returns:
-
getParameter
Description copied from interface:ParameterProvider
Returns the parameterDefinition corresponding to the parameter id- Specified by:
getParameter
in interfaceParameterProvider
- Parameters:
paraId
- - id of the parameter that is returned- Returns:
- Throws:
InvalidIdentification
-
process
Called by PRM when new parameters are received.- Specified by:
process
in interfaceParameterProcessor
-
setParameterProcessor
Description copied from interface:ParameterProvider
Send parameters to this processor.- Specified by:
setParameterProcessor
in interfaceParameterProvider
-
doStart
protected void doStart()- Specified by:
doStart
in classcom.google.common.util.concurrent.AbstractService
-
doStop
protected void doStop()- Specified by:
doStop
in classcom.google.common.util.concurrent.AbstractService
-
getProcessor
-
addAlgorithmTextListener
-
removeAlgorithmTextListener
-
clearAlgorithmOverride
-
overrideAlgorithm
Override the algorithm- Parameters:
calg
-text
-
-
getAlgorithmOverrides
-
getAlgorithmOverride
-
enableTracing
-
disableTracing
-
getTrace
-
getAlgorithmStatus
-