Add load % as an input for port rate
This commit is contained in:
parent
925edb8507
commit
dd7f4a6fd0
@ -317,6 +317,12 @@ void Port::setAverageBitRate(double bitsPerSec)
|
||||
emit portRateChanged(mPortGroupId, mPortId);
|
||||
}
|
||||
|
||||
void Port::setAverageLoadRate(double load)
|
||||
{
|
||||
Q_ASSERT(d.speed() > 0);
|
||||
setAverageBitRate(load*d.speed()*1e6);
|
||||
}
|
||||
|
||||
bool Port::newStreamAt(int index, OstProto::Stream const *stream)
|
||||
{
|
||||
Stream *s = new Stream;
|
||||
|
@ -102,6 +102,10 @@ public:
|
||||
{ return d.transmit_mode(); }
|
||||
bool trackStreamStats() const
|
||||
{ return d.is_tracking_stream_stats(); }
|
||||
double speed() const
|
||||
{ return d.speed(); }
|
||||
double averageLoadRate() const
|
||||
{ return d.speed() ? avgBitsPerSec_/(d.speed()*1e6) : 0; }
|
||||
double averagePacketRate() const
|
||||
{ return avgPacketsPerSec_; }
|
||||
double averageBitRate() const
|
||||
@ -183,6 +187,7 @@ public:
|
||||
|
||||
void setAveragePacketRate(double packetsPerSec);
|
||||
void setAverageBitRate(double bitsPerSec);
|
||||
void setAverageLoadRate(double loadPercent);
|
||||
// FIXME(MED): Bad Hack! port should not need an external trigger to
|
||||
// recalculate - refactor client side domain objects and model objects
|
||||
void recalculateAverageRates();
|
||||
|
@ -22,10 +22,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#include "portgrouplist.h"
|
||||
#include "xqlocale.h"
|
||||
|
||||
#include <cfloat>
|
||||
|
||||
PortWidget::PortWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
averageLoadPercent->setMaximum(DBL_MAX);
|
||||
}
|
||||
|
||||
void PortWidget::setPortGroupList(PortGroupList *portGroups)
|
||||
@ -71,6 +74,14 @@ void PortWidget::setCurrentPortIndex(const QModelIndex &portIndex)
|
||||
SIGNAL(portRateChanged(int, int)),
|
||||
this, SLOT(updatePortRates()));
|
||||
|
||||
double speed = plm->port(currentPortIndex_).speed();
|
||||
portSpeed->setText(QString("Max %L1 Mbps").arg(speed));
|
||||
|
||||
rbLoad->setVisible(speed > 0);
|
||||
averageLoadPercent->setVisible(speed > 0);
|
||||
speedSep->setVisible(speed > 0);
|
||||
portSpeed->setVisible(speed > 0);
|
||||
|
||||
updatePortRates();
|
||||
updatePortActions();
|
||||
}
|
||||
@ -99,6 +110,15 @@ void PortWidget::on_stopTx_clicked()
|
||||
plm->portGroup(curPortGroup).stopTx(&portList);
|
||||
}
|
||||
|
||||
void PortWidget::on_averageLoadPercent_editingFinished()
|
||||
{
|
||||
Q_ASSERT(plm->isPort(currentPortIndex_));
|
||||
|
||||
plm->port(currentPortIndex_).setAverageLoadRate(
|
||||
averageLoadPercent->value()/100);
|
||||
}
|
||||
|
||||
|
||||
void PortWidget::on_averagePacketsPerSec_editingFinished()
|
||||
{
|
||||
Q_ASSERT(plm->isPort(currentPortIndex_));
|
||||
@ -127,6 +147,8 @@ void PortWidget::updatePortRates()
|
||||
if (!plm->isPort(currentPortIndex_))
|
||||
return;
|
||||
|
||||
averageLoadPercent->setValue(
|
||||
plm->port(currentPortIndex_).averageLoadRate()*100);
|
||||
averagePacketsPerSec->setText(QString("%L1")
|
||||
.arg(plm->port(currentPortIndex_).averagePacketRate(), 0, 'f', 4));
|
||||
averageBitsPerSec->setText(QString("%L1")
|
||||
|
@ -43,6 +43,7 @@ private slots:
|
||||
|
||||
void on_startTx_clicked();
|
||||
void on_stopTx_clicked();
|
||||
void on_averageLoadPercent_editingFinished();
|
||||
void on_averagePacketsPerSec_editingFinished();
|
||||
void on_averageBitsPerSec_editingFinished();
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>532</width>
|
||||
<height>42</height>
|
||||
<width>806</width>
|
||||
<height>73</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -75,6 +75,13 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="rateSep">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton">
|
||||
<property name="text">
|
||||
@ -102,6 +109,46 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbLoad">
|
||||
<property name="text">
|
||||
<string>Load</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="averageLoadPercent">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string>%</string>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>4</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="speedSep">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="portSpeed">
|
||||
<property name="toolTip">
|
||||
<string>Port Speed</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Max speed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@ -117,12 +164,12 @@
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>326</x>
|
||||
<y>80</y>
|
||||
<x>450</x>
|
||||
<y>44</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>454</x>
|
||||
<y>79</y>
|
||||
<x>593</x>
|
||||
<y>45</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
@ -133,12 +180,28 @@
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>523</x>
|
||||
<y>80</y>
|
||||
<x>661</x>
|
||||
<y>44</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>651</x>
|
||||
<y>88</y>
|
||||
<x>804</x>
|
||||
<y>45</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>rbLoad</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>averageLoadPercent</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>281</x>
|
||||
<y>43</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>308</x>
|
||||
<y>45</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
@ -263,7 +263,7 @@ void WinPcapPort::populateInterfaceInfo()
|
||||
interfaceInfo_ = new InterfaceInfo;
|
||||
|
||||
interfaceInfo_->speed = adapter->TransmitLinkSpeed != quint64(-1) ?
|
||||
adapter->TransmitLinkSpeed/ulong(1e6) : 0;
|
||||
adapter->TransmitLinkSpeed/1e6 : 0;
|
||||
interfaceInfo_->mtu = adapter->Mtu;
|
||||
|
||||
if (adapter->PhysicalAddressLength == 6) {
|
||||
|
Loading…
Reference in New Issue
Block a user