1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 <2021> 2022 2023 2024 2025 | Index | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 <2021> 2022 2023 2024 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: Problems configuring alarms with PvaPy |
From: | "Veseli, Sinisa via Tech-talk" <tech-talk at aps.anl.gov> |
To: | "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>, KRL Baker - STFC UKRI <k.baker at stfc.ac.uk> |
Date: | Mon, 7 Jun 2021 17:48:22 +0000 |
Hi,
At the moment there is no automated handling of alarm values. You would have to do something like this (compared to your original code example):
bluegill2> diff s.py s.py.orig
48c48
< server.addRecord('counter', pv.copy())
---
> server.addRecord('counter', pv)
57,66d56
< (severity, status, message) = (0, 0, 'ALL CLEAR')
< if c >= pv['alarm_values.highAlarmLimit']:
< (severity, status, message) = (pv['alarm_values.highAlarmSeverity'], 1, 'HIGH ALARM')
< elif c >= pv['alarm_values.highWarningLimit']:
< (severity, status, message) = (pv['alarm_values.highWarningSeverity'], 1, 'HIGH WARNING')
< elif c <= pv['alarm_values.lowAlarmLimit']:
< (severity, status, message) = (pv['alarm_values.lowAlarmSeverity'], 1, 'LOW ALARM')
< elif c <= pv['alarm_values.lowWarningLimit']:
< (severity, status, message) = (pv['alarm_values.lowWarningSeverity'], 1, 'LOW WARNING')
<
72,76d61
< },
< 'alarm' : {
< 'severity' : severity,
< 'status' : status,
< 'message' : message
80d64
< server.update(pv)
bluegill2>
I will add better alarm handling in the next release.
I hope this helps,
Sinisa
--
Siniša Veseli
Scientific Software Engineering & Data Management
Advanced Photon Source
Argonne National Laboratory
sveseli at anl.gov
(630)252-9182From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of KRL Baker - STFC UKRI via Tech-talk <tech-talk at aps.anl.gov>
Sent: Monday, June 7, 2021 8:20 AM To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov> Subject: Problems configuring alarms with PvaPy Hello Tech-Talk,
I am working with PvaPy to create and update some PVs and am trying to work out how to configure the alarms for the pv.
I have created the object using the code below, which creates the ‘counter’ pv and updates the values (which I can see with a pvmonitor or a pvinfo).
initial_time = time.time() seconds, nanoseconds = extract_seconds_and_nanoseconds_from_timestamp(initial_time) timestamp = PvTimeStamp(seconds, nanoseconds, 0)
# configure display values display = PvDisplay(0, 10, 'Test Display', 'Test Format', 'units')
# set up alarm - severity (0=NO_ALARM, 1=MINOR, 2=MAJOR, 3=INVALID, 4=UNDEFINED), status, message alarm = PvAlarm() alarm.setSeverity(0) alarm.setMessage('test alarm message')
alarm_values = PvValueAlarm(FLOAT)
alarm_values.setHighAlarmLimit(9) alarm_values.setLowAlarmLimit(2) alarm_values.setHighWarningLimit(8) alarm_values.setLowWarningLimit(3)
alarm_values.setHighAlarmSeverity(2) alarm_values.setLowAlarmSeverity(2) alarm_values.setHighWarningSeverity(1) alarm_values.setLowWarningSeverity(1) alarm_values.setActive(True)
pv = PvObject({ 'value': FLOAT, 'timeStamp': timestamp, 'display': display, 'alarm': alarm, 'alarm_values': alarm_values }, { 'timeStamp': timestamp.toDict(), 'display': display.toDict(), 'alarm': alarm.toDict(), 'alarm_values': alarm_values.toDict() })
server = PvaServer() server.addRecord('counter', pv) c = 0 startTime = time.time() try: while True: time.sleep(1) if c == 11: c = 0 seconds, nanoseconds = extract_seconds_and_nanoseconds_from_timestamp(time.time()) epics_message = { 'value': c, 'timeStamp': { 'secondsPastEpoch': seconds, 'nanoseconds': nanoseconds } } pv.set(epics_message) c += 0.5 finally: server.stop()
This creates a PV with the following structure: float value 10.5 time_t timeStamp 2021-06-07 13:31:45.733 long secondsPastEpoch 1623069105 int nanoseconds 732768297 int userTag 0 display_t display double limitLow 0 double limitHigh 10 string description "Test Display" string format "Test Format" string units units alarm_t alarm int severity 0 int status 0 string message "test alarm message" valueAlarm_t alarm_values boolean active true float lowAlarmLimit 2 float lowWarningLimit 3 float highWarningLimit 8 float highAlarmLimit 9 int lowAlarmSeverity 2 int lowWarningSeverity 1 int highWarningSeverity 1 int highAlarmSeverity 2 byte hysteresis 0
As you can hopefully see from the code, I have set up the alarms with severity 0 (NO_ALARM) to begin with and set the severity of the warnings and limits to be MINOR and MAJOR (2 and 3).
However, using this set-up I would expect to see the alarm messages raised when the value of the PV approaches 0 or 10, but no alarm messages are displayed. The only time I am able to see messages is if I set the severity of the alarm object to be something other than 0, but this then raises alarm messages for all value states which is not the desired behaviour.
Is there something that I’m missing in the configuration of the alarms? Is there something that I need to set to ‘activate’ the logic behind the alarms?
Kathryn Baker (she/her) Software Development for Accelerator Control Systems Graduate Science and Technology Facilities Council k.baker at stfc.ac.uk
This email and any attachments are intended solely for the use of the named recipients. If you are not the intended recipient you must not use, disclose, copy or distribute this email or any of its attachments and should notify the sender immediately and delete this email from your system. UK Research and Innovation (UKRI) has taken every reasonable precaution to minimise risk of this email or any attachments containing viruses or malware but the recipient should carry out its own virus and malware checks before opening the attachments. UKRI does not accept any liability for any losses or damages which the recipient may sustain due to presence of any viruses. Opinions, conclusions or other information in this message and attachments that are not related directly to UKRI business are solely those of the author and do not represent the views of UKRI. |