sign: GUI code for fetch/display of stream stats

This commit is contained in:
Srivats P 2016-11-24 21:44:38 +05:30
parent bf161811b4
commit fda7807797
14 changed files with 291 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 795 B

View File

@ -76,7 +76,7 @@ MainWindow::MainWindow(QWidget *parent)
portsDock->setObjectName("portsDock");
portsDock->setFeatures(
portsDock->features() & ~QDockWidget::DockWidgetClosable);
statsDock = new QDockWidget(tr("Statistics"), this);
statsDock = new QDockWidget(tr("Port Statistics"), this);
statsDock->setObjectName("statsDock");
statsDock->setFeatures(
statsDock->features() & ~QDockWidget::DockWidgetClosable);
@ -133,6 +133,12 @@ MainWindow::~MainWindow()
delete pgl;
// We don't want to save state for Stream Stats Docks - so close them
QList<QDockWidget*> streamStatsDocks
= findChildren<QDockWidget*>("streamStatsDock");
foreach(QDockWidget *dock, streamStatsDocks)
dock->close(); // this dock is already set to delete on close
QByteArray layout = saveState(0);
appSettings->setValue(kApplicationWindowLayout, layout);
appSettings->setValue(kApplicationWindowGeometryKey, geometry());

View File

@ -58,6 +58,8 @@ HEADERS += \
streamconfigdialog.h \
streamlistdelegate.h \
streammodel.h \
streamstatsmodel.h \
streamstatswindow.h \
variablefieldswidget.h
FORMS += \
@ -71,6 +73,7 @@ FORMS += \
portswindow.ui \
preferences.ui \
streamconfigdialog.ui \
streamstatswindow.ui \
variablefieldswidget.ui
SOURCES += \
@ -99,6 +102,8 @@ SOURCES += \
streamconfigdialog.cpp \
streamlistdelegate.cpp \
streammodel.cpp \
streamstatsmodel.cpp \
streamstatswindow.cpp \
variablefieldswidget.cpp

View File

@ -41,5 +41,6 @@
<file>icons/stream_delete.png</file>
<file>icons/stream_duplicate.png</file>
<file>icons/stream_edit.png</file>
<file>icons/stream_stats.png</file>
</qresource>
</RCC>

View File

@ -1594,3 +1594,46 @@ void PortGroup::processClearStatsAck(PbRpcController *controller)
delete controller;
}
bool PortGroup::getStreamStats(QList<uint> *portList)
{
qDebug("In %s", __FUNCTION__);
if (state() != QAbstractSocket::ConnectedState)
return false;
OstProto::StreamGuidList *guidList = new OstProto::StreamGuidList;
OstProto::StreamStatsList *statsList = new OstProto::StreamStatsList;
PbRpcController *controller = new PbRpcController(guidList, statsList);
if (portList == NULL)
guidList->mutable_port_id_list()->CopyFrom(*portIdList_);
else
for (int i = 0; i < portList->size(); i++)
guidList->mutable_port_id_list()->add_port_id()
->set_id(portList->at(i));
serviceStub->getStreamStats(controller, guidList, statsList,
NewCallback(this, &PortGroup::processStreamStatsList, controller));
return true;
}
void PortGroup::processStreamStatsList(PbRpcController *controller)
{
using OstProto::StreamStatsList;
qDebug("In %s", __FUNCTION__);
StreamStatsList *streamStatsList =
static_cast<StreamStatsList*>(controller->response());
// XXX: It is required to emit the signal even if the returned
// streamStatsList contains no records since the recipient
// StreamStatsModel slot needs to disconnect this signal-slot
// connection to prevent future stream stats for this portgroup
// to be sent to it
emit streamStatsReceived(mPortGroupId, streamStatsList);
delete controller;
}

View File

@ -39,6 +39,7 @@ LOW
namespace OstProto {
class PortContent;
class PortGroupContent;
class StreamStatsList;
}
class QFile;
@ -164,12 +165,16 @@ public:
void processPortStatsList();
void clearPortStats(QList<uint> *portList = NULL);
void processClearStatsAck(PbRpcController *controller);
bool getStreamStats(QList<uint> *portList = NULL);
void processStreamStatsList(PbRpcController *controller);
signals:
void portGroupDataChanged(int portGroupId, int portId = 0xFFFF);
void portListAboutToBeChanged(quint32 portGroupId);
void portListChanged(quint32 portGroupId);
void statsChanged(quint32 portGroupId);
void streamStatsReceived(quint32 portGroupId,
const OstProto::StreamStatsList *stats);
private slots:
void on_reconnectTimer_timeout();

View File

