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

Subject: Re: Fwd: How to pass system environment to .substitutions?
From: Andrew Johnson <[email protected]>
To: [email protected]
Date: Wed, 20 Aug 2008 13:35:37 -0500
> >> I know I can use
> >> ==========================================
> >> dbLoadRecords ("db/test.db","device=${DEV},channel=1")
> >> dbLoadRecords ("db/test.db","device=${DEV},channel=2")
> >> dbLoadRecords ("db/test.db","device=${DEV},channel=3")
> >> dbLoadRecords ("db/test.db","device=${DEV},channel=4")
> >> ==========================================
> >> in st.cmd script and epics will get the system environment "DEV" so
> >> that I don't need to modify my ioc package and just use
> >> export DEV=blahblah
> >> on each device. But I kind of like my st.cmd script to be clean and
> >> neat, thus I made some .substitutions file like:
> >> ======================
> >> file "db/test.db" {
> >>     pattern { device, channel }
> >>         { "${DEV}", 1 }
> >>         { "${DEV}", 2 }
> >>         { "${DEV}", 3 }
> >>         { "${DEV}", 4 }
> >> }
> >> ======================

Since there really isn't much difference in content between these two, you can 
still achieve a clean and neat st.cmd file by moving all of the dbLoadRecords 
commands into a secondary script that you include from the main one:

== st.cmd ==================
# Load test.db for ${DEV}, channels 1 through 4
< loadTestDatabase.cmd
============================

== loadTestDatabase.cmd ====
dbLoadRecords ("db/test.db","device=${DEV},channel=1")
dbLoadRecords ("db/test.db","device=${DEV},channel=2")
dbLoadRecords ("db/test.db","device=${DEV},channel=3")
dbLoadRecords ("db/test.db","device=${DEV},channel=4")
============================

> I need testAll.db to be loaded many times so I don't like to put a lot of
> dbLoadRecords commands in the st.cmd script. Besides, I have like
> five or six macros in the .db file so that I can make it universal to the
> instruments in my charge. But when it appears in the st.cmd script, it's
> a long line and not supposed to be broken into several lines which,
> I'm sorry, doesn't seem perfect to me. While if I use the "pattern" form
> of a .substitutions template, the macros are just grouped logically.
> It's very nice except it can't accept the system environment.

My philosophy about this kind of question is that I really don't like taking 
initialization values or paths from environment variables, because it makes 
it harder to reproduce the same boot conditions at a later date.  All it 
takes is for someone to manually set a few environment variables before 
starting the IOC and you now can't come back three weeks later and get 
exactly the same result unless you remember exactly what those settings were 
â do you keep your ~/.login or ~/.profile files under CVS/SVN control?

In an operational control system reproduceability is important, so IMHO all 
initialization values should be given in startup scripts or .substitutions 
files that can be saved to a revision control system.  That's why I wouldn't 
*want* the IOC to expand environment variables in a .substitutions file 
(although I believe they do work in the filenames, because they get expanded 
in a different point of the code).

HTH,

- Andrew
-- 
Talk is cheap. Show me the code. -- Linus Torvalds


References:
How to pass system environment to .substitutions? Zhichu Chen
Fwd: How to pass system environment to .substitutions? Zhichu Chen

Navigate by Date:
Prev: Re: Recommended display manager? Kasemir, Kay (ky9)
Next: Extending EDM's supported PVs/data acquisition protocols Carl Schumann
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  <20082009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Fwd: How to pass system environment to .substitutions? Zhichu Chen
Next: Agenda for Padua Dalesio, Leo
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  <20082009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Sep 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·