EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Incorrect get_precision
From: "Allison, Stephanie" <[email protected]>
To: "[email protected]" <[email protected]>
Date: Tue, 23 Nov 2010 14:28:26 -0800
Hello tech-talk,

There is a related message on the subject of get_precision by Bernd Schoeneburg here (Oct 2009):

http://www.aps.anl.gov/epics/tech-talk/2009/msg01525.php

There was also another email recently that had a comment about precision (from Michael Abbott) that caught my interest but may not be related.

In our upgrade from 3.14.8.2 to 3.14.11, we discovered some of our clients are showing the wrong precision for calc records.  In fact, the output of caget and camonitor when using the "-s" option is different in precision for calc and calcout records.   For example:

b117-pc12:~>caget SPEAR:Energy.PREC
SPEAR:Energy.PREC              3
b117-pc12:~>caget -s SPEAR:Energy
SPEAR:Energy                   3.000
b117-pc12:~>camonitor -s SPEAR:Energy   
SPEAR:Energy                   2010-11-23 13:56:07.677011 3.000004

(SPEAR:Energy is a calc record, dbpr is at the end of this email).

ai, ao, sel, compress, waveform, dfanout, sub records are all OK.   Just calc's and calcout's are wrong.

Most of our standard epics extensions are like caget and get the proper precision when getting a value as a string.

In the calc and calcout records (in 3.14.11 and 3.14.12 too), get_precision still has the bug that Bernd identified in his email.   The existing code is like this:

static long get_precision(DBADDR *paddr, long *pprecision)
{
    calcRecord *prec = (calcRecord *)paddr->precord;

    if (paddr->pfield == (void *)&prec->val) {
        *pprecision = prec->prec;
    } else {
        recGblGetPrec(paddr, pprecision);
    }
    return 0;
}

The first bug is that pprecision must be initialized before calling recGblGetPrec.  But what I've also discovered is that this line does not always work correctly depending on what channel access call is used - ca_create_subscription or ca_array_get_callback (which makes no sense):

    if (paddr->pfield == (void *)&prec->val)

get_precision for other record types check the field index instead so when I correct calc and calcout like this:

static long get_precision(DBADDR *paddr, long *pprecision)
{
    calcRecord *prec = (calcRecord *)paddr->precord;
    int fieldIndex = dbGetFieldIndex(paddr);

    *pprecision = prec->prec;
    if (fieldIndex != calcRecordVAL)
        recGblGetPrec(paddr, pprecision);
    
    return 0;
}

All works OK.

BTW - the help for camonitor shows this text:

  -s:      Get value as string (may honour server-side precision)

When won't server-side precision be honored/honoured?

I will report a bug via launchpad but thought perhaps others may be interested.   Thank you,

Stephanie Allison
[email protected]

IOC running on Linux RHEL4-32/EPICS 3.14.11:

epics> dbpr("SPEAR:Energy",5)
A: 587.691345214844 ACKS: INVALID       ACKT: YES           ADEL: 0             
ALST: 3.00000227269902                  ASG:                ASP: (nil)          
B: 0                BKPT: 00            C: 0                
CALC: A<0?0:((A*3)/587.6909)            D: 0                DESC: SPEAR Energy  
DISA: 0             DISP: 0             DISS: NO_ALARM      DISV: 1             
DPVT: (nil)         DSET: (nil)         DTYP: <nil>         E: 0                
EGU: GeV            EVNT: 0             F: 0                FLNK:CONSTANT 0     
G: 0                H: 0                HHSV: NO_ALARM      HIGH: 0             
HIHI: 0             HOPR: 0             HSV: NO_ALARM       HYST: 0             
I: 0                INPA:DB_LINK MS1-BD:Curr.VAL NPP MS     INPB:CONSTANT       
INPC:CONSTANT       INPD:CONSTANT       INPE:CONSTANT       INPF:CONSTANT       
INPG:CONSTANT       INPH:CONSTANT       INPI:CONSTANT       INPJ:CONSTANT       
INPK:CONSTANT       INPL:CONSTANT       J: 0                K: 0                
L: 0                LA: 587.691345214844                    
LALM: 3.00000227269902                  LB: 0               LC: 0               
LCNT: 0             LD: 0               LE: 0               LF: 0               
LG: 0               LH: 0               LI: 0               LJ: 0               
LK: 0               LL: 0               LLSV: NO_ALARM      LOLO: 0             
LOPR: 0             LOW: 0              LSET: 0x8a5d450     LSV: NO_ALARM       
MDEL: 0             MLIS: e8 71 bc 08 58 d6 c3 08 0e 00 00 00                   
MLOK: b8 6a a2 08   MLST: 3.00000227269902                  NAME: SPEAR:Energy  
NSEV: NO_ALARM      NSTA: NO_ALARM      PACT: 0             PHAS: 0             
PINI: NO            PPN: (nil)          PPNR: 0x8b8e018     PREC: 3             
PRIO: LOW           PROC: 0             PUTF: 0             RDES: 0x88188a8     
RPCL: 03 01 00 00 00 00 00 00 00 00 47 4c 01 00 00 00 00 00 00 00               
RPRO: 0             RSET: 0x817e9c0     SCAN: Passive       SDIS:CONSTANT       
SEVR: NO_ALARM      SPVT: (nil)         STAT: NO_ALARM      
TIME: 2010-11-23 14:07:10.996273000     TPRO: 0             TSE: 0              
TSEL:CONSTANT       UDF: 0              VAL: 3.00000227269902                   



Replies:
Re: Incorrect get_precision Ralph Lange

Navigate by Date:
Prev: Re: ca_put_callback once again Tim Mooney
Next: Re: Incorrect get_precision Ralph Lange
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: fast epid Mark Rivers
Next: Re: Incorrect get_precision Ralph Lange
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 23 Nov 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·