From 0e7a423e9c5a12cc7744acc99785c90afb8a73c9 Mon Sep 17 00:00:00 2001 From: Aqeel AlShafei Date: Thu, 25 Jun 2026 14:24:30 +0100 Subject: [PATCH 1/6] Modifiy pyRecord_setSevr to set sevr with a message using recGblSetSevrMsg --- devsupApp/src/dbrec.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/devsupApp/src/dbrec.c b/devsupApp/src/dbrec.c index 7802fe5..f686db3 100644 --- a/devsupApp/src/dbrec.c +++ b/devsupApp/src/dbrec.c @@ -125,10 +125,11 @@ static PyObject* pyRecord_setSevr(pyRecord *self, PyObject *args, PyObject *kws) { dbCommon *prec = self->entry.precnode->precord; - static char* names[] = {"sevr", "stat", NULL}; + static char* names[] = {"sevr", "stat", "message", NULL}; short sevr = INVALID_ALARM, stat=COMM_ALARM; + const char *message = NULL; - if(!PyArg_ParseTupleAndKeywords(args, kws, "|hh", names, &sevr, &stat)) + if(!PyArg_ParseTupleAndKeywords(args, kws, "|hhz", names, &sevr, &stat, &message)) return NULL; if(sevrlastEpicsAlarmSev @@ -137,7 +138,13 @@ static PyObject* pyRecord_setSevr(pyRecord *self, PyObject *args, PyObject *kws) PyErr_Format(PyExc_ValueError, "%s: Can't set alarms %d %d", prec->name, sevr, stat); return NULL; } - +// @since 7.0.6 +#ifdef HAS_ALARM_MESSAGE + if(message) { + recGblSetSevrMsg(prec, stat, sevr, "%s", message); + Py_RETURN_NONE; + } +#endif recGblSetSevr(prec, stat, sevr); Py_RETURN_NONE; } From 7e5f9a08bafcf1b563ad742d772d636790c5cb62 Mon Sep 17 00:00:00 2001 From: Aqeel AlShafei Date: Thu, 25 Jun 2026 14:43:26 +0100 Subject: [PATCH 2/6] Add unitest for TestAlarm with and without alarm message --- devsupApp/src/devsup/test/test_db.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/devsupApp/src/devsup/test/test_db.py b/devsupApp/src/devsup/test/test_db.py index 2dc33e0..30829ec 100644 --- a/devsupApp/src/devsup/test/test_db.py +++ b/devsupApp/src/devsup/test/test_db.py @@ -163,3 +163,27 @@ def test_increment(self): with rec: self.assertEqual(rec.VAL, 1) self.assertEqual(rec.UDF, 0) + + +class TestAlarm(IOCHelper): + db = """ + record(longin, "rec:alarm:msg") {} + record(longin, "rec:alarm:plain") {} + """ + + def test_set_severity_message(self): + rec = getRecord("rec:alarm:msg") + + with rec: + rec.setSevr(_dbapi.MAJOR_ALARM, _dbapi.HIHI_ALARM, message="Meaningful alarm message") + self.assertEqual(rec.NSEV, _dbapi.MAJOR_ALARM) + self.assertEqual(rec.NSTA, _dbapi.HIHI_ALARM) + self.assertEqual(rec.NAMSG, "Meaningful alarm message") + + def test_set_severity_without_message(self): + rec = getRecord("rec:alarm:plain") + + with rec: + rec.setSevr(_dbapi.MAJOR_ALARM, _dbapi.COMM_ALARM) + self.assertEqual(rec.NSEV, _dbapi.MAJOR_ALARM) + self.assertEqual(rec.NSTA, _dbapi.COMM_ALARM) From 7bb1cc09f1f3e842dff5465c9d61fa2c580db884 Mon Sep 17 00:00:00 2001 From: Aqeel AlShafei Date: Wed, 1 Jul 2026 11:25:11 +0100 Subject: [PATCH 3/6] Add a version check in the test_alarm unit test if epics is >= 7.0.6.0 --- devsupApp/src/devsup/test/test_db.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/devsupApp/src/devsup/test/test_db.py b/devsupApp/src/devsup/test/test_db.py index 30829ec..421a0b9 100644 --- a/devsupApp/src/devsup/test/test_db.py +++ b/devsupApp/src/devsup/test/test_db.py @@ -178,7 +178,8 @@ def test_set_severity_message(self): rec.setSevr(_dbapi.MAJOR_ALARM, _dbapi.HIHI_ALARM, message="Meaningful alarm message") self.assertEqual(rec.NSEV, _dbapi.MAJOR_ALARM) self.assertEqual(rec.NSTA, _dbapi.HIHI_ALARM) - self.assertEqual(rec.NAMSG, "Meaningful alarm message") + if _dbapi.epicsver[:4] >= (7, 0, 6, 0): + self.assertEqual(rec.NAMSG, "Meaningful alarm message") def test_set_severity_without_message(self): rec = getRecord("rec:alarm:plain") From a72afde99aa0b6cf864dc8db1cfaa298f76691b1 Mon Sep 17 00:00:00 2001 From: Aqeel AlShafei Date: Tue, 4 Aug 2026 11:16:34 +0100 Subject: [PATCH 4/6] Change message to amsg with update PyMethodDef documentation --- devsupApp/src/dbrec.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/devsupApp/src/dbrec.c b/devsupApp/src/dbrec.c index f686db3..5880c04 100644 --- a/devsupApp/src/dbrec.c +++ b/devsupApp/src/dbrec.c @@ -125,11 +125,11 @@ static PyObject* pyRecord_setSevr(pyRecord *self, PyObject *args, PyObject *kws) { dbCommon *prec = self->entry.precnode->precord; - static char* names[] = {"sevr", "stat", "message", NULL}; + static char* names[] = {"sevr", "stat", "amsg", NULL}; short sevr = INVALID_ALARM, stat=COMM_ALARM; - const char *message = NULL; + const char *amsg = NULL; - if(!PyArg_ParseTupleAndKeywords(args, kws, "|hhz", names, &sevr, &stat, &message)) + if(!PyArg_ParseTupleAndKeywords(args, kws, "|hhz", names, &sevr, &stat, &amsg)) return NULL; if(sevrlastEpicsAlarmSev @@ -140,8 +140,8 @@ static PyObject* pyRecord_setSevr(pyRecord *self, PyObject *args, PyObject *kws) } // @since 7.0.6 #ifdef HAS_ALARM_MESSAGE - if(message) { - recGblSetSevrMsg(prec, stat, sevr, "%s", message); + if(amsg) { + recGblSetSevrMsg(prec, stat, sevr, "%s", amsg); Py_RETURN_NONE; } #endif @@ -324,8 +324,9 @@ static PyMethodDef pyRecord_methods[] = { "infos() -> {'name':'value'}\n" "Return a dictionary of all infos for this record."}, {"setSevr", (PyCFunction)pyRecord_setSevr, METH_VARARGS|METH_KEYWORDS, - "setSevr(sevr=INVALID_ALARM, stat=COMM_ALARM)\n" - "Set alarm new alarm severity/status. Record must be locked!"}, + "setSevr(sevr=INVALID_ALARM, stat=COMM_ALARM, amsg=Nome)\n" + "Set alarm new alarm severity/status. Record must be locked!\n" + "amsg requires EPICS Base >= 7.0.6."}, {"setTime", (PyCFunction)pyRecord_setTime, METH_VARARGS, "Set record timestamp if TSE==-2. Record must be locked!"}, {"scan", (PyCFunction)pyRecord_scan, METH_VARARGS|METH_KEYWORDS, From 9c9dfe1e3ea4873e16500ef005d2a5af54f677b3 Mon Sep 17 00:00:00 2001 From: Aqeel AlShafei Date: Tue, 4 Aug 2026 11:16:56 +0100 Subject: [PATCH 5/6] Update TestAalrm test to use amsg instead of message --- devsupApp/src/devsup/test/test_db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devsupApp/src/devsup/test/test_db.py b/devsupApp/src/devsup/test/test_db.py index 421a0b9..2c7ea52 100644 --- a/devsupApp/src/devsup/test/test_db.py +++ b/devsupApp/src/devsup/test/test_db.py @@ -175,7 +175,7 @@ def test_set_severity_message(self): rec = getRecord("rec:alarm:msg") with rec: - rec.setSevr(_dbapi.MAJOR_ALARM, _dbapi.HIHI_ALARM, message="Meaningful alarm message") + rec.setSevr(_dbapi.MAJOR_ALARM, _dbapi.HIHI_ALARM, amsg="Meaningful alarm message") self.assertEqual(rec.NSEV, _dbapi.MAJOR_ALARM) self.assertEqual(rec.NSTA, _dbapi.HIHI_ALARM) if _dbapi.epicsver[:4] >= (7, 0, 6, 0): From 2dd622011009670a7d1803f83df365c492f50a89 Mon Sep 17 00:00:00 2001 From: Aqeel AlShafei Date: Thu, 6 Aug 2026 22:53:47 +0100 Subject: [PATCH 6/6] Fix typo in PyMethodDef --- devsupApp/src/dbrec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devsupApp/src/dbrec.c b/devsupApp/src/dbrec.c index 5880c04..a35b544 100644 --- a/devsupApp/src/dbrec.c +++ b/devsupApp/src/dbrec.c @@ -324,7 +324,7 @@ static PyMethodDef pyRecord_methods[] = { "infos() -> {'name':'value'}\n" "Return a dictionary of all infos for this record."}, {"setSevr", (PyCFunction)pyRecord_setSevr, METH_VARARGS|METH_KEYWORDS, - "setSevr(sevr=INVALID_ALARM, stat=COMM_ALARM, amsg=Nome)\n" + "setSevr(sevr=INVALID_ALARM, stat=COMM_ALARM, amsg=None)\n" "Set alarm new alarm severity/status. Record must be locked!\n" "amsg requires EPICS Base >= 7.0.6."}, {"setTime", (PyCFunction)pyRecord_setTime, METH_VARARGS,