nEDM Interface

nEDM Experiment

nEDM Interface

Repository

Tutorials


Modules


Classes


Externals


Alarms

Alarms page

http://db.nedm1/page/alarms

This page provides an interface to define alarms, which are small scripts that run periodically to check values of variables in the database. The daemon in charge of running this is part of the CouchDB Docker and the code to it may be found in that repository.

To learn about writing alarm code, skip to that section.

Interface

The front page of the interface collects all alarms from the different subsystems and displays them:

alarms front page

By clicking on the Info button, one can get information about when recent alarms have occurred:

alarms more info

One can click on the Code buttons to view a screen where one can see/edit the code, title, description, and emails. To edit an alarm document, one must have write access to the relevant database.

alarms edit

Submitting an alarm is similar to editing an old one, just open the collapsible at the bottom of the page. To submit an alarm document, one must have write access to the relevant database.

alarms new

Writing alarm code

Example code for an alarm:

_last_value = None
def main(db):
    global _last_value
    lv = _last_value
    _last_value = latest_value('run_status', 6)['rows'][0]['value']['max']
    if lv is None: return
    if lv == 0 and _last_value == 1:
        raise AlarmEvent('Coil run begun', 'run_status has changed')

Points to note:

All exceptions should be called like:

if alarm_condition == True:
    AlarmError("error seen here", "More descriptive text about the error")

Alarm scripts should always raise exceptions if an alarm condition exists. The alarm daemon keeps track of the state and only sends emails when the state changes (e.g. an alarm appears, the criticality changes, or the alarm clears).