A Diagnostic Tool for Console Applicationsof the Fermilab Accelerator Control System
Junye Wang, Brian Hendricks
Fermilab
Beam Division Accelerator Controls Department
MS 347 P.O. Box 500
Batavia, IL 60510 USA

Abstract
The Fermilab accelerator console software consists ofconsole manager programs, console applications, and alibrary that has more than one thousand entry points
which is named CLIB. CLIB provides support for dataacquisition, user interface, error handling, memory
management, database access, file access, network access,and many other things.
The CLIB Peeker is a network capable diagnostic toolthat allows programmers to view information about CLIB
routines in a running application. CLIB Peeker runs as anapplication program. It can be used to inspect any
application program running on any active console, and it
can be set up to automatically update any diagnosticinformation. CLIB Peeker is an efficient tool that helps
users debug and improve programs.
1 The purpose of clib peeker
The CLIB (Console LIBrary) of the accelerator controls
system at Fermilab includes more than one thousandroutines for application programmers. Such a wealth of
CLIB routines is very helpful and convenient for users,
but at the same time makes it hard for users to develop amastery of necessary routines. CLIB Peeker can be used tofind syntactically correct but improper usage of theseroutines.
2 CLIB peeker user interface
Users can peek at programs on any console since theinformation is obtained via network (ACNET) requests.
To select which program to peek into, interrupt on thefield 'CNSxxx Slot x' (fig.1). A node selection menu pops
up and lets the user select any console or central node.
After choosing a console or node, a menu of currently
running processes will pop up, and the user can choose
the process that is to be viewed.
Users can choose the information update rate by typing
a number in the brackets of the '< 0> one shot' field (fig.
1). The value the user enters will be interpreted as thenumber of seconds between peeks. A value of zero can beused for a one shot peek.
The CLIB facility selection can be made via the"Pgm_Tools" menu (fig.1). There are presently fourteenof these facilities supported by CLIB Peeker. Thesefacilities include 'Process information', 'Memorymanagement', 'Data acquisition', 'Window management','Graphic window management', 'Error handling', 'Databaseaccess', 'Network access', 'File management', and more.
General statistics information such as current status,
last status, number of function calls, etc. are available for
all facilities. A menu bar controls whether these general
statistics information windows are displayed or not.
You can click on the 'Scaled' button (fig. 1) to choose
between "Raw" and "Scaled" data displays. In "Raw" data
display mode, all information is displayed in numerical
digits except text strings. For example, time will bedisplayed in clinks (the number of seconds since January
1, 1972), logical values will be either '0' or '1', and devices
will be displayed by device index. If the user selects'Scaled' data mode, all information is displayed in text
strings except function call counts. For example, time will
be displayed as 'dd-mmm-yyyy hh:mm:ss' (date stringformat), and logical values will be either 'False' or 'True',and devices will be displayed by name.
Most sub-peekers have their own specific diagnostic
information commands. Users can access these special
commands by clicking on the 'Command' button. Most ofthe windows are movable and resizable. Therefore users
may configure the interface to their needs.
3 Diagnostic information support
A set of inter-program communication routines supports
the CLIB peeking activities. CLIB Peeker sends a request,
which consists of the user selected peek node, peek task,
and a typecode which has been assigned to the userselected facility, to the CLIB facility via ACNET(Accelerator Control NETwork). Then a reply returns
through ACNET with the statistics embedded in the CLIBfacility. In general, the returned information includes
numbers of function calls, errors and status, and othermiscellaneous information.
4 The peekers
CLIB Peeker allows users to peek into "DataAcquisition", "Database Access", "Screen Management","Graphic Window Management", "Error Handling/Logging", "File Access", "Memory Management", "NetworkAccess", "Process Information" and many more.
"DIO Peeker" provides access to data acquisition

