From:	LOCAL:.UMDUHE::CHENML        3-DEC-1996 03:31:54.81
To:	MX%"skelec@nscpmail.physics.umd.edu"
CC:	CHENML
Subj:	The updated doc of FSCC/socket package

User Manual of FSCC Data taking program package

-------- preliminary --------

M.L.Chen J.Goodman
U. of Maryland

I. Introduction

We completed a new FSCC program package which sets up the communication between FSCC and host Sun computer. FSCC therefore can function according to the instructions sent from host and return parameters to the host. This manual is only a very brief description of the FSCC functions provided by this package, and of the way Sun and FSCC communicating. The hope is to help people understand the structure of this package and be able to run it easily in the online system.

II. FSCC functions

The following subroutines are included in this package :
         void trig_isr();
         void set1877_Dmode();
         void set_latch();
         void rd1877_Pdff();
         void rd_latch_Pdff();
         void openFB();
         void closeFB();
         int grito_initFB();
         int evt_buf_check();
         void grito_timer();
         void wd_act();
         void wd_remove();
         void buf_match_act();
         void SGI_com(); * 
         void fast_reset(); *
         void trigHold(); *
         void trigResume(); *
         void dataHelp(); *
*: User callable function, other wise internal functioon.

Above subroutines execute following functions :

1. Data taking functions

1.1
Read in FastBus module slot numbers according to a map file named sockc#_tdc.lst(See example in section VI), here the # is the crate number (1->5).
1.2
Initialize FastBus modules listed in above map files. The TDC mode can be chosen through above map file as well. Therefore without modifying the code, one can simply change the parameters in this file and take data with any preferred TDC modes, for instance, front panel trigger or trigger through back plan, different TDC widow sizes, data taking mode or memory test mode, and so on. An example of this parameter file is shown in section VI.
1.3
Install trigger interrupt, timer and initialize concerned FSCC hardware to make the system ready for data taking.
1.4
Upon receiving a trigger, FSCC read out TDC/Latch modules listed in map files and send the event to down stream (DC2/DM115) through output port.

2. Handshaking function between FSCC and DC2

Together with the handshaking function of DC2 code, when data taking down stream is busy FSCC will hold data in it's data FIFO until DC2 removes the busy flag. This function prevent event lost problem.

3. Run control functions

This software package has the functions of start-run, end-run, and pause/resume a run.

4. Monitoring functions

A timer is used to monitor concerned parameters during a run and to perform the communication functions between FSCC and host computer. The time interval of the timer interrupt can be chosen by user through the parameter file from 1/60 second to seconds. All monitoring functions and the communication with host would run as a background task without slowing down the data taking process. The monitoring functions included in the current version are trigger rate watch, total trigger number report, and TDC buffer mismatch check. FastBus error is monitored as well and the error code are reported to host computer through socket when starting a run.

4. System fast reset function

When a serious error happens, the fast reset function can be used to reset the FastBus modules and concerned FSCC hardware rapidly.

III. Communication between Sun and FSCC

1. Structure

A socket routine running on host computer can set up the communication with and pass commands to the socket routine running on FSCC. The FSCC socket receives the command and, after some simple treatment according to the type of the command, pass it to FSCC data taking software through a communication variable defined on the common area. The timer of FSCC data taking program checks the communication variable at a user defined frequency, then decodes and executes the command.

2. Sun command, FSCC function, and FSCC's responds to Sun

2.1.
Start run
           FSCC actions: Read in FastBus module map
                         Initialize FB modules (TDCs, latch)
                         In case FB error, report error to the host
                         Set FSCC to "ready for data taking" status
                         Initialize run parameters
           Responds to Sun:
                          111 = monitor timer init error
               FB error:  
                           -1 = FB long timer time out
                           -2 = No AK, AK time out
                           -3 = DK or AK release time out
                           -5 = Bad slave status
               (See FB malual for definitions of AK, DK and other concerned 
                                                     parameters)
               0 = command received and startup done without error
2.2.
End run
           FSCC actions: Inhibit trigger
                         Clear FSCC dataFIFO
                         Send run parameter back to host
           Responds to Sun: Total trigger counts in this run
2.3.
Run pause or resume
           FSCC actions: Pause a run         or
                         Resume a paused run
           Responds to SGI: 1 = command received
2.4.
Query trigger counts
           FSCC action: Return current trigger counts 
           Responds to Sun: Trigger counts number
2.5.
Query trigger rate
           FSCC action: Trigger rate is checked automatically at a user 
                        defined frequency. If it is lower than a threshold, 
                        which can be set by user, the error flag will be set.
                        The current version returns the trigger rate to the 
                        host. 
           Responds to Sun: positive integer = Trigger rate
                            -1 = trigger rate monitor off
2.6.
TDC buffer check
           FSCC action: Check TDC buffer mismatch upon host request, and 
                        send checking result back. 
           Responds to Sun: 0 = ok
                            111 = buffer mismatch error
2.7.
Fast reset
 
            FSCC action: Host computer can ask FSCC doing a fast reset. 
                         This function reset TDCs and concerned portion of 
                         FSCC hardware, then ready for taking next event.
            Responds to Sun: 1 = command received
2.8.
Close socket connection

3. An alternate way of instructing FSCC

To do diagnostic/monitoring without bothering the main data taking process, one may want to instruct FSCC executing some monitoring functions without going through the host computer. The FSCC software package provides a command called SGI_com to meet such a requirement. One can type this command on FSCC console and then follow the manual to enter commands.

VI. Useful tips for running FSCC data taking package

1. First step

If the FSCC data taking package is not loaded automatically through boot file, type
              ld<sktrig_sock_jp.o
on the FSCC console to load the package. Then type
              sktrig_sock_jp(#)
to run it.
Here, the # is the crate number (1->5), and the file names are subject to change when the program version is changed.

2. Set up socket connection

Type sockSGI on the host computer, and answer the question about manual. If you do the test, you need to answer 1 to get the manual. spawn sockFSCC_newc# on the FSCC of crate number #. Then the connection is established and you would see a manual shown on the host computer screen. One can simply follow the manual to "talk" to the FSCC.

3. How to get help

After running sktrig_sock_jp(nFBC), Type
               dataHelp
on the FSCC console you will obtain a command explanation and a step by step instruction how to set up the socket.

4. If you want to use FSCC itself to execute any of those commands,

type
 
               SGI_com
on the console then just follow the manual on the screen.

5. sockc#_tdc.lst sample

    11
    13
    15
    17
    99
    21 
    999
    0
    2
    30
    10
    16000
    60000003

    ############################################################
    #The numbers before 99 are slot numbers of TDC modules
    #The number before 999 is the slot number of latch module
    #1/0 : auto fast_reset_flag on/off 
    #n : timer interval in SECs, n= 1/60 x (an integer)
    #mm : "trig count too low" threshold 
    #k : event buffer match checking frequency = k*timer-intervl
    #16000: TDC time window in ns
    #60000000 : HEX, TDC data mode set up (See LeCroy1877 
    # manual) 
    ####################################################