ControllerEvent¶
- class lsst.ts.salobj.topics.ControllerEvent(salinfo: SalInfo, name: str)¶
Bases:
WriteTopic
Write a specific event topic.
- Parameters:
- salinfo
SalInfo
SAL component information.
- name
str
Event name with no prefix, e.g. “summaryState”.
- salinfo
Attributes Summary
The type (class) for a message of this topic.
Get the salobj topic attribute name, e.g.
Internally cached message.
Has
data
ever been set?Get the SAL topic name, e.g.
Methods Summary
A synchronous and possibly less thorough version of
close
.close
()Shut down and release resources.
set
(**kwargs)Set one or more fields of message data
self.data
.set_write
(*[, force_output])Set zero or more fields of
self.data
and write if any field changed or if output forced.write
()Write the current data and return a copy of the data written.
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 set data and write a message for a topic is:
RemoteCommand.set_start
to start a command.CommandEvent.set_write
to write an event.CommandTelemetry.set_write
to write a telemetry message.
- attr_name¶
Get the salobj topic attribute name, e.g. evt_summaryState.
- 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)
.
- has_data¶
Has
data
ever been set?Note: a value of true means at least one field has been set, not that all fields have been set.
- sal_name¶
Get the SAL topic name, e.g. logevent_summaryState.
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.
- set(**kwargs: Any) bool ¶
Set one or more fields of message data
self.data
.This is useful when accumulating data for a topic in different bits of code. Have each bit of code call
set
to set the fields it knows about. Have the last bit of code callwrite
to set the remaining fields and write the completed message.If you have all the information for a topic in one place, it is simpler to call
set_write
to set all of the fields and write the message.- Parameters:
- 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.
- async set_write(*, force_output: bool | None = None, **kwargs: Any) SetWriteResult ¶
Set zero or more fields of
self.data
and write if any field changed or if output forced.- Parameters:
- force_output
bool
, optional If True then write the event, even if no fields have changed. If None (the default), use the class default, which is True for all except ControllerEvent. (The default value is given by class constant
default_force_output
).- **kwargs
dict
[str
,any
] The remaining keyword arguments are field name = new value for that field. See
set
for more information about values.
- force_output
- Returns:
- result
SetWriteResult
The resulting data and some flags.
- result
Notes
The reason there are separate
set_write
andwrite
methods is thatwrite
reliably writes the data, whereas the event version ofset_write
only writes the data ifkwargs
changes it, or ifforce_output
is true.
- async write() BaseMsgType ¶
Write the current data and return a copy of the data written.
- Returns:
- dataself.DataType
The data that was written. This can be useful to avoid race conditions (as found in RemoteCommand).
- Raises:
- RuntimeError
If not running.