EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: [Merge] ~dirk.zimoch/epics-base:dbChannelForDBLinks into epics-base:7.0
From: mdavidsaver via Core-talk <core-talk at aps.anl.gov>
To: mp+378968 at code.launchpad.net
Date: Sat, 16 May 2020 02:19:01 -0000
Review: Needs Fixing

Also, this MR changes the behavior of the following db
to leave dst with a link alarm.  Currently there is no
alarm, which I believe is correct.  Zero length DB links
have long worked.  See my diff comment on the conditional
in question.

record(aai, "src") {
    field(FTVL, "DOUBLE")
    field(NELM, "10")
    field(FLNK, "dst")
    field(PINI, "YES")
}
record(aai, "dst") {
    field(FTVL, "DOUBLE")
    field(NELM, "10")
    field(INP , "src NPP")
}

Diff comments:

> diff --git a/modules/database/src/ioc/db/dbDbLink.c b/modules/database/src/ioc/db/dbDbLink.c
> index f2cb0c5..dbf7cae 100644
> --- a/modules/database/src/ioc/db/dbDbLink.c
> +++ b/modules/database/src/ioc/db/dbDbLink.c
> @@ -160,47 +165,78 @@ static long dbDbGetValue(struct link *plink, short dbrType, void *pbuffer,
>          long *pnRequest)
>  {
>      struct pv_link *ppv_link = &plink->value.pv_link;
> -    DBADDR *paddr = ppv_link->pvt;
> +    dbChannel *chan = linkChannel(plink);
> +    DBADDR *paddr = &chan->addr;
>      dbCommon *precord = plink->precord;
> +    db_field_log *pfl = NULL;
>      long status;
>  
>      /* scan passive records if link is process passive  */
>      if (ppv_link->pvlMask & pvlOptPP) {
> -        status = dbScanPassive(precord, paddr->precord);
> +        status = dbScanPassive(precord, dbChannelRecord(chan));
>          if (status)
>              return status;
>      }
>  
> -    if (ppv_link->getCvt && ppv_link->lastGetdbrType == dbrType) {
> -        status = ppv_link->getCvt(paddr->pfield, pbuffer, paddr);
> -    } else {
> -        unsigned short dbfType = paddr->field_type;
> +    if (ppv_link->getCvt && ppv_link->lastGetdbrType == dbrType)
> +    {
> +        /* shortcut: scalar with known conversion, no filter */
> +        status = ppv_link->getCvt(dbChannelField(chan), pbuffer, paddr);
> +    }
> +    else if (dbChannelFinalElements(chan) == 1 && (!pnRequest || *pnRequest == 1)
> +                && dbChannelSpecial(chan) != SPC_DBADDR
> +                && dbChannelSpecial(chan) != SPC_ATTRIBUTE
> +                && ellCount(&chan->filters) == 0)
> +    {
> +        /* simple scalar: set up shortcut */
> +        unsigned short dbfType = dbChannelFinalFieldType(chan);
>  
>          if (dbrType < 0 || dbrType > DBR_ENUM || dbfType > DBF_DEVICE)
>              return S_db_badDbrtype;
>  
> -        if (paddr->no_elements == 1 && (!pnRequest || *pnRequest == 1)
> -                && paddr->special != SPC_DBADDR
> -                && paddr->special != SPC_ATTRIBUTE) {
> -            ppv_link->getCvt = dbFastGetConvertRoutine[dbfType][dbrType];
> -            status = ppv_link->getCvt(paddr->pfield, pbuffer, paddr);
> -        } else {
> -            ppv_link->getCvt = NULL;
> -            status = dbGet(paddr, dbrType, pbuffer, NULL, pnRequest, NULL);
> -        }
> +        ppv_link->getCvt = dbFastGetConvertRoutine[dbfType][dbrType];
>          ppv_link->lastGetdbrType = dbrType;
> +        status = ppv_link->getCvt(dbChannelField(chan), pbuffer, paddr);
> +    }
> +    else
> +    {
> +        /* filter, array, or special */
> +        ppv_link->getCvt = NULL;
> +
> +        if (ellCount(&chan->filters)) {
> +            /* If filters are involved in a read, create field log and run filters */
> +            pfl = db_create_read_log(chan);
> +            if (!pfl)
> +                return S_db_noMemory;
> +
> +            pfl = dbChannelRunPreChain(chan, pfl);
> +            pfl = dbChannelRunPostChain(chan, pfl);
> +        }
> +
> +        status = dbChannelGet(chan, dbrType, pbuffer, NULL, pnRequest, pfl);
> +
> +        if (pfl)
> +            db_delete_field_log(pfl);
> +
> +        if (status)
> +            return status;
> +
> +        if (pnRequest && *pnRequest <= 0)
> +            return S_db_emptyArray;

I don't think this should be an error as the caller can see that zero elements are being returned.

>      }
>  
> -    if (!status && precord != paddr->precord)
> +    if (!status && precord != dbChannelRecord(chan))
>          recGblInheritSevr(plink->value.pv_link.pvlMask & pvlOptMsMode,
> -            plink->precord, paddr->precord->stat, paddr->precord->sevr);
> +            plink->precord,
> +            dbChannelRecord(chan)->stat, dbChannelRecord(chan)->sevr);
>      return status;
>  }
>  
>  static long dbDbGetControlLimits(const struct link *plink, double *low,
>          double *high)
>  {
> -    DBADDR *paddr = (DBADDR *) plink->value.pv_link.pvt;
> +    dbChannel *chan = linkChannel(plink);
> +    DBADDR *paddr = &chan->addr;
>      struct buffer {
>          DBRctrlDouble
>          double value;


-- 
https://code.launchpad.net/~dirk.zimoch/epics-base/+git/epics-base/+merge/378968
Your team EPICS Core Developers is subscribed to branch epics-base:7.0.

References:
[Merge] ~dirk.zimoch/epics-base:dbChannelForDBLinks into epics-base:7.0 Dirk Zimoch via Core-talk

Navigate by Date:
Prev: Re: [Merge] ~dirk.zimoch/epics-base:dbChannelForDBLinks into epics-base:7.0 mdavidsaver via Core-talk
Next: Build failed: epics-base base-dynamic-rRDD-500 AppVeyor via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024 
Navigate by Thread:
Prev: Re: [Merge] ~dirk.zimoch/epics-base:dbChannelForDBLinks into epics-base:7.0 Dirk Zimoch via Core-talk
Next: Re: [Merge] ~dirk.zimoch/epics-base:dbChannelForDBLinks into epics-base:7.0 mdavidsaver via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024 
ANJ, 21 May 2020 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·