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? Poff, Mark A
- References:
- Subroutine invoked only when PV limit exceeded? Poff, Mark A
- Navigate by Date:
- Prev:
Subroutine invoked only when PV limit exceeded? Poff, Mark A
- Next:
Installing Pydev plugin for Control System Studio Derek Foster
- 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
- Navigate by Thread:
- Prev:
Subroutine invoked only when PV limit exceeded? Poff, Mark A
- Next:
RE: Subroutine invoked only when PV limit exceeded? Poff, Mark A
- 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
|