RemoteCommand¶
-
class
lsst.ts.salobj.topics.RemoteCommand(salinfo, name)¶ Bases:
lsst.ts.salobj.topics.WriteTopicIssue a specific command topic and wait for acknowldgement.
Parameters: Attributes Summary
DataTypeThe type (class) for a message of this topic. dataInternally cached message. has_dataHas dataever been set?metadataGet topic metadata as a TopicMetadata, if available, elseNone.Methods Summary
close()Shut down and release resources. next_ackcmd(ackcmd[, timeout, wait_done])Wait for the next acknowledement for the command put([data, priority])Output this topic. set(**kwargs)Create a new self.dataand set one or more fields.set_start([timeout, wait_done])Create a new self.data, set zero or more fields, and start the command.start([data, timeout, wait_done])Start a command. Attributes Documentation
-
DataType¶ The type (class) for a message of this topic.
When you read or write a message for this topic you are reading or writing an instance of
DataType.Notes
The preferred way to write a message for a topic is:
RemoteCommand.set_startto start a command.CommandEvent.set_putto write an event.CommandTelemetry.set_putto write a telemetry message.
However, it is also possible to use
DataTypeto create a message, then write, it as separate operations. For example, assuming we have aRemotefor SAL component “Test”:# The preferred way to issue a command: await = remote.cmd_wait.set_put(duration=2, timeout=5) # But an alternative is to first create the command, # then send it, as two separate operations: message = remote.cmd_wait.DataType(duration=2) await remote.cmd_wait.start(message, timeout=5) # Or, even more verbosely: message = remote.cmd_wait.DataType() message.duration = 2 await remote.cmd_wait.start(message, timeout=5)
-
data¶ Internally cached message.
Raises: - TypeError
If
datais not an instance ofDataType
Notes
Do not assume the data will be constant. You can make a copy using
copy.copy(data).
Methods Documentation
-
close()¶ Shut down and release resources.
Intended to be called by SalInfo.close(), since that tracks all topics.
-
next_ackcmd(ackcmd, timeout=3600, wait_done=True)¶ Wait for the next acknowledement for the command
Parameters: - ackcmd :
SalInfo.AckCmdType The command acknowledgement returned by the previous wait (e.g. from
start).- timeout :
float, optional Time limit, in seconds. If None then use
DEFAULT_TIMEOUT. This time limit is for the entire command if wait_done is true, else it is for the first acknowledgement after the initial “CMD_ACK”.- wait_done :
bool, optional If True then wait for final command acknowledgement. If False then wait until the next command acknowledgement; if that acknowledgement is not final (the ack code is not in
done_ack_codes), then you will almost certainly want to awaitnext_ackcmdagain.
Returns: - ackcmd :
SalInfo.AckCmdType Command acknowledgement.
Raises: - salobj.AckError
If the command fails or times out.
- RuntimeError
If the command specified by
seq_numis unknown or has already finished.
- ackcmd :
-
put(data=None, priority=0)¶ Output this topic.
Parameters: Raises: - TypeError
If
datais not None and not an instance ofDataType.
-
set(**kwargs)¶ Create a new
self.dataand set one or more fields.Parameters: - **kwargs :
dict[str,any] Dict of field name: new value for that field:
- Any key whose value is
Noneis checked for existence, but the value of the field is not changed. - If the field being set is an array then the value must either be an array of the same length or a scalar (which replaces every element of the array).
- Any key whose value is
Returns: Raises: - AttributeError
If the topic does not have the specified field.
- ValueError
If the field cannot be set to the specified value.
Notes
If one or more fields cannot be set, the data may be partially updated.
- **kwargs :
-
set_start(timeout=3600, wait_done=True, **kwargs)¶ Create a new
self.data, set zero or more fields, and start the command.Parameters: - timeout :
float, optional Time limit, in seconds. If None then use
DEFAULT_TIMEOUT. This time limit is for the entire command ifwait_doneis true, else it is for the first acknowledgement after the initialCMD_ACK. If the command is acknowledged withCMD_INPROGRESSthen the timeout is extended by the timeout value in the acknowledgement. Thus a slow command will not need a long timeout, so long as the command issues aCMD_INPROGRESSacknowledgement with a reasonabletimeoutvalue.- wait_done :
bool, optional If True then wait for final command acknowledgement. If False then wait for the first acknowledgement after the initial “CMD_ACK”; if that acknowledgement is not final (the ack code is not in done_ack_codes), then you will almost certainly want to await
next_ackcmd.- **kwargs :
dict[str,any] The remaining keyword arguments are field name = new value for that field. See
setfor more information about values.
Returns: - ackcmd :
SalInfo.AckCmdType Command acknowledgement.
Raises: - salobj.AckError
If the command fails.
- salobj.AckTimeoutError
If the command times out.
- TypeError
If
datais not None and not an instance ofDataType.
- timeout :
-
start(data=None, timeout=3600, wait_done=True)¶ Start a command.
Parameters: - data :
self.DataType, optional Command message. If
Nonethen send the currentself.data.- timeout :
float, optional Time limit, in seconds. If None then use
DEFAULT_TIMEOUT. This time limit is for the entire command ifwait_doneis true, else it is for the first acknowledgement after the initialCMD_ACK. If the command is acknowledged withCMD_INPROGRESSthen the timeout is extended by the timeout value in the acknowledgement. Thus a slow command will not need a long timeout, so long as the command issues aCMD_INPROGRESSacknowledgement with a reasonabletimeoutvalue.- wait_done :
bool, optional If True then wait for final command acknowledgement. If False then wait for the first acknowledgement after the initial “CMD_ACK”; if that acknowledgement is not final (the ack code is not in done_ack_codes), then you will almost certainly want to await
next_ackcmd.
Returns: - ackcmd :
SalInfo.AckCmdType Command acknowledgement.
Raises: - salobj.AckError
If the command fails.
- salobj.AckTimeoutError
If the command times out.
- RuntimeError
If the
salinfohas not started reading.- TypeError
If
datais not None and not an instance ofDataType.
- data :
-