2.3 * update thread - send *UPD
2.4 * change of ilcserver port 2002->2000
    * initialize clientlen properly in runhandler.c
2.5 * try to read from expected FECs to be powered on
    and send in *POW Pi <powered>to GUI
    * send runnb/runmode to monitor program in monOnline if first
    request in new run. Last runnb/runmode sent if no run.
3.0 * Start implement DBOX handling: dbox.cfg = trigger config
4.0 * New RCU firmware: v2.0 (no RcuLoadLookup)
4.1 *20081208 Implement loading/checking of pedestal memory using RCU instruction memory
    *20081208 Implement DBOX handling according to DBOX documentation
    *Implement DBOX data into event header: dboxtime,dboxevtn,tluevtn
    Implement timeout waiting for RCU - if any RCU is missing the trigger (if all miss DBOX takes care)
    *Add PCA settings in run header:
      pca->preamp_enable = pca->shiftreg & 1;
      pca->gain = (pca->shiftreg >> 1) & 0x03;
      pca->shaper = (pca->shiftreg >> 3) & 0x07;
      pca->shutdown = (pca->shiftreg >> 6) & 1;
      pca->polarity = (pca->shiftreg >> 7) & 1;
      pca->decay_bias = pca->dac;
      SOR dataword after times = pca->shiftreg << 16 | pca->dac;
    Add ALTRO settings in run header
      pedestal subtraction, zero suppression, some ALTRO/RCU register
    *Config files:
      copy configfiles to RUNCONF_DIR/<name>-<runnb>.cfg
    *If pedestal subtraction done
      Read pedestal file used as: pedestals-<id>-<pcasettings = %X-%d,shiftreg,dac>.dat
      Store pedestal file used as: RUNPED_DIR/pedestals-<id>-<runnb>.dat
    *Write ALTRO test data in pedestal memory (i.e. lookup table):
      0) do not use lookup table
      1) DPCFG = 10, i.e. f(t) - fpd
      2) no pedestal run
      3) different cluster samples to the pedestal memory - add 0x2AA, 0x133, some peaks.
      2AA = 4, 155 = 5, PEAKS = 6
    *Insert DRORC_REVISION into rmap instead of a DEFINE in utility.c
    Make all network ports configurable via cfg file.
    Make the sampling clock individual for each RCU.
	 in rcu-<id>.cfg ALTROIF.CLOCK
    Option to reread drorc.cfg and found DRORCs/RCUs

TO BE -> HEPFORGE (DONE)
    *20090111 The READOUT_MEMORY was overwritten by loading the lookup table using the
    RCU instruction memory. Changed in RcuLoadLookup.

    *20090118 Removed in dboxPoll (dbox.c) that it was calling disconnectclient. Had wrong arguments,
    moved that and error output to be after dboxPoll in readout.c.
    inserted #include <stdlib.h> in dbox.c
 
   *20090119 in ilcStartOfRun:
       in ilc-physmem.h Number of FIFOs used 128->16
      /* for safety - empty the data area with spurious events - if any */
           if if (daq_rorc.active[ch]) {

<     else {
<       if (ag.dpcfg_zsenb) daq_param.zerosup = 1;
<       else daq_param.zerosup = 0;
<     }
	*added zerouppression and pedestalsubrtaction flags to runheader:   
<   sorheader.runsettings = 0;
<   if (daq_param.zerosup) {
<     sorheader.runsettings |= 1;
<   }
<   if (daq_param.pedsub) {
<     sorheader.runsettings |= 2;
<   }
     *in loghandler.h
              int runsettings;
           } SORHEADER;

     *in readout.c ilcSetActiveFec
<         if (ret) {
<           sprintf(msgbuf,"%s: *ERROR* AltroReadPedestalFile %s returned with error %d\n",__FUNCTION__,filename,ret);
<           daq_status.feerrors++;
<         }

TO BE -> HEPFORGE DONE
20090123
   added the possibility to read the lookuptable from a file
   loookuptable.dat, manipulated to get pulses at different times
   when simulating events
20090124
   ilc_altro.c
   bug in AltroDisableZerosup: used data2 to write value, should be data1.
