PANIC source-code

PANIC is provided as a python package panic.

The package contains the following essential modules:

  • alarmapi.py,

  • properties.py,

  • ds/PyAlarm.py,

  • gui/gui.py,

and other supporting modules used by the above.

Below are a few notes about the source code.

alarmapi.py

The alarmapi module provides definitions of the following classes:

  • Alarm, which keeps alarm states and let access to alarm attributes,

  • AlarmDS, which provides an interface to manage PyAlarm devices,

  • AlarmAPI, which gives access to Alarms and AlarmDS objects,

Both the PyAlarm device servers and PANIC GUI use the AlarmAPI to manage alarms.

Example of the usage of AlarmAPI is available in the PANIC documentation.

properties.py

The module properties.py provides definitions of all Tango properties related to the PANIC system. It is an excellent place to start when looking for information about configuration properties.

Lists of properties defined in this module are used by alarmapi, PyAlarm and GUI.

PyAlarm.py

PyAlarm.py is the implementation of PyAlarm device server/class.

Below are important points about the structure of the sources:

  • The source code starts with the import of modules. Optional modules (PyTangoArchiving, smslib) are loaded witing try/except clauses. If the PyAlarm cannot load a module (the module is not present), SNAP and/or SMS functionalities are set to disable.

  • AlarmHook class is defined but not used.

  • In addition to tango device interface definitions, there are the following important methods and objects:

    • updateAlarms is providing the main evaluation loop. It is started in a dedicated thread by start method,

    • process_alarm, where alarm state evaluation happen (call of Eval over a formula, state update). it is called by the above,

    • send_alarm, used by the above to annunciate a change of alarm state. The send_alarm uses other methods (SendTelegram, SendSMS, trigger_snapshot,``SendMail``, SaveHtml, trigger_action) to provide annunciations according to the configuration of the alarm,

In case of doubts or missing information on how a particular feature of the PANIC system work, it is worth to look into the source code of the methods mentioned above.