ControllerEvent

class lsst.ts.salobj.topics.ControllerEvent(salinfo, name)

Bases: lsst.ts.salobj.topics.WriteTopic

Write a specific event topic.

Parameters:
salinfo : SalInfo

SAL component information

name : str

Event topic name

Attributes Summary

DataType The class of data for this topic.
data Get or set internally cached data.
has_data Has data ever been set?
metadata Get topic metadata as a TopicMetadata, if available, else None.

Methods Summary

close() Shut down and release resources.
put([data, priority]) Output this topic.
set(**kwargs) Set one or more fields of self.data.
set_put([force_output]) Set zero or more fields of self.data and put if changed or if force_output true.

Attributes Documentation

DataType

The class of data for this topic.

data

Get or set internally cached data.

Parameters:
data : DataType

New data.

Raises:
TypeError

If data is not an instance of DataType

Notes

You must not modify the returned data, nor assume that it will be constant. If you need a copy then make it yourself.

has_data

Has data ever been set?

metadata

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

Methods Documentation

close()

Shut down and release resources.

Intended to be called by SalInfo.close(), since that tracks all topics.

put(data=None, priority=0)

Output this topic.

Parameters:
data : self.DataType or None

New data to replace self.data, if any.

priority : int (optional)

Priority; used to set the priority field of events. Ignored for commands and telemetry.

Raises:
TypeError

If data is not None and not an instance of DataType.

set(**kwargs)

Set one or more fields of 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).
Returns:
did_change : bool

True if 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 data may be partially updated. This is not ideal, but is pragmatic because it is difficult to copy SAL topics (see TSS-3195).

set_put(force_output=False, **kwargs)

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

The data is put if it has never been set (has_data False), or this call changes the value of any field, or force_output is true.

Parameters:
force_output : bool (optional)

If True then output the event, even if no fields have changed.

**kwargs : dict [str, any]

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

Returns:
did_put : bool

True if the data was output, False otherwise

Raises:
AttributeError

If the topic does not have the specified field.

ValueError

If the field cannot be set to the specified value.