sign: GUI code for fetch/display of stream stats
This commit is contained in:
parent
bf161811b4
commit
fda7807797
BIN
client/icons/stream_stats.png
Normal file
BIN
client/icons/stream_stats.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 795 B |
@ -76,7 +76,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
portsDock->setObjectName("portsDock");
|
portsDock->setObjectName("portsDock");
|
||||||
portsDock->setFeatures(
|
portsDock->setFeatures(
|
||||||
portsDock->features() & ~QDockWidget::DockWidgetClosable);
|
portsDock->features() & ~QDockWidget::DockWidgetClosable);
|
||||||
statsDock = new QDockWidget(tr("Statistics"), this);
|
statsDock = new QDockWidget(tr("Port Statistics"), this);
|
||||||
statsDock->setObjectName("statsDock");
|
statsDock->setObjectName("statsDock");
|
||||||
statsDock->setFeatures(
|
statsDock->setFeatures(
|
||||||
statsDock->features() & ~QDockWidget::DockWidgetClosable);
|
statsDock->features() & ~QDockWidget::DockWidgetClosable);
|
||||||
@ -133,6 +133,12 @@ MainWindow::~MainWindow()
|
|||||||
|
|
||||||
delete pgl;
|
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);
|
QByteArray layout = saveState(0);
|
||||||
appSettings->setValue(kApplicationWindowLayout, layout);
|
appSettings->setValue(kApplicationWindowLayout, layout);
|
||||||
appSettings->setValue(kApplicationWindowGeometryKey, geometry());
|
appSettings->setValue(kApplicationWindowGeometryKey, geometry());
|
||||||
|
@ -58,6 +58,8 @@ HEADERS += \
|
|||||||
streamconfigdialog.h \
|
streamconfigdialog.h \
|
||||||
streamlistdelegate.h \
|
streamlistdelegate.h \
|
||||||
streammodel.h \
|
streammodel.h \
|
||||||
|
streamstatsmodel.h \
|
||||||
|
streamstatswindow.h \
|
||||||
variablefieldswidget.h
|
variablefieldswidget.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
@ -71,6 +73,7 @@ FORMS += \
|
|||||||
portswindow.ui \
|
portswindow.ui \
|
||||||
preferences.ui \
|
preferences.ui \
|
||||||
streamconfigdialog.ui \
|
streamconfigdialog.ui \
|
||||||
|
streamstatswindow.ui \
|
||||||
variablefieldswidget.ui
|
variablefieldswidget.ui
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
@ -99,6 +102,8 @@ SOURCES += \
|
|||||||
streamconfigdialog.cpp \
|
streamconfigdialog.cpp \
|
||||||
streamlistdelegate.cpp \
|
streamlistdelegate.cpp \
|
||||||
streammodel.cpp \
|
streammodel.cpp \
|
||||||
|
streamstatsmodel.cpp \
|
||||||
|
streamstatswindow.cpp \
|
||||||
variablefieldswidget.cpp
|
variablefieldswidget.cpp
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,5 +41,6 @@
|
|||||||
<file>icons/stream_delete.png</file>
|
<file>icons/stream_delete.png</file>
|
||||||
<file>icons/stream_duplicate.png</file>
|
<file>icons/stream_duplicate.png</file>
|
||||||
<file>icons/stream_edit.png</file>
|
<file>icons/stream_edit.png</file>
|
||||||
|
<file>icons/stream_stats.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -1594,3 +1594,46 @@ void PortGroup::processClearStatsAck(PbRpcController *controller)
|
|||||||
delete 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ LOW
|
|||||||
namespace OstProto {
|
namespace OstProto {
|
||||||
class PortContent;
|
class PortContent;
|
||||||
class PortGroupContent;
|
class PortGroupContent;
|
||||||
|
class StreamStatsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
class QFile;
|
class QFile;
|
||||||
@ -164,12 +165,16 @@ public:
|
|||||||
void processPortStatsList();
|
void processPortStatsList();
|
||||||
void clearPortStats(QList<uint> *portList = NULL);
|
void clearPortStats(QList<uint> *portList = NULL);
|
||||||
void processClearStatsAck(PbRpcController *controller);
|
void processClearStatsAck(PbRpcController *controller);
|
||||||
|
bool getStreamStats(QList<uint> *portList = NULL);
|
||||||
|
void processStreamStatsList(PbRpcController *controller);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void portGroupDataChanged(int portGroupId, int portId = 0xFFFF);
|
void portGroupDataChanged(int portGroupId, int portId = 0xFFFF);
|
||||||
void portListAboutToBeChanged(quint32 portGroupId);
|
void portListAboutToBeChanged(quint32 portGroupId);
|
||||||
void portListChanged(quint32 portGroupId);
|
void portListChanged(quint32 portGroupId);
|
||||||
void statsChanged(quint32 portGroupId);
|
void statsChanged(quint32 portGroupId);
|
||||||
|
void streamStatsReceived(quint32 portGroupId,
|
||||||
|
const OstProto::StreamStatsList *stats);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_reconnectTimer_timeout();
|
void on_reconnectTimer_timeout();
|
||||||
|
@ -23,9 +23,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "portstatsfilterdialog.h"
|
#include "portstatsfilterdialog.h"
|
||||||
#include "portstatsmodel.h"
|
#include "portstatsmodel.h"
|
||||||
#include "portstatsproxymodel.h"
|
#include "portstatsproxymodel.h"
|
||||||
|
#include "streamstatsmodel.h"
|
||||||
|
#include "streamstatswindow.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
#include <QDockWidget>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
|
extern QMainWindow *mainWindow;
|
||||||
|
|
||||||
PortStatsWindow::PortStatsWindow(PortGroupList *pgl, QWidget *parent)
|
PortStatsWindow::PortStatsWindow(PortGroupList *pgl, QWidget *parent)
|
||||||
: QWidget(parent), proxyStatsModel(NULL)
|
: 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()
|
void PortStatsWindow::on_tbFilter_clicked()
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
|
@ -49,6 +49,7 @@ private slots:
|
|||||||
|
|
||||||
void on_tbClear_clicked();
|
void on_tbClear_clicked();
|
||||||
void on_tbClearAll_clicked();
|
void on_tbClearAll_clicked();
|
||||||
|
void on_tbGetStreamStats_clicked();
|
||||||
|
|
||||||
void on_tbResolveNeighbors_clicked();
|
void on_tbResolveNeighbors_clicked();
|
||||||
void on_tbClearNeighbors_clicked();
|
void on_tbClearNeighbors_clicked();
|
||||||
|
@ -86,6 +86,22 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<widget class="QToolButton" name="tbStartCapture" >
|
<widget class="QToolButton" name="tbStartCapture" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
|
44
client/streamstatsmodel.cpp
Normal file
44
client/streamstatsmodel.cpp
Normal 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
43
client/streamstatsmodel.h
Normal 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
|
||||||
|
|
30
client/streamstatswindow.cpp
Normal file
30
client/streamstatswindow.cpp
Normal 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);
|
||||||
|
}
|
35
client/streamstatswindow.h
Normal file
35
client/streamstatswindow.h
Normal 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
|
||||||
|
|
23
client/streamstatswindow.ui
Normal file
23
client/streamstatswindow.ui
Normal 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>
|
Loading…
Reference in New Issue
Block a user