20090125
   ilc_altro.c
   bug in AltroShiftAcqStart: data2 -> rdata:      else if (data != rdata) {
20090126
   ilc_altro.c
   in RcuLoadLookup/RcuReadLookup insert myacl to load only active channels in chip,
   and for all channels in an active chip
   add delays from 100 -> 1000 microseconds to allow 5MHz sampling.
20090127
   loghandler.h - changed data format version to 410
   typedefs.h, readout.h, readout.c , run.cfg - added the possibility to stop
   the run at a RCU readout error (ERR_REG2), for test of hardware readout.
20090205
   can stop run if roerror if error flagged in RCU trailer
   data format read from run.cfg
   typedefs.h : onroerror, dataformat
   readout.c: added end run if roerror. dumpRunConfig(). use daq_param.dataformat
   in SOR/BOF header
   added one DRORC: addedd the initialize of 4 memory buffers in ilcOpen
20090206
To handle mapping of channels correctly:
//      if ( (ch = ilcFindRorcSerial(rmap[j].serial,j,&daq_rorc)) >= 0) {
        if ( (ch = ilcFindRorcSerial(rmap[j].serial,rmap[j].channel,&daq_rorc)) >= 0) {
20090209
copyfiles: only if logging data
20090211
usleep(100000) in fecPower
TO BE -> HEPFORGE
20090217
copyfiles: added taht pedestal files are copied only if logging
startofrun: add daq_param.trigger to run header.settings
copyfiles: local trigger get .l<extension> to distinguish it from dbox running

20090218
added:
getting eudaq run number when not local run
one extra entry in runheader giving the eudaq run number

20090219
timeout handling when running with more than one RCU
added daq_param.rotimeout
RUN.ROTIMEOUT in run.cfg
timeout in ilcRun in readout.c

20090220
loghandler.h: 2GB max file size

20090223
readout.c ilcRun only first 100 errors

200902228
readout.c statusOfFecPower: print return status to msglog

version 4.2
20090415
make it possible to reread event, i.e. load active list twice.
RUN.REREAD flag in run.cfg
dataformat = (RUN.DATAFORMAT << 16) | DAQ_VERSION
# 0 - reversed data
#RUN.DATAFORMAT 0 
# 1 - 3 10 bits words in each 32 bit word.
RUN.DATAFORMAT 1

*20090625
in run.cfg
# ----- VARIABLES READ ONLY ONCE AT PROGRAM START
# ----- THESE VALUES MAY BE CHANGED FROM RUN CONTROL
PROG.INIT
#Load lookup tables at power on - read only program start
LOOKUP.POW     1
#Load lookup tables at start daq - read only program start
LOOKUP.START   0

Modified readRunConfig and dumpRunConfig

added _USE_NOHW flag

version 4.3
-----------
dbhandler to set some ALTRO settings and FECs to readout
change so that it can be run as root from other users
can make memory test

version 4.4
-----------
added such that one can have rcu active in readout.
modified:
ilc-physmem.h rcuactive in ILCRORC
ilc-rcu.c  ilc-rcu.h to read files active-rcu.<type>
files.c files.h to update active-rcu.<type>
readout.c set rcuactive flag and use it instead of active for readout
dbhandler.c dbhandler.h to handle *RCUACTIVE command from GUI
run as suid root:
-rwsrwsr-x  1 root   root   220197 Feb 18 10:06 ilcrorc-readout

20100225
modified:
Allocation of the physmem memory.
 Physical address: 0x86000000.
 Size of the physmem memory: 972554240 (0x39f80000) bytes, 243138560 (0x0e7e0000) words.
 DataBlock 0: 0x86000000 (0x86000000).
 UserBlock 0: 0x7b79b000 (0x7b79b000).
 DataBlock 1: 0x8a000000 (0x8a000000).
 UserBlock 1: 0x7f79b000 (0x7f79b000).
 DataBlock 2: 0x8e000000 (0x8e000000).
 UserBlock 2: 0x8379b000 (0x8379b000).
 DataBlock 3: 0x92000000 (0x92000000).
 UserBlock 3: 0x8779b000 (0x8779b000).
 ReadyFifoAddress 0: 0x96000000 (0x8b79b000).
 ReadyFifoAddress 1: 0x96008000 (0x8b7a3000).
 ReadyFifoAddress 2: 0x96010000 (0x8b7ab000).
 ReadyFifoAddress 3: 0x96018000 (0x8b7b3000).
 Send data block: 0x9a000000 (0x8f79b000).
 Send data return block: 0x96020000 (0x8b7bb000).
 ReadyFifoAddress data: 0x8b7bb000 (0x8b7bb000).

 ReadyFifoAddress was put in data area of DRORC data block 2
2 * MAX_MAPPING instead of 4 * MAX_MAPPING

20100331
--------
*TRIG in dbhandler

20100409
--------
*TRIG DS dboxsource TS triggersource

version 4.5
-----------

20100812
--------
*POW 0 check if RCU is powered on in runhandler.c

version 4.6
===========

20110819
--------

1) Add zero suppression information to run header
RUN SETTINGS
0: zero suppression done
1: pedestal subtraction done
2-3: Samples above threshold (0-3)
4-13: Zero suppression threshold (0-1023)
14-16: Number of postsamples (0-7)
17-18: Number of presamples (0-3)
19-22: Number of pretrigger samples (0-15)


2) Add an extra word to event header with the UNIX timestamp
readout.c
    clock_gettime(CLOCK_REALTIME, &ts);  // event time in seconds/nanoseconds - added v4.6
    *data_buffer++ = (int)ts.tv_sec;
    *data_buffer++ = (int)ts.tv_nsec;

