From b5024df8fd7b05bc94b9fa8d1fbb7f1e0a9e2972 Mon Sep 17 00:00:00 2001 From: Ivan Finch Date: Tue, 30 Jun 2026 13:47:09 +0100 Subject: [PATCH] ioc: fix timestamp masking for monitor subscriptions --- ioc/singlesource.cpp | 3 +-- test/testqsingle.cpp | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ioc/singlesource.cpp b/ioc/singlesource.cpp index 024f676..28c0366 100644 --- a/ioc/singlesource.cpp +++ b/ioc/singlesource.cpp @@ -55,8 +55,7 @@ void subscriptionCallback(SingleSourceSubscriptionCtx* subscriptionContext, { DBLocker F(dbChannelRecord(subscriptionContext->info->chan)); - // TODO MappingInfo::nsecMask - IOCSource::get(currentValue, MappingInfo(), Value(), change, pChannel, pDbFieldLog); + IOCSource::get(currentValue, *subscriptionContext->info, Value(), change, pChannel, pDbFieldLog); } // Make sure that the initial subscription update has occurred on both channels before continuing diff --git a/test/testqsingle.cpp b/test/testqsingle.cpp index 04c060a..c971227 100644 --- a/test/testqsingle.cpp +++ b/test/testqsingle.cpp @@ -1009,6 +1009,25 @@ void testMonitorDBE(TestClient& ctxt) testEq(val["value"].as(), 43); } +void testMonitorNsecMask(TestClient& ctxt) +{ + testDiag("%s", __func__); + + TestSubscription sub(ctxt.monitor("test:nsec") + .maskConnected(true) + .maskDisconnected(true)); + + auto val(sub.waitForUpdate()); + + // nsec:lsb:8 clears the low 8 bits: 102030 -> 101888, userTag -> 142 + testFldEq(val, "timeStamp.nanoseconds", int32_t(101888)); +#if DBR_UTAG + testFldEq(val, "timeStamp.userTag", int32_t(142)); +#else + testSkip(1, "no UTAG"); +#endif +} + void testiocsh(TestClient& ctxt) { testDiag("%s", __func__); @@ -1061,7 +1080,7 @@ void testiocsh(TestClient& ctxt) MAIN(testqsingle) { - testPlan(116); + testPlan(118); testSetup(); pvxs::logger_config_env(); generalTimeRegisterCurrentProvider("test", 1, &testTimeCurrent); @@ -1106,6 +1125,7 @@ MAIN(testqsingle) testMonitorAIFilt(mctxt); testMonitorDBEAlarm(mctxt); testMonitorDBE(mctxt); + testMonitorNsecMask(mctxt); testiocsh(mctxt); } timeSim = false;