PCAS: ENUM string table cache is not updated on DBE_PROPERTY updates

Bug #1612944 reported by Ralph Lange
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EPICS Base
Fix Released
Medium
Unassigned
3.14
Fix Released
Medium
Ralph Lange
3.15
Fix Released
Medium
Ralph Lange
3.16
Fix Released
Medium
Unassigned

Bug Description

From Wang Xiaoqiang (PSI) <xiaoqiang.wang _AT_ psi.ch>:

TL;DR: When DBE_PROPERTY event is posted in a PCAS application for an Enum typed PV, the client will be noticed but with the stale state strings.

I have create an enum typed PV “MTEST:ENUM", initially with two states [ZERO, ONE], in a PCAS(py) application.
Then this is how I expand it to 3 states and send the DBE_PROPERTY event.
// pseudo code, only to show the sequence
dd = app_table.getDD(gddAppType_dbr_ctrl_enum)
dd[gddAppTypeIndex_dbr_ctrl_enum_value].put(0)
dd[gddAppTypeIndex_dbr_ctrl_enum_enums].put([‘ZERO’,’ONE’,’TWO'])
myPV.postEvent(DBE_PROPERTY, dd)

One the client, I put a monitor with type DBR_GR_ENUM and mask DBE_PROPERTY, and print the states string in the callback.
# a.py
def valueCB(epicsArgs, userArgs):
    print(epicsArgs['pv_statestrings’])

chan1 = CaChannel('MTEST:ENUM')
chan1.searchw()
chan1.add_masked_array_event(ca.DBR_GR_ENUM, None, ca.DBE_PROPERTY, valueCB)
chan1.flush_io()
while True:
    time.sleep(2)

The result is that the callback is called for the property change event, but the state string remains the same.
$ python a.py
('ZERO', 'ONE')
('ZERO', 'ONE’)
If I then run “caget -d DBR_GR_ENUM MTEST:ENUM”, it does print the changed state strings.

However if I load such a mbbo record into IOC,
record(mbbo, "MTEST:ENUM")
{
    field (ZRST, "ZERO")
    field (ONST, "ONE")
}
 and change the state string with "dbpf MTEST:ENUM.TWST TWO”, the client will receive the event with the changed state strings.
$ python a.py
('ZERO', 'ONE')
('ZERO', 'ONE', 'TWO’)

I have doubted the PCASpy implementation. So I tested the above mbbo record through the ca-gateway(2.1.0), the result is consistent with the PCASpy application. It receives the event but with the stale state strings.

The test is with Base 3.14.12.5.

Tags: cas
Revision history for this message
Ralph Lange (ralph-lange) wrote :

A suggested patch from Wang Xiaoqiang (PSI) <xiaoqiang.wang _AT_ psi.ch>:

I seem to find some clue.

The bug that is reported on launchpad can be worked around by creating a gdd of gddAppType_dbr_ctrl_double type and filling in the meta properties. This has to been do even if there is only a value update.

The bug with the enum typed PV is because casPVI caches the enum string table and only refresh it when PV gets created. So I implemented a fix to update this table during the call of postEvent.
https://github.com/xiaoqiangwang/epics-base/commit/3ca62daa6045d12cc7e71284885309310e9a062e

After these two changes, the DBE_PROPERTY event is properly received by client with updated meta property.

The test I used is here https://github.com/paulscherrerinstitute/pcaspy/blob/master/example/dynamic_property.py
Changing “MTEST:CHANGE” will cause MTEST:ENUM states and MTEST:RAND high alarm limit to change. And this change can be monitored from a client.
$ caput MTEST:CHANGE 3

$ python a.py
('ONE', 'TWO')
('ZERO', 'ONE', 'TWO')

Changed in epics-base:
milestone: 3.14.12.6 → none
Revision history for this message
Ralph Lange (ralph-lange) wrote :

Testing with the CA Gateway (commit 4a1f2b5)
https://github.com/epics-extensions/ca-gateway/commit/4a1f2b508b01d42da0758bb6c03c30db0ed9016e
shows the patch working.

Revision history for this message
Ralph Lange (ralph-lange) wrote :

I pushed the patch to the 3.14 branch.
Please update the status for the other branches when the regular merge is done.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.