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.
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.
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 changed or ifforce_output
true.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 write a message for a topic is:
RemoteCommand.start
to start a command.CommandEvent.write
to write an event.CommandTelemetry.write
to write a telemetry message.
- 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?A value of true simply means that
set
orset_write
has been called at least once since the topic was constructed. All public fields will have their default value until they are set to something else. (Private fields are automatically set when the message is written.)
- 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.
- 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 callset_write
(withforce_output=True
, for events) to set the remaining fields and write the completed message. Or set all fields withset
and then callwrite
to write the 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:
- **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.
- async set_write(*, force_output: bool | None = None, **kwargs: Any) SetWriteResult ¶
Set zero or more fields of
self.data
and write if changed or ifforce_output
true.- Parameters:
- force_output
bool
, optional If false, only write the message if this call changes any of the specified fields, or if
has_data
is false. If true, always write the message. IfNone
(the default), use the class default, which is:False
for events (ControllerEvent
)True
for telemetry (ControllerTelemetry
)True
for generic write topics (WriteTopic
, this class).
- **kwargs
dict
[str
,any
] field_name=new_value
for fields you wish to set. Unspecified fields retain their current value, which may have been set by earlier calls toset
orset_write
.
- 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 message, whereasset_write
may not (for details, seeforce_output
above).The default value for force_output is specified by class constant
default_force_output
.
- async write() BaseMsgType ¶
Write the current data and return a copy of the data written.
- Returns:
- dataself.DataType
A copy of the data that was written. This can be useful to avoid race conditions (as found in RemoteCommand).