activity. Data acquisition involves input and output toaccelerator hardware as well as reading database
information concerning that hardware. It involves reading,setting, controlling, and scaling values as well as handlingalarms and miscellaneous device attributes. The "DIOPeeker" will display counts of function calls and errors. Itwill also show the number of devices and lists of devices
being read and set as well as the frequency of retrievals.
In addition, timing statistics are shown for the data
accesses being performed. "DIO Peeker" will be introduced as an example later.
"Data Pool Peeker" and "Database Peeker" look at low
level data acquisition routines. These two peekers display
the numbers of data base manager and data pool manager
function calls used in the peeked application. They also
display the errors of the last functions called.
"Window Manager Peeker" shows each window
manager function call counts and errors. It also displays
the attributes of existing windows, switch information,slider information, menu bar information, select field
information, and help field information.
"Graphic Window Manager Peeker" is similar to the"Window Manager Peeker". It displays the information of
all graphic windows built in the inspected application
program.
"Error Handling/Logging Peeker" peeks at programs
that use error handling and logging routines. Error
handling routines check error codes, expand them to give
text descriptions, and save errors encountered duringexecution of the program. Error messages can be written
to a shared circular log file. This peeker will display theError Handling/Logging routine call counts and many
miscellaneous pieces of information.
"File Peeker" can peek at applications that use shared
read/write access files. It displays numbers of function
calls and errors. It also displays which file and record waslast read and last written and any error associated with theaccess. Additionally, timing information is displayed forcommunications with the central file server process.
"Memory Peeker" allows you to inspect dynamic
memory problems. It shows how much dynamic memory
has been allocated by the program, how many memory
calls have been made, whether or not memory blocks havebeen overwritten, etc.
"ACNET API Peeker" peeks at programs that use
interprocess communication routines. This peeker will
display the inter-process communication function callcounts, and also show the current ACNET handle,
requests, and errors.
"Process Information Peeker" will show you theinspected process' name, user name, process start up time,process ID, CPU time, memory information, date of CLIB
image, type of CLIB in use, and more.

routines. "DIO Peeker" inspects accelerator device I/O
problems. Click on the field 'CNSxxx Slot x' (fig. 1) toselect the target application. DIO Peeker supports a lot ofdiagnostic information that will be categorized anddisplayed in four windows: 'Device Counts', 'Error Counts','Function Calls', and 'Status'.
The 'Device Counts' window shows users the count of:individual retrieval devices, retrieval devices in lists,
individual setting devices, setting devices in lists,
snapshot devices being read, retrieval lists, setting lists,table device lists, scaling information (PDB-Process DataBlock) entries, devices read on event or at various
frequencies, entries in the DI (Device Index) pool, settings
attempted, and setting errors.
The 'Error Counts' window displays the error counts
while running the application. These errors are generated
by the application calling DIO routines, DBM (Data BaseManager) routines, DPM (Data Pool Manager) routines,or ACNET (Accelerator Control NETwork) routines. Inaddition, the number of DPM pending, database timeouts,and memory free errors are also displayed in the 'Error
Counts' window.
The 'Function Calls' window displays the number ofcalls to the various data acquisition functions.
The 'Status' window displays which device and which
property of the device were last read and last set and any
errors associated with the access. Also, it shows timing
statistics (in 15 Hz ticks) for the data accesses being
performed, such as the longest DBPROC (the process oftransmitting the database request list to the central device
database server), the total time spent in DBPROCs, thelongest DPPROC (the process of making new requests toand deletions from the data pool), and the total time spentin DPPROCs. The timeout for reading from or setting to
the data pool and the timeout for reading from thedatabase are also displayed in this window. Additionally,
the error message logging state (on or off), the device
setting flag state (enabled or disabled), the stale data
notify flag (True or False), and the MIO use flag (usingDIO routines to read and set from memory rather than theactual devices) are shown in this window.
If you click on the 'Command' button, a command menu
pops up which allows you to read specific diagnostics or
set various parameters. There are presently 10 commandsin the menu:
1)
2)
3)
4)
5)
6)

5 Example "DIO peeker"
There are hundreds of data acquisition routines inCLIB. More than half of the applications use DIO

7)
8)'Clear Statistics': clear DIO diagnostic values'Setting enable': enable device settings'Setting disable': disable device settings'Delete Cache': delete all entries from DIO's memory
cache of central database information'Toggle Logging': enable or disable the logging of lowlevel error messages'Set Timeout': set timeout for reading information,
setting information, and accessing database information.
'Enable Stale Notify': enable stale reading notification'Disable Stale Notify': disable stale reading notifica-

tion'Read List Devices': return the list IDs and number ofdevices for device reading or setting lists. If you click
on a list ID, information about all of the devices in
the list will be displayed including device name,device property, FTD, data size, and data offset.
10) 'Read Single Devices': returns information about
individual devices that have been read or set in theinspected application. The information returned
includes device name, device property, FTD, datasize, and data offset.
9)

The CLIB Peeker system continues to grow as thefunctionality of CLIB does. New facilities and new
information for already supported facilities are continuallybeing added. This system has repeatedly been used toinvestigate difficult problems during application program
development as well as problems resulting from errors
occurring elsewhere in the control system. The network
capable nature of this system has been especially usefulwhen programmers call control system personnel forassistance in debugging applications running in theiroffices.

6 Conclusions

Figure 1