Я использую QCustomPlot
для отображения данных из IMU в реальном времени следующим образом:
void Settings::realtimeDataSlot(double x_acceleration_g, double y_acceleration_g, double z_acceleration_g)
{
static QTime time(QTime::currentTime());
// calculate two new data points:
double key = time.elapsed()/1000.0; // time elapsed since start of demo, in seconds
static double lastPointKey = 0;
if (key-lastPointKey > 0.02) // at most add point every 2 ms
{
ui->customPlot->graph(0)->addData(key, x_acceleration_g);
ui->customPlot->graph(1)->addData(key, y_acceleration_g);
ui->customPlot->graph(2)->addData(key, z_acceleration_g);
ui->lbl_time->setText("Time elapsed:"+QString::number(key));
if (key-lastPointKey > 0.05)
lastPointKey = key;
}
// make key axis range scroll with the data (at a constant range size of 8):
ui->customPlot->xAxis->setRange(key, 8, Qt::AlignRight);
ui->customPlot->replot();
// calculate frames per second:
static double lastFpsKey;
static int frameCount;
++frameCount;
if (key-lastFpsKey >2) // average fps over 2 seconds
{
ui->statusbar->showMessage(
QString("%1 FPS, Total Data points: %2")
.arg(frameCount/(key-lastFpsKey), 0, 'f', 0)
.arg(ui->customPlot->graph(0)->data()->size()+ui->customPlot->graph(1)->data()->size())
, 0);
lastFpsKey = key;
frameCount = 0;
}
}
}
Теперь мне нужно сохранить double x_acceleration_g
в буфере (как std::vector<double>
) как минимум с 10 выборками . Чтобы выполнить некоторую обработку сигнала.
не могли бы вы показать мне способ хранения данных в буфере?