Browse Source

Add 12 hour and 24 hour speed graphs

adaptive-webui-19844
dzmat 6 years ago
parent
commit
0af17bf7e9
  1. 50
      src/gui/properties/speedplotview.cpp
  2. 11
      src/gui/properties/speedplotview.h
  3. 4
      src/gui/properties/speedwidget.cpp

50
src/gui/properties/speedplotview.cpp

@ -42,14 +42,20 @@ namespace @@ -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<PointData> @@ -120,9 +126,9 @@ SpeedPlotView::Averager::Averager(int divider, boost::circular_buffer<PointData>
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) @@ -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) @@ -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() @@ -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::PointData> &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()

11
src/gui/properties/speedplotview.h

@ -64,7 +64,9 @@ public: @@ -64,7 +64,9 @@ public:
MIN1 = 0,
MIN5,
MIN30,
HOUR6
HOUR6,
HOUR12,
HOUR24
};
struct PointData
@ -76,7 +78,7 @@ public: @@ -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: @@ -116,8 +118,13 @@ private:
boost::circular_buffer<PointData> m_data5Min;
boost::circular_buffer<PointData> m_data30Min;
boost::circular_buffer<PointData> m_data6Hour;
boost::circular_buffer<PointData> m_data12Hour;
boost::circular_buffer<PointData> m_data24Hour;
boost::circular_buffer<PointData> *m_currentData;
Averager m_averager30Min;
Averager m_averager6Hour;
Averager m_averager12Hour;
Averager m_averager24Hour;
QMap<GraphID, GraphProperties> m_properties;

4
src/gui/properties/speedwidget.cpp

@ -71,6 +71,8 @@ SpeedWidget::SpeedWidget(PropertiesWidget *parent) @@ -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<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged)
, this, &SpeedWidget::onPeriodChange);
@ -148,7 +150,7 @@ void SpeedWidget::update() @@ -148,7 +150,7 @@ void SpeedWidget::update()
void SpeedWidget::onPeriodChange(int period)
{
m_plot->setViewableLastPoints(static_cast<SpeedPlotView::TimePeriod>(period));
m_plot->setPeriod(static_cast<SpeedPlotView::TimePeriod>(period));
}
void SpeedWidget::onGraphChange(int id)

Loading…
Cancel
Save