diff --git a/Plot/FloatBuffer.h b/Plot/FloatBuffer.h index e928420..9c044de 100644 --- a/Plot/FloatBuffer.h +++ b/Plot/FloatBuffer.h @@ -1,11 +1,12 @@ #pragma once #include -#include +#include #include #include #include #include #include + using namespace std; class FloatBuffer : public QObject { @@ -66,14 +67,23 @@ public: void append_samples_circular(const std::vector>& samples, int signal_index) { int num_samples_to_add = samples.size(); + if(m_length > maxSize){ + m_data.erase(m_data.begin(),m_data.begin()+num_samples_to_add); + for(int i=0;i getData() { - QList qData; - qData.reserve(m_length); - for (unsigned i=0; i < m_length; i++) { - qreal d = get(i); - qData.append(d); - } - return qData; - } +// Q_INVOKABLE QList getData() { +// QList qData; +// qData.reserve(m_length); +// for (unsigned i=0; i < m_length; i++) { +// qreal d = get(i); +// qData.append(d); +// } +// return qData; +// } void startSweep() { // When switching from continuous to repeated-sweep mode, stop acting like a ring buffer @@ -137,6 +149,7 @@ public: m_length = 0; dataChanged(); } + m_start_test = 0; } @@ -179,7 +192,7 @@ public: std::vector dif_mean(double avg){ std::vector tmp; - for (std::vector::iterator it = data_begin(); it != m_data.end(); ++it){ + for (std::deque::iterator it = data_begin(); it != m_data.end(); ++it){ tmp.push_back(*it - avg); } return tmp; @@ -199,11 +212,12 @@ public slots: private: float m_secondsPerSample; - std::vector m_data; + std::deque m_data; size_t m_start; size_t m_length; size_t m_first_samples_ignored; size_t m_start_test; + size_t maxSize; unsigned unwrapIndex(unsigned index) { if (index >= m_start) { @@ -230,13 +244,13 @@ private: /* A number of samples at the beginning of the buffer can be ignored by * the application. Use data_begin() and data_size() to access the rest of data */ - std::vector::iterator data_begin() + std::deque::iterator data_begin() { - return (m_data.begin() + m_first_samples_ignored); + return (m_data.begin() + m_first_samples_ignored); } float data_size() { - return (m_data.size() - m_first_samples_ignored); + return (m_data.size() - m_first_samples_ignored); } };