BaseEssRule¶
- class lsst.ts.watcher.BaseEssRule(*, config, name, topic_attr_name, field_name, sensor_info_name, big_is_bad, is_indexed, units, value_format='0.2f', log=None)¶
Bases:
PollingRule
Check one kind of ESS data, e.g. temperature or humidity.
- Parameters:
- configstruct
Rule configuration. The following fields are read:
warning_level :
float
|None
Warning level. None to not use this level.serious_level :
float
|None
Serious level. None to not use this level.critical_level :
float
|None
Critical level. None to not use this level.warning_period :
float
Period [s] after which the warning alarm will be raised.serious_period :
float
Period [s] after which the serious alarm will be raised.critical_period :
float
Period [s] after which the critical alarm will be raised.hysteresis :
float
The amount by which the measurement must decrease below (or increase above ifbig_is_bad
false) a severity level, before alarm severity is decreased.{sensor_info_name} A field whose name is given by
sensor_info_name
that contains information about the sensors to read. A list of dicts whose format depends on is_indexed. If is_indexed false, the fields are:sal_index : int SAL index of topic.
sensor_names : list[str] A list of sensor names.
If is_indexed true, the fields are:
sal_index : int SAL index of topic.
sensor_info : list[dict[str, str | list[int]]] A list of topic-specific sensor info with fields:
sensor_name : str Name of sensor.
indices : list[int], optional Indices of field to read. If omitted then read all non-nan values.
warning_msg :
str
, optional The first part of the reason string for a warning alarm. This should say what the operators should do.serious_msg :
str
, optional The first part of the reason string for a serious alarm. This should say what the operators should do.critical_msg :
str
, optional The first part of the reason string for a critical alarm. This should say what the operators should do.
- name
str
The name of the rule.
- topic_attr_name
str
The attr name of the ESS telemetry topic, e.g. “tel_temperature” or “tel_relativeHumidity”.
- field_name
str
The name of the ESS topic field, e.g. “temperatureItem” or “humidity”.
- sensor_info_name
str
Name of sensor info field in
config
.- is_indexed
bool
Is the field indexed? This controls the format of sensor info in the config.
- units
str
Units of measurement.
- value_format
str
, optional Format for float value (threshold level or measured value) without a leading colon, e.g. “0.2f”
- log
logging.Logger
, optional Parent logger.
Notes
This uses
FilteredEssFieldWrapper
and its kin, because ESS data must be filtered by the value of thesensorName
field (and index, if the data is array-valued).- Attributes:
- PollingRule attributes
All attributes from
PollingRule
, plus:- field_wrappers
FieldWrapperList
Wrappers for ESS telemetry fields.
- sensors
dict
Sensor configuration (the config field specified by
sensor_field_info_name
).- threshold_handler
ThresholdHandler
Threshold handler for ESS data.
Attributes Summary
Get the rule name.
Methods Summary
Compute and set alarm severity and reason.
Return a jsonschema as a
dict
, to validate configuration.is_usable
(disabled_sal_components)Return True if rule can be used, despite disabled SAL components.
make_config
(**kwargs)Make a config from keyword arguments, after applying defaults.
setup
(model)Create filtered topic wrappers
start
()Start any background tasks, such as a polling loop.
stop
()Stop all background tasks.
update_alarm_severity
(**kwargs)Compute and set alarm severity and reason.
Attributes Documentation
- name¶
Get the rule name.
Methods Documentation
- compute_alarm_severity() tuple[lsst.ts.xml.enums.Watcher.AlarmSeverity, str] | None ¶
Compute and set alarm severity and reason.
- Parameters:
- **kwargs
dict
[str
,typing.Any
] Keyword arguments. If triggered by
TopicCallback
callingupdate_alarm_severity
, the arguments will be as follows:data :
salobj.BaseMsgType
Message from the topic described by topic_callback.topic_callback :
TopicCallback
Topic callback wrapper.
- **kwargs
- Returns:
- None, if no change or unknown, or a tuple of two values:
- severity:
lsst.ts.idl.enums.Watcher.AlarmSeverity
The new alarm severity.
- reason
str
Detailed reason for the severity, e.g. a string describing what value is out of range, and what the range is. If
severity
isNONE
then this value is ignored (but still required) and the old reason is retained until the alarm is reset tonominal
state.
Notes
You may return
NoneNoReason
if the alarm state isNONE
.
- abstract classmethod get_schema() dict[str, Any] ¶
Return a jsonschema as a
dict
, to validate configuration.Notes
Please provide default values for all fields for which defaults make sense. This makes watcher configuration files easier to write.
If your rule has no configuration then return
None
.We recommend that you write the schema as yaml, for compactness, then use yaml.safe_load to convert it to a dict. For example:
schema_yaml = """ $schema: http://json-schema.org/draft-07/schema# description: Configuration for MyRule type: object properties: ... required: [...] additionalProperties: false """ return yaml.safe_load(schema_yaml)
- is_usable(disabled_sal_components: set[tuple[str, int]]) bool ¶
Return True if rule can be used, despite disabled SAL components.
The default implementation returns true if all remotes used by this rule are enabled. Override if you need something more complicated. The attributes
config
,name
andremote_info_list
are all available when this method is called.
- classmethod make_config(**kwargs: str) SimpleNamespace ¶
Make a config from keyword arguments, after applying defaults.
- Parameters:
- kwargs
The configuration, as a dict of property: name. The allowed properties and values are specified by the rule’s config schema.
- Returns:
- config
types.SimpleNamespace
The rule configuration, with defaults applied as needed.
- config
- Raises:
- jsonschema.ValidationError
If the provided kwargs are incorrect (missing keys, misspelled keys, incorrect data types…).
- async poll_loop()¶
- start()¶
Start any background tasks, such as a polling loop.
This is called when the watcher goes into the enabled state.
Notes
Do not assume that
start
is called beforestop
; the order depends on the initial state of the Watcher.Immediate subclasses need not call super().start()
- stop()¶
Stop all background tasks.
This is called when the watcher goes out of the enabled state, and must stop any tasks that might trigger an alarm state change.
Notes
Do not assume that
start
is called beforestop
; the order depends on the initial state of the Watcher.This base implementation does nothing, so immediate subclasses need not call
super().stop()
.
- async update_alarm_severity(**kwargs: Any) None ¶
Compute and set alarm severity and reason.
This must run quickly. If computing alarm severity is expensive, override this method to start a thread that computes the data and create a background task to manage the thread, then return.
- Parameters:
- **kwargs
dict
[str
,typing.Any
] Keyword arguments. If called by
TopicCallback
, the arguments will be as follows:data :
salobj.BaseMsgType
Message from the topic described by topic_callback.topic_callback :
TopicCallback
Topic callback wrapper.
- **kwargs