Class Cop1TcPacketHandler
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractService
-
- org.yamcs.tctm.AbstractLink
-
- org.yamcs.tctm.AbstractTcDataLink
-
- org.yamcs.tctm.ccsds.Cop1TcPacketHandler
-
- All Implemented Interfaces:
com.google.common.util.concurrent.Service
,SystemParametersProducer
,VcUplinkHandler
,Link
,TcDataLink
public class Cop1TcPacketHandler extends AbstractTcDataLink implements VcUplinkHandler
Assembles TC packets into TC frames as per CCSDS 232.0-B-3 and sends them out via FOP1Implements the FOP (transmitter) part of the Communications Operations Procedure-1 CCSDS 232.1-B-2 September 2010
The FOP1 implementation is a little different than the standard: the "Initiate AD service with CLCW check" will wait for the first CLCW and immediately set the vS to the nR in the CLCW. The standard specifies that the vS has somehow to be set manually to an CLCW observed value before calling the "Initiate AD with CLCW check" directive.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.yamcs.tctm.Link
Link.Status
-
-
Field Summary
Fields Modifier and Type Field Description static CommandOption
OPTION_BYPASS
protected String
sv_cop1Status_id
protected ArrayDeque<PreparedCommand>
waitQueue
-
Fields inherited from class org.yamcs.tctm.AbstractTcDataLink
cmdPostProcessor, commandHistoryPublisher, dataCount, housekeepingInterval, sp_dataCount_id, sv_linkStatus_id
-
Fields inherited from class org.yamcs.tctm.AbstractLink
config, disabled, eventProducer, linkName, log, timeService, yamcsInstance
-
-
Constructor Summary
Constructors Constructor Description Cop1TcPacketHandler(String yamcsInstance, String linkName, TcManagedParameters.TcVcManagedParameters vmp, ScheduledThreadPoolExecutor executor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMonitor(Cop1Monitor monitor)
protected void
collectSystemParameters(long time, List<ParameterValue> list)
adds system parameters link status and data in/out to the list.protected Link.Status
connectionStatus()
In case the link should be connected (i.e. is running and enabled) this method is called to return the actual connection statusvoid
disableCop1(boolean bypassAll)
protected void
doStart()
protected void
doStop()
CompletableFuture<org.yamcs.protobuf.Cop1Config>
getCop1Config()
CompletableFuture<org.yamcs.protobuf.Cop1Status>
getCop1Status()
Semaphore
getDataAvailableSemaphore()
long
getFirstFrameTimestamp()
Returns the timestamp of the first frame ready to be dispatched orTimeEncoding.INVALID_INSTANT
if there is no frame.TcTransferFrame
getFrame()
Retrieves the next frame in the Virtual Channel, or returns null if there is no frame available at the moment.VcUplinkManagedParameters
getParameters()
return the virtual channel parametersCompletableFuture<Void>
initiateAD(boolean clcwCheck)
CompletableFuture<Void>
initiateAD(boolean clcwCheck, long waitMillisec)
Initiate AD with or without CLCW check The returned future will be completed when the operation has been initiated.CompletableFuture<Void>
initiateADWithUnlock()
Initiate AD with Unlock.CompletableFuture<Void>
initiateADWithVR(int vR)
Initiate AD with set V(R).void
onCLCW(int clcw)
Called when a new CLCW is received from the remote systemvoid
purgeSentQueue()
void
purgeWaitQueue()
void
removeMonitor(Cop1Monitor monitor)
CompletableFuture<Void>
resume()
Resume the AD service (if it is suspended)void
sendTc(PreparedCommand pc)
CompletableFuture<Void>
setConfig(org.yamcs.protobuf.Cop1Config config)
void
setDataAvailableSemaphore(Semaphore dataAvailableSemaphore)
The semaphore will be used by the data link to signal when there is some data to be transmitted.void
setupSystemParameters(SystemParametersCollector sysParamCollector)
Called by the LinkManager before startup if theSystemParametersCollector
service is enabled, to setup necessary things for later parameter collection.CompletableFuture<Void>
setVs(int vs)
CompletableFuture<Void>
setWindowWidth(int K)
Set the FOP sliding window with - that is the maximum number of commands that can be unacknoledged at one time.CompletableFuture<Void>
terminateAD()
Terminate the AD service-
Methods inherited from class org.yamcs.tctm.AbstractTcDataLink
ackCommand, failedCommand, getCurrentTime, getDataInCount, getDataOutCount, getParent, getYamcsInstance, init, initPostprocessor, resetCounters, setCommandHistoryPublisher, setParent
-
Methods inherited from class org.yamcs.tctm.AbstractLink
disable, doDisable, doEnable, enable, getConfig, getDetailedStatus, getEventLoop, getLinkStatus, getName, getSystemParameters, isDisabled, isRunningAndEnabled
-
Methods inherited from class com.google.common.util.concurrent.AbstractService
addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, 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, getDetailedStatus, getLinkStatus, getName, getSpec, isDisabled
-
-
-
-
Field Detail
-
OPTION_BYPASS
public static final CommandOption OPTION_BYPASS
-
waitQueue
protected ArrayDeque<PreparedCommand> waitQueue
-
sv_cop1Status_id
protected String sv_cop1Status_id
-
-
Constructor Detail
-
Cop1TcPacketHandler
public Cop1TcPacketHandler(String yamcsInstance, String linkName, TcManagedParameters.TcVcManagedParameters vmp, ScheduledThreadPoolExecutor executor)
-
-
Method Detail
-
addMonitor
public void addMonitor(Cop1Monitor monitor)
-
removeMonitor
public void removeMonitor(Cop1Monitor monitor)
-
sendTc
public void sendTc(PreparedCommand pc)
- Specified by:
sendTc
in interfaceTcDataLink
-
getFrame
public TcTransferFrame getFrame()
Description copied from interface:VcUplinkHandler
Retrieves the next frame in the Virtual Channel, or returns null if there is no frame available at the moment.- Specified by:
getFrame
in interfaceVcUplinkHandler
- Returns:
-
getFirstFrameTimestamp
public long getFirstFrameTimestamp()
Description copied from interface:VcUplinkHandler
Returns the timestamp of the first frame ready to be dispatched orTimeEncoding.INVALID_INSTANT
if there is no frame.The timestamp is used by the
MasterChannelFrameMultiplexer
to select the Virtual Channel from which the next frame is sent in case of FIFO priority scheme.- Specified by:
getFirstFrameTimestamp
in interfaceVcUplinkHandler
- Returns:
-
setVs
public CompletableFuture<Void> setVs(int vs)
-
initiateAD
public CompletableFuture<Void> initiateAD(boolean clcwCheck, long waitMillisec)
Initiate AD with or without CLCW check The returned future will be completed when the operation has been initiated.- Parameters:
clcwCheck
- - if true, a CLCW will be expected from the remote system and used to initialise the vS. - If false, the current value of vS will be used.
-
initiateAD
public CompletableFuture<Void> initiateAD(boolean clcwCheck)
-
initiateADWithVR
public CompletableFuture<Void> initiateADWithVR(int vR)
Initiate AD with set V(R). This will cause a BC frame to be sent to the remote system.The returned future is completed as soon as a BC frame has been sent downstream (could be unsuccessful!).
- Parameters:
vR
-
-
initiateADWithUnlock
public CompletableFuture<Void> initiateADWithUnlock()
Initiate AD with Unlock. This causes a BC Unlock frame to be sent to the remote system.
-
terminateAD
public CompletableFuture<Void> terminateAD()
Terminate the AD service- Returns:
-
setWindowWidth
public CompletableFuture<Void> setWindowWidth(int K)
Set the FOP sliding window with - that is the maximum number of commands that can be unacknoledged at one time.- Parameters:
K
-- Returns:
-
resume
public CompletableFuture<Void> resume()
Resume the AD service (if it is suspended)- Returns:
-
purgeSentQueue
public void purgeSentQueue()
-
purgeWaitQueue
public void purgeWaitQueue()
-
onCLCW
public void onCLCW(int clcw)
Called when a new CLCW is received from the remote system- Parameters:
clcw
-
-
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
-
getDataAvailableSemaphore
public Semaphore getDataAvailableSemaphore()
-
disableCop1
public void disableCop1(boolean bypassAll)
-
setDataAvailableSemaphore
public void setDataAvailableSemaphore(Semaphore dataAvailableSemaphore)
The semaphore will be used by the data link to signal when there is some data to be transmitted.A permit will be released in these circumstances
- a new AD telecommand has been placed into the incoming queue;
- a BC frame has been released
- a BD command has been released
- Specified by:
setDataAvailableSemaphore
in interfaceVcUplinkHandler
- Parameters:
dataAvailableSemaphore
-
-
getParameters
public VcUplinkManagedParameters getParameters()
Description copied from interface:VcUplinkHandler
return the virtual channel parameters- Specified by:
getParameters
in interfaceVcUplinkHandler
- Returns:
-
setConfig
public CompletableFuture<Void> setConfig(org.yamcs.protobuf.Cop1Config config)
-
getCop1Config
public CompletableFuture<org.yamcs.protobuf.Cop1Config> getCop1Config()
-
getCop1Status
public CompletableFuture<org.yamcs.protobuf.Cop1Status> getCop1Status()
-
setupSystemParameters
public void setupSystemParameters(SystemParametersCollector sysParamCollector)
Description copied from interface:Link
Called by the LinkManager before startup if theSystemParametersCollector
service is enabled, to setup necessary things for later parameter collection.The method is called only on the links that implement the
SystemParametersProducer
interface; they are also registered with theSystemParametersCollector
to be called regularly after the start.- Specified by:
setupSystemParameters
in interfaceLink
- Overrides:
setupSystemParameters
in classAbstractLink
-
collectSystemParameters
protected void collectSystemParameters(long time, List<ParameterValue> list)
Description copied from class:AbstractLink
adds system parameters link status and data in/out to the list.The inheriting classes should call super.collectSystemParameters and then add their own parameters to the list
- Overrides:
collectSystemParameters
in classAbstractLink
-
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 classAbstractLink
-
-