Restore session end time to previous behavior, with better logging and documentation.

It turns out the session end time was intentionally not being set in ParseSummary,
probably due to its unreliability. This may be revisited once things are more
stable, but for now the old behavior is retained.
This commit is contained in:
sawinglogz 2019-06-05 17:08:45 -04:00
parent fd6f3c3f0a
commit ce38fbcdde
2 changed files with 37 additions and 11 deletions

View File

@ -3597,7 +3597,7 @@ bool PRS1DataChunk::ParseSummaryF3(void)
if ((it=this->hbdata.find(5)) != this->hbdata.end()) {
this->duration = (it.value()[1] << 8 ) + it.value()[0];
} else {
qWarning() << "missing summary duration";
qWarning() << this->sessionid << "missing summary duration";
}
return true;
@ -4024,15 +4024,20 @@ bool PRS1Import::ImportSummary()
if (!ok) {
return false;
}
summary_duration = summary->duration;
if (summary->duration == 0) {
// This does occasionally happen and merely indicates a brief session with no useful data.
//qDebug() << summary->sessionid << "duration == 0";
return false;
return true; // Don't bail for now, since some summary parsers are still very broken, so we want to proceed to events/waveforms.
}
summary_duration = summary->duration;
session->set_last(qint64(summary->timestamp + summary->duration) * 1000L);
// Intentionally don't set the session's duration based on the summary duration.
// That only happens in PRS1Import::ParseSession() as a last resort.
// TODO: Revisit this once summary parsing is reliable.
//session->set_last(...);
return true;
}
@ -4573,13 +4578,22 @@ bool PRS1Import::ParseSession(void)
if (session->first() > 0) {
if (session->last() < session->first()) {
// Compliance and session parsing both use set_last() to set the session's last timestamp.
// Events and waveforms use updateLast().
//
// if last isn't set, duration couldn't be gained from summary, parsing events or waveforms..
// This session is dodgy, so kill it
qWarning() << sessionid << "Session last() earlier than first(), downgrading to summary only";
// Compliance uses set_last() to set the session's last timestamp, so it
// won't reach this point.
if (compliance != nullptr) {
qWarning() << sessionid << "compliance didn't set session end?";
}
// Events and waveforms use updateLast() to set the session's last timestamp,
// so they should only reach this point if there was a problem parsing them.
if (event != nullptr || !wavefile.isEmpty() || !oxifile.isEmpty()) {
qWarning() << sessionid << "Downgrading session to summary only";
}
session->setSummaryOnly(true);
// Only use the summary's duration if the session's duration couldn't be
// derived from events or waveforms.
// TODO: Revisit this once summary parsing is reliable.
session->really_set_last(session->first()+(qint64(summary_duration) * 1000L));
}
save = true;

View File

@ -126,6 +126,17 @@ static QString ts(qint64 msecs)
return QDateTime::fromMSecsSinceEpoch(msecs).toString(Qt::ISODate);
}
static QString dur(qint64 msecs)
{
qint64 s = msecs / 1000L;
int h = s / 3600; s -= h * 3600;
int m = s / 60; s -= m * 60;
return QString("%1:%2:%3")
.arg(h, 2, 10, QChar('0'))
.arg(m, 2, 10, QChar('0'))
.arg(s, 2, 10, QChar('0'));
}
static QString byteList(QByteArray data, int limit=-1)
{
int count = data.size();
@ -154,6 +165,7 @@ void ChunkToYaml(QFile & file, PRS1DataChunk* chunk)
out << " ext: " << chunk->ext << endl;
out << " session: " << chunk->sessionid << endl;
out << " start: " << ts(chunk->timestamp * 1000L) << endl;
out << " duration: " << dur(chunk->duration * 1000L) << endl;
// hblock for V3 non-waveform chunks
if (chunk->fileVersion == 3 && chunk->htype == 0) {