ControllerCommand#
- class lsst.ts.salobj.topics.ControllerCommand(salinfo, name, queue_len=100)#
Bases:
ReadTopicRead a specified command topic.
- Parameters:
Notes
Each command must be acknowledged by writing an appropriate
ackcmdmessage. If you use a callback function to process the command then this happens automatically, as follows:If the callback function returns
Nonethen send a final acknowledgement withack=SalRetCode.CMD_COMPLETE.If the callback function returns an acknowledgement (instance of
SalInfo.AckCmdType) instead ofNone, then send that as the final acknowledgement. This is very unusual, but might be useful if the callback wants to exit early and leave some background task or thread processing the rest of the command.If the callback function raises
asyncio.TimeoutErrorthen send a final acknowledgement withack=SalRetCode.CMD_TIMEOUT.If the callback function raises
asyncio.CancelledErrorthen send a final acknowledgement withack=SalRetCode.CMD_ABORTED.If the callback function raises
ExpectedErrorthen send a final acknowledgement withack=SalRetCode.CMD_FAILEDandresult=f"Failed: {exception}".If the callback function raises any other
Exceptionthen do the same asExpectedErrorand also log a traceback.
Methods Summary
ack(data, ackcmd)Acknowledge a command by writing a new state.
ack_in_progress(data, timeout[, result])Ackowledge this command as "in progress".
next(*[, timeout])Wait for data, returning old data if found.
Methods Documentation
- async ack(data, ackcmd)#
Acknowledge a command by writing a new state.
- Parameters:
data (
DataType) – Data for the command being acknowledged.ackcmd (
salobj.AckCmdType) – Command acknowledgement data.
- Raises:
RuntimeError – If self.salinfo is not running. This may occur at shutdown. (It is much less likely if the SalInfo as not started, because the SalInfo will not have received any commands.)
- Return type:
- async ack_in_progress(data, timeout, result='')#
Ackowledge this command as “in progress”.
- Parameters:
- Raises:
RuntimeError – If self.salinfo is not running. This may occur at shutdown. (It is much less likely if the SalInfo as not started, because the SalInfo will not have received any commands.)
- Return type:
- async next(*, timeout=None)#
Wait for data, returning old data if found.
Unlike
RemoteEvent.nextandRemoteTelemetry.next, the flush argument is not allowed; the only way to flush old commands is to callflush.- Parameters:
timeout (
float, optional) – Time limit, in seconds. If None then no time limit.- Returns:
data – Command data.
- Return type:
DataType- Raises:
asyncio.TimeoutError – If no message is available within the specified time limit.
RuntimeError – If a callback function is present.
Notes
Do not modify the data or assume that it will be static. If you need a private copy, then copy it yourself.