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-02folder in/iocBoot/.Navigate to the
config.xmlfile ofrefIOC. In01you will see macros being defined, in02you will see the01config file being referenced. Create aconfig.xmlfile inioc<newIOC>-IOC-02and do the same.Check that there is a
st-common.cmdfile inioc<newIOC>-IOC-01if there is, note how
st.cmdreferences this. Copy this file intoioc<newIOC>-IOC-02and refactor all instances of01to02. Then, where the file callsst-common.cmd, you will need to add a line that navigates to theioc<newIOC>-IOC-01directory above it (there will be an example of this inioc<refIOC>-IOC-02).if there is not, note how the
st.cmdandst-common.cmdare set up inrefIOC. Inioc<newIOC>-IOC-01, transition thest.cmdcontents to ast-common.cmdfile and refactor thest.cmdto reference this in a similar way. Now follow the step above!
Copy across the
Makefile- this stays unchanged.Copy across
envPaths, changingioc<newIOC>-IOC-01toioc<newIOC>-IOC-02if it appears.Copy across
dllPath<...>andrelPathsfiles. 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-02Appfolder in/<newIOC>/Navigate to
<newIOC>-IOC-01Appand copy acrossDbto the02Appfolder.Empty the
O.folders of all.dbfiles.Delete all
.substitutionsfiles 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-01Appand copy acrosssrcto the02Appfolder.Empty the contents of both
O.folders.Delete the
build.makfileRename the
<...>Main.cppfile with the correct IOC number, and rename the header in the file itself.In the
Makefile, updateAPPNAMEwith the correct IOC number - but theinclude ...line needs to stay the same.
Check whether
<newIOC>-IOC-01Apphas aprotocolfileIf 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
makethe<newIOC>foldermake iocstartupsin 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.