mdavidsaver / pvxs

PVA protocol client/server library and utilities.
https://mdavidsaver.github.io/pvxs/
Other
19 stars 25 forks source link

PREC from DB isn't reported correctly. #55

Closed ericonr closed 10 months ago

ericonr commented 10 months ago

Describe the bug

An ao value in an IOC database doesn't report its precision correctly (or at all?) when using the PVXS server.

To Reproduce Steps to reproduce the behavior:

  1. Create ao record with field(PREC, 3)
  2. Confirm precision is set correctly with caget -d CTRL_DOUBLE: Precision: 3
  3. Check that display.precision field exists in pvinfo output
  4. Try and get display.precision field with pvget or p4p (for the latter, precision is reported as 0, even)

Care was taken to ensure the access wasn't happening through p4pgw, to eliminate the chance of it causing the issue.

caget -d CTRL_DOUBLE full output:

caget -d CTRL_DOUBLE DE-23SL11:BS-FOFBCtrl:SYSIDUpdateTime-SP
DE-23SL11:BS-FOFBCtrl:SYSIDUpdateTime-SP
    Native data type: DBF_DOUBLE
    Request type:     DBR_CTRL_DOUBLE
    Element count:    1
    Value:            0.001
    Status:           NO_ALARM
    Severity:         NO_ALARM
    Units:            s
    Precision:        3
    Lo disp limit:    0
    Hi disp limit:    0
    Lo alarm limit:   nan
    Lo warn limit:    nan
    Hi warn limit:    nan
    Hi alarm limit:   nan
    Lo ctrl limit:    0.001
    Hi ctrl limit:    100

pvinfo:

EPICS_PVA_ADDR_LIST=de-23rabpm-co-iocsrv EPICS_PVA_AUTO_ADDR_LIST=NO pvinfo DE-23SL11:BS-FOFBCtrl:LAMPUpdateTime-SP            (hla2)
DE-23SL11:BS-FOFBCtrl:LAMPUpdateTime-SP
Server: 10.20.26.110:41676
Type:
    epics:nt/NTScalar:1.0
        double value
        alarm_t alarm
            int severity
            int status
            string message
        time_t timeStamp
            long secondsPastEpoch
            int nanoseconds
            int userTag
        structure display
            double limitLow
            double limitHigh
            string description
            string units
            int precision
            enum_t form
                int index
                string[] choices
        structure control
            double limitLow
            double limitHigh
            double minStep
        structure valueAlarm
            boolean active
            double lowAlarmLimit
            double lowWarningLimit
            double highWarningLimit
            double highAlarmLimit
            int lowAlarmSeverity
            int lowWarningSeverity
            int highWarningSeverity
            int highAlarmSeverity
            double hysteresis

pvget -M raw:

EPICS_PVA_ADDR_LIST=de-23rabpm-co-iocsrv EPICS_PVA_AUTO_ADDR_LIST=NO pvget -M raw DE-23SL11:BS-FOFBCtrl:LAMPUpdateTime-SP      (hla2)
DE-23SL11:BS-FOFBCtrl:LAMPUpdateTime-SP epics:nt/NTScalar:1.0
    double value 0.001
    alarm_t alarm
        int severity 0
        int status 0
        string message
    time_t timeStamp 2023-08-21 12:54:18.502
        long secondsPastEpoch 1692633258
        int nanoseconds 502497987
        int userTag 0
    structure display
        double limitLow 0
        double limitHigh 0
        string description "Set repetitive mode update time"
        string units s
        enum_t form (0) Default
            int index 0
            string[] choices [Default, String, Binary, Decimal, Hex, Exponential, Engineering]
    structure control
        double limitLow 0.001
        double limitHigh 100
    structure valueAlarm
        double lowAlarmLimit nan
        double lowWarningLimit nan
        double highWarningLimit nan
        double highAlarmLimit nan

pvget -M raw -r display.precision:

EPICS_PVA_ADDR_LIST=de-23rabpm-co-iocsrv EPICS_PVA_AUTO_ADDR_LIST=NO pvget -M raw -r display.precision DE-23SL11:BS-FOFBCtrl:LAMPUpdateTime-SP
DE-23SL11:BS-FOFBCtrl:LAMPUpdateTime-SP ⏎

p4p:

In [15]: c = Context(nt=False)

In [16]: m = c.get(name="DE-23SL11:BS-FOFBCtrl:LAMPUpdateTime-SP")

In [17]: m.tolist()
Out[17]:
[('value', 0.001),
 ('alarm', [('severity', 0), ('status', 0), ('message', '')]),
 ('timeStamp',
  [('secondsPastEpoch', 1692633258),
   ('nanoseconds', 502497987),
   ('userTag', 0)]),
 ('display',
  [('limitLow', 0.0),
   ('limitHigh', 0.0),
   ('description', 'Set repetitive mode update time'),
   ('units', 's'),
   ('precision', 0),
   ('form',
    [('index', 0),
     ('choices',
      ['Default',
       'String',
       'Binary',
       'Decimal',
       'Hex',
       'Exponential',
       'Engineering'])])]),
 ('control', [('limitLow', 0.001), ('limitHigh', 100.0), ('minStep', 0.0)]),
 ('valueAlarm',
  [('active', False),
   ('lowAlarmLimit', nan),
   ('lowWarningLimit', nan),
   ('highWarningLimit', nan),
   ('highAlarmLimit', nan),
   ('lowAlarmSeverity', 0),
   ('lowWarningSeverity', 0),
   ('highWarningSeverity', 0),
   ('highAlarmSeverity', 0),
   ('hysteresis', 0.0)])]

Expected behavior A clear and concise description of what you expected to happen.

Information (please complete the following):

Alternately, from a successful build, include the output of pvxinfo -D.

Host: linux-x86_64
Target: linux-x86_64 Linux gcc
Toolchain
    __cplusplus = 201103
    GCC 12.2.0
    _GLIBCXX_USE_CXX11_ABI = 1
    __GLIBCXX__ 20220819
Versions
    PVXS 1.2.2 ()
    EPICS 7.0.7.1-DEV
    libevent 2.1.12-stable
Runtime
    uname() -> Linux S-SWC03-L 5.19.0-50-generic #50-Ubuntu SMP PREEMPT_DYNAMIC Mon Jul 10 18:24:29 UTC 2023 x86_64
    epicsThreadGetCPUs() -> 8
    osiLocalAddr() -> 10.15.2.110

Additional context

This problem was noticed when using a pydm interface with pva://, where the spinbox controls worked thanks to DRVH and DRVL set in the database, but didn't allow decimal values.

mdavidsaver commented 10 months ago

Confirmed. ad9ba0f085a4229443e08c51fd26e4eb0ad09554 added NTScalar::form, but ioc/iocsource.cpp does not yet make use of this.

mdavidsaver commented 10 months ago

With b0c7c8fcd0c35e79c00b3eca39486156a380e43a, display.precision should be set by QSRV2.

ericonr commented 10 months ago

And it is, thanks!