EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: Subroutine invoked only when PV limit exceeded?
From: "Poff, Mark A" <[email protected]>
To: Andrew Johnson <[email protected]>, "[email protected]" <[email protected]>
Cc: "Poff, Mark A" <[email protected]>
Date: Mon, 28 Jul 2014 18:01:30 +0000
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
 

Replies:
Re: Subroutine invoked only when PV limit exceeded? Andrew Johnson
References:
Subroutine invoked only when PV limit exceeded? Poff, Mark A
Re: Subroutine invoked only when PV limit exceeded? Andrew Johnson

Navigate by Date:
Prev: Installing Pydev plugin for Control System Studio Derek Foster
Next: Re: Subroutine invoked only when PV limit exceeded? Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Subroutine invoked only when PV limit exceeded? Andrew Johnson
Next: Re: Subroutine invoked only when PV limit exceeded? Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 17 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·