kind of working
This commit is contained in:
parent
cc6d96feb6
commit
3859d8090b
@ -56,7 +56,6 @@ bool Chart::myWheelEvent(QGraphicsSceneWheelEvent *event) {
|
||||
}
|
||||
|
||||
void Chart::XRangeChanged(qreal min, qreal max) {
|
||||
std::cerr << "XRangeChanged" << min << "\t"<< max << std::endl;
|
||||
if (series().at(0)->type() == QtCharts::QAbstractSeries::SeriesTypeLine) {
|
||||
QLineSeries *s = static_cast<QLineSeries *>(series().at(0));
|
||||
if (max > s->at(s->count()-1).x()) {
|
||||
|
@ -6,12 +6,12 @@ DataLoader::DataLoader()
|
||||
|
||||
}
|
||||
|
||||
DataResult1D DataLoader::doLoad(const DataRequest &request) {
|
||||
DataResult1D DataLoader::doLoad(DataRequest &request) {
|
||||
std::vector<double> x, y;
|
||||
x = request.array.getDimension(1).asSampledDimension().axis(request.count[0], request.start[0]);
|
||||
//if (request.start + request.count);
|
||||
if (request.start + request.count > request.array.dataExtent())
|
||||
request.count = request.array.dataExtent() - request.start;
|
||||
request.array.getData(y, request.count, request.start);
|
||||
|
||||
DataResult1D res(request.id, request.array.id(), x, y);
|
||||
return res;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public:
|
||||
DataLoader();
|
||||
|
||||
public slots:
|
||||
DataResult1D doLoad(const DataRequest &request);
|
||||
DataResult1D doLoad(DataRequest &request);
|
||||
};
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ void DataQueue::run() {
|
||||
DataResult1D data = loader->doLoad(requestQueue.front());
|
||||
resultMap.insert(std::pair<std::string, DataResult1D>(data.id, data));
|
||||
emit resultReady(QString::fromStdString(data.id));
|
||||
requestQueue.pop();
|
||||
requestQueue.pop_front();
|
||||
stop = requestQueue.size() == 0 || stopped;
|
||||
}
|
||||
mutex.unlock();
|
||||
@ -30,8 +30,13 @@ void DataQueue::requestData(const nix::DataArray &array, const nix::NDSize &coun
|
||||
requestId = nix::util::createId();
|
||||
DataRequest dr(requestId, array, count, offset);
|
||||
mutex.lock();
|
||||
// if (requestQueue.)
|
||||
requestQueue.push(dr);
|
||||
std::deque<DataRequest>::iterator it;
|
||||
for (it = requestQueue.begin(); it < requestQueue.end(); it++) {
|
||||
std::cerr << it->array.id() << std::endl;
|
||||
if (it->array.id() == array.id())
|
||||
std::cerr << "updating request" <<std::endl;
|
||||
}
|
||||
requestQueue.push_back(dr);
|
||||
mutex.unlock();
|
||||
start();
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <queue>
|
||||
#include <iostream>
|
||||
#include <nix.hpp>
|
||||
#include <deque>
|
||||
|
||||
#include "dataloader.h"
|
||||
#include "dataresult1d.h"
|
||||
@ -32,7 +33,7 @@ public slots:
|
||||
|
||||
|
||||
private:
|
||||
std::queue<DataRequest> requestQueue;
|
||||
std::deque<DataRequest> requestQueue;
|
||||
std::map<std::string, DataResult1D> resultMap;
|
||||
QMutex mutex;
|
||||
DataLoader *loader;
|
||||
|
@ -24,12 +24,14 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
DataLoader *loader = new DataLoader();
|
||||
loader->moveToThread(&dataQueue);
|
||||
|
||||
dataQueue.start();
|
||||
/*
|
||||
file = nix::File::open("/home/grewe/zwischenlager/2017-08-17-af-invivo-1/2017-08-17-af-invivo-1.nix",
|
||||
nix::FileMode::ReadOnly);
|
||||
|
||||
//file = nix::File::open("/Users/jan/zwischenlager/threading_test/dataservice/data/2017-08-17-af-invivo-1.nix",
|
||||
//nix::FileMode::ReadOnly);
|
||||
*/
|
||||
file = nix::File::open("/Users/jan/zwischenlager/threading_test/dataservice/data/2017-08-17-af-invivo-1.nix",
|
||||
nix::FileMode::ReadOnly);
|
||||
nix::Block b = file.getBlock(0);
|
||||
this->voltage = b.getDataArray("V-1");
|
||||
this->eod = b.getDataArray("EOD");
|
||||
|
@ -123,14 +123,19 @@ void MultiChartView::loadData(const ArrayInfo &info) {
|
||||
|
||||
void MultiChartView::newDataRequest(const std::string &entity_id, qreal max) {
|
||||
std::cerr << "request new data from: "<< entity_id << " with max: "<< max << std::endl;
|
||||
|
||||
nix::NDSize offset(1, data_buffer[entity_id]->size());
|
||||
nix::NDSize count(1, 100000);
|
||||
std::string request_id;
|
||||
std::cerr << offset << count;
|
||||
|
||||
dataQueue->requestData(arrayMap[entity_id], count, offset, request_id);
|
||||
}
|
||||
|
||||
|
||||
void MultiChartView::dataReady(QString requestId){
|
||||
// need to make sure, that only one tasks does the conversion on the same buffer at the same time.
|
||||
std::cerr << "converting data for array: " << requestId.toStdString() << std::endl;
|
||||
DataResult1D data = dataQueue->getData(requestId);
|
||||
if (data.id.empty()) {
|
||||
return;
|
||||
@ -142,6 +147,7 @@ void MultiChartView::dataReady(QString requestId){
|
||||
}
|
||||
|
||||
void MultiChartView::dataConverted(QString entityId, double ymin, double ymax) {
|
||||
std::cerr << "data converted for: " << entityId.toStdString() << std::endl;
|
||||
Chart *chart = chartMap[entityId.toStdString()];
|
||||
QLineSeries *series;
|
||||
bool newSeries = false;
|
||||
@ -156,6 +162,7 @@ void MultiChartView::dataConverted(QString entityId, double ymin, double ymax) {
|
||||
newSeries = true;
|
||||
} else {
|
||||
series = static_cast<QLineSeries*>(chart->series().at(0));
|
||||
series->replace(*data_buffer[entityId.toStdString()]);
|
||||
}
|
||||
|
||||
if (chart->axisX()->type() == QAbstractAxis::AxisTypeValue) {
|
||||
|
Loading…
Reference in New Issue
Block a user