Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Panel
11. How do I create a startup script for my ioc?

The third and final script is specifically to setup and start your EPICS ioc.

The 'startupConsole-bd32.cmd' lets you start your EPICS ioc as a foreground process in your host.

This lets you observe the ioc boot process to catch errors and interact with the ioc shell via iocConsole.

This is useful during development for debugging. Once the ioc has been tested fully, you can automatically start and run the process in background.

Under linuxRT, your EPICS ioc must run as a real-time process. It must lock the kernel in memory.

The following command in your 'startupConsole-bd32.cmd' does that:

ulimit -l unlimited

The following line is also needed to run the ioc with real-time priorities:

ulimit -r unlimited

Finally, you will be running your ioc as a specific user called as 'laci' who has permissions to run this ioc:
Setup the permissions for this user 'laci':

umask 002

Now you are ready to start your IOC and have it run as a foreground process.

Create a directory called as 'vioc-b34-bd32' for your ioc as below:
 
mkdir $IOC/ioc-b34-bd32/vioc-b34-bd32

cd $IOC/ioc-b34-bd32/vioc-b34-bd32
 
Set up a soft link to the 'bin' directory of your IOC app that you created in step (6). This is where your executable is:

ln -s  /afs/slac/g/lcls/epics/R3-14-12-4_1-0/iocTop/TestMyTest/Development/bin/linuxRT-x86 bin

Create an ASCII text file called 'screenrc' with the following lines in it:

deflog on

logtstamp on

defscrollback 10000

'screenrc' is passed as an argument to the 'screen' process and allows us to customize a few parameters such as number of lines stored in history buffer that we can scroll back for viewing.

In the same directory $IOC/ioc-b34-my01/vioc-b34-my01, add a startup script 'iocStartup.cmd' for vioc-b34-my01:

It setups some shell environment variables used by all iocs, and starts the st.cmd file in your ioc boot directory.

The EPICS environment variables that are set in this script can be used by your application's st.cmd script.

The default st.cmd script generated by the module icdTemplates, expects the following environment values to be defined somewhere.

iocStartup.cmd may be a good place to define it:

epicsEnvSet("IOC_NAME","VIOC:B34:BD32")

epicsEnvSet("IOC_APP","/afs/slac/g/lcls/epics/R3-14-12-4_1-0/iocTop/TestMyTest/Development")

epicsEnvSet("IOC_BOOT","${IOC_APP}/iocBoot/vioc-b34-bd32")

epicsEnvSet("IOC_COMMON","/afs/slac/g/lcls/epics/iocCommon")

epicsEnvSet("SYS_FACILITY","SYS0")

In addition to setting these environment variables, this script also executes some scripts common to all EPICS IOCs, such as below:

${IOC_COMMON}/All/Dev/linuxRT_pre_st.cmd

${IOC_COMMON}/All/Dev/linuxRT_post_st.cmd

The IOC application startup occurs between the pre and post scirpts:

cd ${IOC_BOOT}

< st.cmd

Panel
12. What are the guidelines for creating App-specific st.cmd?

Work is still in progress regarding standardizing App-specific st.cmd.

The IOC engineer has freedom to be creative with this script during development.

But the following are expected as a minimum when the ioc is installed in production.

That is the reason they are included in the default template provided by the icdTemplates module, as a guideline:

    1.  Making available several key paths and variables to your ioc by setting the environment variables.
      These were auto-generated during the application 'make' process and stored the 'envPaths' file under your ioc's boot directory.
      st.cmd should set all these variables using 'envPaths'.
      < envPaths
    2. Set the '<TOP>' variable. You could do this via the macro ${IOC_APP} which was defined in 'iocStartup.cmd' as describe before.
      epicsEnvSet(TOP,"${IOC_APP}")
    3. Load Timing-related databases using standard templates.
    4. Load iocAdmin and iocRelease databases using standard templates
    5. Load database for autosave using standard templates and use "makeAutosaveFiles" to autogenerate the PVs to be autoasaved/restored.

While the above is common guideline for all iocs, the following is specific to linuxRT.

You can set up real-time priorities after iocInit() for your driver threads and this can be done with a script such as rtPrioritySetup.cmd.

cd ${IOC_BOOT}

system("/bin/su root -c `pwd`/rtPrioritySetup.cmd")

Look at /afs/slac/g/lcls/epics/R3-14-12-4_1-0/iocTop/TestMyTest/Development/iocBoot/vioc-b34-bd32/rtPrioritySetup.cmd as an example.

...