Experimental Physics and
| |||||||||||||||||
|
Andrew, thanks very much for that suggestion. I modified the sub record as follows and it seems to work:
record(“MY_PV_sub”)
{
field(SDIS, "MY_PV.SEVR")
field(DISV, "0")
field(INPA, “MY_PV”)
field(SNAM, “MY_PV_subroutine”)
}
This prevents the subroutine from being called when the Severity is zero - which is a significant improvement - but if the PV value bounces around while in the HIHI range (for example), the subroutine is called each time. What I was hoping for is a setup
which calls the subroutine only once when an alarm state is entered, and isn't called again until the alarm state is exited/re-entered. For example, perhaps the subroutine, when called, could examine the current severity level and change the DISV value on
the fly to a different severity level…but that might be a pretty ugly way to do it. Do you have any thoughts?
Thanks again,
Mark
-----Original Message-----
From: Andrew Johnson [mailto:[email protected]] Sent: Monday, July 28, 2014 12:14 PM To: Poff, Mark A; [email protected] Subject: Re: Subroutine invoked only when PV limit exceeded? Hi Mark,
On 07/28/2014 10:18 AM, Poff, Mark A wrote:
> In my EPICS database, for certain PVs I use forward links and sub
> records such that, whenever the PV value changes, a subroutine is
> called. It’s a pretty basic implementation:
>
> record(longin, “MY_PV”)
> {
> field(SCAN, “Passive”)
> field(HIHI, “30”)
> field(HHSV, “MAJOR”)
> field(FLNK, “MY_PV_sub”)
> }
>
> record(“MY_PV_sub”)
> {
> field(INPA, “MY_PV”)
> field(SNAM, “MY_PV_subroutine”)
> }
>
> What I’d like to do additionally (or /_instead_/) is to call a
> subroutine only when MY_PV goes to the HIHI alarm state (in the
> example above, when the value of MY_PV goes from less than 30 to 30 or
> greater). I assumed it could be done by somehow looking at
> MY_PV.SEVR, but I can’t figure out how to do it. Is it possible to
> define the database records so that a subroutine is executed only when
> the associated PV goes into an alarm state?
You can use the SDIS link and DISV field of your MY_PV_sub record to do part of that, see https://wiki-ext.aps.anl.gov/epics/index.php/RRM_3-14_dbCommon#Scan_Fields
for a brief description, but you'll only be able to disable the subroutine on one of the alarm state/severity values (I might do that on MY_PV.SEVR == 0). However your subroutine can read the alarm status and severity through the existing INPA link and
act accordingly. The code you need would look something like this:
#include "dbAccessDefs.h"
#include "menuAlarmStat.h"
long MY_PV_subroutine(subRecord *prec)
epicsEnum16 stat, sevr;
if (dbGetAlarm(&prec->inpa, &stat, &sevr)) {
/* Handle link problem ... */
}
switch (stat) {
case menuAlarmStatHIHI:
/* ... */
break;
case menuAlarmStatHIGH:
/* ... */
break;
}
/* ... */
}
HTH,
- Andrew
--
Advertising may be described as the science of arresting the human intelligence long enough to get money from it. -- Stephen Leacock
| ||||||||||||||||
ANJ, 17 Dec 2015 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |