2.2 Add IOC instances to one application
Use one compiled application for several IOC instances. Each instance has
its own startup directory under iocBoot; all use the same mouseApp code.
Complete Generate and run an IOC application first. In each command
below, start in the directory containing tools/ and mouse/.
Choose the names
The generator uses these options:
| Option | Selects | Example |
|---|---|---|
-p | Application code and executable | mouse |
-l | Location in the IOC name | park |
-d | Device part of the IOC name | woodmouse |
-f | Folder containing the application | jeonglee_mouse |
Use ASCII letters, digits, and underscores for APPNAME, LOCATION, and
FOLDER. Keep the application name’s case unchanged when adding an
instance. Avoid ioc in application and location names.
Add another location
-
From the directory containing
mouse/, generate a second instance:bash tools/generate_ioc_structure.bash -l park -p mouseparkis outside the predefined facility locations. Enterywhen asked to continue. The script createsmouse/iocBoot/iocpark-mouse/. -
In the same parent directory, generate an instance with another device name:
bash tools/generate_ioc_structure.bash -l park -p mouse -d woodmouseThis creates
mouse/iocBoot/iocpark-woodmouse/. The application code remainsmouseApp, and both instances run themouseexecutable. -
In
mouse/, build the application and prepare local diagnostic output:cd mouse make mkdir -p epics-pvinfo/env epics-pvinfo/names export TARGET_TOP="$PWD" -
In
mouse/, start the location instance:cd iocBoot/iocpark-mouse ./st.cmdWait for
iocRun: All initialization complete, then enterexit. -
From
iocpark-mouse/, start the device instance:cd ../iocpark-woodmouse ./st.cmdWait for initialization and enter
exitbefore continuing.
Use a different folder name
-
Return to the directory containing
tools/andmouse/. Copy the application to a destination that does not already exist:cp -a mouse jeonglee_mouseKeep the exact folder name
jeonglee_mouserather than substituting your own username so the remaining commands in this lesson match as shown. -
Generate an instance in that folder:
bash tools/generate_ioc_structure.bash -l bts -p mouse -f jeonglee_mouse-fselects the folder.-p mouseselects the application already in that folder. The instance isiocBoot/iocbts-mouse/. -
In
jeonglee_mouse/, rebuild the copied application:cd jeonglee_mouse make clean uninstall make mkdir -p epics-pvinfo/env epics-pvinfo/names export TARGET_TOP="$PWD" cd iocBoot/iocbts-mouse ./st.cmdWait for initialization, then enter
exit.
Check an invalid application name
From the directory containing tools/ and jeonglee_mouse/, try changing
the case of the existing application name:
bash tools/generate_ioc_structure.bash -l ar05 -p mOuse -f jeonglee_mouse
The generator must reject the mismatch between mOuse and mouse.
A rejected command returns a nonzero status; it is the expected result
of this exercise.
Verification
In mouse/, compare the startup files:
diff iocBoot/iochome-mouse/st.cmd iocBoot/iocpark-mouse/st.cmd
diff iocBoot/iochome-mouse/st.cmd iocBoot/iocpark-woodmouse/st.cmd
The IOC identity and location-dependent settings differ. diff returns
status 1 when it finds differences; that status does not mean the
generator failed.
The exercise is complete when all three added instances initialize and
the wrong-case application name is rejected. To add a fourth location,
repeat the generator with -l lab -p mouse, build, and run its startup.