Class AlgorithmManager

java.lang.Object
com.google.common.util.concurrent.AbstractService
org.yamcs.AbstractProcessorService
org.yamcs.algorithms.AlgorithmManager
All Implemented Interfaces:
com.google.common.util.concurrent.Service, ParameterProcessor, ParameterProvider, ProcessorService

public class AlgorithmManager extends AbstractProcessorService implements ParameterProvider, ProcessorService, ParameterProcessor
Manages the provision of requested parameters that require the execution of one or more XTCE algorithms.

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.

  • Constructor Details

    • AlgorithmManager

      public AlgorithmManager()
  • Method Details

    • getSpec

      public Spec getSpec()
      Description copied from interface: ProcessorService
      Returns the valid configuration of the input args of this service.
      Specified by:
      getSpec in interface ProcessorService
      Returns:
      the argument specification, or null if the args should not be validated.
    • registerAlgorithmEngine

      public static void registerAlgorithmEngine(String name, AlgorithmEngine eng)
    • init

      public void init(Processor processor, YConfiguration config, Object spec)
      Specified by:
      init in interface ProcessorService
      Overrides:
      init in class AbstractProcessorService
      config - service configuration as specified in processor.yaml
      spec - passed by the user when creating the processor (for instance via the REST API)
    • startProviding

      public void startProviding(org.yamcs.xtce.Parameter paramDef)
      Description copied from interface: ParameterProvider
      Adds a new parameter to the list of parameters that have to provided
      Specified by:
      startProviding in interface ParameterProvider
    • createContext

      public AlgorithmExecutionContext createContext(String name)
      Create a new algorithm execution context.
      Parameters:
      name - - name of the context
      Returns:
      the newly created context
    • removeContext

      public void removeContext(AlgorithmExecutionContext ctx)
    • activateAlgorithm

      public ActiveAlgorithm activateAlgorithm(org.yamcs.xtce.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 interface ParameterProvider
    • stopProviding

      public void stopProviding(org.yamcs.xtce.Parameter paramDef)
      Description copied from interface: ParameterProvider
      Removes a parameter from the list of parameters that have to be provided
      Specified by:
      stopProviding in interface ParameterProvider
    • canProvide

      public boolean canProvide(org.yamcs.xtce.Parameter p)
      Specified by:
      canProvide in interface ParameterProvider
    • canProvide

      public boolean canProvide(org.yamcs.protobuf.Yamcs.NamedObjectId itemId)
      Description copied from interface: ParameterProvider
      Returns whether or not a given parameter can be provided by this provider
      Specified by:
      canProvide in interface ParameterProvider
      Returns:
    • getParameter

      public org.yamcs.xtce.Parameter getParameter(org.yamcs.protobuf.Yamcs.NamedObjectId paraId) throws InvalidIdentification
      Description copied from interface: ParameterProvider
      Returns the parameterDefinition corresponding to the parameter id
      Specified by:
      getParameter in interface ParameterProvider
      Parameters:
      paraId - - id of the parameter that is returned
      Returns:
      Throws:
      InvalidIdentification
    • process

      public void process(ProcessingData data)
      Called by PRM when new parameters are received.
      Specified by:
      process in interface ParameterProcessor
    • setParameterProcessor

      public void setParameterProcessor(ParameterProcessor parameterRequestManager)
      Description copied from interface: ParameterProvider
      Send parameters to this processor.
      Specified by:
      setParameterProcessor in interface ParameterProvider
    • doStart

      protected void doStart()
      Specified by:
      doStart in class com.google.common.util.concurrent.AbstractService
    • doStop

      protected void doStop()
      Specified by:
      doStop in class com.google.common.util.concurrent.AbstractService
    • getProcessor

      public Processor getProcessor()
    • addAlgorithmTextListener

      public void addAlgorithmTextListener(AlgorithmTextListener listener)
    • removeAlgorithmTextListener

      public void removeAlgorithmTextListener(AlgorithmTextListener listener)
    • clearAlgorithmOverride

      public void clearAlgorithmOverride(org.yamcs.xtce.CustomAlgorithm calg)
    • overrideAlgorithm

      public void overrideAlgorithm(org.yamcs.xtce.CustomAlgorithm calg, String text)
      Override the algorithm
      Parameters:
      calg -
      text -
    • getAlgorithmOverrides

      public Collection<org.yamcs.xtce.CustomAlgorithm> getAlgorithmOverrides()
    • getAlgorithmOverride

      public org.yamcs.xtce.CustomAlgorithm getAlgorithmOverride(org.yamcs.xtce.Algorithm algo)
    • enableTracing

      public void enableTracing(org.yamcs.xtce.Algorithm algo)
    • disableTracing

      public void disableTracing(org.yamcs.xtce.Algorithm algo)
    • getTrace

      public AlgorithmTrace getTrace(org.yamcs.xtce.Algorithm algo)
    • getAlgorithmStatus

      public org.yamcs.protobuf.AlgorithmStatus getAlgorithmStatus(org.yamcs.xtce.Algorithm algo)