Skip to content
Snippets Groups Projects
Commit adc8ea24 authored by Pieter Donker's avatar Pieter Donker
Browse files

Task #10073: changed dumping procedure in TBBDriver

parent 091e58bd
No related branches found
No related tags found
No related merge requests found
...@@ -39,7 +39,7 @@ using namespace TBB; ...@@ -39,7 +39,7 @@ using namespace TBB;
//--Constructors for a ReadCmd object.---------------------------------------- //--Constructors for a ReadCmd object.----------------------------------------
ReadCmd::ReadCmd(): ReadCmd::ReadCmd():
itsSecondstime(0), itsSampleNr(0), itsPrepages(0), itsPostpages(0), itsStage(0), itsSecondstime(0), itsSampleNr(0), itsPrepages(0), itsPostpages(0), itsStage(0),
itsLastSavedSecond(0), itsLastSavedSampleNr(0), itsLastSavedSecond(0), itsLastSavedSampleNr(0),
itsLastSavedNrOfSamples(0), itsLastSavedSampleFreq(0), itsLastSavedNrOfSamples(0), itsLastSavedSampleFreq(0),
itsTimestamp(0), itsTimeBefore(0), itsTimeAfter(0) itsTimestamp(0), itsTimeBefore(0), itsTimeAfter(0)
{ {
...@@ -96,14 +96,14 @@ void ReadCmd::saveTbbEvent(GCFEvent& event) ...@@ -96,14 +96,14 @@ void ReadCmd::saveTbbEvent(GCFEvent& event)
void ReadCmd::sendTpEvent() void ReadCmd::sendTpEvent()
{ {
switch (itsStage) { switch (itsStage) {
// stage 0, haal de sampletijd op van het laatst geschreven frame // stage 0, haal de sampletijd op van het laatst geschreven frame
// stage 1, haal de sample frequentie op van het laatst gescreven frame // stage 1, haal de sample frequentie op van het laatst gescreven frame
// en kijk of gevraagde data aanwezig is. // en kijk of gevraagde data aanwezig is.
// stage 2, zet udp poort gegevens // stage 2, zet udp poort gegevens
// stage 3, verstuur 1 arp bericht // stage 3, verstuur 1 arp bericht
// stage 4, stuur het read commando // stage 4, stuur het read commando
// get last saved sampletime and samplenr // get last saved sampletime and samplenr
case 0: { case 0: {
TPReadrEvent tp_event; TPReadrEvent tp_event;
...@@ -112,12 +112,12 @@ void ReadCmd::sendTpEvent() ...@@ -112,12 +112,12 @@ void ReadCmd::sendTpEvent()
tp_event.mp = (uint32)TS->getChMpNr(getChannelNr()); tp_event.mp = (uint32)TS->getChMpNr(getChannelNr());
tp_event.pid = (uint32)TS->getChMemWriter(getChannelNr()); tp_event.pid = (uint32)TS->getChMemWriter(getChannelNr());
tp_event.regid = 4; tp_event.regid = 4;
TS->boardPort(getBoardNr()).send(tp_event); TS->boardPort(getBoardNr()).send(tp_event);
TS->setBoardUsed(getBoardNr()); TS->setBoardUsed(getBoardNr());
TS->boardPort(getBoardNr()).setTimer(TS->timeout()); TS->boardPort(getBoardNr()).setTimer(TS->timeout());
} break; } break;
// get last saved samplefreq // get last saved samplefreq
case 1: { case 1: {
TPReadrEvent tp_event; TPReadrEvent tp_event;
...@@ -126,12 +126,12 @@ void ReadCmd::sendTpEvent() ...@@ -126,12 +126,12 @@ void ReadCmd::sendTpEvent()
tp_event.mp = TS->getChMpNr(getChannelNr()); tp_event.mp = TS->getChMpNr(getChannelNr());
tp_event.pid = TS->getChMemWriter(getChannelNr()); tp_event.pid = TS->getChMemWriter(getChannelNr());
tp_event.regid = 6; tp_event.regid = 6;
TS->boardPort(getBoardNr()).send(tp_event); TS->boardPort(getBoardNr()).send(tp_event);
TS->setBoardUsed(getBoardNr()); TS->setBoardUsed(getBoardNr());
TS->boardPort(getBoardNr()).setTimer(TS->timeout()); TS->boardPort(getBoardNr()).setTimer(TS->timeout());
} break; } break;
// send UDP header settings for CEP port // send UDP header settings for CEP port
case 2: { case 2: {
TPUdpEvent tp_event; TPUdpEvent tp_event;
...@@ -154,19 +154,19 @@ void ReadCmd::sendTpEvent() ...@@ -154,19 +154,19 @@ void ReadCmd::sendTpEvent()
TS->setBoardUsed(getBoardNr()); TS->setBoardUsed(getBoardNr());
TS->boardPort(getBoardNr()).setTimer(TS->timeout()); TS->boardPort(getBoardNr()).setTimer(TS->timeout());
} break; } break;
// send 1 arp message // send 1 arp message
case 3: { case 3: {
TPArpEvent tp_event; TPArpEvent tp_event;
tp_event.opcode = oc_ARP; tp_event.opcode = oc_ARP;
tp_event.status = 0; tp_event.status = 0;
TS->boardPort(getBoardNr()).send(tp_event); TS->boardPort(getBoardNr()).send(tp_event);
TS->setBoardUsed(getBoardNr()); TS->setBoardUsed(getBoardNr());
TS->boardPort(getBoardNr()).setTimer(TS->timeout()); TS->boardPort(getBoardNr()).setTimer(TS->timeout());
} break; } break;
// send requested data to CEP // send requested data to CEP
case 4: { case 4: {
TPReadEvent tp_event; TPReadEvent tp_event;
...@@ -216,21 +216,19 @@ void ReadCmd::saveTpAckEvent(GCFEvent& event) ...@@ -216,21 +216,19 @@ void ReadCmd::saveTpAckEvent(GCFEvent& event)
itsLastSavedSampleFreq = tp_ack.data[1]; itsLastSavedSampleFreq = tp_ack.data[1];
//LOG_DEBUG_STR(formatString("Last frame info: time=%lu samplenr=%lu nSamples=%lu freq=%lu", //LOG_DEBUG_STR(formatString("Last frame info: time=%lu samplenr=%lu nSamples=%lu freq=%lu",
// itsLastSavedSecond, itsLastSavedSampleNr, itsLastSavedNrOfSamples, itsLastSavedSampleFreq )); // itsLastSavedSecond, itsLastSavedSampleNr, itsLastSavedNrOfSamples, itsLastSavedSampleFreq ));
double sampletime = 1. / (itsLastSavedSampleFreq * 1E6); // in sec double sampletime = 1. / (itsLastSavedSampleFreq * 1E6); // in sec
// calculate time of last sample in memory // calculate time of last sample in memory
NsTimestamp NsTimestamp lastSampleTime(itsLastSavedSecond + ((itsLastSavedSampleNr + itsLastSavedNrOfSamples) * sampletime));
lastSampleTime(itsLastSavedSecond + ((itsLastSavedSampleNr + itsLastSavedNrOfSamples) * sampletime));
// calculate time of first sample in memory // calculate time of first sample in memory
NsTimestamp NsTimestamp firstSampleTime((double)lastSampleTime - (TS->getChPageSize(getChannelNr()) * itsLastSavedNrOfSamples * sampletime));
firstSampleTime((double)lastSampleTime - (TS->getChPageSize(getChannelNr()) * itsLastSavedNrOfSamples * sampletime));
// calculate start and stop time // calculate start and stop time
NsTimestamp startTimestamp = itsTimestamp - itsTimeBefore; NsTimestamp startTimestamp(itsTimestamp - itsTimeBefore);
NsTimestamp stopTimestamp = itsTimestamp + itsTimeAfter; NsTimestamp stopTimestamp(itsTimestamp + itsTimeAfter);
#if 1 #if 1
//LOG_DEBUG_STR(formatString("Timestamp = %lu seconds %lu nseconds", itsTimestamp.sec(), itsTimestamp.nsec())); //LOG_DEBUG_STR(formatString("Timestamp = %lu seconds %lu nseconds", itsTimestamp.sec(), itsTimestamp.nsec()));
LOG_DEBUG_STR(formatString("firstSampleTime= %lu seconds %lu nseconds", firstSampleTime.sec(), firstSampleTime.nsec())); LOG_DEBUG_STR(formatString("firstSampleTime= %lu seconds %lu nseconds", firstSampleTime.sec(), firstSampleTime.nsec()));
...@@ -238,40 +236,40 @@ void ReadCmd::saveTpAckEvent(GCFEvent& event) ...@@ -238,40 +236,40 @@ void ReadCmd::saveTpAckEvent(GCFEvent& event)
LOG_DEBUG_STR(formatString("startTimestamp = %lu seconds %lu nseconds", startTimestamp.sec(), startTimestamp.nsec())); LOG_DEBUG_STR(formatString("startTimestamp = %lu seconds %lu nseconds", startTimestamp.sec(), startTimestamp.nsec()));
LOG_DEBUG_STR(formatString("stopTimestamp = %lu seconds %lu nseconds", stopTimestamp.sec(), stopTimestamp.nsec())); LOG_DEBUG_STR(formatString("stopTimestamp = %lu seconds %lu nseconds", stopTimestamp.sec(), stopTimestamp.nsec()));
#endif #endif
// to get last part of recording // to get last part of recording
if (itsTimestamp == 0.0) { if (itsTimestamp == 0.0) {
itsTimestamp = lastSampleTime; itsTimestamp = lastSampleTime;
} }
// check if center time in memory // check if center time in memory
if ((itsTimestamp >= firstSampleTime) && (itsTimestamp <= lastSampleTime)) { if ((itsTimestamp >= firstSampleTime) && (itsTimestamp <= lastSampleTime)) {
// check if start time in memory, if not correct it // check if start time in memory, if not correct it
if (startTimestamp < firstSampleTime) { if (startTimestamp < firstSampleTime) {
LOG_WARN_STR(formatString("Not all requested prepages are available for rcu[%d]", TS->convertChanToRcu(getChannelNr()))); LOG_WARN_STR(formatString("Not all requested prepages are available for rcu[%d]", TS->convertChanToRcu(getChannelNr())));
LOG_WARN_STR(formatString("requested starttime = %lf, first time in memory = %lf", (double)startTimestamp, (double)firstSampleTime)); LOG_WARN_STR(formatString("requested starttime = %lf, first time in memory = %lf", (double)startTimestamp, (double)firstSampleTime));
startTimestamp = firstSampleTime; startTimestamp = firstSampleTime;
} }
// check if stop time in memory, if not correct it // check if stop time in memory, if not correct it
if (stopTimestamp > lastSampleTime) { if (stopTimestamp > lastSampleTime) {
LOG_WARN_STR(formatString("Not all requested postpages are available for rcu[%d]", TS->convertChanToRcu(getChannelNr()))); LOG_WARN_STR(formatString("Not all requested postpages are available for rcu[%d]", TS->convertChanToRcu(getChannelNr())));
LOG_WARN_STR(formatString("requested stoptime = %lf, last time in memory = %lf", (double)stopTimestamp, (double)lastSampleTime)); LOG_WARN_STR(formatString("requested stoptime = %lf, last time in memory = %lf", (double)stopTimestamp, (double)lastSampleTime));
stopTimestamp = lastSampleTime; stopTimestamp = lastSampleTime;
} }
} }
else { else {
// requested time not in memory // requested time not in memory
LOG_WARN_STR(formatString("Requested time(data) not in memory for rcu[%d]", TS->convertChanToRcu(getChannelNr()))); LOG_WARN_STR(formatString("Requested time(data) not in memory for rcu[%d]", TS->convertChanToRcu(getChannelNr())));
LOG_WARN_STR(formatString("requested time = %lf, in memory [%lf .. %lf]", (double)itsTimestamp, (double)firstSampleTime, (double)lastSampleTime)); LOG_WARN_STR(formatString("requested time = %lf, in memory [%lf .. %lf]", (double)itsTimestamp, (double)firstSampleTime, (double)lastSampleTime));
setDone(true); setDone(true);
} }
itsTimeBefore = itsTimestamp - startTimestamp; itsTimeBefore.set(itsTimestamp - startTimestamp);
itsTimeAfter = stopTimestamp - itsTimestamp; itsTimeAfter.set(stopTimestamp - itsTimestamp);
// convert it to board units // convert it to board units
itsSecondstime = (uint32)itsTimestamp.sec(); itsSecondstime = (uint32)itsTimestamp.sec();
itsSampleNr = (uint32)(itsTimestamp.nsec() / (sampletime * 1E9)); itsSampleNr = (uint32)(itsTimestamp.nsec() / (sampletime * 1E9));
itsPrepages = (uint32)ceil(((double)(itsTimestamp - startTimestamp) / sampletime) / itsLastSavedNrOfSamples); itsPrepages = (uint32)ceil(((double)(itsTimestamp - startTimestamp) / sampletime) / itsLastSavedNrOfSamples);
...@@ -294,7 +292,7 @@ void ReadCmd::saveTpAckEvent(GCFEvent& event) ...@@ -294,7 +292,7 @@ void ReadCmd::saveTpAckEvent(GCFEvent& event)
} }
else if (event.signal == TP_ARP_ACK) { else if (event.signal == TP_ARP_ACK) {
TPArpAckEvent tp_ack(event); TPArpAckEvent tp_ack(event);
if (tp_ack.status != 0) { if (tp_ack.status != 0) {
setStatus(0, (tp_ack.status << 24)); setStatus(0, (tp_ack.status << 24));
} }
...@@ -316,7 +314,7 @@ void ReadCmd::saveTpAckEvent(GCFEvent& event) ...@@ -316,7 +314,7 @@ void ReadCmd::saveTpAckEvent(GCFEvent& event)
LOG_INFO_STR(formatString("TBB busy, %d pages left", tp_ack.pages_left)); LOG_INFO_STR(formatString("TBB busy, %d pages left", tp_ack.pages_left));
usleep(100000); // wait for some time and try again usleep(100000); // wait for some time and try again
} }
else { else {
if (tp_ack.status != 0) { if (tp_ack.status != 0) {
setStatus(0, (tp_ack.status << 24)); setStatus(0, (tp_ack.status << 24));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment