A PinK Floyd Primer

First things first

This primer will not teach you how to write PinK (Floyd) scripts. For that, buy a TCL/TK book with examples and work through them.

Floyd is an extension of TCL (windowless) and PinK is an extension of TCL/TK (X11 windows) - both programs are distributed by the HERMES collaboration. Pink/Floyd extend TCL/TK by adding database functions.

How the database works

A server running in the background listens for connections from database clients. It is the server that manages the database disk files, which are in the CERN RZ format (random access). I have the server configured to respond to TCP/IP connections, so with a little work anyone from a remote host can access the database.

For speed, I run the database in a mode that is a hybrid of the so-called "booking" and "updating" modes. In HERMES terminology, "booking" means adding new information into the database, and "updating" means replacing existing data with new data using timestamps for setting validity periods. As examples, I book to the Bor table, but I update the Eos table. The difference? If I booked the Eos table each row is considered valid (in a timewise fashion) and each time a client connects and fetches the Eos table thousands of rows would be sent across! In update mode only the last row is sent.

For the remainder of this primer, I will be using PinK examples. Where Floyd would require a different set of commands I will point this out. For demonstration purposes, I will illustrate the scan script.

How to create an executable script

The best (i.e. most portable) way to create a PinK/Floyd script is to start the file off with the following lines:

#!/bin/sh
# Pink/Floyd will consider this line and the next as a comment \
exec floyd "$0" "$@"
#rest of script follows ...

Notice that sh is invoked and will execute floyd. floyd will be passed the command line parameters and will ignore any lines beginning with "#" (the backslash "\" is interpreted as a line continuation character in TCL/TK) and thus will ignore the exec line and continue executing the remaining script. If you prefer PinK then substitute "pink -f" for "floyd".

At this point I should point out that pink and floyd are large programs. If you don't intend on reading lots of tables, or fooling with  ADAMO GAF files, I suggest using pinky or floydy instead. They are considerably smaller in size.

The scan script

When scan starts up, it fetches a copy of the EvtPar table from the database. The EvtPar table is a convenient way to query data by name from the database; to date, evtpars consist of epicure data and scaler data. In the following example, I will show how to fetch the EvtPar table and query its elements (you type what is in blue):

p2hp2 % pink
PinK Version 0.21 (01.05.96), compiled May 3 1996 starting up.
(C) HERMES Collaboration 1994,95,96

Will use autoload directory: '/p2hp2/usr4/hermes/pro/lib/pinklib'.

DAD: reading /p2hp2/usr4/hermes/pro/lib/dadinit.cnf
pink >dadConnect evt EvtparStream
DAD Client Software
--- Version 1.35 (PL 20) starting up
pink >
grabobj EvtPar
pink >evt Update [gettime]
pink >evt Disconnect

Whoa! What just happened here? You just got a copy of the EvtPar table. We connected to the EvtparStream (which happens to contain the EvtPar table) using dadConnect and created the evt "object" with which we can operate on the stream; we next created a PinK "object" for referring to the table using grabobj; and requested the currently valid evtpars using Update and the Pink/Floyd utility function gettime. We cleaned up after ourselves by disconnecting from the server using Disconnect, as we don't need to access the EvtparStream anymore.



More to come as I find time.
Stay Tuned ...

In the meantime, you can refer to http://hermes.desy.de/pink/ to read the formal documentation. Feel free to hack around - you can't really hurt anything as you have to be a "chief" to WRITE to the database. If you're reading this, you probably aren't a "chief" :).