From 939ae5a11e7df7c30e71350edd86d0f06a0176c2 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sun, 14 Apr 2013 09:15:04 -0400 Subject: [PATCH] wrapper recGblSetSevr --- devsupApp/src/dbrec.c | 25 +++++++++++++++++++++++++ python/devsup/_nullapi.py | 6 ++++++ 2 files changed, 31 insertions(+) diff --git a/devsupApp/src/dbrec.c b/devsupApp/src/dbrec.c index 17e8ad3..2148993 100644 --- a/devsupApp/src/dbrec.c +++ b/devsupApp/src/dbrec.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include "pydevsup.h" @@ -135,6 +137,27 @@ fail: return NULL; } +static PyObject* pyRecord_setSevr(pyRecord *self, PyObject *args, PyObject *kws) +{ + dbCommon *prec = self->entry.precnode->precord; + + static char* names[] = {"sevr", "stat", NULL}; + short sevr = INVALID_ALARM, stat=COMM_ALARM; + + if(!PyArg_ParseTupleAndKeywords(args, kws, "|hh", names, &sevr, &stat)) + return NULL; + + if(sevrlastEpicsAlarmSev + || statlastEpicsAlarmCond) + { + PyErr_Format(PyExc_ValueError, "%s: Can't set alarms %d %d", prec->name, sevr, stat); + return NULL; + } + + recGblSetSevr(prec, sevr, stat); + Py_RETURN_NONE; +} + static PyObject* pyRecord_scan(pyRecord *self, PyObject *args, PyObject *kws) { dbCommon *prec = self->entry.precnode->precord; @@ -249,6 +272,8 @@ static PyMethodDef pyRecord_methods[] = { "Lookup info name\ninfo(name, def=None)"}, {"infos", (PyCFunction)pyRecord_infos, METH_NOARGS, "Return a dictionary of all infos for this record."}, + {"setSevr", (PyCFunction)pyRecord_setSevr, METH_VARARGS|METH_KEYWORDS, + "Set alarm new alarm severity/status Record must be locked!"}, {"scan", (PyCFunction)pyRecord_scan, METH_VARARGS|METH_KEYWORDS, "scan(sync=False)\nScan this record. If sync is False then" "a scan request is queued. If sync is True then the record" diff --git a/python/devsup/_nullapi.py b/python/devsup/_nullapi.py index 17a9419..eae5bda 100644 --- a/python/devsup/_nullapi.py +++ b/python/devsup/_nullapi.py @@ -46,6 +46,12 @@ class _Record(object): for this record """ + def setSevr(self, sevr=3, stat=15): + """setSevr(sevr=INVALID, stat=COMM) + + Set new alarm condition. + """ + def scan(self, sync=False, reason=None, force=0): """Scan this record.