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  <20192020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: EPICS 7.0.2.1 release preparation
From: Dirk Zimoch via Core-talk <[email protected]>
To: <[email protected]>
Date: Tue, 7 May 2019 11:37:55 +0200
Hi Andrew,

I finally found some time to come back to the 'dbll' code. You described the new link methods, but I still have a question.

1. You wrote:
The following new routines in dbLink.h allow you to examine the link
support that is attached to a particular link field:
int dbLinkIsDefined(const struct link *plink);  /* 0 or 1 */
int dbLinkIsConstant(const struct link *plink); /* 0 or 1 */
int dbLinkIsVolatile(const struct link *plink); /* 0 or 1 */
int dbIsLinkConnected(const struct link *plink); /* 0 or 1 */
The first one dbLinkIsDefined() tells you whether the field is attached
to a link support at all.

But to use them, I have to cast the field like ((DBLINK *)dbEntry.pfield) before I even know if it is a link at all, because the functions work on links, not on generic db fields. Can that be safe?

2. Also you mentioned the new "faster" way to get the links:

There is now a faster way to find all the DB links that point to a
particular record though, the dbDbLink.c code now keeps an ELList of
those links for the new lock-set code in dbLock.c to use.

This is true if I already have the record. But does it make a difference if I only have the record name (or a name pattern)? In that case I need iterate all records anyway. Only that this time I do it to find the target record(s) instead of the records with links. So with n records it is O(n) in both cases.

Or is it so that 2 is actually the solution to 1?

Dirk


On 04.04.19 17:27, Dirk Zimoch via Core-talk wrote:
Thanks. I will try. when it works I will make a merge request for dbll.

Is there any interest in the EPICS 3 version of dbll? I can make a merge
request if you want.

Dirk

On 03.04.19 23:56, Johnson, Andrew N. via Core-talk wrote:
Hi Dirk,

On 4/3/19 8:31 AM, Dirk Zimoch via Core-talk wrote:
I have seen that dbGetFieldType() and dbGetLinkType() are about to be
removed. What is the replacement for dbGetLinkType()? I want to find
out if a field is a PV link.
Those routines were deleted before the 7.0.2.1 release that was
published (although not formally announced) on March 20th. They were the
last vestiges of the dbStatic "Forms" support routines.

EPICS 7 now has extensible link types that don't map to the old "if it
isn't a constant or a DB link it must be a CA link" rules. We started
introducing these changes in 3.15.1 (the dbLink.h header was created in
2012 and first published in the 3.15.0.1 developer release in 2014). You
can now develop your own link types, and the IOC code can't know how to
look inside the link data structures for those links. We still support
the old CA and DB link types though, so code that sticks its fingers
into them will generally still work, but we don't let you do that with
the new link types.

The following new routines in dbLink.h allow you to examine the link
support that is attached to a particular link field:
int dbLinkIsDefined(const struct link *plink);  /* 0 or 1 */
int dbLinkIsConstant(const struct link *plink); /* 0 or 1 */
int dbLinkIsVolatile(const struct link *plink); /* 0 or 1 */
int dbIsLinkConnected(const struct link *plink); /* 0 or 1 */
The first one dbLinkIsDefined() tells you whether the field is attached
to a link support at all. The next two give you some characteristics of
the link type; a constant link only provides a value at record
initialization time, so is comparable to the old DCT_LINK_CONSTANT; a
volatile link is one that may disconnect and reconnect at runtime (a DB
link is not volatile, while CA and pva links are since the server they
talk to can go down).

You can call the routine dbIsLinkConnected() to find out whether a
volatile link is currently connected to its target or not, although
there is of course no guarantee that the connection state won't change
immediately after the routine has returned. The calcout record now uses
this routine to populate the fields that allow you to see the connection
state of its link fields.

You can find out more about the other routines in dbLink.h by reading
the Doxygen comments that appear above the equivalent function pointers
in the definition of struct lset. I haven't talked about dbJLink.h which
is how new link types get to parse their addresses.

I use it in a utility function "dbll" (database list links) to show
which records link to given records or field: dbll recordpattern[.field]

The core of the function is:

    for (status = dbFirstRecordType(&dbEntry); !status; status =
dbNextRecordType(&dbEntry))
    for (status = dbFirstRecord(&dbEntry); !status; status =
dbNextRecord(&dbEntry))
    {
#if EPICS_VERSION*10000+EPICS_REVISION*100+EPICS_MODIFICATION >= 31411
        if (dbIsAlias(&dbEntry)) continue;
#endif
        for (status = dbFirstField(&dbEntry, 0); !status; status =
dbNextField(&dbEntry, 0))
        {
            if (dbGetLinkType(&dbEntry) == DCT_LINK_PV)
            {
                const char* target = ((DBLINK
*)dbEntry.pfield)->value.pv_link.pvname;
                if (!match || (
                        (strchr(target, '.') ? 1 : 0) == (d ? 1 : 0) ?
                            epicsStrGlobMatch(target, match) :
                            alt_match ? epicsStrGlobMatch(target,
alt_match) : 0))
                {
                    printf("%s.%s ==> %s\n",
dbGetRecordName(&dbEntry), dbGetFieldName(&dbEntry),
                        dbGetString(&dbEntry));
                }
            }
        }
    }
    dbFinishEntry(&dbEntry);

You can look at ((DBLINK *)dbEntry.pfield)->type which gives you one of
the link type constants defined at the top of link.h. The above
dbGetLinkType(&dbEntry) == DCT_LINK_PV condition is equivalent to that
type being any of PV_LINK, PN_LINK, DB_LINK or CA_LINK, which are
compatible with the old meanings.

There is now a faster way to find all the DB links that point to a
particular record though, the dbDbLink.c code now keeps an ELList of
those links for the new lock-set code in dbLock.c to use. I would be
happy to see a version of your "dbll" utility which uses those
back-links added to dbDbLink.c. If you're interested in contributing
such a utility to Base please let us know (both Michael and I have been
working in different parts of the link code recently).

- Andrew

--
Arguing for surveillance because you have nothing to hide is no
different than making the claim, "I don't care about freedom of
speech because I have nothing to say." -- Edward Snowdon


Replies:
Re: EPICS 7.0.2.1 release preparation Johnson, Andrew N. via Core-talk
References:
EPICS 7.0.2.1 release preparation Michael Davidsaver via Core-talk
Re: EPICS 7.0.2.1 release preparation Dirk Zimoch via Core-talk
Re: EPICS 7.0.2.1 release preparation Johnson, Andrew N. via Core-talk
Re: EPICS 7.0.2.1 release preparation Dirk Zimoch via Core-talk

Navigate by Date:
Prev: Re: [Merge] ~info-martin-konrad/epics-base:dont-nuke-global-cac-thread-id-in-exit-handler into epics-base:3.15 mdavidsaver via Core-talk
Next: Build completed: epics-base base-dbparser-cleanup-245 AppVeyor via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: EPICS 7.0.2.1 release preparation Dirk Zimoch via Core-talk
Next: Re: EPICS 7.0.2.1 release preparation Johnson, Andrew N. via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
ANJ, 07 May 2019 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·