Package org.yamcs.tctm
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
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.yamcs.tctm.Link
Link.Status
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.tctm.AbstractTcDataLink
cmdPostProcessor, commandHistoryPublisher, housekeepingInterval
Fields inherited from class org.yamcs.tctm.AbstractLink
config, dataInCount, dataOutCount, disabled, eventProducer, LINK_NAMESPACE, linkName, log, timeService, yamcsInstance
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
doEnable()
protected void
Called eachAbstractTcDataLink.housekeepingInterval
milliseconds, can be used to establish tcp connections or similar thingsprotected void
doStart()
protected void
doStop()
Returns a default linkSpec
.void
init
(String yamcsInstance, String linkName, YConfiguration config) Called at startup to initialize the link.void
run()
boolean
Sendsprotected abstract void
shutDown()
Called at shutdown (if the link is enabled) or when the link is disabledprotected abstract void
startUp()
Called at start up (if the link is enabled) or when the link is enabledprotected abstract void
CalledMethods inherited from class org.yamcs.tctm.AbstractTcDataLink
ackCommand, failedCommand, getDataInCount, initPostprocessor, initPostprocessor2, postprocess, setCommandHistoryPublisher
Methods inherited from class org.yamcs.tctm.AbstractLink
addAction, collectSystemParameters, connectionStatus, dataIn, dataOut, disable, enable, getAction, getActions, getConfig, getCurrentTime, getDataOutCount, getDetailedStatus, getEventLoop, getLinkStatus, getName, getParent, getSystemParameters, getYamcsInstance, isDisabled, isRunningAndEnabled, resetCounters, setParent, setupSystemParameters
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 org.yamcs.tctm.Link
disable, enable, getConfig, getDataOutCount, getDetailedStatus, getExtraInfo, getLinkStatus, getName, getParent, getSpec, isDisabled, isEffectivelyDisabled, resetCounters, setParent, setupSystemParameters
Methods inherited from interface org.yamcs.parameter.SystemParametersProducer
getFrequency
Methods inherited from interface org.yamcs.tctm.TcDataLink
isCommandingAvailable, isTcDataLinkImplemented
-
Field Details
-
commandQueue
-
-
Constructor Details
-
AbstractThreadedTcDataLink
public AbstractThreadedTcDataLink()
-
-
Method Details
-
getDefaultSpec
Description copied from interface:Link
Returns a default linkSpec
. 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 interfaceLink
- Overrides:
getDefaultSpec
in classAbstractTcDataLink
-
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 interfaceLink
- Overrides:
init
in classAbstractTcDataLink
config
- - the configuration - cannot be null (but can be empty)- Throws:
ConfigurationException
-
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
-
sendCommand
Sends- Specified by:
sendCommand
in interfaceTcDataLink
- Returns:
-
run
public void run() -
doEnable
protected void doEnable()- Overrides:
doEnable
in classAbstractLink
-
doDisable
protected void doDisable()- Overrides:
doDisable
in classAbstractLink
-
doHousekeeping
protected void doHousekeeping()Called eachAbstractTcDataLink.housekeepingInterval
milliseconds, can be used to establish tcp connections or similar things -
uplinkCommand
Called- Parameters:
pc
-- Throws:
IOException
-
startUp
Called at start up (if the link is enabled) or when the link is enabled- Throws:
Exception
-
shutDown
Called at shutdown (if the link is enabled) or when the link is disabled- Throws:
Exception
-