The Tcl-interface to The SINQ histogram memory

The entry point to the Tcl interface for the SINQ histogram memory is the SINQHM command. The exact syntax is:
SINQHM name computer port
This command creates a new command, name, which will be used in future to refer to the histogram memory. The next parameters specify the computer name of the histogram memory (HM) and the port number where it is listening (mostly 2400). This command initialises all necesaary data structures and starts a connection to a SINQ HM master server. For the explanation of that, please refer to documentation for the histogram memory.

Configuration commands

Now the HM is ready to be configured. The name created as above will for the purpose of this explanation been assumed to be HMM, for histogram memory master. This understands the following commands:

HMM config mode modif n length binwidth
this configures the HM. The parameters are: mode as the measuring mode, modif, another mode qualifier, n the number of histograms, length for the length of the histograms and binwidth, the size of an individual bin. Currently only 1,2,4 are supported binwidths. The mode parameter can be:
SQHM_TRANS
transparent mode, no binning takes place. Useful for debugging.
SQHM_HM_DIG
normal histogram mode with digitised read out.
SQHM_HM_PSD
a special for charge division read out for a PSD. Binning takes place.
SQHM_HM_TOF
time of flight mode.
Possible values for the modif are:
SQHM_DEBUG
starts a debugger in the histogram memory.
SQHM_UD
selction of histogram according to up/down bit from electronics???
SQHM_CNT_OR
counts out of range events, for debugging purposes.
SQHM_BO_IGN
ignores bin overflow.
SQHM_BO_SMAX
leaves overflowed bins at maximum count.
SQHM_BO_CNT
count bin overflows. They are left in a table.
SQHM_STROBO
stroboscopic mode. A signal from the front end electrics defines the histogram where to bin too.
HMM deconfig harsh
deconfigures the HM. harsh can be 0 or 1. If 1 all child processes will be removed as well.
HMM debug level
controls the level of debugging information printed by the HM to its COM1 console port.
HMM exit
terminates the histogram memory software. DO NOT USE, a reboot is necessary or a manual restart of the software.
HMM status
prints a status report for the HM.
HMM DAQ name
starts a data aquisition client with name name. This is needed in order to invoke data aquisition and read the histogram memory. For more information see the main histogram memory documentation. Name is a new command afterwards.
HMM delDAQ name
terminates the client name. Its associated command gets removed as well.

Data aquisition commands

This section describes the commands understood by the command generated by HMM DAQ name. These commands control data aquisition and read out. For the purpose of this description, the name of the DAQ command will be assumed to be HMS, for histogram memory slave. This understands the following commands:
HMS read n start end array
This reads histogram n into the Tcl array array, which will be created as necessary. A value of -1 for n means read out of the whole histogram memory. Reading starts at bin start and end bins are read. The resulting array will hold values from 0 - end (i.e. Array(0), array(1),..) where the values read can be found.
HMS write n start end array
can be used to write data to the histogram memory. The meaning of the parameters is the same as for read. Please take care to initialise the value array properly.
HMS zero n start end
a special form of write, which fills the HM with 0.
HMS start
starts a data aquisition.
HMS stop
stops a data aquisition.
HMS inhibit
pauses a data aquistion.
HMS continue
continues an inhibited data aquisition session.

So, this is fairly complex In order clarify the usage of this feature, an example will be given. In this example a DMC type HM will be configured, data be collected and read out. The DAQ slave will be deleted. The data read out will be printed.

SINQHM HMM pfe31.psi.ch 2400
HMM deconfig 1
HMM config SQHM_HM_DIG SQHM_BO_SMAX 1 400 4
HMM DAQ HMS
HMS zero 1 0 400
HMS start
after 30000 # sleep 30 seconds 
HMM status
HMS stop
HMS read 1 0 400 Result
HMM delDAQ HMS
for { set i 0} { $i < 400 } { incr i} {
   puts stdout [format "Counts in bin %d: %d" $i $Result($i)]
 }