java.lang.Object
com.google.common.util.concurrent.AbstractService
org.yamcs.tctm.UdpParameterDataLink
- All Implemented Interfaces:
com.google.common.util.concurrent.Service
,Runnable
,Link
,ParameterDataLink
public class UdpParameterDataLink
extends com.google.common.util.concurrent.AbstractService
implements ParameterDataLink, Runnable
Receives PP data via UDP.
The UDP packets are protobuf encoded ParameterData. We don't use any checksum, assume it's done by UDP.
-
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
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.yamcs.protobuf.Pvalue.ParameterData
decodeDatagram
(byte[] data, int offset, int length) DecodePvalue.ParameterData
from the content of a single received UDP Datagram.void
disable()
Sets the disabled to true such that getNextPacket ignores the received datagramsprotected void
doStart()
protected void
doStop()
void
enable()
Sets the disabled to false such that getNextPacket does not ignore the received datagramslong
long
Returns statistics with the number of datagrams received and the number of invalid datagramsReturns the current link status.getName()
Return the name of the linkorg.yamcs.protobuf.Pvalue.ParameterData
Called to retrieve the next packet.void
init
(String instance, String name, YConfiguration config) Called at startup to initialize the link.boolean
return true if the link has been disabled by the user.void
void
run()
void
setParameterSink
(ParameterSink parameterSink) 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
getExtraInfo, getParent, getSpec, isEffectivelyDisabled, setParent, setupSystemParameters
-
Constructor Details
-
UdpParameterDataLink
public UdpParameterDataLink()
-
-
Method Details
-
init
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.
-
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
-
run
public void run() -
getNextData
public org.yamcs.protobuf.Pvalue.ParameterData getNextData()Called to retrieve the next packet. It blocks in reading on the UDP socket.- Returns:
- anything that looks as a valid packet, just the size is taken into account to decide if it's valid or not
-
decodeDatagram
public org.yamcs.protobuf.Pvalue.ParameterData decodeDatagram(byte[] data, int offset, int length) throws IOException DecodePvalue.ParameterData
from the content of a single received UDP Datagram.UdpParameterDataLink
has configurable support for either Protobuf or JSON-encoded data. Extending links may provide a custom decoder by overriding this method.- Parameters:
data
- data buffer. The data received starts fromoffset
and runs forlength
long.offset
- offset of the data receivedlength
- length of the data received- Throws:
IOException
-
getLinkStatus
Description copied from interface:Link
Returns the current link status.- Specified by:
getLinkStatus
in interfaceLink
-
getDetailedStatus
Returns statistics with the number of datagrams received and the number of invalid datagrams- Specified by:
getDetailedStatus
in interfaceLink
-
disable
public void disable()Sets the disabled to true such that getNextPacket ignores the received datagrams -
enable
public void enable()Sets the disabled to false such that getNextPacket does not ignore the received datagrams -
isDisabled
public boolean isDisabled()Description copied from interface:Link
return true if the link has been disabled by the user.See also
Link.isEffectivelyDisabled()
- Specified by:
isDisabled
in interfaceLink
-
getDataInCount
public long getDataInCount()- Specified by:
getDataInCount
in interfaceLink
-
getDataOutCount
public long getDataOutCount()- Specified by:
getDataOutCount
in interfaceLink
-
resetCounters
public void resetCounters()- Specified by:
resetCounters
in interfaceLink
-
setParameterSink
- Specified by:
setParameterSink
in interfaceParameterDataLink
-
getConfig
-
getName
Description copied from interface:Link
Return the name of the link
-