diff --git a/src/gui/properties/speedplotview.cpp b/src/gui/properties/speedplotview.cpp index 8dee762df..608e0f0cf 100644 --- a/src/gui/properties/speedplotview.cpp +++ b/src/gui/properties/speedplotview.cpp @@ -42,14 +42,20 @@ namespace MIN1_SEC = 60, MIN5_SEC = 5 * 60, MIN30_SEC = 30 * 60, - HOUR6_SEC = 6 * 60 * 60 + HOUR6_SEC = 6 * 60 * 60, + HOUR12_SEC = 12 * 60 * 60, + HOUR24_SEC = 24 * 60 * 60 }; const int MIN5_BUF_SIZE = 5 * 60; const int MIN30_BUF_SIZE = 5 * 60; const int HOUR6_BUF_SIZE = 5 * 60; + const int HOUR12_BUF_SIZE = 10 * 60; + const int HOUR24_BUF_SIZE = 10 * 60; const int DIVIDER_30MIN = MIN30_SEC / MIN30_BUF_SIZE; const int DIVIDER_6HOUR = HOUR6_SEC / HOUR6_BUF_SIZE; + const int DIVIDER_12HOUR = HOUR12_SEC / HOUR12_BUF_SIZE; + const int DIVIDER_24HOUR = HOUR24_SEC / HOUR24_BUF_SIZE; // table of supposed nice steps for grid marks to get nice looking quarters of scale @@ -120,9 +126,9 @@ SpeedPlotView::Averager::Averager(int divider, boost::circular_buffer void SpeedPlotView::Averager::push(const PointData &pointData) { // Accumulator overflow will be hit in worst case on longest used averaging span, - // defined by divider value. Maximum divider is DIVIDER_6HOUR = 72 - // Using int32 for accumulator we get overflow when transfer speed reaches 2^31/72 ~~ 28.4 MBytes/s. - // With quint64 this speed limit is 2^64/72 ~~ 228 PBytes/s. + // defined by divider value. Maximum divider is DIVIDER_24HOUR = 144 + // Using int32 for accumulator we get overflow when transfer speed reaches 2^31/144 ~~ 14.2 MBytes/s. + // With quint64 this speed limit is 2^64/144 ~~ 114 PBytes/s. // This speed is inaccessible to an ordinary user. m_accumulator.x += pointData.x; for (int id = UP; id < NB_GRAPHS; ++id) @@ -149,8 +155,13 @@ SpeedPlotView::SpeedPlotView(QWidget *parent) , m_data5Min(MIN5_BUF_SIZE) , m_data30Min(MIN30_BUF_SIZE) , m_data6Hour(HOUR6_BUF_SIZE) + , m_data12Hour(HOUR12_BUF_SIZE) + , m_data24Hour(HOUR24_BUF_SIZE) + , m_currentData(&m_data5Min) , m_averager30Min(DIVIDER_30MIN, m_data30Min) , m_averager6Hour(DIVIDER_6HOUR, m_data6Hour) + , m_averager12Hour(DIVIDER_12HOUR, m_data12Hour) + , m_averager24Hour(DIVIDER_24HOUR, m_data24Hour) , m_period(MIN5) , m_viewablePointsCount(MIN5_SEC) { @@ -196,24 +207,38 @@ void SpeedPlotView::pushPoint(const SpeedPlotView::PointData &point) m_data5Min.push_back(point); m_averager30Min.push(point); m_averager6Hour.push(point); + m_averager12Hour.push(point); + m_averager24Hour.push(point); } -void SpeedPlotView::setViewableLastPoints(TimePeriod period) +void SpeedPlotView::setPeriod(const TimePeriod period) { m_period = period; switch (period) { case SpeedPlotView::MIN1: m_viewablePointsCount = MIN1_SEC; + m_currentData = &m_data5Min; break; case SpeedPlotView::MIN5: m_viewablePointsCount = MIN5_SEC; + m_currentData = &m_data5Min; break; case SpeedPlotView::MIN30: m_viewablePointsCount = MIN30_BUF_SIZE; + m_currentData = &m_data30Min; break; case SpeedPlotView::HOUR6: m_viewablePointsCount = HOUR6_BUF_SIZE; + m_currentData = &m_data6Hour; + break; + case SpeedPlotView::HOUR12: + m_viewablePointsCount = HOUR12_BUF_SIZE; + m_currentData = &m_data12Hour; + break; + case SpeedPlotView::HOUR24: + m_viewablePointsCount = HOUR24_BUF_SIZE; + m_currentData = &m_data24Hour; break; } @@ -225,22 +250,15 @@ void SpeedPlotView::replot() if ((m_period == MIN1) || (m_period == MIN5) || ((m_period == MIN30) && m_averager30Min.isReady()) - || ((m_period == HOUR6) && m_averager6Hour.isReady()) ) + || ((m_period == HOUR6) && m_averager6Hour.isReady()) + || ((m_period == HOUR12) && m_averager12Hour.isReady()) + || ((m_period == HOUR24) && m_averager24Hour.isReady()) ) viewport()->update(); } boost::circular_buffer &SpeedPlotView::getCurrentData() { - switch (m_period) { - case SpeedPlotView::MIN1: - case SpeedPlotView::MIN5: - default: - return m_data5Min; - case SpeedPlotView::MIN30: - return m_data30Min; - case SpeedPlotView::HOUR6: - return m_data6Hour; - } + return *m_currentData; } quint64 SpeedPlotView::maxYValue() diff --git a/src/gui/properties/speedplotview.h b/src/gui/properties/speedplotview.h index 637282980..acdfbc72e 100644 --- a/src/gui/properties/speedplotview.h +++ b/src/gui/properties/speedplotview.h @@ -64,7 +64,9 @@ public: MIN1 = 0, MIN5, MIN30, - HOUR6 + HOUR6, + HOUR12, + HOUR24 }; struct PointData @@ -76,7 +78,7 @@ public: explicit SpeedPlotView(QWidget *parent = nullptr); void setGraphEnable(GraphID id, bool enable); - void setViewableLastPoints(TimePeriod period); + void setPeriod(TimePeriod period); void pushPoint(const PointData &point); @@ -116,8 +118,13 @@ private: boost::circular_buffer m_data5Min; boost::circular_buffer m_data30Min; boost::circular_buffer m_data6Hour; + boost::circular_buffer m_data12Hour; + boost::circular_buffer m_data24Hour; + boost::circular_buffer *m_currentData; Averager m_averager30Min; Averager m_averager6Hour; + Averager m_averager12Hour; + Averager m_averager24Hour; QMap m_properties; diff --git a/src/gui/properties/speedwidget.cpp b/src/gui/properties/speedwidget.cpp index 56012f7b6..0ab151413 100644 --- a/src/gui/properties/speedwidget.cpp +++ b/src/gui/properties/speedwidget.cpp @@ -71,6 +71,8 @@ SpeedWidget::SpeedWidget(PropertiesWidget *parent) m_periodCombobox->addItem(tr("5 Minutes")); m_periodCombobox->addItem(tr("30 Minutes")); m_periodCombobox->addItem(tr("6 Hours")); + m_periodCombobox->addItem(tr("12 Hours")); + m_periodCombobox->addItem(tr("24 Hours")); connect(m_periodCombobox, static_cast(&QComboBox::currentIndexChanged) , this, &SpeedWidget::onPeriodChange); @@ -148,7 +150,7 @@ void SpeedWidget::update() void SpeedWidget::onPeriodChange(int period) { - m_plot->setViewableLastPoints(static_cast(period)); + m_plot->setPeriod(static_cast(period)); } void SpeedWidget::onGraphChange(int id)