SAD and Python with EPICS - KEK:Accelerator Laboratory

Download Report

Transcript SAD and Python with EPICS - KEK:Accelerator Laboratory

SAD and Python with
EPICS
at IHEP,Beijing, 2002.8.21
Noboru Yamamoto
KEK, JAPAN
Simple, well understood behavior
High Level Applications in KEKB
●
Applications and Operator displays in KEKB
Application Launcher
SAD medm Python
Top
Level
Applications
268
19
31
misc
Total
5
292
●
SAD is widely used for high level applications.
●
medm/dm2k is used for simple displays.
●
Python is also used for application development.
SAD applications
●
Operator Interface
–
–
–
●
Optics measurement
Optics calculation and Optics
Collision Monitors ...
Slow Feedback (with OPI)*
–
–
iBump:a system keeps beams in collision
Closed orbit correction
*)It is preferable to separate FB loop and its user interface into different
processes.
KEKB Launcher
●
●
●
●
●
Program written in SAD/KEKB Frame
Starting point of KEKB operation
User can register a new command on the
fly*.
simple load balancing between servers.
User can select a host to execute a
command.
*) Application reads a configuration file , kbl.conf, at start up and on
request by operator.
Applications in KBL
A sample SAD/KBFrame application
Applications using Python and Pmw
SAD and Python compared
●
SAD
–
–
–
–
–
Accelerator modeling
Developed at KEK
Mathematica like
scripting
support CA and Tk
widget
Modules for KEKB
operation
●
Python
–
–
–
–
–
–
General Purpose Object
Oriented dynamic language
Developed by Open source
project
Simple and Clean syntax
Support CA and Tk widget
RDBMS interface
Variety of extension
modules
SAD installation
●
SAD Source Download Page
–
–
–
–
http://acc-physics.kek.jp/SAD/SADDownloadPage.html
You need ID and password to download the source code.
Contact [email protected] for your ID and
password.
You also need Tcl/Tk source code and a patch specific to
SAD/Tkinter.
Electric conference room for SAD (in Japanese).
SAD script
●
●
SAD Scripts follows Mathematica(R) syntax.No
statements, just functions.
Every Elements has a form:
–
–
●
Some Element has a special notation
–
–
●
Head[arg1, arg2,...]
eg. If[cond, st1, st2 ]
Plus[ 1, 2] <-> 1+2
List[a,b,c] <-> {a, b, c}
Name of element/function is same as that of
Mathematica.
KEKB Frame
●
Framework, i.e. a collection of
programs/scripts, to support
development of GUI
Application
–
–
–
●
Standard Menu
Help menu including “Process
Info”
status bar including print button
Build upon Tkinter Widget Set
Extending SAD
●
●
●
●
SAD modules can be used to extend SAD script
functionality, i.e. add a new function to SAD
script.
SAD modules is a library written in SAD script.
Fortran and C is used to develop SAD program
itself.
Fortran or C can be used add a new functionality
to SAD script.
Python installation
●
Python Web site: http://www.python.org/
–
–
–
–
–
Source code and binary(Windows, Mac, rpm)
gnuzip;tar; configure; make from tar.gz file.
Use of Pmw(Python mega widget) together with
Tkinter is recommended
Use of Gtk+(PyGtk) is another possibility.
Get CA interface from ANL EPICS web site or KEKB
web site (or Both)
Python syntax
●
●
Python uses indentation to specify a block
structure of a program e.g.:
if cond :
statements_1
else:
statements_2
other_statements
Usage of special characters are common to most
of programing language.
Extending Python
●
●
●
●
Python modules add new functions and/or classes
to Python language.
There already exists a rich set of Python modules.
C or C++ can be also used to develop new
modules ( C-modules).
Tools such as SWIG can be used to develop a Cmodule.
Embedding Python
●
●
●
Python can be used as an extension language of
the existing program.
It adds flexibility and extendability to the
program.
For example, PostgreSQL, a free RDBMS, can
use Python to define a stored procedure or define
a new object.