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  2010  <20112012  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  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: How the EPICS IOC determines the link type {CA_LINK/DB_LINK/CONSTANT}
From: Abadie Lana <[email protected]>
To: Andrew Johnson <[email protected]>, "[email protected]" <[email protected]>
Date: Tue, 18 Oct 2011 17:46:28 +0200
Thanks Andrew.
I had a look at the code you mentioned to see if it is a constant or not.
Sorry for my stupid question here... but  a link of type constant in EPICS is always a double/long? it cannot be a string?
I did the following test
record(stringout, "$(PSH)-COS:TraceMessage") {
  field(DESC, "Trace Message from IOC")
  field(DTYP, "Soft Channel")
  field(OMSL, "supervisory")
  field(VAL,  "Trace mode ON")
  field(DOL, "Test string for dol")
}

epics> dbpr RF-ICH1-COS:TraceMessage 4
ACKS: NO_ALARM      ACKT: YES           APST: On Change     ASG:                
ASP: (nil)          BKPT: 00            DESC: Trace Message from IOC            
DISA: 0             DISP: 0             DISS: NO_ALARM      DISV: 1             
DOL:CA_LINK Test NPP NMS                DPVT: (nil)         DSET: 0x2ba72ff70a20
DTYP: Soft Channel  EVNT: 0             FLNK:CONSTANT 0     
.... 
epics> 


and in the case of a timestamp

record(stringin, "$(PSH)-COS:CurrentTime") {
  field(DESC, "Current Date and Time of the IOC")
  field(DTYP, "Soft Timestamp")
  field(SCAN, "1 second")
  field(PINI, "YES")
  field(INP, "@%d/%m/%Y %H:%M:%S")
}

I have this, INST_IO (which corresponds to the entry in the dbd file for DTYP). But is it a constant for you?
epics> dbpr RF-ICH1-COS:CurrentTime 4
ACKS: NO_ALARM      ACKT: YES           APST: On Change     ASG:                
ASP: (nil)          BKPT: 00            DESC: Current Date and Time of the IOC  
DISA: 0             DISP: 0             DISS: NO_ALARM      DISV: 1             
DPVT: (nil)         DSET: 0x2ba72ff70e20                    DTYP: Soft Timestamp
EVNT: 0             FLNK:CONSTANT 0     INP:INST_IO @%d/%m/%Y %H:%M:%S          
LCNT: 0             LSET: 0xbfd1ff0     
MLIS: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00               
MLOK: 10 b2 fc 0b 00 00 00 00           MPST: On Change     
NAME: RF-ICH1-COS:CurrentTime           NSEV: NO_ALARM      NSTA: NO_ALARM     ....

Thanks for your clarification

Lana
________________________________________
From: Andrew Johnson [[email protected]]
Sent: Monday, October 17, 2011 7:56 PM
To: [email protected]; Abadie Lana
Subject: Re: How the EPICS IOC determines the link type {CA_LINK/DB_LINK/CONSTANT}

Hi Lana,

On 2011-10-17 Abadie Lana wrote:
> I had a quick look at the epics base code but i could not find where the
> link type was set. What I mean is the following:
> In the dbd file, there are some record types which have some fields of type
>  INLINK/OUTLINK/FWDLINK. Depending on the cases, it can point to a constant
>  (like DOL field for instance) or to a timestamp (TSE) or to a real PV.
>  When I looked at the code, there is a notion of link type associated with
>  this type of fields and a link type can be either
>  CA_LINK/CONSTANT/DB_LINK/PV_LINK(=DB+CA_LINK). However I didn't find where
>  and how the links were set at IOC start up. I'm really interesting in
>  knowing how the IOC knows if the field points to a real PV... Thanks a lot
>  for your help

This is a bit complicated and spread over several source files; I usually have
to go back to the source code to understand it properly every time.

When the storage for a record is allocated, all IN/OUT/FWDLINK fields are
initialized with plink->type = CONSTANT (by dbAllocRecord() in dbStaticRun.c).

Determining whether an INLINK/OUTLINK/FWDLINK field is a CONSTANT or a PV_LINK
takes place when dbPutString() inside src/dbStatic/dbStaticLib.c parses the
string value being assigned to the field.  If the field name is INP or OUT it
also has to check the DTYP field since device support determines what link
type it expects to see.  A CONSTANT value is found by parsing the string using
both epicsStrtod() and strtol(); if either of those routines accepts the whole
string then it's a CONSTANT, otherwise it becomes a PV_LINK and we parse the
string for the link options appropriate for the link direction.

The code that resolves a PV_LINK type into either a DB_LINK vs CA_LINK exists
in two places; at iocInit time the link resolution occurs in the routine
doResolveLinks() in src/misc/iocInit.c but if you change the link field at
runtime it is then determined in dbPutFieldLink() inside src/db/dbAccess.c.

In both cases the code checks for CA/CP/CPP options and does a dbNameToAddr()
to determine if the link target matches a record and field name found in this
IOC; if found the result is a DB_LINK.  If there were CA/CP/CPP options or the
name lookup failed this is a Channel Access link so it calls dbCaAddLink() (a
macro from dbCa.h which expands to dbCaAddLinkCallback() in src/db/dbCa.c with
some default arguments for the callback parameters).

Note that this code has been modified in some branches that will appear in
future (3.15) releases, so talk to me first if you have some requirement that
might involve changing it.

HTH,

- Andrew
--
Optimization is the process of taking something that works and
replacing it with something that almost works, but costs less.
-- Roger Needham


Replies:
Re: How the EPICS IOC determines the link type {CA_LINK/DB_LINK/CONSTANT} Andrew Johnson
References:
EPICS Workshop Fall 2011 Dirk Zimoch
How the EPICS IOC determines the link type {CA_LINK/DB_LINK/CONSTANT} Abadie Lana
Re: How the EPICS IOC determines the link type {CA_LINK/DB_LINK/CONSTANT} Andrew Johnson

Navigate by Date:
Prev: Re: aSub and zero length arrays Andrew Johnson
Next: long strings Michael Davidsaver
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: How the EPICS IOC determines the link type {CA_LINK/DB_LINK/CONSTANT} Andrew Johnson
Next: Re: How the EPICS IOC determines the link type {CA_LINK/DB_LINK/CONSTANT} Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·