panic.panic module

panic – The Package for Alarms and Notification of Incidences from Controls


Classes

AlarmDS

class panic.panic.AlarmDS(name, api=None)[source]

This Class allows to manage the PyAlarm devices from the AlarmAPI

acknowledge(alarm, comment)[source]

Acknowledge of an active Alarm Returns True if there’s no more active alarms, else returns False

disable(tag=None, comment=None, timeout=None)[source]

If Tag is None this method disables the whole device

enable(tag=None)[source]

If Tag is None, this method will enable the whole device, but individual disables will be kept

get()[source]

Returns a device proxy

get_active_alarms()[source]

Returns the list of currently active alarms

get_alarm_properties()[source]

Method used in all panic classes

init()[source]

forces the device to reload its configuration

read(filters='*')[source]

Updates from the database the Alarms related to this device

state()[source]

Returns device state

status()[source]

Returns device status

Alarm

class panic.panic.Alarm(tag, device='', formula='', description='', receivers='', config='', severity='', api=None)[source]
add_receiver(receiver, write=True)[source]

Adds a new receiver

clear()[source]

This method just initializes Flags updated from PyAlarm devices, it doesn’t reset alarm in devices

disable(comment='', timeout='')[source]

Disables evaluation of Alarm in its PyAlarm device

enable()[source]

Enables alarm evaluation

get_active()[source]

This method connects to the Device to get the value and timestamp of the alarm attribute

get_attribute(full=False)[source]

Gets the boolean attribute associated to this alarm

get_ds()[source]

Gets and AlarmDS object related to this alarm

get_quality()[source]

it just translates severity to the equivalent Tango quality, but does NOT get actual attribute quality (which may be INVALID)

get_time(attr_value=None)[source]

This method extracts alarm activation timestamp from the ActiveAlarms array. It returns 0 if the alarm is not active.

parse_config()[source]

Checks the Alarm config related to this alarm

parse_description()[source]

Replaces $TAG and $NAME in Alarm descriptions

static parse_formula(formula)[source]

Gets “TAG:formula#comment” and returns (tag,formula)

parse_severity()[source]

Replaces $TAG and $SEVERITY in Alarm severities

remove_receiver(receiver, write=True)[source]

Removes a receiver

rename(name)[source]

Renames the Alarm and writes in DB

replace_receiver(old, new, write=True)[source]

Replaces a receiver

reset(comment)[source]

Acknowledges and resets the Alarm in its PyAlarm device

set_severity(new_severity)[source]

Sets the severity of Alarm and writes in DB

setup(tag=None, device=None, formula=None, description=None, receivers=None, config=None, severity=None, write=False)[source]

Assigns values to Alarm struct

write(device='', exclude='', update=True)[source]

Updates the Alarm config for the given device in the database :param: update controls whether the device.init() will be called or not, if not the alarm will not be applied yet

api

panic.panic.api

alias of AlarmAPI

AlarmAPI

class panic.panic.AlarmAPI(filters='*', tango_host=None, logger=30)[source]

Panic API is a dictionary-like object

add(tag, device, formula='', description='', receivers='', severity='WARNING', load=True, config=None, overwrite=False)[source]

Adds a new Alarm to the database

edit_phonebook(tag, value, section='')[source]

Adds a person to the phonebook

export_configurations(filename, regexp=None)[source]

Save devices property values to a .csv file

export_to_csv(filename, regexp=None, alarms=None, config=False, states=False)[source]

Saves the alarms currently loaded to a .csv file

export_to_dict(regexp=None, alarms=None, config=True, states=False)[source]
If config is True, the returned dictionary contains a double key:
  • data[‘alarms’][TAG] = {alarm config}
  • data[‘devices’] = {PyAlarm properties}
filter_alarms(regexp, alarms=None)[source]

Filter alarms by regular expression, use ! to negate the search

filter_hierarchy(rel, alarms=None)[source]

TOP are those alarms which state is evaluated using other Alarms values. BOTTOM are those alarms that have no alarms below or have a TOP alarm that depends from them.

get(tag='', device='', attribute='', receiver='', severity='', alarms=None)[source]

Gets alarms matching the given filters (tag,device,attribute,receiver,severity)

get_basic_alarms()[source]

Children are those alarms that have no alarms below or have a higher alarm that depends from them.

get_phonebook(load=True)[source]

gets the phonebook, returns a list

group_macro(match)[source]

For usage details see:

https://github.com/tango-controls/PANIC/
blob/documentation/doc/recipes/AlarmsHierarchy.rst
load(filters=None, exported=False)[source]

Reloads all alarm properties from the database :param filters: is used to specify which devices to be loaded

load_configurations(filename, regexp=None)[source]

Updates devices properties values from a .csv file

modify(tag, device, formula='', description='', receivers='', severity='WARNING', config=None, load=True)[source]

Modfies an Alarm in the database

parse_alarms(formula)[source]

Searches for alarm tags used in the formula

parse_attributes(formula, replace=True)[source]

Returns all tango attributes that appear in a formula

parse_phonebook(receivers)[source]

