Model¶
- class lsst.ts.watcher.Model(domain, config, alarm_callback=None, log=None)¶
Bases:
objectWatcher model: constructs and manages rules and alarms.
- Parameters:
- domain
lsst.ts.salobj.Domain DDS Domain.
- config
types.SimpleNamespace Watcher configuration validated against the Watcher schema.
- alarm_callbackcallable, optional
Coroutine (async function) to call whenever an alarm changes state, or None if no callback wanted. The coroutine receives one argument: this alarm.
- log
logging.Logger, optional Parent logger.
- domain
- Raises:
- TypeError
If alarm_callback is not None and not a coroutine.
Attributes Summary
Get the enabled state of the Watcher model.
Methods Summary
acknowledge_alarm(name, severity, user)Acknowledge one or more alarms.
add_rule(rule)Add a rule.
close()Stop rules and close remotes.
disable()Disable the model.
enable()Enable the model.
get_filtered_topic_wrapper(topic, filter_field)Get an existing
TopicWrapper.get_rules(name_regex)Get all rules whose name matches the specified regular expression.
make_filtered_topic_wrapper(topic, filter_field)Make a FilteredTopicWrapper, or return an existing one, if found.
mute_alarm(name, duration, severity, user)Mute one or more alarms for a specified duration.
start()Start all remotes.
unacknowledge_alarm(name)Unacknowledge one or more alarms.
unmute_alarm(name)Unmute one or more alarms.
Attributes Documentation
- enabled¶
Get the enabled state of the Watcher model.
Methods Documentation
- async acknowledge_alarm(name, severity, user)¶
Acknowledge one or more alarms.
- Parameters:
- name
str Regular expression for alarm name(s) to acknowledge.
- severity
lsst.ts.idl.enums.Watcher.AlarmSeverityorint Severity to acknowledge. If the severity goes above this level the alarm will unacknowledge itself.
- user
str Name of user; used to set acknowledged_by.
- name
- add_rule(rule)¶
Add a rule.
- Parameters:
- rule
BaseRule Rule to add.
- rule
- Raises:
- ValueError
If a rule by this name already exists.
- RuntimeError
If the rule uses a remote for which no IDL file is available in the ts_idl package. Or if the rule references a topic that does not exist. Or if a RemoteInfo specifies index=0 for an indexed SAL component and index_required is true.
- async close()¶
Stop rules and close remotes.
- disable()¶
Disable the model. A no-op if already disabled.
- async enable()¶
Enable the model. A no-op if already enabled.
- get_filtered_topic_wrapper(topic, filter_field)¶
Get an existing
TopicWrapper.- Parameters:
- topic
lsst.ts.salobj.ReadTopic Topic to read.
- filter_field
str Field to filter on. The field must be a scalar. It should also have a smallish number of expected values, in order to avoid caching too much data.
- topic
- Raises:
- KeyError
If the wrapper is not in the registry.
- get_rules(name_regex)¶
Get all rules whose name matches the specified regular expression.
- Parameters:
- name_regex
str Regular expression for alarm name(s) to return.
- name_regex
- Returns:
- rules
generator An iterator over rules.
- rules
- make_filtered_topic_wrapper(topic, filter_field)¶
Make a FilteredTopicWrapper, or return an existing one, if found.
Call this, instead of constructing a
FilteredTopicWrapperdirectly. That makes sure cached value is returned, if it exists (avoiding an exception in the class constructor).- Parameters:
- topic
lsst.ts.salobj.ReadTopic Topic to read.
- filter_field
str Field to filter on. The field must be a scalar. It should also have a smallish number of expected values, in order to avoid caching too much data.
- topic
Notes
Watcher rules typically do not use
FilteredTopicWrapperdirectly. Instead they use subclasses ofBaseFilteredFieldWrapper. Each filtered field wrapper creates aFilteredTopicWrapperfor internal use.
- async mute_alarm(name, duration, severity, user)¶
Mute one or more alarms for a specified duration.
- Parameters:
- name
str Regular expression for alarm name(s) to mute.
- duration
float How long to mute the alarm (sec)
- severity
lsst.ts.idl.enums.Watcher.AlarmSeverityorint Severity to mute; used to set the
mutedSeverityfield of thealarmevent.- user
str Name of user; used to set acknowledged_by.
- name
- async start()¶
Start all remotes.