EPICS_Introduction

advertisement
Found on http://www.semanticmetadata.net/category/comic/
Elke Zimoch, 3. October 2011
Wir schaffen Wissen – heute für morgen
Paul Scherrer Institut
Elke Zimoch
Introduction to EPICS
Elke Zimoch, 3. October 2011
Acknowledgment
Some slides in this talk came form the
„Getting started with EPICS“ lecture series of APS.
My special thanks go to
Ned Arnold
and
John Maclean
from the Advanced Photon Source.
The original talks can be found on
www.aps.anl.gov/epics/docs/GSWE.php
More people to thank for support:
Timo Korhonen, Detlef Vermeulen, Dirk Zimoch
Elke Zimoch, 3. October 2011
Contents
Morning: Introduction to EPICS Lecture
• What is EPICS?
• Examples from the EPICS tool box
• What are Records?
• How to set up an IOC?
• Conclusion
Afternoon: Hands-on training
• Implementation of a Cooling System (IOC)
• Some simple clients (medm)
• Some more exercises
Elke Zimoch, 3. October 2011
What is EPICS?
EPICS is an abbreviation for:
Experimental Physics and Industrial Control System
EPICS is:
• A collaboration
• A software tool kit
• A control system
architecture
EPICS
EPICS:
• supports distributed control systems for large research
facilities like accelerators
• uses Client/Server and Publish/Subscribe methods
• uses the Channel Access (CA) network protocol
Elke Zimoch, 3. October 2011
Who uses EPICS?
Some members of the collaboration (very incomplete!):
–
–
–
–
–
–
–
–
–
–
–
ANL (APS Accelerator, APS Beamlines, IPNS), Chicago, USA
LANL, Los Alamos, USA
ORNL (SNS), Oak Ridge, USA
SLAC (SSRL, LCLS), Standford, USA
JLAB (CEBAF), Newport, USA
DESY, Hamburg, Deutschland
BESSY, Berlin, Deutschland
Gemini 8m-Telescope, Hawaii, USA
PSI (SLS, SwissFEL), Villigen, Switzerland
KEK, Tsukuba, Japan
DIAMOND Light Source (Rutherford Appleton Laboratory),
Oxfordshire, England
– Australian Synchrotron, Melbourne, Australia
– Iter (Test Fusion Power Plant), South France
– ESS (European Spallation Source), Lund, Sweden
Elke Zimoch, 3. October 2011
History
• In 1989 started a collaboration between Los Alamos National
Laboratory (GTA) and Argonne National Laboratory (APS)
(Jeff Hill, Bob Dalesio & Marty Kraimer)
GTA: Ground Test Accelerator
APS: Advanced Photon Source
• More than 150 licenses agreements were signed, before
EPICS became Open Source in 2004
• Team work on problems, for example over “Tech Talk” mailing
list and webpage:
http://www.aps.anl.gov/epics/
• Two collaboration meetings every year (spring and autum)
in turns in America, Asia, and Europa
• Collaborative efforts vary
– Assistance in finding bugs
– Add manpower: Share tools, schemes, and advice
Elke Zimoch, 3. October 2011
Are there alternatives to EPICS?
System Name:
Collaborations:
• EPICS
Used at more than one Lab
• TANGO
Pro:
Bugs are already found
• DOOCS
• Tine
Single Site Systems:
Developed and used in one Lab
Pro:
Your problems solved
perfectly
• PVSS
(Cern)
Contra:
Complicated to adapt
to your problems
Contra:
You are on your own
(no one can help)
Commercial System
Pro:
Outsource your problems
Contra:
Expensive
Elke Zimoch, 3. October 2011
The architecture of EPICS
Network based Client/Server Model (hence the EPICS logo):
EPICS
CA
Client
CA
Client
Client Layer
Connection Layer
CA
Server
CA
Server
Server Layer
• For EPICS, client and server refer to their Channel Access
role: i.e. Channel Access Client and Channel Access Server
• This standard control system architecture is often called
3 tier architecture or 3 layer model
Elke Zimoch, 3. October 2011
What is Channel Access?
• A protocol how to transfer data over network
• A single data unit is called Process Variable
• A Process Variable has a unique name, which is used to refer
to the data (Naming convention needed!)
• The detailed operation of Channel Access is unimportant for
most programmers (it already works…)
• Channel Access is not dependent on a single programming
language (native library in C/C++, Java, and C# available)
• The entire set of Process Variables establish a Distributed
Real-time Database of machine status, information and
control parameters
EPICS Database
CAS
CAS
CAS
CAS
Process
Process
Process
Process
Variables
Variables
Variables
Variables
Elke Zimoch, 3. October 2011
Some Details of Channel Access
1. Query: Broadcast (UDP)
CA Client
2. Reply: direct connection (UDP)
3. All further queries and replies work
directly (Point-To-Point) (TCP)
Network
CA Server 1
CA Server 2
CA Server 3
Default UDP ports: 5064 and 5065 Defined in environment variables
Default TCP ports: 5064 and 5065 Need to be free in firewall!
Elke Zimoch, 3. October 2011
Channel Access Commands
“connection request”
or “search request”
Channel Access Client
Who has a PV named
“S1A:H1:CurrentAO”?
“get” or
“caget”
“put” or
“caput”
What is its
value?
Change its
value to
30.5
“set a monitor”
Notify me when the value
changes
CA Client
CA Server
Channel Access Server
I do.
25.5
AMPS
Process Variables:
OK, it is
now 30.5
“put complete”
S1A:H1:CurrentAO
S1:P1:x
or
S1:P1:y
S1:G1:vacuum
or
30.5 is too high.
It is now set to
the maximum
value of 27.5.
It is
now
It is
now
It is
now
20.5
AMPS
10.5
AMPS
0.0023
AMPS
“post an event”
or
“post a monitor”
You are not
authorized to
change this
value
Elke Zimoch, 3. October 2011
Contents
Morning: Introduction to EPICS Lecture
• What is EPICS?
• Examples from the EPICS tool box
• What are Records?
• How to set up an IOC?
• Conclusion
Afternoon: Hands-on training
• Implementation of a Cooling System (IOC)
• Some simple clients (medm)
• Some more exercises
Elke Zimoch, 3. October 2011
Examples from the EPICS software tool box
CA Client
CA Client
Client Programs:
alarmhandler
Striptool, medm,
many more …
(user programs)
Control Room
CA Server
CAIOC
Server
Input
Output
Cannel Access:
(UDP/TCP)
Server Programs:
(user programs)
iocCore
Records
Elke Zimoch, 3. October 2011
What is an IOC?
• A special CA Server and CA Client
(IOCs can “talk” to each other)
• A computer running the “IOC Core” program (at least once)
• This computer may be:
- VME based, operating system vxWorks (only possibility for old
EPICS Versions up to 3.14) or RTEMS
- PC, operating system Windows, Linux, RTEMS
- Apple, operating system OSX
- UNIX Workstation, operating system Solaris
• An IOC normally is connected to input and/or output
hardware (otherwise called softIOC)
• An IOC runs a record database, which defines what this IOC
is doing
Elke Zimoch, 3. October 2011
Some EPICS Client Programs
(from the EPICS Website – very incomplete, selection is no assessment)
• ALH: Alarm Handler
• BURT: Backup and Restore Tool
• CASR: Host-based Save/Restore
• CAU: Channel Access Utility
• Channel Archiver (SNS)
• CSS and BOY: Control System Studio and Best OPI,Yet
• Channel Watcher (SLAC)
• EDM: Extensible Display Manager (ORNL)
• JoiMint: Java Operator Interface and Management INtegration Toolkit
(DESY)
• Knobs: Knob Manager and KnobConfig, an Interface to SunDials
• MEDM: Motif Editor und Display Manager
• StripTool: Strip-chart Plotting Tool
• and many more …
+ Command line tools (caget, caput, …)
Elke Zimoch, 3. October 2011
Client Program: Command line tools
• Read a PV named <NAME>
caget NAME
>caget ARIDI-PCT:CURRENT
ARIDI-PCT:CURRENT 350.56
>
>caput ARIDI-PCT:CURRENT 401.5
Old: ARIDI-PCT:CURRENT 350.56
caput NAME value
New: ARIDI-PCT:CURRENT 401.5
>
• Get information about that Record
>cainfo ARIDI-PCT:CURRENT
cainfo NAME
ARIDI-PCT:CURRENT
State:
connected
>camonitor
• Start a monitor
Host: ARIDI-PCT:CURRENT
sls-cagw-1
250.542
Access:
read, no write
camonitor NAME ARIDI-PCT:CURRENT
ARIDI-PCT:CURRENT
Data type: 250.537
DBR_DOUBLE
(Cancel with [Ctrl] + [c])
ARIDI-PCT:CURRENT
250.533
Element count:
1
ARIDI-PCT:CURRENT
250.525
>
>
• Write a PV named <NAME>
Elke Zimoch, 3. October 2011
Client Program: medm
Elke Zimoch, 3. October 2011
Client Program: StripTool
channel
values
time
Elke Zimoch, 3. October 2011
Client Program: Alarmhandler
Tree structure of
Records
Guidance
Panel with more
Information
• Records have predefined alarm states (SEVR):
everything ok
– NO_ALARM
warning
– MINOR
alert (non controls problem)
– MAJOR
CA server ok, hardware error
– INVALID
No server!
– not connected
to the client (no Record state)
Elke Zimoch, 3. October 2011
Contents
Morning: Introduction to EPICS Lecture
• What is EPICS?
• Examples from the EPICS tool box
• What are Records?
• How to set up an IOC?
• Conclusion
Afternoon: Hands-on training
• Implementation of a Cooling System (IOC)
• Some simple clients (medm)
• Some more exercises
Elke Zimoch, 3. October 2011
What are Records?
A Record is an object with
– a unique name
– properties (fields) that contain information (data)
different data types can appear in different fields
– the ability to perform actions on that data
unique name
XYZ1234
Employee
: James Bond
Badge Number: 007
Address
: Whitehall, London
Salary
: £70070.07
fields
Data
Elke Zimoch, 3. October 2011
Make a Record from a Measured Value
recordwith
(ai, a"ARIDI-PCT:CURRENT")
unique name ARIDI-PCT:CURRENT
{
ai
A value with afield
data(EGU,
type "mA") 295,5
field a(EGUF,
with
unit "400")
mA
field (EGUL, "0")
with afield
time(HOPR,
stamp "370")
17.2.2005 14:21:16
field (LOPR,
NO_ALARM
with a severity (alarm
status) "0")
field (DESC, "Beam current in SR")
with technical
limits "HY8401") 0 bis 400
field (DTYP,
field (INP,
"#C3 S0 @") 0 bis 370
with graphical
limits
Configured by
with a}description „Beam current in SR“
developer
Readback from hardware/driver
VAL
SEVR
TIME
Elke Zimoch, 3. October 2011
Records and Channel Access Process Variables
• A PV name is comprised of two parts
– The record name, and
– the name of a field belonging to that record
• For example…
A Process variable name
ARIDI-PCT:CURRENT.
A record name
A dot to join them
EGU
A field name
• No dots allowed in Record names!
• Note that if no field name is given, Channel Access will
default to using the VAL field
“ARIDI-PCT:CURRENT” is interpreted as “ARIDI-PCT:CURRENT.VAL”
Elke Zimoch, 3. October 2011
What do Records do?
•
Depends on
1. Record Type
2. Field values
•
Records are active, they do things
– Get data from other records or from
hardware
– Perform calculations
– Check values are in range and raise
alarms
– Put data to other records or to
hardware
– Activate or disable other records
– Wait for hardware signals (interrupts)
•
record do nothing until they are processed
•Analog in
•Analog out
•Binary in
•Binary out
•Calculation
•Calculation out
•Compression
•Data fanout
•Event
•Fanout
•Histogram
•Motor
•Multi bit binary input
•Multi bit binary output
•PID control
•Pulse counter
•Pulse delay
•Scan
•Select
•Sequence
•String in
•String out
•Subarray
•Subroutine
•Waveform
Elke Zimoch, 3. October 2011
Record Processing
• Record processing can be periodic or event
driven
• Periodic: Standard scan rates are…
– 10, 5, 2, 1, 0.5, 0.2 and 0.1 seconds
– Custom scan rates can be configured up to
speeds allowed by operating system and
hardware
– No precise timing!
• Event driven: Events include
– Hardware interrupts
– Request from another record via links
– EPICS Events
– Channel Access Puts
Elke Zimoch, 3. October 2011
The Record Reference Manual
• Explains records from the EPICS base release
• Explains database concepts, record types, and record fields
• New Version as Wiki:
http://www.aps.anl.gov/epics/wiki/index.php/RRM_3-14
• Old Version (R3.13):
html: http://www.aps.anl.gov/epics/EpicsDocumentation/AppDevManuals/RecordRef/Recordref-1.html
pdf: http://www.aps.anl.gov/epics/EpicsDocumentation/AppDevManuals/RecordRef/Recordref.pdf
• More Records exist.
For example Motor Record (part of synApps package):
http://www.aps.anl.gov/bcda/synApps/index.php
Elke Zimoch, 3. October 2011
Example: Measure a Value
CA Client: medm
medm sets a CA monitor
Operator
every time the value changes
record triggers callback
IOC
Record Support
Device Support
Driver
Value (34 °C)
record …
field (SCAN, “.1 second”)
field (DTYP, “Hy8401”)
field (INP, “#C3 S0 @”)
field (VAL, “34”)
every 0.1 seconds the record
asks the driver for a value
and the driver reports back
Elke Zimoch, 3. October 2011
Contents
Morning: Introduction to EPICS Lecture
• What is EPICS?
• Examples from the EPICS tool box
• What are Records?
• How to set up an IOC?
• Conclusion
Afternoon: Hands-on training
• Implementation of a Cooling System (IOC)
• Some simple clients (medm)
• Some more exercises
Elke Zimoch, 3. October 2011
IOC Overview: What has to be done?
make
EPICS base
iocCore
some functions:
dbLoadDatabase
dbLoadTemplate
iocInit
driver
(optional)
seq (snl code)
(optional)
your own C-code
(optional)
xxxApp
configures
what the
IOC does
startup script: st.cmd
call iocCore functions
text file
dbd files:xxxApp.dbd
(data base definitions)
EPICS Version dependent!
additional files for drivers
text files
comes with
EPICS base
or drivers
substitution
template file
template
file
files
template file
text files
configure
Records
database files (db)
text files
Elke Zimoch, 3. October 2011
Steps towards your IOC (1/4)
• What you need before you start
– Build tools: gcc, make, tar, gzip
for EPICS
– Perl scripting language
extensions like
– Development package of readline
medm
– Development packages of X11 and Motif
– A text editor (e.g. nedit, kwrite, emacs)
• Browse EPICS home http://aps.anl.gov/epics
– Get latest Base
the latest is not always best:
– Get Extensions:
have a look at techTalk, read
“Known Problems” and
Config files 3.14, medm
“Release Notes”
read “Installation Instructions”
(Read Me) as well …
Elke Zimoch, 3. October 2011
Steps towards your IOC (2/4)
• Extract Base and Extension packages
tar xvfz baseR3.14.12-1.tar.gz
tar xvfz extensionsTop_20070703.tar.gz
tar xvfz medm3_1_5.tar.gz –C extensions/src
• Build Base
vxWorks-ppc604
win32
cygwin-x86
export EPICS_HOST_ARCH=linux-x86
cd base-3.14.12-1
make
export PATH=~/base-3.14.12-1/bin/linux-x86:$PATH
• Test the installation
softIoc
Elke Zimoch, 3. October 2011
Steps towards your IOC (3/4)
• Build Extensions (here: medm)
cd extensions/configure
– Edit the RELEASE file
nedit RELEASE
This is something
you often have to do
with EPICS
components
• Set correct path to EPICS Base, e.g.
EPICS_BASE=/home/epics/base-3.14.12-1
make
cd ../src/medm3_1_5
make
export PATH=~/extensions/bin/linux-x86:$PATH
• Test the installation
medm
Elke Zimoch, 3. October 2011
Steps towards your IOC (4/4)
• Make environment variables permanent
– Edit ~/.basrc and add variables:
export EPICS_HOST_ARCH=linux-x86
export EPICS_BASE=/home/epics/base-3.14.12-1
export EPICS_EXTENSIONS=/home/epics/extensions
export PATH=$EPICS_BASE/bin/$EPICS_HOST_ARCH:\
$EPICS_EXTENSIONS/bin/$EPICS_HOST_ARCH:$PATH
• EPICS can also be installed centrally (and maybe should)
– e.g. /opt/epics/base-3.14.12 and
/opt/epics/extensions
– or /usr/local/epics/…
Elke Zimoch, 3. October 2011
How does an st.cmd file look like (on Linux)?
start Application
set environment
on the IOC
load dbd files
and register them
configure hardware
(depends on driver)
load records
start IOC
“trainingIOC” should be meaningful (not exampleIOC or myIOC)
Elke Zimoch, 3. October 2011
How to create a record 1: db file
Record Type
Record Name
Driver
information
periodic
Record
processing
Records can be created in any editor
Graphical creation with VDCT (not used at PSI)
Elke Zimoch, 3. October 2011
How to create a record 2: substitutions and templates
• What to do if you have more than one instance
of a device?
– Multiply the record and change the name
works ok
– If you have 20 motors db file gets lengthy
– If the device not only needs one record but
more
(BPM with at least x, y, and intensity)
db file gets even more lengthy and
confusing [spell maintenance nightmare]
• Solution provided by EPICS:
substitution (with macro definition) and template
files
Elke Zimoch, 3. October 2011
How to create a record 2: substitutions and templates
DEVICE = MTRT1
$(DEVICE)-TEMP:READ
MTRT1-TEMP:READ
Elke Zimoch, 3. October 2011
IOC System in real … step by step
1.
2.
3.
4.
5.
6.
Prepare Application (make EPICS base + driver)
Write startup script (st.cmd file)
Write records (db file or substitution + template files)
Save to boot directory
Set boot parameters of VME computer
Reboot
– Load and start operating system (vxWorks)
– Load and start st.cmd
•
•
•
•
Load dbd files
Configure hardware
Load records
Start IOC (iocInit) and create records
7. Test functionality
8. Debug files and go to step 6
IOC Development: configure text files (no code, no make)
Elke Zimoch, 3. October 2011
Contents
Morning: Introduction to EPICS Lecture
• What is EPICS?
• Examples from the EPICS tool box
• What are Records?
• How to set up an IOC?
• Conclusion
Afternoon: Hands-on training
• Implementation of a Cooling System (IOC)
• Some simple clients (medm)
• Some more exercises
Elke Zimoch, 3. October 2011
10 really neat Things about EPICS
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
It is free
It is Open Source
There are lots of users
All a client needs to know to access data is a PV name
You can pick the best tools out there …
… or build your own
The boring stuff is already done
There is a lot of expertise available close by
A good contribution becomes internationally known
It does not matter, if you need 10 or 10 million PVs
(it is scalable)
11. It is fun (but maybe do not tell this to your management)
Elke Zimoch, 3. October 2011
Where to learn more?
• EPICS home page
http://www.aps.anl.gov/epics/
• Tech Talk: listen (and learn)
http://www.aps.anl.gov/epics/tech-talk/index.php
• Getting Started with EPICS lecture series
http://www.aps.anl.gov/epics/docs/GSWE.php
• Collaboration Meeting (twice a year)
http://www.aps.anl.gov/epics/meetings.php
Elke Zimoch, 3. October 2011
Contents
Morning: Introduction to EPICS Lecture
• What is EPICS?
• Examples from the EPICS tool box
• What are Records?
• How to set up an IOC?
• Conclusion
Afternoon: Hands-on training
• Implementation of a Cooling System (IOC)
• Some simple clients (medm)
• Some more exercises
Elke Zimoch, 3. October 2011
Example: Cooling System
IOC
ADC
Analog In
Database
MTTR1-LI:TEMP1
INP
Problem:
EGU:
Binary I/O
VAL
deg C
Calculation
Binary out
MTRT1-LI:CALC
Sensor
T1
In the LINAC we have a water chiller thatMTRT1-LI:COOL-SW
must be
INPA
turned ON whenever
the average temperature of
OUT
INPB
VAL
two temperature sensors rises
aboveDOL
a set point.
ADC
C:
10
The set point is nominally
45 degrees centigrade.
Analog In
MTRT1-LI:TEMP2
INP
Sensor
T2
EGU:
CALC: ( (A+B)/2 ) > C
Chiller
SCAN: 10 second
VAL
deg C
Elke Zimoch, 3. October 2011
• files prepared in directory
Training/vxWorks
• Installation directory:
/home/ioc/MTEST-VME-T1
• Installation:
copy (cp) st.cmd and db file
cp st.cmd /home/ioc/MTEST-VME-T1
cp COOLER.db /home/ioc/MTEST-VME-T1
Elke Zimoch, 3. October 2011
medm – say it with Pictures
MTRT1-LI-COOL:TEMP1
Elke Zimoch, 3. October 2011
IOC System in real … step by step
 1. Prepare Application (make EPICS base + driver)
 2. Write startup script (st.cmd file)
3. Write records (db file or substitution + template files)
4. Save to boot directory: /home/ioc/<IOC-NAME>
 5. Set boot parameters of VME computer
6. Reboot: type reboot in minicom window
– Load and start operating system
– Load and start st.cmd
•
•
•
•
Load dbd files
Configure hardware
Load records
Start IOC (iocInit) and create records
7. Test functionality
8. Debug files and go to step 6
Elke Zimoch, 3. October 2011
Download