@ -23,9 +23,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "portstatsfilterdialog.h"
#include "portstatsmodel.h"
#include "portstatsproxymodel.h"
#include "streamstatsmodel.h"
#include "streamstatswindow.h"
#include "settings.h"
#include <QDockWidget>
#include <QHeaderView>
#include <QMainWindow>
extern QMainWindow *mainWindow;
PortStatsWindow::PortStatsWindow(PortGroupList *pgl, QWidget *parent)
: QWidget(parent), proxyStatsModel(NULL)
@ -219,6 +225,38 @@ void PortStatsWindow::on_tbClearAll_clicked()
}
}
void PortStatsWindow::on_tbGetStreamStats_clicked()
{
QList<PortStatsModel::PortGroupAndPortList> portList;
StreamStatsModel *streamStatsModel;
// Get selected ports
model->portListFromIndex(selectedColumns(), portList);
if (portList.size()) {
QDockWidget *dock = new QDockWidget(tr("Stream Statistics"),
mainWindow);
streamStatsModel = new StreamStatsModel(dock);
dock->setWidget(new StreamStatsWindow(streamStatsModel, dock));
dock->setObjectName("streamStatsDock");
dock->setFloating(true);
dock->setAttribute(Qt::WA_DeleteOnClose);
mainWindow->addDockWidget(Qt::BottomDockWidgetArea, dock);
}
// Get stream stats for selected ports, portgroup by portgroup
for (int i = 0; i < portList.size(); i++)
{
PortGroup &pg = pgl->portGroupByIndex(portList.at(i).portGroupId);
if (pg.getStreamStats(&portList[i].portList)) {
connect(&pg,SIGNAL(streamStatsReceived(
quint32, const OstProto::StreamStatsList*)),
streamStatsModel, SLOT(appendStreamStatsList(
quint32, const OstProto::StreamStatsList*)));
}
}
}
void PortStatsWindow::on_tbFilter_clicked()
{
bool ok;

View File

@ -49,6 +49,7 @@ private slots:
void on_tbClear_clicked();
void on_tbClearAll_clicked();
void on_tbGetStreamStats_clicked();
void on_tbResolveNeighbors_clicked();
void on_tbClearNeighbors_clicked();

View File

@ -86,6 +86,22 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tbGetStreamStats" >
<property name="toolTip" >
<string>Fetch Selected Port Stream Stats</string>
</property>
<property name="statusTip" >
<string>Fetches stream statistics from the selected port(s)</string>
</property>
<property name="text" >
<string>Fetch Stream Stats</string>
</property>
<property name="icon" >
<iconset resource="ostinato.qrc" >:/icons/stream_stats.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tbStartCapture" >
<property name="toolTip" >

View File

@ -0,0 +1,44 @@
/*
Copyright (C) 2016 Srivats P.
This file is part of "Ostinato"
This is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#include "streamstatsmodel.h"
#include "protocol.pb.h"
StreamStatsModel::StreamStatsModel(QObject *parent)
: QStringListModel(parent)
{
}
void StreamStatsModel::clearStats()
{
stats_.clear();
setStringList(stats_);
}
void StreamStatsModel::appendStreamStatsList(
quint32 /*portGroupId*/,
const OstProto::StreamStatsList *stats)
{
stats_.append(stats->DebugString().c_str());
setStringList(stats_);
// Prevent receiving any future updates from this sender
disconnect(sender(), 0, this, 0);
}

43
client/streamstatsmodel.h Normal file
View File

@ -0,0 +1,43 @@
/*
Copyright (C) 2016 Srivats P.
This file is part of "Ostinato"
This is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef _STREAM_STATS_MODEL_H
#define _STREAM_STATS_MODEL_H
#include <QStringListModel> // FIXME: remove
namespace OstProto {
class StreamStatsList;
}
class StreamStatsModel: public QStringListModel // FIXME: change to TableModel
{
Q_OBJECT
public:
StreamStatsModel(QObject *parent = 0);
public slots:
void clearStats();
void appendStreamStatsList(quint32 portGroupId,
const OstProto::StreamStatsList *stats);
private:
QList<QString> stats_; // FIXME: remove
};
#endif

View File

@ -0,0 +1,30 @@
/*
Copyright (C) 2016 Srivats P.
This file is part of "Ostinato"
This is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#include "streamstatswindow.h"
#include <QAbstractItemModel>
StreamStatsWindow::StreamStatsWindow(QAbstractItemModel *model, QWidget *parent)
: QWidget(parent)
{
setupUi(this);
streamStats->setModel(model);
}

View File

@ -0,0 +1,35 @@
/*
Copyright (C) 2016 Srivats P.
This file is part of "Ostinato"
This is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef _STREAM_STATS_WINDOW_H
#define _STREAM_STATS_WINDOW_H
#include "ui_streamstatswindow.h"
class QAbstractItemModel;
class StreamStatsWindow: public QWidget, private Ui::StreamStatsWindow
{
Q_OBJECT
public:
StreamStatsWindow(QAbstractItemModel *model, QWidget *parent = 0);
};
#endif

View File

@ -0,0 +1,23 @@
<ui version="4.0" >
<class>StreamStatsWindow</class>
<widget class="QWidget" name="streamStatsWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>551</width>
<height>452</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QHBoxLayout" >
<item>
<widget class="QListView" name="streamStats" />
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>