EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

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

Subject: constant links with strings
From: [email protected] (Peregrine McGehee)
To: "'[email protected]'" <[email protected]>
Date: Fri, 11 Dec 1998 08:12:04 -0700
Please find included a short routine to convert CA links to CONSTANT links. 
I needed this to allow use of strings in CapFast hardware inputs to genSub 
records.

As has been previously discussed in tech-talk, dbPutString() assumes that 
if a link can not be completed parsed by strtod() then it must be a process 
variable rather than a constant. Besides impacting full use of the genSub 
record, this has also been a bane for those wishing to initialize string 
records.

Rozelle Wright mentioned a proposal to modify the dbPutString logic to 
allow links to include a special leading character such as '$' to indicate 
that this really is a constant value. Although the routine described here 
solves the problem for genSub records it does not address the issue for 
string records.

Several implementation points:
1) The genSub record invokes the user supplied initialization routine on 
the second record initialization pass during iocInit. If the code listed 
below was called in the first pass, the dbCaRemoveLink() call would be 
unnecessary and the link type would be PV_LINK rather than CV_LINK or 
DB_LINK.

2) The transfer of data between the pv_link and constantStr could be 
considerably simplified by leveraging off the alignment of the elements 
within the plink->value union. However, this is more robust and follows the 
logic in dbCvtCaLinkToConstant() in dbStaticLib.

3) The call to recGblInitConstantLink() is required due to the order of 
operations in the genSub init_record().


long
rpCvtCaLinkToConstant(struct link *plink, short dbfType, void * valptr)
{
    char str[MAX_STRING_SIZE];

    if (plink->type == CONSTANT) return OK;
    if (plink->type != CA_LINK) return ERROR;

/*  Tell the dbCaLink task to forget this PV. */
    dbCaRemoveLink(plink);

/* Save the PV name and clean up. */
    strcpy(str, plink->value.pv_link.pvname);
    free(plink->value.pv_link.pvname);

/* Create the new CONSTANT link. */
    plink->type = CONSTANT;
    plink->value.constantStr = dbCalloc(strlen(str) + 1, sizeof(char));
    strcpy(plink->value.constantStr, str);

/* Initialize the CONSTANT link. */
    recGblInitConstantLink(plink, dbfType, valptr);

    return OK;
} 	

Aloha,
	Peregrine

Peregrine M. McGehee		Task Leader, LEDA Control System
Deputy Coordinator, Los Alamos Astrophysics	http://laastro.lanl.gov
(505) 667-3273	MS H820, LANL, Los Alamos, NM 87545


Navigate by Date:
Prev: Re: Monitors on a stringin record Marty Kraimer
Next: RE:PC Fonts.... schoeneburg
Index: 1994  1995  1996  1997  <19981999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: Links between IOCs Jeff Hill
Next: Activity logging Rolf Keitel
Index: 1994  1995  1996  1997  <19981999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 10 Aug 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·