EPICS How-Tos
Total Page:16
File Type:pdf, Size:1020Kb
EPICS How-Tos Sep 10, 2021 Contents 1 Installation on Linux/UNIX/DARWIN (Mac)1 1.1 What is EPICS about?..........................................1 1.2 Prepare your system...........................................1 1.3 Install EPICS...............................................1 1.4 Test EPICS................................................2 1.5 Create a demo/test ioc to test ca and pva.................................3 1.6 Add the asyn package..........................................4 1.7 Install StreamDevice (by Dirk Zimoch, PSI)..............................5 2 Packages required for EPICS on Centos 87 2.1 Overview.................................................7 2.2 Packages required to build EPICS base.................................8 2.3 Packages required by the sequencer...................................8 2.4 Packages required by epics-modules/asyn................................8 2.5 Packages required by the Canberra and Amptek support in epics-modules/mca............8 2.6 Packages required by the Linux drivers in epics-modules/measComp.................8 2.7 Packages required by areaDetector/ADSupport/GraphicsMagick....................8 2.8 Packages required by areaDetector/ADEiger..............................9 2.9 Packages required to build aravis 7.0.2 for areaDetector/ADAravis...................9 2.10 Packages required to build areaDetector/ADVimba...........................9 2.11 Packages required to build EDM.....................................9 2.12 Packages required to build MEDM...................................9 3 Creation of an Input/Output Controller (IOC) 11 4 Installation on Windows 15 4.1 Introduction............................................... 15 4.2 Required Tools.............................................. 16 4.3 Choice 1: Compiler........................................... 16 4.4 Choice 2: Build Environment and Tool Installation........................... 16 4.5 Choice 3: Static or DLL Build / Deployment.............................. 17 4.6 Windows Path Names.......................................... 17 4.7 Put Tools in the PATH.......................................... 18 4.8 Install and Build............................................. 18 5 How To Port EPICS to a new OS/Architecture 31 i 6 Common Database patterns 33 6.1 Pull Alarm Status w/o Data....................................... 33 6.2 Combined Setting and Readback..................................... 33 7 How to run an EPICS Collaboration Meeting 35 7.1 Organization............................................... 35 7.2 Communications............................................. 36 7.3 Facilities................................................. 36 7.4 Agenda.................................................. 36 8 How to Avoid Copying Arrays with waveformRecord 37 8.1 Example................................................. 37 9 How to find which IOC provides a PV 43 9.1 Find Host and TCP port......................................... 43 9.2 Find which process is using a TCP port (Linux only).......................... 44 9.3 Find information about a process (Linux only)............................. 44 9.4 Additional: Finding the procServ/screen running an IOC (Linux only)................. 44 ii CHAPTER 1 Installation on Linux/UNIX/DARWIN (Mac) 1.1 What is EPICS about? We assume that you know more or less what EPICS is. Here we want to start from scratch and get to the point where we have a working server, offering some PVs for reading (caget or pvget) and writing (caput or pvput), and we read and write on them from another terminal, either on the same machine or on another one in the same network. If you are going to use two different machines, you will have to repeat the steps for installing EPICS for both of them. 1.2 Prepare your system You need make, c++ and libreadline to compile from source. On macOS these dependencies can be installed by using e.g. homebrew. On Linux you can use apt-get install. The Packages required for EPICS on Centos 8 document lists all of the packages required to build EPICS base, the sequencer, synApps modules, and areaDetector. 1.3 Install EPICS mkdir $HOME/EPICS cd $HOME/EPICS git clone --recursive https://github.com/epics-base/epics-base.git cd epics-base make After compiling you should put the path into $HOME/.profile or into $HOME/.bashrc by adding the following to either one of those files: export EPICS_BASE=${HOME}/EPICS/epics-base export EPICS_HOST_ARCH=$(${EPICS_BASE}/startup/EpicsHostArch) export PATH=${EPICS_BASE}/bin/${EPICS_HOST_ARCH}:${PATH} 1 EPICS How-Tos EpicsHostArch is a program provided by EPICS that returns the architecture of your system. Thus the code above should be fine for every architecture. 1.4 Test EPICS Now log out and log in again, so that your new path is set correctly. Alternatively, you can execute the three lines above beginning with export directly from the terminal. Run softIoc and, if everything is ok, you should see an EPICS prompt. softIoc epics> You can exit with ctrl-c or by typing exit. Voilà. Ok, that is not very impressive, but at least you know that EPICS is installed correctly. So now let us try something more complex, which will hopefully suggest how EPICS works. In whatever directory you like, prepare a file test.db that reads like record(ai,"temperature:water") { field(DESC,"Water temperature in the fish tank") } This file defines a record instance called temperature:water, which is an analog input (ai) record. As you can imagine DESC stays for Description. Now we start softIoc again, but this time using this record database. softIoc-d test.db Now, from your EPICS prompt, you can list the available records with the dbl command and you will see something like epics> dbl temperature:water epics> Open a new terminal (we call it nr. 2) and try the command line tools caget and caput. You will see something like your prompt> caget temperature:water temperature:water0 your prompt> caget temperature:water.DESC temperature:water.DESC Water temperature in the fish tank your prompt> caput temperature:water 21 Old : temperature:water0 New : temperature:water 21 your prompt> caput temperature:water 24 Old : temperature:water 21 New : temperature:water 24 your prompt> caget temperature:water temperature:water 24 ... etc. Now open yet another terminal (nr. 3) and try camonitor as 2 Chapter 1. Installation on Linux/UNIX/DARWIN (Mac) EPICS How-Tos camonitor temperature:water First, have a look at what happens when you change the temperature:water value from terminal nr. 2 using caput. Then, try to change the value by some tiny amounts, like 15.500001, 15.500002, 15.500003. You will see that camonitor reacts but the readings do not change. If you wanted to see more digits, you could run camonitor-g8 temperature:water For further details on the Channel Access protocol, including documentation on the caput, caget, camonitor... command line tools, please refer to the Channel Access Reference Manual. In real life, however, it is unlikely that the 8 digits returned by your thermometer (in this example) are all significant. We should thus limit the traffic to changes of the order of, say, a hundredth of a degree. To do this, we add one line to the file test.db, so that it reads record(ai,"temperature:water") { field(DESC,"Water temperature in Lab 10") field(MDEL,".01") } MDEL stands for Monitor Deadband. If you now run softIoc-d test.db with the new test.db file, you will see that camonitor reacts only to changes that are larger than 0.01. This was just a simple example. Please refer to a recent Record Reference Manual for further information. 1.5 Create a demo/test ioc to test ca and pva mkdir -p $HOME/EPICS/TEST/testIoc cd $HOME/EPICS/TEST/testIoc makeBaseApp.pl -t example testIoc makeBaseApp.pl -i -t example testIoc make cd iocBoot/ioctestIoc chmod u+x st.cmd ioctestIoc> ./st.cmd #!../../bin/darwin-x86/testIoc < envPaths epicsEnvSet("IOC","ioctestIoc") epicsEnvSet("TOP","/Users/maradona/EPICS/TEST/testIoc") epicsEnvSet("EPICS_BASE","/Users/maradona/EPICS/epics-base") cd "/Users/maradona/EPICS/TEST/testIoc" ## Register all support components dbLoadDatabase "dbd/testIoc.dbd" testIoc_registerRecordDeviceDriver pdbbase ## Load record instances dbLoadTemplate "db/user.substitutions" dbLoadRecords "db/testIocVersion.db", "user=junkes" dbLoadRecords "db/dbSubExample.db", "user=junkes" #var mySubDebug 1 #traceIocInit cd "/Users/maradona/EPICS/TEST/testIoc/iocBoot/ioctestIoc" iocInit (continues on next page) 1.5. Create a demo/test ioc to test ca and pva 3 EPICS How-Tos (continued from previous page) Starting iocInit ############################################################################ ## EPICS R7.0.1.2-DEV ## EPICS Base built Mar 8 2018 ############################################################################ iocRun: All initialization complete 2018-03-09T13:07:02.475 Using dynamically assigned TCP port 52908. ## Start any sequence programs #seq sncExample, "user=maradona" epics> dbl maradona:circle:tick maradona:compressExample maradona:line:b maradona:aiExample maradona:aiExample1 maradona:ai1 maradona:aiExample2 ... etc. ... epics> Now in another terminal, one can try command line tools like caget, caput, camonitor, cainfo (Channel Access) pvget, pvput, pvlist, eget,... (PVAccess) 1.6 Add the asyn package cd $HOME/EPICS mkdir support cd support git clone https://github.com/epics-modules/asyn.git cd asyn Edit $HOME/EPICS/support/asyn/configure/RELEASE and set EPICS_BASE like EPICS_BASE=${HOME}/EPICS/epics-base Comment IPAC=... and SNCSEQ=..., as they are not needed for the