Class TcpTcTmDataLink

java.lang.Object
com.google.common.util.concurrent.AbstractService
All Implemented Interfaces:
com.google.common.util.concurrent.Service, Runnable, SystemParametersProducer, Link, TcDataLink, TmPacketDataLink

public class TcpTcTmDataLink extends AbstractTmDataLink implements TcDataLink, Runnable
  • Field Details

    • commandHistoryPublisher

      protected CommandHistoryPublisher commandHistoryPublisher
    • dataOutCount

      protected AtomicLong dataOutCount
    • cmdPostProcessor

      protected CommandPostprocessor cmdPostProcessor
    • tmSocket

      protected Socket tmSocket
    • host

      protected String host
    • port

      protected int port
    • initialDelay

      protected long initialDelay
  • Constructor Details

    • TcpTcTmDataLink

      public TcpTcTmDataLink()
  • Method Details

    • init

      public void init(String instance, String name, 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 AbstractTmDataLink
      config - - the configuration - cannot be null (but can be empty)
      Throws:
      ConfigurationException
    • checkAndOpenSocket

      protected void checkAndOpenSocket() throws IOException
      Throws:
      IOException
    • isSocketOpen

      protected boolean isSocketOpen()
    • sendBuffer

      protected void sendBuffer(byte[] data) throws IOException
      Throws:
      IOException
    • closeSocket

      protected void closeSocket()
    • run

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

      public TmPacket getNextPacket()
    • initPostprocessor

      protected void initPostprocessor(String instance, YConfiguration config) throws ConfigurationException
      Throws:
      ConfigurationException
    • sendCommand

      public boolean sendCommand(PreparedCommand pc)
      Description copied from interface: TcDataLink
      Attempt to send the command and return true if the command has been sent or its processing has finished.

      If false is returned, the LinkManager will attempt to send the command via the next TC link (if any).

      The link is expected to update the CommandHistoryPublisher.AcknowledgeSent ack in the command history if the method returned true. If it returned false, the ack should not be updated (it will be updated by the next link or by the Link Manager if there is other no link).

      The link can update the CommandHistoryPublisher.AcknowledgeSent ack with a negative ack and return true (i.e. the command has not been really sent but it has finished processing).

      The return true/false has been introduced in Yamcs 5.6.0. Before that version, the old method sendTc was implicitly returning true. As of Yamcs 5.6.0 most links return true even when they cannot send the command (setting the negative Sent ack).

      Throwing an exception is equivalent with returning false, except a error log will be printed (this is considered a bug)

      Specified by:
      sendCommand in interface TcDataLink
      Returns:
    • setCommandHistoryPublisher

      public void setCommandHistoryPublisher(CommandHistoryPublisher commandHistoryListener)
      Specified by:
      setCommandHistoryPublisher in interface TcDataLink
    • failedCommand

      protected void failedCommand(org.yamcs.protobuf.Commanding.CommandId commandId, String reason)
      Send to command history the failed command
    • ackCommand

      protected void ackCommand(org.yamcs.protobuf.Commanding.CommandId commandId)
      send an ack in the command history that the command has been sent out of the link
      Parameters:
      commandId -
    • doStart

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

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

      protected long getCurrentTime()
      Overrides:
      getCurrentTime in class AbstractLink
    • getDataOutCount

      public long getDataOutCount()
      Specified by:
      getDataOutCount in interface Link
      Overrides:
      getDataOutCount in class AbstractTmDataLink
    • resetCounters

      public void resetCounters()
      Specified by:
      resetCounters in interface Link
      Overrides:
      resetCounters in class AbstractTmDataLink
    • getParent

      public AggregatedDataLink getParent()
      Description copied from interface: Link
      If this link is a sublink of an aggregated link, get the parent link.
      Specified by:
      getParent in interface Link
    • setParent

      public void setParent(AggregatedDataLink parent)
      Description copied from interface: Link
      Set the parent link if this is a sublink of an aggregated link.
      Specified by:
      setParent in interface Link
    • doDisable

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

      public void doEnable()
      Overrides:
      doEnable in class AbstractLink
    • getDetailedStatus

      public String getDetailedStatus()
      Specified by:
      getDetailedStatus in interface Link
      Overrides:
      getDetailedStatus in class AbstractLink
      Returns:
      more detailed status information
    • connectionStatus

      protected Link.Status connectionStatus()
      Description copied from class: AbstractLink
      In case the link should be connected (i.e. is running and enabled) this method is called to return the actual connection status
      Specified by:
      connectionStatus in class AbstractLink