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-laci-rt.cmd' lets you start your EPICS -based 'virtual' ioc as a foreground process in your host.

When the ioc is started as a foreground process, you can This lets you observe the ioc boot process and 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.

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

The following command in your 'startupConsole-laci-rt.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 'virtual' ioc process under the following directory:
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-3_1-0/iocTop/Test/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, then changes to the ioc boot directory 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-3_1-0/iocTop/Test/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 Apllication Startup is sandwiched application startup occurs between the above  two pre and post scirpts:

cd ${IOC_BOOT}

< st.cmd

...