Interfacing Programs to ALS Controls
There are several ways for programs to access the ALS control system to read
(and in some cases write) information. This web is a collection of the
documentation and code. This is a work in progress, so some parts are
incomplete. Comments to akbiocca@lbl.gov
Accessing the Control System Efficiently
Minimizing network and data server loading requires efficient use of
the protocols and data access libraries.
The underlying Channel Access protocol has a set of optimized
functions that determine where the data is served from (the
discovery process), maintain a single TCP/IP connection to
each data source, and efficiently transport blocks of data.
It is inefficient to gather data in small increments - it is
important to group the gathering of data together, and important
to not re-discover channels each time they are frequently accessed.
As an example of the efficiency of this system, the Archiver gathers
7,000 channels of new data in the control system periodically (every few
minutes). Of these, 5,000 are control and boolean type values that do not
often change and 2,000 are analog input values that change frequently.
The control values are 'monitored' which means that the data
is only transmitted over the network when changes occur.
Monitoring techniques are advanced and beyond the scope of this document.
The analog input values are read in a 'group', and this read process
takes xx milliseconds. A 'get group' of a few channels typically
requires 2-6 milliseconds, and this time is of course somewhat more for
larger data sets.
Most of the data in the control system originates in the
Intelligent Local Controllers (ILCs) that exist out in proximity
to the devices such as magnet power supplies, beam position monitors, etc.
Each of these devices reads data at hundreds to thousands of times per
second. This data is stored in a local memory that is periodically
polled via the serial link from the CMM, at about 10-20hz.
This is in turn scanned by the CRIOC (Control Room Input Output Controller)
at about 12 hz. Thus new data is available on the order of every
100 milliseconds. Attempting to read data faster than 10hz is
not useful. Programs should perform 'get group' methods at less
than 10 hz, and only as often as they actually require data.
Multiple groups can be created so that if only a few channels are
required part of the time, and a larger set at other times, a separate
group for each set increases performance and efficiency.
The paradigm we have evolved to for reading data is to create a
'data set' or 'group' that is transferred at once. This is
efficient for the network and the data servers such as the
CRIOC. The programmatic interface for this is to build a group by
repeatedly calling 'add channel to group'. Once the whole group is constructed
a call to 'get group' will gather all the data and bring it into the local
memory of the program, in data structures that were created as the
group was built.
Finally 'read from group' accesses from the
data retrieved during the 'get' phase, a local memory access.
The data includes not only the value, but also the status of that
value. Possible status' include errors (not connected, stale data),
or that a new value has been read. It is important to check the
status of the data. A special value is sometimes used to indicate
invalid data. This value was chosen to be unlikely to occur in normal
operation (1.2345e-30?), but the status contains more info, and is a
better way to handle the data.
Access Methods
- Simple Channel Access
is the preferred method of access for new programs that
require high performance reading and writing values. A C library
interface is provided that makes efficient use of EPICS Channel
Access while remaining simpler to program. This is a short range
access method, limited to the local subnets in the control
system and on the accelerator floor. It has high performance
capability. It is used by programs like the Data Archiver
that require the best performance.
- Remote UDP Data Service
is a new access method that provides network based access
to programs and systems unable to run the full SCA
protocol, or which are located outside the range
of channel access. The protocol is a simple UDP
protocol to a gateway server that maintains the
channel access connections to the data servers.
The UDP protocol is routable over long distances
and the server is intentionally medium to low performance.
This is still under development and the first
client is a few hundred lines of native PERL, targeted
at inclusion into simple scripts and CGI programs that need to read
moderate amounts of controls data. It is planned to add writing controls
to this at some future time and essentially replacing
RS232 interfaces. A C interface is also planned.
- LinkBW-CA
is a compatibility library (DLL) allowing legacy programs to
access the control system with little or no change to
their code. It is a replacement DLL that has equivalent
functionality to the original linkbw DLL.
It can access data either via Channel Access or the DMM.
It is under development.
Language Specific Methods
- C and C++
should use SCA.
- Labview
access is supported by binding through to the C libraries
that actually gather the data.
- Matlab
also accesses controls by binding to the underlying C
routines for data access.
- Java
is supported by a new access method for Java programs providing
efficient access to the control system. It is a wrapper on SCA and
has similar local range limitations. Performance may be
limited by the Java environment.
- Visual Basic
can also use the underlying C interface in Simple Channel
Access.
- PERL
is supported via the Remote UDP service. It is medium performance
and read-only at this time.
Legacy Methods
- LinkBW
is the original access library, in use by many programs in
the control room. This pc DLL provides a number of types of
access but requires a special private HDLC connection to
the DMM to operate. It is being replaced by linkbw-ca
or other access methods. New programs SHOULD NOT use this
library.
- DCE Remote Procedure Calls
are a PC-type remote procedure call readonly access that
a special version of linkbw can access. This allows a
legacy control room program to be run in a readonly mode
outside the control room. Support for this mode is
provided on a secondary basis, it is not considered
operationally required and is used primarily for
debugging or casual status monitoring.
- RS232 Controls Access
is provided by servers that run on each beamline gateway.
This interface provides basic functionality for beamline
systems that are unable to use network access, allowing
them to read and set parameters such as insertion device
gap and read machine beam current. Network methods are
to be preferred, and most users have moved to Simple
Channel Access (above). If only reading values is required
then Remote Udp Data Service (above) is a better choice
if applicable.
Note that some portions of this site are restricted to LBNL or ALS access.
Contact AKBiocca@LBL.gov for access issues.