Greetings,
Since there seemed to be no reply to my original post, and I was able to figure this out, I'm posting my solution for the benefit of the community.
The original post is below for continuity. Recapping:
1) how to dynamically (at run time) generate new PV names based upon the current box (node) the code is running on. This nodeName is comprised of XXX-123456:<PV_NAME>, where the 123456 is the last 3 bytes of the box's MAC address. So Box A would be XXX-123456:<PV_NAME> and box B would be XXX-7890AB:<PV_NAME>, etc.
Solution:
- During initialization, my init code will generate a file: nodeName
- this file contains the following 1 line:
epicsEnvSet("EPICS_NODE_NAME", "XXX-123456:")
- Each record in the DB is defined in a similar manner:
record(longin,"$(nodeID)Sample1_R")
- In the st.cmd file, I added the following line:
< opt/data/nodeName
- This occurs AFTER the ioc_registerRecordDeviceDriver call and before loading of each (of 3) database files
- Then, the database records are loaded in this manner:
dbLoadRecords("db/Variables.db", "nodeID = $(EPICS_NODE_NAME)")
- The end result is as I desired: Each PV is now pre-pended with the unique nodeName generated @ boot time.
This took a bit of research and searching around, though the tech-talk mailing list and the documentation. Eventually, I was able to piece together enough so that this solution revealed itself.
Thanks!
Regards,
Stephen Beckwith
==========================================================
Original Post:
Greetings All,
I have the following quandray to which I am unable
to find a solution. Given my (limited) understanding of EPICS and how
it describes it's databases/records, maybe I'm missing something here,
or maybe I'm just SOL.
Setup: EPICS 3.14.12.4
ASYN4-22
Target: Host mode run for testing (AMD x86, Ubuntu Linux) Eventual target is Dual-Core ARM Cortex A9 running Embedded Linux.
Desired
Goal: @ initialization (run-time), when the records are loaded (after
initialization), via a .subs file, have the .subs file itself include
another file that was written during initialiation which contains data
for macro substitution.
Current setup:
- st.cmd uses dbLoadTemplate "db/node.subs"
- node .sub has 3 sets of:
file "db/db1.db" {
{ nodeID = "AA-000102:" }
}
- This then gives one a Process Variable (PV) of: "AA-000102:SystemTemp" for example
This works just fine dandy.
Now, what I would like to do is: Replace the "AA-000102" with another string, read from
a file that was genrated/written prior to loading the DB.
So this becomes like a "macro within a macro" sort of situation.
Scouring tech-talk doesn't turn up anything - there a couple close ones, but trying them failed. . .
The
"AA-000102" is the "node name" for the device where "000102" is really
the last 3 bytes of the devices MAC address. I have the code that
generates this information, that I can then write to a file, or EXPORT
to the environment (though I believe this would be too late to have any
affect).
The "hard way" is for me to re-create this .subs file @ initialization
with the correct information, but that seems alot of work. Or run some
utility prior to starting EPICS IOC to generate this static file. . .
I was hoping the EPICS system would be smart enough handle this for me.
This is a "run-time" binding (sort of), which limits my options over a static setup.
Thank you for your time and expertise.
Regards,
Stephen Beckwith