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  2011  2012  <20132014  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  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: Substitutions defaults and tricks
From: "Brown, Garth" <[email protected]>
To: "Pietryla, Anthony F." <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Fri, 15 Nov 2013 16:15:05 -0800
Hi Tony,
In your example, there wouldn't be an option of whether you define TS1ST in st.cmd. You lose the default value so you must define it. The problem that I'm trying to solve is that there are literally hundreds of values with facility-specific defaults, not just TS1ST, and of those values most systems only need to define non-default values for a few of them if any.
In my example, I used the macros SYS, SYS0_TS1, and SYS1_TS1, which aren't in the template file, to demonstrate the sort of functionality I'm thinking of. Msi doesn't directly support conditional substitutions, but you can get some conditional behavior this way. The scope only extends to that one line. Once that line is expanded, SYS0_TS1 and SYS1_TS1 are lost. The conditional behavior can't survive to be used by dbLoadRecords.

I'll add a few tangentially related thoughts on how msi/macLib might be modified. It would be nice if there was a way to keep a macro with a default value in a template unexpanded. That is, if sample.template contains the line
	field(X, "$(MYX=3)" )
then sample.substitutions could have a way to indicate that MYX shouldn't be expanded and should retain the default value part, so that sample.db still had exactly that line. As it is, you can leave MYX undefined, which expands to
	field(X, "3" )
Or you can have in the substitutions { MYX='$(MYX)' }, which expands to
	field(X, "$(MYX)" )    # default value is lost
The macro with default can't survive msi unchanged.
If there were a way to leave the macro undefined with the default value intact, I could solve my problem with two levels of substitutions files: a general substitutions file that contained macros with defaults for everywhere, and environment specific substitutions files  that used the output of the general one as a template.
Getting more technical about how that might work, you could interpret { MYX=$(MYX) } recursive definition as not wanting the macro substituted, rather than as an error condition. Right now, macLib will turn this into $(MYX, recursive), indicating an error and losing the default value.
I had a look in macCore.c where this case is handled, and didn't immediately see how to implement that. The recursive definition is detected one call stack level below where the default value is specified.

Garth

-----Original Message-----
From: Pietryla, Anthony F. [mailto:[email protected]] 
Sent: Friday, November 15, 2013 6:25 AM
To: Brown, Garth
Cc: [email protected]
Subject: Re: Substitutions defaults and tricks

Garth,

If I understand what you want correctly you can have your substitution file setup like this:

pattern { SYS, SYS0_TS1, SYS1_TS1, TS1ST, ....    }
       { SYS0,         1,        2,      \$(TS1ST) , ....   }

then your database will contain the macro $(TS1ST) and you can make your substitutions in the st.cmd file.

Tony 

On Nov 14, 2013, at 7:09 PM, "Brown, Garth" <[email protected]>
 wrote:

> We have a module which is used by many systems in slightly different environments. Each environment has a long list of default settings that work for nearly every IOC in that environment.
> If my environments are SYS0 and SYS1, and I want to define default values for the macro TS1ST, I can do something like this:
> Substitutions file for SYS0 contains
> file evrPatternAll.db 
> {     
>  pattern { SYS, SYS0_TS1, SYS1_TS1, TS1ST, ....    }
>        { SYS0,         1,        2,      \$(TS1ST=$($(SYS)_TS1)) , ....   }
> ....
> 
> And in the output, $($(SYS)_TS1)) becomes $(SYS0_TS1), which becomes 1, so $(TS1ST) from evrPatternAll.db is substituted by $(TS1ST=1), which is what I wanted as the default value in SYS0.
> If I want to use this for SYS1, I could change that to file 
> evrPatternAll.db
> {     
>  pattern { SYS, SYS0_TS1, SYS1_TS1, TS1ST, ....    }
>        { SYS1,         1,        2,      \$(TS1ST=$($(SYS)_TS1)) , ....   }
> ....
> 
> And I get $(TS1ST=2), the desired SYS1 default value. 
> That may be a useful trick, but it's not quite what I want. The file my example is based on has lots more in the pattern line, and many more lines. To simplify maintenance and reduce errors for all the installations where we want to take the per-environment defaults, I want a way for users to just define SYS  in one place, preferably a macro in dbLoadRecords. That would let you cut and paste one st.cmd line into new systems, while maintaining per-environment defaults centrally. Does anyone have a way to do that, or good alternatives for this type of problem?
> 
> Thanks,
> Garth
> 


--
Anthony Pietryla
Controls Engineer
Advanced Photon Source
Argonne National Laboratory

Phone: 630-252-7430
Fax: 630-252-6123



Replies:
Re: Substitutions defaults and tricks Andrew Johnson
RE: Substitutions defaults and tricks Emmanuel Mayssat
References:
Substitutions defaults and tricks Brown, Garth
Re: Substitutions defaults and tricks Pietryla, Anthony F.

Navigate by Date:
Prev: RE: Epics installation Mark Rivers
Next: Re: Substitutions defaults and tricks Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Substitutions defaults and tricks Pietryla, Anthony F.
Next: Re: Substitutions defaults and tricks Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 20 Apr 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·