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