Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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:

OptionSelectsExample
-pApplication code and executablemouse
-lLocation in the IOC namepark
-dDevice part of the IOC namewoodmouse
-fFolder containing the applicationjeonglee_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

  1. From the directory containing mouse/, generate a second instance:

    bash tools/generate_ioc_structure.bash -l park -p mouse
    

    park is outside the predefined facility locations. Enter y when asked to continue. The script creates mouse/iocBoot/iocpark-mouse/.

  2. In the same parent directory, generate an instance with another device name:

    bash tools/generate_ioc_structure.bash -l park -p mouse -d woodmouse
    

    This creates mouse/iocBoot/iocpark-woodmouse/. The application code remains mouseApp, and both instances run the mouse executable.

  3. 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"
    
  4. In mouse/, start the location instance:

    cd iocBoot/iocpark-mouse
    ./st.cmd
    

    Wait for iocRun: All initialization complete, then enter exit.

  5. From iocpark-mouse/, start the device instance:

    cd ../iocpark-woodmouse
    ./st.cmd
    

    Wait for initialization and enter exit before continuing.

Use a different folder name

  1. Return to the directory containing tools/ and mouse/. Copy the application to a destination that does not already exist:

    cp -a mouse jeonglee_mouse
    

    Keep the exact folder name jeonglee_mouse rather than substituting your own username so the remaining commands in this lesson match as shown.

  2. Generate an instance in that folder:

    bash tools/generate_ioc_structure.bash -l bts -p mouse -f jeonglee_mouse
    

    -f selects the folder. -p mouse selects the application already in that folder. The instance is iocBoot/iocbts-mouse/.

  3. 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.cmd
    

    Wait 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.