Replaces phonebook entries in a receivers list

The behavior of phonebook parsing is dependent on using ‘%’ to mark phonebook entries.

purge(device, tag, load=False)[source]

Removes any alarm from a device matching the given tag. Database must be reloaded afterwards to update the alarm list.

remove(tag, load=True)[source]

Removes an alarm from the system.

remove_phonebook(tag)[source]

Removes a person from the phonebook

rename(tag, new_tag='', new_device='', load=True)[source]

Renames an existing tag, it also allows to move to a new device.

replace_alarms(formula)[source]

Replaces alarm tags by its equivalent device/alarm attributes

save_phonebook(new_prop)[source]

Saves a new phonebook in the database

save_tag(tag)[source]

Shortcut to force alarm update in database

set_alarm_configuration(tag, device, config)[source]

This method is not operative yet, in the future will be used to do customized setups for each alarm.

start_servers(tag='', device='', host='')[source]

Starts Alarm Servers matching the filters

stop_servers(tag='', device='')[source]

Stops Alarm Servers matching the filters

update_servers(targets)[source]

Forces PyAlarm devices to reload selected alarms

Functions

current

panic.panic.current()[source]

setAlarmDeviceProperty

panic.panic.setAlarmDeviceProperty(device, prop, value)[source]

Sets property of the device

getAlarmDeviceProperties

panic.panic.getAlarmDeviceProperties(device)[source]

Method used in all panic classes

getAttrValue

panic.panic.getAttrValue(obj, default=None)[source]

Extracts rvalue in tango/taurus3/4 compatible way If default = True, obj is returned

main

panic.panic.main()[source]

getAlarmDeviceProperty

panic.panic.getAlarmDeviceProperty(device, prop)[source]

Gets the value of pointed property from the device


raw autodoc

class panic.panic.Alarm(tag, device='', formula='', description='', receivers='', config='', severity='', api=None)[source]

Bases: object

add_receiver(receiver, write=True)[source]

Adds a new receiver

clear()[source]

This method just initializes Flags updated from PyAlarm devices, it doesn’t reset alarm in devices

disable(comment='', timeout='')[source]

Disables evaluation of Alarm in its PyAlarm device

enable()[source]

Enables alarm evaluation

get_acknowledged()[source]
get_active()[source]

This method connects to the Device to get the value and timestamp of the alarm attribute

get_attribute(full=False)[source]

Gets the boolean attribute associated to this alarm

get_ds()[source]

Gets and AlarmDS object related to this alarm

get_enabled()[source]
get_model()[source]
get_quality()[source]

it just translates severity to the equivalent Tango quality, but does NOT get actual attribute quality (which may be INVALID)

get_time(attr_value=None)[source]

This method extracts alarm activation timestamp from the ActiveAlarms array. It returns 0 if the alarm is not active.

parse_config()[source]

Checks the Alarm config related to this alarm

parse_description()[source]

Replaces $TAG and $NAME in Alarm descriptions

static parse_formula(formula)[source]

Gets “TAG:formula#comment” and returns (tag,formula)

parse_severity()[source]

Replaces $TAG and $SEVERITY in Alarm severities

remove_receiver(receiver, write=True)[source]

Removes a receiver

rename(name)[source]

Renames the Alarm and writes in DB

replace_receiver(old, new, write=True)[source]

Replaces a receiver

reset(comment)[source]

Acknowledges and resets the Alarm in its PyAlarm device

set_severity(new_severity)[source]

Sets the severity of Alarm and writes in DB

setup(tag=None, device=None, formula=None, description=None, receivers=None, config=None, severity=None, write=False)[source]

Assigns values to Alarm struct

to_dict()[source]
to_str()[source]
write(device='', exclude='', update=True)[source]

Updates the Alarm config for the given device in the database :param: update controls whether the device.init() will be called or not, if not the alarm will not be applied yet

class panic.panic.AlarmAPI(filters='*', tango_host=None, logger=30)[source]

Bases: fandango.objects.SingletonMap

Panic API is a dictionary-like object

CSV_COLUMNS = ['tag', 'device', 'description', 'severity', 'receivers', 'formula']
CURRENT = None
GROUP_EXP = 'GROUP\\(((?:[ \'"])?[^)]*(?:[ \'"])?)\\)'
add(tag, device, formula='', description='', receivers='', severity='WARNING', load=True, config=None, overwrite=False)[source]

Adds a new Alarm to the database

edit_phonebook(tag, value, section='')[source]

Adds a person to the phonebook

evaluate(formula, device=None, timeout=1000, _locals=None)[source]
export_configurations(filename, regexp=None)[source]

Save devices property values to a .csv file

export_to_csv(filename, regexp=None, alarms=None, config=False, states=False)[source]

Saves the alarms currently loaded to a .csv file

export_to_dict(regexp=None, alarms=None, config=True, states=False)[source]
If config is True, the returned dictionary contains a double key:
  • data[‘alarms’][TAG] = {alarm config}
  • data[‘devices’] = {PyAlarm properties}
