ControllerTelemetry

class lsst.ts.salobj.topics.ControllerTelemetry(salinfo: SalInfo, name: str)

Bases: lsst.ts.salobj.topics.write_topic.WriteTopic

Write a specific telemetry topic.

Parameters
salinfoSalInfo

SAL component information.

namestr

Telemetry topic name, with no prefix.

Attributes Summary

DataType

The type (class) for a message of this topic.

data

Internally cached message.

default_force_output

has_data

Has data ever been set?

metadata

Get topic metadata as a TopicMetadata, if available,else None.

volatile

Does this topic have volatile durability?

Methods Summary

basic_close()

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 if force_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 of DataType

Notes

Do not assume the data will be constant. You can make a copy using copy.copy(data).

default_force_output = True
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.

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 call write 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
**kwargsdict [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).

Returns
did_changebool

True if self.data was changed, or if this was the first call to set.

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: Optional[bool] = None, **kwargs: Any) lsst.ts.salobj.topics.write_topic.SetWriteResult

Set zero or more fields of self.data and write if changed or if force_output true.

Parameters
force_outputbool, 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).

**kwargsdict [str, any]

The remaining keyword arguments are field name = new value for that field. See set for more information about values.

Returns
result

The resulting data and some flags.

Notes

The reason there are separate set_write and write methods is that write reliably writes the data, whereas the event version of set_write only writes the data if kwargs changes it, or if force_output is true.

async write() lsst.ts.salobj.type_hints.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).