Duplicating IOCs
IOC Duplication script
There is a script in ibex utils to duplicate IOCs, more information can be found here.
The manual instructions below can also be used.
Navigate to an IOC folder which has two or more IOCs: here we have two folders to focus on, <ioc>/iocBoot/
and <ioc>/<ioc>-IOC-0<n>App
(where n
is the number of IOCs). Make sure this IOC has a st-common.cmd
file (to make your life easier!). Let us refer to this as refIOC
.
Now, let’s get cracking!
Making IOC 2: iocBoot/ioc<newIOC>-IOC-02>
Create a new
ioc<newIOC>-IOC-02
folder in/iocBoot/
.Navigate to the
config.xml
file ofrefIOC
. In01
you will see macros being defined, in02
you will see the01
config file being referenced. Create aconfig.xml
file inioc<newIOC>-IOC-02
and do the same.Check that there is a
st-common.cmd
file inioc<newIOC>-IOC-01
if there is, note how
st.cmd
references this. Copy this file intoioc<newIOC>-IOC-02
and refactor all instances of01
to02
. Then, where the file callsst-common.cmd
, you will need to add a line that navigates to theioc<newIOC>-IOC-01
directory above it (there will be an example of this inioc<refIOC>-IOC-02
).if there is not, note how the
st.cmd
andst-common.cmd
are set up inrefIOC
. Inioc<newIOC>-IOC-01
, transition thest.cmd
contents to ast-common.cmd
file and refactor thest.cmd
to reference this in a similar way. Now follow the step above!
Copy across the
Makefile
- this stays unchanged.Copy across
envPaths
, changingioc<newIOC>-IOC-01
toioc<newIOC>-IOC-02
if it appears.Copy across
dllPath<...>
andrelPaths
files. These also stay unchanged.
Making IOC 2: <newIOC>-IOC-02App
This one may be slightly less straightforward. There may be nuances and additional things in this folder to deal with that aren’t mentioned below - either try find another IOC with similar oddities or ask someone!
Create a new
<newIOC>-IOC-02App
folder in/<newIOC>/
Navigate to
<newIOC>-IOC-01App
and copy acrossDb
to the02App
folder.Empty the
O.
folders of all.db
files.Delete all
.substitutions
files from top level.In
Db\O.windows-x64\Makefile
, refactor the lineDB += something.db ...
with#DB += xxx.db
(e.g just comment it out)
Navigate to
<newIOC>-IOC-01App
and copy acrosssrc
to the02App
folder.Empty the contents of both
O.
folders.Delete the
build.mak
fileRename the
<...>Main.cpp
file with the correct IOC number, and rename the header in the file itself.In the
Makefile
, updateAPPNAME
with the correct IOC number - but theinclude ...
line needs to stay the same.
Check whether
<newIOC>-IOC-01App
has aprotocol
fileIf it does, just copy this across. As far as I can see, the Makefiles and folder contents seem to be the same.
After duplication
After either using the script or creating duplicates manually be sure to make and test to IOC.
Making the IOC
make
the<newIOC>
foldermake iocstartups
in EPICS topTry to run your new IOC!
Testing the IOC
Navigate to IOCTestframework
or the ioc/<newIOC>
folder (wherever the IOC tests live).
Refactor DEVICE_PREFIX
to <newIOC>_02
and you will need to refactor any calls to get_default_ioc_dir()
with additional parameter iocnum
(or whatever the equivalent is in your test module, this should be pretty intuitive).
WARNING: If you will also be making more IOCs via the method below, you should be very confident that your new <newIOC>_02
behaves the same as <newIOC>_01
before duplicating: any issues with <newIOC_02
will be propagated in every other new IOC you make as well.