# Training Setup

## Initial Computer Setup

Each time you boot a computer with the LiveCD, open a terminal window
and type:

sudo mkdir /ade/training

sudo mount -t nfs ics-srv02.sns.ornl.gov:/ade/training /ade/training

*Note: This takes about 2 minutes to complete...*

source /ade/training/setup.sh

As long as the computer keeps running, those files should remain
'mounted', so you won't have to type this again *until the next power
cycle* *or reboot*.

Why? The Ubuntu LiveCD contains a generic Linux and EPICS environment,
primarily to allow SNS personnel to use EDM on their PCs and laptops
without having to permanently install Linux. It is not specific to this
training session, plus it is read-only, so additional files are kept on
a network file server, where you can also save training files. As a
result of those mount commands, you should be able to use the
"Places/Computer" menu, navigate to "Filesystem", then the
/ade/training/groups directory, and see something like this:

![](media/image1.png){width="4.774305555555555in"
height="3.685416666666667in"}

Under /ade/training/Docs, you will eventually find all the training
documentations, including this Intro. *If possible, open their "pdf"
version.* While you can open the original "ppt" or "doc" files with Open
Office, that will usually be much slower and use more memory on your
computer.

## Where to save stuff

The Live CD setup is read-only and does not alter the local hard drive
of your computer at all. In order to save files that you create in the
process of the hands-on training sessions, they need to be stored on the
file server. Each group has its own file folder under

/ade/training/groups/t1, t2, t3, \...

So the first team uses the 't1' folder, the second the 't2' folder and
so on.

Anything stored on the "Desktop" or other location local to your
computer will be lost after a reboot!

## Initial Soft-IOC Setup

In the following days, we'll learn more about the 'IOC', database, etc.,
as well as the client tools. To get started, we need to create a
so-called 'soft IOC'. Don't worry about details for now, just do
it^TM\ Nike^:

\# Go to your directory on the server,

> \# i.e. the 't1', 't2', ... folder:

cd /ade/training/groups/t1

mkdir soft

cd soft

makeBaseApp.pl --t example softApp

makeBaseApp.pl --i --t example iocSoft

*Enter 'soft' when asked for the application to boot.*

> *Use 'vi' or Applications/Accessories/Text Editor' to modify the file\
> iocBoot/iocSoft/st.cmd : Wherever it says "ubuntuHost",\
> replace that with your group name, i.e. "t1", "t2", \...*
>
> *Also edit the file configure/RELEASE: Change the line #SNCSEQ=....
> into\
> SNCSEQ=/ade/training/ubuntu_stuff/ext/src/seq*

chmod +x iocBoot/iocSoft/st.cmd

make

## Start/Stop the Soft IOC

In a terminal window, do this to start the soft IOC:

cd /ade/training/groups/t1/soft/iocBoot/iocSoft

./st.cmd

You should find yourself in the "IOC Shell". Try the following:

dbl\
(data base list) should give a list of record names, including
"t1:calcExample". If you don't see records with "t1", "t2" or whatever
your group name is, you need to edit the st.cmd file again.

dbpr "t1:calcExample"\
(data base print record) prints the fields of the record with given
name.

dbpr "t1:calcExample", 4\
prints *all* the fields of the record with given name. It's usually a
good idea to always use "dbpr ...., 4". As a side note, you don't have
to use quotes on a soft IOC. So

dbpr t1:calcExample, 4\
would work as well. But: On a "real" vxWorks IOC, you must use quotes
around the record names (because of differences between the vxWorks and
the IOC shell...). So it's best to get into the habit of always using
quotes, since that works everywhere.

exit\
exits the IOC shell and stops the soft IOC.

When we later change to the "database", you will have to restart the
soft IOC by typing "exit" and then start it again via "./st.cmd". In
case you already successfully executed the exit command right now, start
the IOC shell again since it needs to be up and running for most of the
training.

## Database Cheat Sheet

... ignore for now, but you'll need this later.

-   You will find two copies of each database file:\
    One in /ade/training/groups/t1/soft/softApp/Db, and another in
    /ade/training/groups/t1/soft/db. Note the "Db" vs. "db". You should
    only ever add/modify databases under softApp/Db. The EPICS make
    system will install them into the db directory, maybe after some
    processing like removal of comments and expansion of macros.
    Anything you do to those installed databases in the "db" directory
    will be overwritten!

-   Recipe for adding a database:\
    cd soft/softApp/Db\
    \# add a new \*.db file\
    \# edit Makefile, add a new "DB += ..." line\
    make

-   Recipe for changing a database:\
    cd soft/softApp/Db\
    \# edit the \*.db file\
    make

-   We can create or edit database (\*.db) files any which way we want.
    Popular choices are "vi" and "vdct". The latter needs to be launched
    with the "dbd" file:\
    cd soft/softApp/Db\
    \# Start blank instance\
    vdct ../../dbd/soft.dbd &\
    \# Edit existing database\
    vdct ../../dbd/soft.dbd dbExample1.db &

## More IOC Shell commands

help\
should give a list of available commands.

dbgf "t1:calcExample.DESC"\
is the database-get-field, and

dbpf "t1:calcExample.DESC", "new value"\
is the database-put-field.