Commit 90ebcc22 authored by dino's avatar dino
Browse files

Minor modifications in fileATCA.cpp

git-svn-id: svn://gal-serv.lnl.infn.it/agata/trunk/narval_emulator@1109 170316e4-aea8-4b27-aad4-0380ec0519c9
parent 9a953711
......@@ -191,29 +191,24 @@ int fileATCA::GetMezzanine(unsigned int slot, unsigned short *buffer)
}
}
// mezzCache FULL !!
numFlushed++;
bool doPrint = ( (numFlushed<10) || (numFlushed<100 && (numFlushed%10)==0) || ((numFlushed%100)==0) ) ? true : false;
if(doPrint) {
LOCK_COUT;
cout << " fileATCA_" << fileID << "{" << crystID << "} flushing buffer of cached mezzanines";
for(unsigned int nn = 0; nn < cacheLength; nn++) {
if(mezzCache[nn].slot != 0xFFFFFFFF) {
cout << " " << mezzCache[nn].slot;
dropped[mezzCache[nn].slot]++;
}
mezzCache[nn].slot = 0xFFFFFFFF;
DEBUG_LINE << " crystID=" << crystID << " fileID=" << fileID << " flushing buffer of cached mezzanines";
}
cout << " {" << numFlushed << "}" << endl;
}
else {
for(unsigned int nn = 0; nn < cacheLength; nn++) {
if(mezzCache[nn].slot != 0xFFFFFFFF) {
dropped[mezzCache[nn].slot]++;
if(doPrint)
cout << " " << mezzCache[nn].slot;
}
mezzCache[nn].slot = 0xFFFFFFFF;
}
}
if(doPrint)
cout << " {" << numFlushed << "}" << endl;
memset(numData, 0, sizeof(numData));
totData = fixData = 0;
......@@ -229,7 +224,7 @@ int fileATCA::GetMezzFromCache(unsigned int slot, unsigned short *buff)
good = mezzCache + indData[slot][0];
if(good->slot != slot)
cout << "Inconsistency in mezzCache !!!!!" << endl;
DEBUG_LINE "Inconsistency in mezzCache !!!!!" << endl;
else
seen = 1;
if(numData[slot] > 1) {
......@@ -239,7 +234,7 @@ int fileATCA::GetMezzFromCache(unsigned int slot, unsigned short *buff)
for(unsigned int nn = 1; nn < numData[slot]; nn++) {
mezzCache_t * pCached = mezzCache + indData[slot][nn];
if(pCached->slot != slot)
cout << "Inconsistency in mezzCache !!!!!" << endl;
DEBUG_LINE "Inconsistency in mezzCache !!!!!" << endl;
else
seen++;
unsigned short *pdat = pCached->addr ? pCached->addr : pCached->buff;
......@@ -270,7 +265,7 @@ int fileATCA::GetMezzFromCache(unsigned int slot, unsigned short *buff)
}
else {
LOCK_COUT;
cout << "fileATCA::GetMezzanine inconsistent cache for slot " << slot
DEBUG_LINE " inconsistent cache for slot " << slot
<< " (found " << seen << " instead of " << numData[slot] << ")" << endl;
return EvFinish;;
}
......@@ -358,17 +353,18 @@ void fileATCA::FixCache()
mezzCache[nn].addr = NULL;
fixData--;
}
if(++seen == totData)
if(++seen >= totData)
break;
}
}
}
}
// If the call refers to this FileATCA (which==fileID) we can read a full buffer,
// If the call refers to this FileATCA (which==fileID) we can read a full buffer.
// Otherwise we must verify how much space is still available in rawDataBuffer, skipping the read if there is less than one full mezzanine.
// NOTICE: rawDataBuffer is not a circular buffer and if needed the previous data has to be shifted to its beginning
// NOTICE: rawDataBuffer is not a circular buffer; when needed, the previous data has to be shifted to its beginning
// Takes also care of writing the raw data (wmask 1)
// Takes care also of diverting the trace-capture mezznines to file (until a normal mezzanine is found)
int fileATCA::ReadNextBuffer(int which)
{
//cout << "\nReadNextBuffer - " << fileID << endl;
......@@ -433,8 +429,8 @@ int fileATCA::ReadNextBuffer(int which)
}
}
#if 1
// we remove trace-capture data starting from nMezz and continuing
// until a regular mezzanine is found or all mezzanines have been consumed
// remove trace-capture data starting from nMezz and continuing until
// a regular mezzanine is found or all mezzanines have been consumed
while(true) {
unsigned short *uu = rawDataBuffer + nMezz*lenMezzTotal;
if( (uu[0]&0xFFF0) != 0xDA50 )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment