Development of the Software Tools Using Python
for EPICS-Based Control System
Tatsuro Nakamura, Kazuro Furukawa, Jun-Ichi Odagiri, Noboru Yamamoto
KEK, Tsukuba, Ibaraki, JapanAbstruct
In the commissioning phase of accelerators, many application programs are built and modified frequently by nonexpert programmers. Scripting language such as
Python is suitable for such quick development. Since EPICS Channel Access interface library in Python was developed in KEKB accelerator control system, many
programs has been written in Python. We have been developing, providing some tools and libraries for Python programming. Some of the recent developments in
KEK are reported, and possible applications are also discussed.

Introduction----- About KEKBKEKB is an asymmetric electron-positron collider
at 8 × 3.5 GeV/c for B-meson physics.
KEKB started in operation in Dec.1998.
KEKB accelerators control system:
EPICS-basedMore than 100 VME/VxWorks computers as IOC
Several workstations of 4 kinds of platform
PA-RISC/HP-UX,PC-AT/Linux,

Simple-CA

casaveSimple-CA library iscasave isA wrapper library of Python-CA
Easier to use
Single get or put operation in single function call“db”

Compatible to EPICS database file(It implicitly waits until the request is completed.)“dbpf”

List of dbpf commands

Example of synchronous get by Simple-CA“simple” Each line contains channel name and value.
“valstat” Each line contains channel name, value,

import casvalue = cas.caget("channel_name")severity, status, and timestamp.

Alpha/OSF1,Macintosh/OSX

List operation of Simple-CA
Multiple channels at single function call

Introduction

a library module to save channel values to files.
Available formats are----- About Python

Python is an interpretive programming language.
Suitable for rapid application development

Example of configuration file of casavefrom casave import defSaveFile
defSaveFile(More efficient than multiple function call foreach channels

iocname = "ioc_name",filename = "save_file_name.db",
filedir = "dir_path/",Example of multiple gets by Simple-CAbackup = "flat",

import cas

format = "db",v1,v2,v3 = cas.caget(["name1","name2","name3"])chanlist = [("channel_name1","rec_name1","INP","ai"),("channel_name2","rec_name2","DOL","ao"),

Simple and easy to learn("cahnnel_name3","rec_name3","DOL","bo")])

Python has powerful features:
Efficient high level data structures

CA-Widgets

Object-oriented programming

CA-Widgets is a ready-made widget library

Rich libraries, which cover wide range of areas
Python code is highly productive and maintainable.

Convenient parts set to build GUI of control
application programs.
CA-Widgets is:

Python-CA is a Python interface module to EPICS
CA (Channel Access).
Python-CA provides basic functions of CA:
get, put, monitor

record(ai,“rec_name1") {field(INP, " 1.250000000000000000E+00")}
record(ao,“rec_name2") {field(DOL, " 8.000000000000000000E+00")}
record(bo,“rec_name3") {field(DOL, " 0")}Sample code of save operation using casave

based on Tkinter (Python interface to Tcl/Tk)

Python-CA

Example of saved file (db format)

easily extensible using object-oriented featureof Python/Tkinter.

from casave import SaveFileDict
import configuration1, configuration2, configuration3
for v in SaveFileDict.values():v.get()
v.dbsave()

Examples:caBitPattern widgets
Bit pattern representation of channel value

All of Python programs which perform CA are built
based on this module.

caused red by MAJOR severity

AutoSaver
AutoSaver ----- An application of casave
AutoSaver automatically save files whenmonitoring channels are disconnected.

Example of Python-CA (get operation)
import ca

Channel Information Display
shown by middle mouse buttonchan = ca.channel("channel_name")

AutoSaverchan.wait_conn()chan.get()ca.pend_event(1.0)
value = chan.val

1.234

caWritableLabel widget
Text representation of channel value→(1) channels are monitored(3) values are saved(2) when disconnecteddouble click

dialog box to enter new value

IOCrecord
1.234

file
1.234
(4) read files at start up time