TAPS: Snapshot of calibration config changes
Core: Improve End-Of-Run handling

Copied from Elog entry 18054:
Changes to TDAQexperiment:
Moved the block of code where a slave system checks the event ID to just after the ADC read loop and just before
the scaler-read code block. This means that the slave system knows if the master is signaling end-of-run before
it starts to read the scalers. Thus a scaler read is performed on all systems (which have scalers) when the
end-of-run is issued from the DAQ gui. Previously only the master was reading scalers at end-of-run
Checked that slaves do scaler read at end-of-run on the debugger...OK
Also ran the event-merger so that all data streams are dumped to disk individually.
Visually check the individual stream files...e.g.
> od -d scratch/tagga_0.dat | less
> /65278
65278 = 0xfefe is the scaler buffer marker
See scaler blocks in the data at events 9999, 19999.... and also at the last event before end-of-run
This side appears to be working.

However the last scaler read was not showing up in merged data, and several events at the end of the
individual-stream files were also not showing up in the merged data file.
Traced the problem to TA2DataServer::MultiProcess(). When the end-buffer is detected coming from the daq master,
there can still be a merged data buffer (containing the last few events) sitting in the system. It has not been
written to file as the buffer is not full. Now when end-buffer is detected from the master, TA2DataServer checks
the merged-data buffer and if there is anything there it writes it to the merged output file, BEFORE writing the
end-of-file buffer.
Note that this last partially-filled buffer will probably not be caught by the online data sorter. When running
online not all merged data buffers are analysed as this could slow down data collection.
Checked the merged files for a sequence of run/end commands from the gui. Each file contains scaler-read blocks
from exp-trigger, beampolmon and tagga at events 9999, .....
Each also contains a scaler block from exp-trigger, beampolmon, tagga in the last event.

AcquRoot seems to process files CBTagg_3085/6/7.dat correctly offline. These files were taken in one daq session
(without taking the daq down in between files)
It seems to be working correctly, but needs a bit more testing.
Core: Fix FASTBUS SMI over VME read/write timing

Copied from Elog entry 18056:
The Tagger FASTBUS readout is over an ancient TTL link from VME to the 1821 SMI
There is no handshake on this and the TTL signals are slow, requiring some time to settle.
Previously read/write operations to the 1821 SMI have been slowed down using usleep(1) to wait a little while
after the read/write is performed.
However we have seen that usleep(1) does not guarantee 1 micro-second...often it is considerably longer.
Thus usleep(1) has been replaced by a Pause() procedure, which is just a little loop which basically does
nothing except delay return from the read.
The loop maximum EKPhSMITimeout has been set to 200.
This seems to be safe. Tagger Scalers and QDCs seem to read OK.
The QDC read is now considerably faster.

virtual void Pause(){ for(Int_t i=0; i<EKPhSMITimeout; i++){i++;i--;}}

//---------------------------------------------------------------------
inline void TVME_KPhSMI::R_KPH(Int_t a, UShort_t *pdata)
{
  // Read SMI register a
  // a "pause" is necessary afterwards as the SMI-register bus is slow
  *pdata = *fSMIreg[a];
  Pause();
  //usleep(1);
}

//-----------------------------------------------------------------------
inline void TVME_KPhSMI::W_KPH( Int_t a, UShort_t data )
{
  // Write SMI register a
  // a "pause" is necessary afterwards as the SMI-register bus is slow
  *fSMIreg[a] = data;
  Pause();
  //usleep(1);
}