next up previous contents index
Next: Language Elements Up: CODA Readout Language (CRL) Previous: Compiler Flags   Contents   Index

Code Sections

There are 4 types of code sections: a compiler option.global declaration section, readout(trigger) functions, state transition command functions, and user command functions. A minimal but compilable readout list shell (which does nothing except not Crash) looks like as follows:

readout list FRED 


polling 


test readout


begin download 

end download



begin prestart 

end prestart



begin end 

end end



begin pause 

end pause



begin go 

end go



begin trigger usertrig 

end trigger



begin done usertrig 

end done



begin done 

end done

In the above example the rol named FRED is a test list. It contains no global declarations and a begin-end function declaration for each of the Run Control transitions (Download, Prestart, End, Pause, and Go). It contains a single trigger done pair of routines named `usertrig', and finally it contains the global done routine (unamed).

The CODA Readout software supports the use of multiple trigger sources. For each source there must exist a trigger-done pair that is uniquely named. Readout of an event is complete when all valid trigger sources have been serviced (i.e. trigger routine followed by done executed for that source). Then the global done routine is executed and all sources re-enabled for a new event. If ts control is enabled then the ROC expects the hardware trigger information to be conveyed on the Trigger Supervisor ROC cable connected to a TS interface card (TJNAF design). The ROC receives a 6 bit code (4 trigger type bits, one sync bit, and a late fail bit). This code is generated via memory lookup in the Readout Code MLU of the Trigger Supervisor, with the trigger inputs as an address.

When the ROC receives the trigger from the TS a named "trigger" list will be executed and a local variable called "EVTYPE" will be set with the value of the trigger information from the TS (if ts control is not specified then the default value of EVTYPE=1). In addition to specifying instructions for hardware triggers, the following state transitions may also have ROC instructions associated with them: download, prestart, go, pause, and end (with identical readout section names: download, etc.):

begin prestart

...            # clear/initialize hardware 

end prestart

The user may define hist own routines that may be called (or spawned as a task inVxWorks) in any of the transition lists. These routines are created as

void so no valuesmay be returned:

begin userCode

...               # user specific (can be called from ... # other lists) 

end userCode

Finally, the user has available a global declaration section for the readout list. Constantdefinitions, variable declarations as well as include statements may be added to the global section after the final compiler directive but before the first begin code statement:

readout list FRED 

maximum 1024,500 

sfi readout

const SLOT = 12            # Constant Slot number of ADC 
include "mycode.h"         # include my own C code 
unsigned long ped[64];     # declare an array to hold pedestals

begin download

...

List statements may either be English-like readout statements defined in the next sec-tion, or may be any valid c expressions (the file is first passed to a CODA readout language interpreter (ccrl), and then to the c pre-processor and compiler). Individual lines of c code must end with a semicolon. Larger sections of c code may be imbedded by placing %% prior to and at the end of the code section. Very large sections of user ccode may best be added by using the include statement in the global section of the readout list.


next up previous contents index
Next: Language Elements Up: CODA Readout Language (CRL) Previous: Compiler Flags   Contents   Index
Mohammad Ahmed 2003-07-23