Limit raw data in PRS1/Session YAML to 100 bytes per entry.

This changes the reference output, compared to prior versions, but
it runs much faster and doesn't affect user-observable behavior.
This commit is contained in:
sawinglogz 2019-05-28 21:09:17 -04:00
parent 1892ceda85
commit d0150d18ef
3 changed files with 21 additions and 12 deletions

View File

@ -1273,6 +1273,7 @@ public:
m_unit = UNIT;
}
};
const PRS1ParsedEventType PRS1TidalVolumeEvent::TYPE;
class PRS1ParsedSettingEvent : public PRS1ParsedValueEvent
{
@ -1313,7 +1314,8 @@ class T : public P \
public: \
static const PRS1ParsedEventType TYPE = E; \
T(int start, int ARG) : P(TYPE, start, ARG) {} \
}
}; \
const PRS1ParsedEventType T::TYPE
#define PRS1_DURATION_EVENT(T, E) _PRS1_EVENT(T, E, PRS1ParsedDurationEvent, duration)
#define PRS1_VALUE_EVENT(T, E) _PRS1_EVENT(T, E, PRS1ParsedValueEvent, value)
#define PRS1_PRESSURE_EVENT(T, E) _PRS1_EVENT(T, E, PRS1PressureEvent, value)
@ -1345,7 +1347,7 @@ PRS1_VALUE_EVENT(PRS1PressurePulseEvent, EV_PRS1_PP);
PRS1_VALUE_EVENT(PRS1RERAEvent, EV_PRS1_RERA); // TODO: should this really be a duration event?
PRS1_VALUE_EVENT(PRS1NonRespondingEvent, EV_PRS1_NRI); // TODO: is this a single event or an index/hour?
PRS1_VALUE_EVENT(PRS1FlowRateEvent, EV_PRS1_FLOWRATE); // TODO: is this a single event or an index/hour?
PRS1_VALUE_EVENT(PRS1Test1Event, EV_PRS1_TEST1); // TODO: replace test1/2 event with unknownvalue events and appropriate mapping
PRS1_VALUE_EVENT(PRS1Test1Event, EV_PRS1_TEST1);
PRS1_VALUE_EVENT(PRS1Test2Event, EV_PRS1_TEST2);
//********************************************************************************************

View File

@ -125,12 +125,15 @@ static QString ts(qint64 msecs)
return QDateTime::fromMSecsSinceEpoch(msecs).toString(Qt::ISODate);
}
static QString byteList(QByteArray data)
static QString byteList(QByteArray data, int limit=-1)
{
int count = data.size();
if (limit == -1 || limit > count) limit = count;
QStringList l;
for (int i = 0; i < data.size(); i++) {
for (int i = 0; i < limit; i++) {
l.push_back(QString( "%1" ).arg((int) data[i] & 0xFF, 2, 16, QChar('0') ).toUpper());
}
if (limit < count) l.push_back("...");
QString s = l.join("");
return s;
}
@ -180,7 +183,7 @@ void ChunkToYaml(QFile & file, PRS1DataChunk* chunk)
}
// data
out << " data: " << byteList(chunk->m_data) << endl;
out << " data: " << byteList(chunk->m_data, 100) << endl;
// data CRC
out << " crc: " << hex << chunk->storedCrc << endl;

View File

@ -133,22 +133,26 @@ static QString eventChannel(ChannelID i)
return s;
}
static QString intList(EventStoreType* data, int count)
static QString intList(EventStoreType* data, int count, int limit=-1)
{
if (limit == -1 || limit > count) limit = count;
QStringList l;
for (int i = 0; i < count; i++) {
for (int i = 0; i < limit; i++) {
l.push_back(QString::number(data[i]));
}
if (limit < count) l.push_back("...");
QString s = "[ " + l.join(",") + " ]";
return s;
}
static QString intList(quint32* data, int count)
static QString intList(quint32* data, int count, int limit=-1)
{
if (limit == -1 || limit > count) limit = count;
QStringList l;
for (int i = 0; i < count; i++) {
for (int i = 0; i < limit; i++) {
l.push_back(QString::number(data[i] / 1000));
}
if (limit < count) l.push_back("...");
QString s = "[ " + l.join(",") + " ]";
return s;
}
@ -216,15 +220,15 @@ void SessionToYaml(QString filepath, Session* session)
out << " data:" << endl;
out << " min: " << e.Min() << endl;
out << " max: " << e.Max() << endl;
out << " raw: " << intList((EventStoreType*) e.m_data.data(), e.count()) << endl;
out << " raw: " << intList((EventStoreType*) e.m_data.data(), e.count(), 100) << endl;
if (e.type() != EVL_Waveform) {
out << " delta: " << intList((quint32*) e.m_time.data(), e.count()) << endl;
out << " delta: " << intList((quint32*) e.m_time.data(), e.count(), 100) << endl;
}
if (e.hasSecondField()) {
out << " data2:" << endl;
out << " min: " << e.min2() << endl;
out << " max: " << e.max2() << endl;
out << " raw: " << intList((EventStoreType*) e.m_data2.data(), e.count()) << endl;
out << " raw: " << intList((EventStoreType*) e.m_data2.data(), e.count(), 100) << endl;
}
}
}