diff --git a/ioc/singlesource.cpp b/ioc/singlesource.cpp index f881797..f7e87c4 100644 --- a/ioc/singlesource.cpp +++ b/ioc/singlesource.cpp @@ -85,6 +85,11 @@ void subscriptionValueCallback(void* userArg, struct dbChannel* pChannel, // ARCHIVE events will get the same data fields as VALUE if(change & DBE_ARCHIVE) change = (change&~DBE_ARCHIVE)|DBE_VALUE; + + // promote DBE_ALARM only to also fetch value + if((change & (DBE_VALUE|DBE_ARCHIVE|DBE_ALARM)) == DBE_ALARM) + change |= DBE_VALUE; + change &= UpdateType::Everything; // does not include DBE_ARCHIVE subscriptionCallback(subscriptionContext, UpdateType::type(change), pChannel, pDbFieldLog); } diff --git a/test/testqsingle.cpp b/test/testqsingle.cpp index e0ac64a..f07436f 100644 --- a/test/testqsingle.cpp +++ b/test/testqsingle.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -878,6 +879,46 @@ void testMonitorAIFilt(TestClient& ctxt) sub2.testEmpty(); } +void testMonitorDBEAlarm(TestClient& ctxt) +{ + testDiag("%s", __func__); + + auto prec(testdbRecordPtr("test:ai")); + { + ioc::DBLocker L(prec); + + prec->tpro = 50; // initial + prec->sevr = 0; + prec->stat = 0; + } + + TestSubscription sub(ctxt.monitor("test:ai.TPRO") + .record("DBE", DBE_ALARM) + .maskConnected(true) + .maskDisconnected(true)); + + auto val(sub.waitForUpdate()); + testShow()<<"Initial\n"<(), 50); + testEq(val["alarm.severity"].as(), 0); + + { + ioc::DBLocker L(prec); + + prec->tpro = 52; // event discarded + db_post_events(prec, &prec->tpro, DBE_VALUE); + prec->tpro = 53; + prec->sevr = MAJOR_ALARM; + prec->stat = READ_ALARM; + db_post_events(prec, &prec->tpro, DBE_VALUE|DBE_ALARM); + } + + val = sub.waitForUpdate(); + testShow()<<"Delta\n"<(), 53); + testEq(val["alarm.severity"].as(), 2); +} + void testMonitorDBE(TestClient& ctxt) { testDiag("%s", __func__); @@ -910,7 +951,7 @@ void testMonitorDBE(TestClient& ctxt) MAIN(testqsingle) { - testPlan(95); + testPlan(99); testSetup(); pvxs::logger_config_env(); generalTimeRegisterCurrentProvider("test", 1, &testTimeCurrent); @@ -953,6 +994,7 @@ MAIN(testqsingle) testMonitorAI(mctxt); testMonitorBO(mctxt); testMonitorAIFilt(mctxt); + testMonitorDBEAlarm(mctxt); testMonitorDBE(mctxt); } timeSim = false;