Class AbstractThreadedTcDataLink

java.lang.Object
com.google.common.util.concurrent.AbstractService
org.yamcs.tctm.AbstractLink
org.yamcs.tctm.AbstractTcDataLink
org.yamcs.tctm.AbstractThreadedTcDataLink
All Implemented Interfaces:
com.google.common.util.concurrent.Service, Runnable, SystemParametersProducer, Link, LinkActionProvider, TcDataLink
Direct Known Subclasses:
TcpTcDataLink, UdpTcDataLink

public abstract class AbstractThreadedTcDataLink extends AbstractTcDataLink implements Runnable
Abstract link that starts a thread when it's enabled and stops it when it's disabled.

The startUp() and shutDown() methods are called at startup/enable and shutdown/disable times on the working thread.

This class provides queueing and rate limiting function.

args:

  • tcQueueSize: maximum size of the queue. If the queue is full, the commands will be rejected. If the argument is not specified, the queue will be unlimited in size.
  • tcMaxRate: maximum number of commands to send per second.
  • Field Details

  • Constructor Details

    • AbstractThreadedTcDataLink

      public AbstractThreadedTcDataLink()
  • Method Details

    • getDefaultSpec

      public Spec getDefaultSpec()
      Description copied from interface: Link
      Returns a default link Spec. This can be used in an implementation of {Link.getSpec(). Eventually (after a few years), it is expected to migrate this logic directly into {LinkLink.getSpec(), rather than returning null from there. But we want to give sufficient time for links everywhere to start defining their arguments.
      Specified by:
      getDefaultSpec in interface Link
      Overrides:
      getDefaultSpec in class AbstractTcDataLink
    • init

      public void init(String yamcsInstance, String linkName, YConfiguration config) throws ConfigurationException
      Description copied from interface: Link
      Called at startup to initialize the link.

      The config corresponds to the map that is under the link definition in yamcs.instance.yaml.

      Specified by:
      init in interface Link
      Overrides:
      init in class AbstractTcDataLink
      config - - the configuration - cannot be null (but can be empty)
      Throws:
      ConfigurationException
    • 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
    • sendCommand

      public boolean sendCommand(PreparedCommand pc)
      Sends
      Specified by:
      sendCommand in interface TcDataLink
      Returns:
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • doEnable

      protected void doEnable()
      Overrides:
      doEnable in class AbstractLink
    • doDisable

      protected void doDisable()
      Overrides:
      doDisable in class AbstractLink
    • doHousekeeping

      protected void doHousekeeping()
      Called each AbstractTcDataLink.housekeepingInterval milliseconds, can be used to establish tcp connections or similar things
    • uplinkCommand

      protected abstract void uplinkCommand(PreparedCommand pc) throws IOException
      Called
      Parameters:
      pc -
      Throws:
      IOException
    • startUp

      protected abstract void startUp() throws Exception
      Called at start up (if the link is enabled) or when the link is enabled
      Throws:
      Exception
    • shutDown

      protected abstract void shutDown() throws Exception
      Called at shutdown (if the link is enabled) or when the link is disabled
      Throws:
      Exception