filter_alarms(regexp, alarms=None)[source]

Filter alarms by regular expression, use ! to negate the search

filter_hierarchy(rel, alarms=None)[source]

TOP are those alarms which state is evaluated using other Alarms values. BOTTOM are those alarms that have no alarms below or have a TOP alarm that depends from them.

filter_severity(sev, alarms=None)[source]
get(tag='', device='', attribute='', receiver='', severity='', alarms=None)[source]

Gets alarms matching the given filters (tag,device,attribute,receiver,severity)

get_admins_for_alarm(alarm='')[source]
get_basic_alarms()[source]

Children are those alarms that have no alarms below or have a higher alarm that depends from them.

get_class_property(klass, prop)[source]
get_configs(tag='*')[source]
get_db_properties(ref, props)[source]
get_db_property(ref, prop)[source]
get_ds_proxy(dev)[source]
get_global_receivers(tag='', renew=False)[source]
get_phonebook(load=True)[source]

gets the phonebook, returns a list

get_states(tag='', device='')[source]
group_macro(match)[source]

For usage details see:

https://github.com/tango-controls/PANIC/
blob/documentation/doc/recipes/AlarmsHierarchy.rst
has_tag(tag, raise_=False)[source]
items()[source]
keys()[source]
load(filters=None, exported=False)[source]

Reloads all alarm properties from the database :param filters: is used to specify which devices to be loaded

load_configurations(filename, regexp=None)[source]

Updates devices properties values from a .csv file

load_from_csv(filename, device=None, write=True)[source]
modify(tag, device, formula='', description='', receivers='', severity='WARNING', config=None, load=True)[source]

Modfies an Alarm in the database

parse_alarms(formula)[source]

Searches for alarm tags used in the formula

parse_attributes(formula, replace=True)[source]

Returns all tango attributes that appear in a formula

parse_phonebook(receivers)[source]

Replaces phonebook entries in a receivers list

The behavior of phonebook parsing is dependent on using ‘%’ to mark phonebook entries.

purge(device, tag, load=False)[source]

Removes any alarm from a device matching the given tag. Database must be reloaded afterwards to update the alarm list.

put_class_property(klass, prop, value)[source]
put_db_properties(ref, props)[source]
put_db_property(ref, prop, value)[source]
remove(tag, load=True)[source]

Removes an alarm from the system.

remove_phonebook(tag)[source]

Removes a person from the phonebook

rename(tag, new_tag='', new_device='', load=True)[source]

Renames an existing tag, it also allows to move to a new device.

replace_alarms(formula)[source]

Replaces alarm tags by its equivalent device/alarm attributes

save_phonebook(new_prop)[source]

Saves a new phonebook in the database

save_tag(tag)[source]

Shortcut to force alarm update in database

set_alarm_configuration(tag, device, config)[source]

This method is not operative yet, in the future will be used to do customized setups for each alarm.

split_formula(formula, keep_operators=False)[source]
start_servers(tag='', device='', host='')[source]

Starts Alarm Servers matching the filters

stop_servers(tag='', device='')[source]

Stops Alarm Servers matching the filters

update_servers(targets)[source]

Forces PyAlarm devices to reload selected alarms

values()[source]
class panic.panic.AlarmDS(name, api=None)[source]

Bases: object

This Class allows to manage the PyAlarm devices from the AlarmAPI

acknowledge(alarm, comment)[source]

Acknowledge of an active Alarm Returns True if there’s no more active alarms, else returns False

disable(tag=None, comment=None, timeout=None)[source]

If Tag is None this method disables the whole device

enable(tag=None)[source]

If Tag is None, this method will enable the whole device, but individual disables will be kept

get()[source]

Returns a device proxy

get_active_alarms()[source]

Returns the list of currently active alarms

get_alarm_properties()[source]

Method used in all panic classes

get_config(update=False)[source]
get_property(prop)[source]
init()[source]

forces the device to reload its configuration

ping()[source]
put_property(prop, value)[source]
read(filters='*')[source]

Updates from the database the Alarms related to this device

state()[source]

Returns device state

status()[source]

Returns device status

panic.panic.SetProxy = <bound method ProxiesDict.__setitem__ of defaultdict(<bound method ProxiesDict.__default_factory__ of defaultdict(..., {})>, {})>

The _proxies object allows to retrieve either DeviceProxy or DeviceServer objects.

  • GetProxy(a/dev/name) will return a DeviceProxy by default.
  • SetProxy(‘a/dev/name’,object) allows to set a different object to be returned (e.g. a device running in the same process)
panic.panic.api

alias of AlarmAPI

panic.panic.current()[source]
panic.panic.getAlarmDeviceProperties(device)[source]

Method used in all panic classes

panic.panic.getAlarmDeviceProperty(device, prop)[source]

Gets the value of pointed property from the device

panic.panic.getAttrValue(obj, default=None)[source]

Extracts rvalue in tango/taurus3/4 compatible way If default = True, obj is returned

panic.panic.main()[source]
panic.panic.setAlarmDeviceProperty(device, prop, value)[source]

Sets property of the device