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;
//--Constructors for a ReadCmd object.----------------------------------------
ReadCmd::ReadCmd():
itsSecondstime(0), itsSampleNr(0), itsPrepages(0), itsPostpages(0), itsStage(0),
itsLastSavedSecond(0), itsLastSavedSampleNr(0),
itsLastSavedSecond(0), itsLastSavedSampleNr(0),
itsLastSavedNrOfSamples(0), itsLastSavedSampleFreq(0),
itsTimestamp(0), itsTimeBefore(0), itsTimeAfter(0)
{
......@@ -96,14 +96,14 @@ void ReadCmd::saveTbbEvent(GCFEvent& event)
void ReadCmd::sendTpEvent()
{
switch (itsStage) {
// stage 0, haal de sampletijd op van het laatst geschreven frame
// stage 1, haal de sample frequentie op van het laatst gescreven frame
// en kijk of gevraagde data aanwezig is.
// stage 2, zet udp poort gegevens
// stage 3, verstuur 1 arp bericht
// stage 4, stuur het read commando
// get last saved sampletime and samplenr
case 0: {
TPReadrEvent tp_event;
......@@ -112,12 +112,12 @@ void ReadCmd::sendTpEvent()
tp_event.mp = (uint32)TS->getChMpNr(getChannelNr());
tp_event.pid = (uint32)TS->getChMemWriter(getChannelNr());
tp_event.regid = 4;
TS->boardPort(getBoardNr()).send(tp_event);
TS->setBoardUsed(getBoardNr());
TS->boardPort(getBoardNr()).setTimer(TS->timeout());
} break;
// get last saved samplefreq
case 1: {
TPReadrEvent tp_event;
......@@ -126,12 +126,12 @@ void ReadCmd::sendTpEvent()
tp_event.mp = TS->getChMpNr(getChannelNr());
tp_event.pid = TS->getChMemWriter(getChannelNr());
tp_event.regid = 6;
TS->boardPort(getBoardNr()).send(tp_event);
TS->setBoardUsed(getBoardNr());
TS->boardPort(getBoardNr()).setTimer(TS->timeout());
} break;
// send UDP header settings for CEP port
case 2: {
TPUdpEvent tp_event;
......@@ -154,19 +154,19 @@ void ReadCmd::sendTpEvent()
TS->setBoardUsed(getBoardNr());
TS->boardPort(getBoardNr()).setTimer(TS->timeout());
} break;
// send 1 arp message
case 3: {
TPArpEvent tp_event;
tp_event.opcode = oc_ARP;
tp_event.status = 0;
TS->boardPort(getBoardNr()).send(tp_event);
TS->setBoardUsed(getBoardNr());
TS->boardPort(getBoardNr()).setTimer(TS->timeout());
} break;
// send requested data to CEP
case 4: {
TPReadEvent tp_event;
......@@ -216,21 +216,19 @@ void ReadCmd::saveTpAckEvent(GCFEvent& event)
itsLastSavedSampleFreq = tp_ack.data[1];
//LOG_DEBUG_STR(formatString("Last frame info: time=%lu samplenr=%lu nSamples=%lu freq=%lu",
// itsLastSavedSecond, itsLastSavedSampleNr, itsLastSavedNrOfSamples, itsLastSavedSampleFreq ));
double sampletime = 1. / (itsLastSavedSampleFreq * 1E6); // in sec
// calculate time of last sample in memory
NsTimestamp
lastSampleTime(itsLastSavedSecond + ((itsLastSavedSampleNr + itsLastSavedNrOfSamples) * sampletime));
NsTimestamp lastSampleTime(itsLastSavedSecond + ((itsLastSavedSampleNr + itsLastSavedNrOfSamples) * sampletime));
// calculate time of first sample in memory
NsTimestamp
firstSampleTime((double)lastSampleTime - (TS->getChPageSize(getChannelNr()) * itsLastSavedNrOfSamples * sampletime));
NsTimestamp firstSampleTime((double)lastSampleTime - (TS->getChPageSize(getChannelNr()) * itsLastSavedNrOfSamples * sampletime));
// calculate start and stop time
NsTimestamp startTimestamp = itsTimestamp - itsTimeBefore;
NsTimestamp stopTimestamp = itsTimestamp + itsTimeAfter;
NsTimestamp startTimestamp(itsTimestamp - itsTimeBefore);
NsTimestamp stopTimestamp(itsTimestamp + itsTimeAfter);
#if 1
//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()));
......@@ -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("stopTimestamp = %lu seconds %lu nseconds", stopTimestamp.sec(), stopTimestamp.nsec()));
#endif
// to get last part of recording
// to get last part of recording
if (itsTimestamp == 0.0) {
itsTimestamp = lastSampleTime;
}
// check if center time in memory
if ((itsTimestamp >= firstSampleTime) && (itsTimestamp <= lastSampleTime)) {
// check if start time in memory, if not correct it
if (startTimestamp < firstSampleTime) {
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;
}
// check if stop time in memory, if not correct it
if (stopTimestamp > lastSampleTime) {
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;
}
}
else {
// 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 = %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);
}
itsTimeBefore = itsTimestamp - startTimestamp;
itsTimeAfter = stopTimestamp - itsTimestamp;
}
itsTimeBefore.set(itsTimestamp - startTimestamp);
itsTimeAfter.set(stopTimestamp - itsTimestamp);
// convert it to board units
itsSecondstime = (uint32)itsTimestamp.sec();
itsSampleNr = (uint32)(itsTimestamp.nsec() / (sampletime * 1E9));
itsPrepages = (uint32)ceil(((double)(itsTimestamp - startTimestamp) / sampletime) / itsLastSavedNrOfSamples);
......@@ -294,7 +292,7 @@ void ReadCmd::saveTpAckEvent(GCFEvent& event)
}
else if (event.signal == TP_ARP_ACK) {
TPArpAckEvent tp_ack(event);
if (tp_ack.status != 0) {
setStatus(0, (tp_ack.status << 24));
}
......@@ -316,7 +314,7 @@ void ReadCmd::saveTpAckEvent(GCFEvent& event)
LOG_INFO_STR(formatString("TBB busy, %d pages left", tp_ack.pages_left));
usleep(100000); // wait for some time and try again
}
else {
else {
if (tp_ack.status != 0) {
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