From a06c2ea69c3ee13452dc8502ad44e2de55a8ea47 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 3 Sep 2021 07:32:49 -0700 Subject: [PATCH 1/8] Change function name propEventCB to propDataCB --- src/gatePv.cc | 20 ++++++++++---------- src/gatePv.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gatePv.cc b/src/gatePv.cc index d9b5322..e047b02 100644 --- a/src/gatePv.cc +++ b/src/gatePv.cc @@ -96,8 +96,8 @@ extern "C" { extern void logEventCB(EVENT_ARGS args) { // log event callback gatePvData::logEventCB(args); } - extern void propEventCB(EVENT_ARGS args) { // prop event callback - gatePvData::propEventCB(args); + extern void propDataCB(EVENT_ARGS args) { // prop event callback + gatePvData::propDataCB(args); } } @@ -857,7 +857,7 @@ int gatePvData::propMonitor(void) if(ca_read_access(chID)) { gateDebug1(5,"gatePvData::propMonitor() type=%ld\n",dataType()); rc=ca_create_subscription(dataType(),0,chID,DBE_PROPERTY, - ::propEventCB,this,&propID); + ::propDataCB,this,&propID); if(rc != ECA_NORMAL) { fprintf(stderr,"%s gatePvData::propMonitor: " "ca_create_subscription failed for %s:\n" @@ -1531,10 +1531,10 @@ void gatePvData::logEventCB(EVENT_ARGS args) } } -void gatePvData::propEventCB(EVENT_ARGS args) +void gatePvData::propDataCB(EVENT_ARGS args) { gatePvData* pv=(gatePvData*)ca_puser(args.chid); - gateDebug3(5,"gatePvData::propEventCB(gatePvData=%p)(gateVCData=%p) type=%d\n", + gateDebug3(5,"gatePvData::propDataCB(gatePvData=%p)(gateVCData=%p) type=%d\n", (void *)pv, (void*)pv->vc, (unsigned int)args.type); gdd* dd; @@ -1543,14 +1543,14 @@ void gatePvData::propEventCB(EVENT_ARGS args) #endif #if DEBUG_BEAM - printf("gatePvData::propEventCB(): status=%d %s\n", + printf("gatePvData::propDataCB(): status=%d %s\n", args.status, pv->name()); #endif #if DEBUG_DELAY if(!strncmp("Xorbit",pv->name(),6)) { - printf("%s gatePvData::propEventCB: %s state=%d\n",timeStamp(),pv->name(), + printf("%s gatePvData::propDataCB: %s state=%d\n",timeStamp(),pv->name(), pv->getState()); } #endif @@ -1560,9 +1560,9 @@ void gatePvData::propEventCB(EVENT_ARGS args) // only sends event_data and does ADD transactions if(pv->active()) { - gateDebug3(5,"gatePvData::propEventCB() %s PV %s propGetPending %d\n",pv->getStateName(),pv->name(),pv->propGetPending()); + gateDebug3(5,"gatePvData::propDataCB() %s PV %s propGetPending %d\n",pv->getStateName(),pv->name(),pv->propGetPending()); if(pv->propGetPending()) { - gateDebug1(5,"gatePvData::propEventCB() Ignore first propEvent %s PV\n",pv->getStateName()); + gateDebug1(5,"gatePvData::propDataCB() Ignore first propEvent %s PV\n",pv->getStateName()); pv->markPropNoGetPending(); return; } @@ -1597,7 +1597,7 @@ void gatePvData::propEventCB(EVENT_ARGS args) if (pv->needAddRemove()) { - gateDebug0(5,"gatePvData::propEventCB() need add/remove\n"); + gateDebug0(5,"gatePvData::propDataCB() need add/remove\n"); pv->markAddRemoveNotNeeded(); pv->vc->vcAdd(ctrlType); } diff --git a/src/gatePv.h b/src/gatePv.h index 5472abd..dcdf047 100644 --- a/src/gatePv.h +++ b/src/gatePv.h @@ -305,7 +305,7 @@ class gatePvData static void accessCB(ACCESS_ARGS args); // access security callback static void eventCB(EVENT_ARGS args); // value-changed callback static void logEventCB(EVENT_ARGS args); // value-changed callback - static void propEventCB(EVENT_ARGS args); // value-changed callback + static void propDataCB(EVENT_ARGS args); // DBE_PROPERTY data-changed callback static void alhCB(EVENT_ARGS args); // alh info value-changed callback static void putCB(EVENT_ARGS args); // put callback static void getCB(EVENT_ARGS args); // get callback From 3b4fc2ec7ebf9d8dea63c0e449c96d770f53e24e Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 3 Sep 2021 18:34:09 -0700 Subject: [PATCH 2/8] Add a dbr_time subscription w/ new propEventCB() handler. --- src/gatePv.cc | 60 +++++++++++++++++++++++++++++++++++++++++---------- src/gatePv.h | 1 + 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/gatePv.cc b/src/gatePv.cc index e047b02..5b43cbf 100644 --- a/src/gatePv.cc +++ b/src/gatePv.cc @@ -96,9 +96,12 @@ extern "C" { extern void logEventCB(EVENT_ARGS args) { // log event callback gatePvData::logEventCB(args); } - extern void propDataCB(EVENT_ARGS args) { // prop event callback - gatePvData::propDataCB(args); - } + extern void propDataCB(EVENT_ARGS args) { // prop data event callback + gatePvData::propDataCB(args); + } + extern void propEventCB(EVENT_ARGS args) { // prop value event callback + gatePvData::propEventCB(args); + } } // quick access to global_resources @@ -855,7 +858,8 @@ int gatePvData::propMonitor(void) // gets native element count number of elements: if(ca_read_access(chID)) { - gateDebug1(5,"gatePvData::propMonitor() type=%ld\n",dataType()); + // DBE_PROPERTY data subscription + gateDebug1(5,"gatePvData::propMonitor() dataType=%ld\n",dataType()); rc=ca_create_subscription(dataType(),0,chID,DBE_PROPERTY, ::propDataCB,this,&propID); if(rc != ECA_NORMAL) { @@ -864,8 +868,21 @@ int gatePvData::propMonitor(void) " %s\n", timeStamp(),name()?name():"Unknown",ca_message(rc)); rc=-1; - } else { - rc=0; + } + + // DBE_PROPERTY event subscription + gateDebug1(5,"gatePvData::propMonitor() eventType=%ld\n",eventType()); + rc=ca_create_subscription(eventType(),0,chID,DBE_PROPERTY, + ::propEventCB,this,&propID); + if(rc != ECA_NORMAL) { + fprintf(stderr,"%s gatePvData::propMonitor: " + "ca_create_subscription event failed for %s:\n" + " %s\n", + timeStamp(),name()?name():"Unknown",ca_message(rc)); + rc=-1; + } + + if(rc==0) { markPropMonitored(); #if OMIT_CHECK_EVENT #else @@ -1580,12 +1597,33 @@ void gatePvData::propDataCB(EVENT_ARGS args) #endif pv->vc->setPvData(dd); } + } + ++(pv->event_count); + } +} - gateDebug2(4,"gatePvData::propEventCB() %s PV %s runValueDataCB\n",pv->getStateName(),pv->name()); - if ((dd = pv->runValueDataCB(&args))) // Create the value gdd +void gatePvData::propEventCB(EVENT_ARGS args) +{ + gatePvData* pv=(gatePvData*)ca_puser(args.chid); + gateDebug3(5,"gatePvData::propEventCB(gatePvData=%p)(gateVCData=%p) type=%d\n", + (void *)pv, (void*)pv->vc, (unsigned int)args.type); + gdd* dd; + +#ifdef RATE_STATS + ++pv->mrg->client_event_count; +#endif + + if(args.status==ECA_NORMAL) + { + // only sends event_data and does ADD transactions + if(pv->active()) + { + gateDebug2(4,"gatePvData::propEventCB() %s PV %s runEventCB\n",pv->getStateName(),pv->name()); + if ((dd = pv->runEventCB(&args))) // Create the value gdd { -#if DEBUG_BEAM - printf(" dd=%p needAddRemove=%d\n", dd, pv->needAddRemove()); + gateDebug2(3,"gatePvData::propEventCB() %s PV %s setEventData\n",pv->getStateName(),pv->name()); +#if DEBUG_ENUM + dumpdd(1, "gatePvData::propEventCB setEventData", pv->name(), dd); #endif gateDebug2(3,"gatePvData::propEventCB() %s PV %s setEventData\n",pv->getStateName(),pv->name()); #if DEBUG_ENUM @@ -1597,7 +1635,7 @@ void gatePvData::propDataCB(EVENT_ARGS args) if (pv->needAddRemove()) { - gateDebug0(5,"gatePvData::propDataCB() need add/remove\n"); + gateDebug0(5,"gatePvData::propEventCB() need add/remove\n"); pv->markAddRemoveNotNeeded(); pv->vc->vcAdd(ctrlType); } diff --git a/src/gatePv.h b/src/gatePv.h index dcdf047..1388ff0 100644 --- a/src/gatePv.h +++ b/src/gatePv.h @@ -306,6 +306,7 @@ class gatePvData static void eventCB(EVENT_ARGS args); // value-changed callback static void logEventCB(EVENT_ARGS args); // value-changed callback static void propDataCB(EVENT_ARGS args); // DBE_PROPERTY data-changed callback + static void propEventCB(EVENT_ARGS args); // DBE_PROPERTY value-changed callback static void alhCB(EVENT_ARGS args); // alh info value-changed callback static void putCB(EVENT_ARGS args); // put callback static void getCB(EVENT_ARGS args); // get callback From 4968d6e0cd4b3d78e7af3d9809cbe70975e2e465 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 13 May 2022 02:15:12 -0700 Subject: [PATCH 3/8] Fix whitespace --- src/gatePv.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gatePv.h b/src/gatePv.h index 1388ff0..86407b0 100644 --- a/src/gatePv.h +++ b/src/gatePv.h @@ -305,8 +305,8 @@ class gatePvData static void accessCB(ACCESS_ARGS args); // access security callback static void eventCB(EVENT_ARGS args); // value-changed callback static void logEventCB(EVENT_ARGS args); // value-changed callback - static void propDataCB(EVENT_ARGS args); // DBE_PROPERTY data-changed callback - static void propEventCB(EVENT_ARGS args); // DBE_PROPERTY value-changed callback + static void propDataCB(EVENT_ARGS args); // DBE_PROPERTY data-changed callback + static void propEventCB(EVENT_ARGS args); // DBE_PROPERTY value-changed callback static void alhCB(EVENT_ARGS args); // alh info value-changed callback static void putCB(EVENT_ARGS args); // put callback static void getCB(EVENT_ARGS args); // get callback From bcb04d8e69f932d53ff97c5c8dba5e19aa6700d9 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 24 May 2022 16:33:12 -0700 Subject: [PATCH 4/8] Fix some function names in gateDebug and dumpdd diag stmts --- src/gatePv.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gatePv.cc b/src/gatePv.cc index 5b43cbf..f54e731 100644 --- a/src/gatePv.cc +++ b/src/gatePv.cc @@ -1584,16 +1584,16 @@ void gatePvData::propDataCB(EVENT_ARGS args) return; } - gateDebug1(3,"gatePvData::propEventCB() %s PV runDataCB\n",pv->getStateName()); + gateDebug1(3,"gatePvData::propDataCB() %s PV runDataCB\n",pv->getStateName()); if ((dd = pv->runDataCB(&args))) // Create the attributes gdd { #if DEBUG_BEAM printf(" dd=%p needAddRemove=%d\n", dd, pv->needAddRemove()); #endif // Update attribute cache - gateDebug2(3,"gatePvData::propEventCB() %s PV %s setPvData\n",pv->getStateName(),pv->name()); + gateDebug2(3,"gatePvData::propDataCB() %s PV %s setPvData\n",pv->getStateName(),pv->name()); #if DEBUG_ENUM - dumpdd(1, "gatePvData::propEventCB setPvData", pv->name(), dd); + dumpdd(1, "gatePvData::propDataCB setPvData", pv->name(), dd); #endif pv->vc->setPvData(dd); } From 12002c97a6c650b53bee6c74b92ee5ad346af13f Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 24 May 2022 16:36:25 -0700 Subject: [PATCH 5/8] Swap order of gatePvData::propEventCB() and gatePvData::propDataCB() in file. This isn't really necessary, but it makes for a cleaner visual diff against the github master branch. --- src/gatePv.cc | 96 +++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/src/gatePv.cc b/src/gatePv.cc index f54e731..c34a7c0 100644 --- a/src/gatePv.cc +++ b/src/gatePv.cc @@ -1548,6 +1548,54 @@ void gatePvData::logEventCB(EVENT_ARGS args) } } +void gatePvData::propEventCB(EVENT_ARGS args) +{ + gatePvData* pv=(gatePvData*)ca_puser(args.chid); + gateDebug3(5,"gatePvData::propEventCB(gatePvData=%p)(gateVCData=%p) type=%d\n", + (void *)pv, (void*)pv->vc, (unsigned int)args.type); + gdd* dd; + +#ifdef RATE_STATS + ++pv->mrg->client_event_count; +#endif + + if(args.status==ECA_NORMAL) + { + // only sends event_data and does ADD transactions + if(pv->active()) + { + gateDebug2(4,"gatePvData::propEventCB() %s PV %s runEventCB\n",pv->getStateName(),pv->name()); + if ((dd = pv->runEventCB(&args))) // Create the value gdd + { + gateDebug2(3,"gatePvData::propEventCB() %s PV %s setEventData\n",pv->getStateName(),pv->name()); +#if DEBUG_ENUM + dumpdd(1, "gatePvData::propEventCB setEventData", pv->name(), dd); +#endif + gateDebug2(3,"gatePvData::propEventCB() %s PV %s setEventData\n",pv->getStateName(),pv->name()); +#if DEBUG_ENUM + dumpdd(1, "gatePvData::propEventCB setEventData", pv->name(), dd); +#endif + // This dd will have an undefined timeStamp as it comes + // from a dbr_ctrl_* structure + pv->vc->setEventData(dd); // Create new setPropData()??? + + if (pv->needAddRemove()) + { + gateDebug0(5,"gatePvData::propEventCB() need add/remove\n"); + pv->markAddRemoveNotNeeded(); + pv->vc->vcAdd(ctrlType); + } + else + { + // Post the event + pv->vc->vcPostEvent(pv->mrg->propertyEventMask()); + } + } + } + ++(pv->event_count); + } +} + void gatePvData::propDataCB(EVENT_ARGS args) { gatePvData* pv=(gatePvData*)ca_puser(args.chid); @@ -1602,54 +1650,6 @@ void gatePvData::propDataCB(EVENT_ARGS args) } } -void gatePvData::propEventCB(EVENT_ARGS args) -{ - gatePvData* pv=(gatePvData*)ca_puser(args.chid); - gateDebug3(5,"gatePvData::propEventCB(gatePvData=%p)(gateVCData=%p) type=%d\n", - (void *)pv, (void*)pv->vc, (unsigned int)args.type); - gdd* dd; - -#ifdef RATE_STATS - ++pv->mrg->client_event_count; -#endif - - if(args.status==ECA_NORMAL) - { - // only sends event_data and does ADD transactions - if(pv->active()) - { - gateDebug2(4,"gatePvData::propEventCB() %s PV %s runEventCB\n",pv->getStateName(),pv->name()); - if ((dd = pv->runEventCB(&args))) // Create the value gdd - { - gateDebug2(3,"gatePvData::propEventCB() %s PV %s setEventData\n",pv->getStateName(),pv->name()); -#if DEBUG_ENUM - dumpdd(1, "gatePvData::propEventCB setEventData", pv->name(), dd); -#endif - gateDebug2(3,"gatePvData::propEventCB() %s PV %s setEventData\n",pv->getStateName(),pv->name()); -#if DEBUG_ENUM - dumpdd(1, "gatePvData::propEventCB setEventData", pv->name(), dd); -#endif - // This dd will have an undefined timeStamp as it comes - // from a dbr_ctrl_* structure - pv->vc->setEventData(dd); // Create new setPropData()??? - - if (pv->needAddRemove()) - { - gateDebug0(5,"gatePvData::propEventCB() need add/remove\n"); - pv->markAddRemoveNotNeeded(); - pv->vc->vcAdd(ctrlType); - } - else - { - // Post the event - pv->vc->vcPostEvent(pv->mrg->propertyEventMask()); - } - } - } - ++(pv->event_count); - } -} - // This is the callback registered with ca_add_subscription in the // alhMonitor routine. If conditions are right, it calls the routines From d925c21fc5e66f5b316f9444e12dbf747dffbbca Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 22 Jun 2022 13:22:28 -0700 Subject: [PATCH 6/8] Adjust eventsReceived counts in TestCSStudio to align w/ gateway 2 subscription changes. --- testTop/pyTestsApp/TestCSStudio.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/testTop/pyTestsApp/TestCSStudio.py b/testTop/pyTestsApp/TestCSStudio.py index 0a5e0fb..d84bbfd 100644 --- a/testTop/pyTestsApp/TestCSStudio.py +++ b/testTop/pyTestsApp/TestCSStudio.py @@ -76,17 +76,18 @@ def testCSStudio_ValueAndPropMonitor(self): (ioc_cbref, ioc_uaref, ioc_eventid) = ca.create_subscription(ioc, mask=dbr.DBE_VALUE | dbr.DBE_ALARM, use_time=True, callback=self.onChangeIOC) (ioc_cbref2, ioc_uaref2, ioc_eventid2) = ca.create_subscription(ioc, mask=dbr.DBE_PROPERTY, use_ctrl=True, callback=self.onChangeIOC) - gwtests.wait_until(lambda: self.eventsReceivedIOC == 2 and self.eventsReceivedGW == 2, 5.0) + gwtests.wait_until(lambda: self.eventsReceivedIOC == 2 and self.eventsReceivedGW == 3, 5.0) # set value on IOC ioc_value = ca.create_channel("ioc:gwcachetest") ca.put(ioc_value, 10.0, wait=True) if gwtests.verbose: print("Wrote value 10.0 to ioc:gwcachetest") + sys.stdout.flush() - gwtests.wait_until(lambda: self.eventsReceivedIOC == self.eventsReceivedGW, 5.0) - self.assertTrue(self.eventsReceivedIOC == self.eventsReceivedGW, - "After setting value, no. of received updates differ: GW {0}, IOC {1}" + gwtests.wait_until(lambda: self.eventsReceivedIOC == 3 and self.eventsReceivedGW == 4, 5.0) + self.assertTrue(self.eventsReceivedIOC == 3 and self.eventsReceivedGW == 4, + "After setting value, no. of received updates wrong: GW {0}, IOC {1}" .format(str(self.eventsReceivedGW), str(self.eventsReceivedIOC))) (are_diff, diffs) = self.compareStructures() @@ -99,13 +100,16 @@ def testCSStudio_ValueAndPropMonitor(self): ca.put(ioc_hihi, 123.0, wait=True) if gwtests.verbose: print("Wrote value 123.0 to ioc:gwcachetest.HIHI") + sys.stdout.flush() + ca.put(ioc_value, 11.0, wait=True) if gwtests.verbose: print("Wrote value 11.0 to ioc:gwcachetest") + sys.stdout.flush() - gwtests.wait_until(lambda: self.eventsReceivedIOC == self.eventsReceivedGW, 5.0) - self.assertTrue(self.eventsReceivedIOC == self.eventsReceivedGW, - "After setting property, no. of received updates differ: GW {0}, IOC {1}" + gwtests.wait_until(lambda: self.eventsReceivedIOC == 5 and self.eventsReceivedGW == 6, 5.0) + self.assertTrue(self.eventsReceivedIOC == 5 and self.eventsReceivedGW == 6, + "After setting property, no. of received updates wrong: GW {0}, IOC {1}" .format(str(self.eventsReceivedGW), str(self.eventsReceivedIOC))) (are_diff, diffs) = self.compareStructures() From 6db3640aabd1920d3b52c9dbdd0b9ec56f08b75a Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 22 Jun 2022 12:58:36 -0700 Subject: [PATCH 7/8] Minor fix to warning msg --- testTop/pyTestsApp/gwtests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testTop/pyTestsApp/gwtests.py b/testTop/pyTestsApp/gwtests.py index fc49864..8e3401d 100644 --- a/testTop/pyTestsApp/gwtests.py +++ b/testTop/pyTestsApp/gwtests.py @@ -53,7 +53,7 @@ def setup(): if 'TOP' in os.environ: gwLocation = os.path.join(os.environ['TOP'], '..') else: - print("Warning: TOP not set. Using default value of '..'") + print("Warning: TOP not set. Using default value of '../..'") gwExecutable = os.path.join(gwLocation, 'bin', hostArch, 'gateway') if not os.path.exists(gwExecutable): From 9aa33eeae0ac4a31bc84a145215155a337d153cf Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 22 Jun 2022 16:06:32 -0700 Subject: [PATCH 8/8] Also adjust eventsReceived counts in TestDBEProp --- testTop/pyTestsApp/TestDBEProp.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testTop/pyTestsApp/TestDBEProp.py b/testTop/pyTestsApp/TestDBEProp.py index 4ffc520..dd76d8b 100644 --- a/testTop/pyTestsApp/TestDBEProp.py +++ b/testTop/pyTestsApp/TestDBEProp.py @@ -55,9 +55,9 @@ def testPropAlarmLevels(self): for val in range(10): ioc.put(val, wait=True) - gwtests.wait_until(lambda: self.eventsReceivedGW == 1 and self.eventsReceivedIOC == 1, 5.0) + gwtests.wait_until(lambda: self.eventsReceivedGW == 2 and self.eventsReceivedIOC == 1, 5.0) # We get 1 event: at connection - self.assertTrue(self.eventsReceivedGW == 1, 'GW events expected: 1; received: ' + str(self.eventsReceivedGW)) + self.assertTrue(self.eventsReceivedGW == 2, 'GW events expected: 2; received: ' + str(self.eventsReceivedGW)) self.assertTrue(self.eventsReceivedIOC == 1, 'IOC events expected: 1; received: ' + str(self.eventsReceivedIOC)) self.eventsReceived = 0 @@ -69,8 +69,8 @@ def testPropAlarmLevels(self): # Depending on the IOC (supporting PROPERTY changes on limits or not) we get 0 or 4 events. # Pass test if updates from IOC act the same as updates from GW - self.assertTrue(self.eventsReceivedGW == self.eventsReceivedIOC, - "Expected equal number of updates; received {0} from GW and {1} from IOC".format(self.eventsReceivedGW, self.eventsReceivedIOC)) + self.assertTrue(self.eventsReceivedGW == (self.eventsReceivedIOC + 1), + "Expected GW updates to be one more than IOC; received {0} from GW and {1} from IOC".format(self.eventsReceivedGW, self.eventsReceivedIOC)) if __name__ == '__main__':