Commit c2449107 authored by Jan Becker's avatar Jan Becker
Browse files

[scheli] Reduce memory consumption by not storing raw data

parent 98818393
......@@ -14,6 +14,7 @@
#include <seiscomp3/core/genericrecord.h>
#include <seiscomp3/math/filter/butterworth.h>
#include <seiscomp3/gui/core/application.h>
#include <seiscomp3/gui/core/utils.h>
using namespace Seiscomp;
......@@ -94,7 +95,8 @@ void HeliCanvas::Row::update() {
}
HeliCanvas::HeliCanvas() {
HeliCanvas::HeliCanvas(bool saveUnfiltered)
: _saveUnfiltered(saveUnfiltered) {
_records = NULL;
_filteredRecords = NULL;
_scale = 1.0f;
......@@ -225,25 +227,29 @@ bool HeliCanvas::feed(Record *rec) {
arr->typedData()[i] *= _scale;
crec->setData(arr.get());
if ( !_records->feed(crec.get()) ) return false;
arr = (FloatArray*)crec->data()->copy(Array::FLOAT);
GenericRecordPtr frec = new GenericRecord(*crec);
GenericRecordPtr frec;
if ( _saveUnfiltered ) {
if ( !_records->feed(crec.get()) ) return false;
arr = (FloatArray*)crec->data()->copy(Array::FLOAT);
frec = new GenericRecord(*crec);
frec->setData(arr.get());
}
else
frec = crec;
if ( _filter ) {
if ( _filteredRecords->empty() ) {
_filter->setSamplingFrequency(frec->samplingFrequency());
_filter->setStartTime(frec->startTime());
_filter->setStreamID(frec->networkCode(), frec->stationCode(),
frec->locationCode(), frec->channelCode());
frec->locationCode(), frec->channelCode());
}
_filter->apply(arr->size(), arr->typedData());
}
frec->setData(arr.get());
_filteredRecords->feed(frec.get());
if ( !_filteredRecords->feed(frec.get()) ) return false;
if ( _rows.empty() ) return false;
Core::Time startTime = rec->startTime();
......@@ -450,7 +456,7 @@ void HeliCanvas::render(QPainter &p) {
if ( currentTextLine == 0 ) {
p.drawText(QRect(0, rowPos-fontHeight, _labelMargin, rowHeight+2*fontHeight + heightOfs),
Qt::AlignLeft | Qt::AlignVCenter,
_rows[i].time.toString("%H:%M").c_str());
Gui::timeToString(_rows[i].time, "%H:%M"));
currentTextLine = skipTextLines;
}
else
......
......@@ -26,7 +26,7 @@
class HeliCanvas {
public:
HeliCanvas();
HeliCanvas(bool saveUnfiltered = false);
~HeliCanvas();
public:
......@@ -88,6 +88,7 @@ class HeliCanvas {
int _rowTimeSpan;
QVector<Row> _rows;
bool _saveUnfiltered;
Seiscomp::Core::Time _currentTime;
int _numberOfRows;
float _scale;
......
......@@ -83,7 +83,10 @@ HCApp::~HCApp() {
for ( it = _helis.begin(); it != _helis.end(); ++it )
delete it.value().canvas;
if ( _streamThread ) delete _streamThread;
if ( _streamThread ) {
_streamThread->stop(true);
delete _streamThread;
}
}
......@@ -303,7 +306,7 @@ bool HCApp::run() {
Core::Time endTime = _endTime.valid()?_endTime:Core::Time::GMT();
for ( size_t i = 0; i < _streamCodes.size(); ++i ) {
HeliCanvas *heli = new HeliCanvas;
HeliCanvas *heli = new HeliCanvas();
_helis[_streamCodes[i]] = heli;
heli->setAntialiasingEnabled(_antialiasing);
......@@ -320,8 +323,6 @@ bool HCApp::run() {
heli->setRowColors(colors);
}
if ( !_filterString.empty() )
if ( !heli->setFilter(_filterString) ) {
std::cerr << "Unable to set filter: " << _filterString << std::endl;
......
Supports Markdown
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