CASI - Channel Archive Scripting Interface

This is a SWIG-based scripting interface to the ChannelArchiver I/O library.
(It replaces the previous, TCL-only "ATAC" extension)

SWIG, tcl, perl, python

SWIG generates the glue code to get from a C/C++ library, in this case the ChannelArchiver I/O library, to a scripting language like perl, python, ...
So far supported: There are example scripts, some using tk, BLT, Pmw. Originally only tcl was supported because it provides cross-platform portablility for GUI programming. Personally I find python is a better language than tcl for calculation and writing reusable modules. It also turns out to have the same or even better support for tk & BLT. Perl is certainly a good pick for text processing.

Setup

Details on building casi as well as how to install python and useful extensions are in the Readme.htm file in the casi source directory.
On Unix systems, the scripting languages like python can be installed in /usr/bin, /usr/local/bin or ... Vladimir Sirotenko suggested using
  #! /bin/env python
  
to keep the scripts independent from installation details. This means they run as long a python is in your PATH. This doesn't work in all cases, though. It is also a security hole if someone sneaks a fake python in your PATH. On Windows, .py files are usually associated with python, .pl can be bound to perl etc., the shebang is ignored.
On Unix you might have to set LD_LIBRARY_PATH to include the casi shared libraries as well as the EPICS base libraries. For Win32, the EPICS base DLLs (ca, Com, Db) have to be in PATH.
The python scripts use some means of rootwidget.option_readfile ('optionDB') so that the colors and fonts can be adjusted globally.

Usage

Again, details are in the Readme.htm file in the casi source directory.
The scripting tcl and python syntax closely reflect the C++ class hierarchy of the ChannelArchiver I/O library. There are SWIG-generated decriptions for perl, python, and tcl.

Example Scripts

While most are available for python and tcl with very similar functionality, this concentrates on the python ones because of their cleaner syntax.
The script casi/python/101.py shows the most basic way to dump all values for a given channel:
import casiTools, casi
archiveName, channelName=("../../Engine/Test/freq_directory","fred")
archive = casi.archive()
channel = casi.channel()
value   = casi.value()
archive.open (archiveName)
archive.findChannelByName (channelName, channel)
channel.getFirstValue (value)
while value.valid():
    print casiTools.formatValue (value)
    value.next()
Other examples that are worth looking at: Please note that most of them can be run directly from the command line as well as called from other python scripts.