WriteTopic¶
- class lsst.ts.salobj.topics.WriteTopic(*, salinfo: SalInfo, name: str, sal_prefix: str, min_seq_num: typing.Optional[int] = 1, max_seq_num: int = 2147483647, initial_seq_num: typing.Optional[int] = None)¶
Bases:
lsst.ts.salobj.topics.base_topic.BaseTopic
Base class for topics that are output.
This includes controller events, controller telemetry, remote commands and
cmdack
writers.- Parameters
- salinfo
SalInfo
SAL component information
- name
str
Topic name, without a “command_” or “logevent_” prefix.
- sal_prefix
str
SAL topic prefix: one of “command_”, “logevent_” or “”
- min_seq_num
int
orNone
, optional Minimum value for the
private_seqNum
field. The default is 1. IfNone
thenprivate_seqNum
is not set; this is needed for the cmdack writer, which sets the field itself.- max_seq_num
int
, optional Maximum value for
private_seqNum
, inclusive. The default is the maximum allowed positive value (private_seqNum
is a 4-byte signed int). Ignored ifmin_seq_num
isNone
.- initial_seq_num
int
, optional Initial sequence number; if
None
use min_seq_num.
- salinfo
- Attributes
Attributes Summary
The type (class) for a message of this topic.
Internally cached message.
Has
data
ever been set?Get topic metadata as a
TopicMetadata
, if available,else None.Does this topic have volatile durability?
Methods Summary
A synchronous and possibly less thorough version of
close
.close
()Shut down and release resources.
put
([data])Output this topic.
set
(**kwargs)Set one or more fields of message data cache
self.data
.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_start
to start a command.CommandEvent.set_put
to write an event.CommandTelemetry.set_put
to write a telemetry message.
However, it is also possible to use
DataType
to create a message, then write, it as separate operations. For example, assuming we have aRemote
for 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
data
is not an instance ofDataType
Notes
Do not assume the data will be constant. You can make a copy using
copy.copy(data)
.
- metadata¶
Get topic metadata as a
TopicMetadata
, if available,else None.
- volatile¶
Does this topic have volatile durability?
Methods Documentation
- basic_close() None ¶
A synchronous and possibly less thorough version of
close
.Intended for exit handlers and constructor error handlers.
- async close() None ¶
Shut down and release resources.
Intended to be called by SalInfo.close(), since that tracks all topics.
- put(data: Optional[lsst.ts.salobj.type_hints.BaseDdsDataType] = None) None ¶
Output this topic.
- set(**kwargs: Any) bool ¶
Set one or more fields of message data cache
self.data
.- Parameters
- **kwargs
dict
[str
,any
] Dict of field name: new value for that field:
Any key whose value is
None
is 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).
- **kwargs
- 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 message data may be partially updated.