loghandler.c
#define EVTHEADER_LENGTH 8
typedef struct {
.....
  int tseconds; // event time - added v4.6
  int tnanoseconds;
} EVTHEADER;

20120523
loghandler.h
DAQ_VERSION 440 -> DAQ_VERSION 460

20120528
Added the handling of loading selected/failed lookup tables in Altro

readout.c
---------
int loadSelectedLookupTables(int mode);
int verifyLookupTables();

ilc_altro.c
-----------
int readFailedLookupList(u_int fecs[], char *filename);
void modifyLookupList(u_int *fecs, u_long *acl);
int AltroVerifyLookupTable(chan_key *dev,u_long *acl,int type,int dest,int verify, FILE *flog);

modified WriteLookupTable to write file with errors in config-xxx/lookuplist.txt


runhandler.c
------------
void sendlut(int client, int retstat);
modified decodehandler with commands
  // Load/verify lookup tables
  else if (!strcmp(ptr,"*LUT")) {
    retstat = 0;
    iarg = decodeargument();
    switch(iarg) {
    case LUT_LOAD_FAILED:
    case LUT_LOAD_SELECTED:
    case LUT_LOAD_ALL:
      retstat = loadSelectedLookupTables(iarg);
      break;
    case LUT_VERIFY_ALL:
      retstat = verifyLookupTables();
      break;
    }
    sendlut(client,retstat);

dbhandler.c
-----------

handle read the failed list, write and read selected list.
  // LUT Lookup Tables Failed FECs to reload - added v4.6
  else if (!strcmp(ptr,"*LUT")) {
    return DB_CMD_LUT;
  }
  // LUS Lookup Tables selected FECs to reload - added v4.6
  else if (!strcmp(ptr,"*LUS")) {
    return DB_CMD_LUS;
  }

version 4.7
===========


In start of run header add the time as in the event header

readout.c

StartOfRun
  // event time in nanoseconds - added v4.7
  struct timespec ts;
  // SOR time in seconds/nanoseconds - added v4.7
  clock_gettime(CLOCK_REALTIME, &ts);
  sorheader.tseconds = (int)ts.tv_sec;
  sorheader.tnanoseconds = (int)ts.tv_nsec;

EndOfRun
  eorheader.tseconds = (int)ts.tv_sec;
  eorheader.tnanoseconds = (int)ts.tv_nsec;


loghandler.c

#define SORHEADER_LENGTH 11
#define DAQ_VERSION 470

  int tseconds; // added version 4.7
  int tnanoseconds; // added version 4.7
} SORHEADER;

#define EORHEADER_LENGTH 7
  int tseconds; // added version 4.7
  int tnanoseconds; // added version 4.7
} EORHEADER;


Add missing RCU.ID when loading lookup tables at DAQ START

ilcSetActiveFrontEnd

id = daq_rorc.rcuid[ch];

	if (daq_param.load & LOAD_LOOKUP_START) {
	// Print RCU ID in lookup table error log - added here in version 4.7
	  if (flogfout != NULL) {
	    fprintf(flogfout,"RCU.ID %d\n",id);
	  }

