From bf161811b4440e8d88fe4dfc4d132671a5e4f1e0 Mon Sep 17 00:00:00 2001 From: Srivats P Date: Mon, 21 Nov 2016 18:39:55 +0530 Subject: [PATCH] sign: Add Stream Stats button to GUI port config --- client/port.h | 2 ++ client/portconfigdialog.cpp | 8 ++++++++ client/portconfigdialog.ui | 7 +++++++ client/portswindow.cpp | 1 + server/abstractport.cpp | 14 ++++++++++++++ server/abstractport.h | 2 ++ 6 files changed, 34 insertions(+) diff --git a/client/port.h b/client/port.h index 281a61a..4c8f292 100644 --- a/client/port.h +++ b/client/port.h @@ -98,6 +98,8 @@ public: { return d.is_exclusive_control(); } OstProto::TransmitMode transmitMode() { return d.transmit_mode(); } + bool trackStreamStats() + { return d.track_stream_stats(); } double averagePacketRate() { return avgPacketsPerSec_; } double averageBitRate() diff --git a/client/portconfigdialog.cpp b/client/portconfigdialog.cpp index 96028fd..466a46d 100644 --- a/client/portconfigdialog.cpp +++ b/client/portconfigdialog.cpp @@ -67,10 +67,12 @@ PortConfigDialog::PortConfigDialog( qDebug("reservedBy_ = %d", reservedBy_); exclusiveControlButton->setChecked(portConfig_.is_exclusive_control()); + streamStatsButton->setChecked(portConfig_.track_stream_stats()); // Disable UI elements based on portState if (portState.is_transmit_on()) { transmitModeBox->setDisabled(true); + streamStatsButton->setDisabled(true); } } @@ -103,6 +105,7 @@ void PortConfigDialog::accept() } pc.set_is_exclusive_control(exclusiveControlButton->isChecked()); + pc.set_track_stream_stats(streamStatsButton->isChecked()); // Update fields that have changed, clear the rest if (pc.transmit_mode() != portConfig_.transmit_mode()) @@ -120,5 +123,10 @@ void PortConfigDialog::accept() else portConfig_.clear_is_exclusive_control(); + if (pc.track_stream_stats() != portConfig_.track_stream_stats()) + portConfig_.set_track_stream_stats(pc.track_stream_stats()); + else + portConfig_.clear_track_stream_stats(); + QDialog::accept(); } diff --git a/client/portconfigdialog.ui b/client/portconfigdialog.ui index 14ded8f..95b5a8d 100644 --- a/client/portconfigdialog.ui +++ b/client/portconfigdialog.ui @@ -69,6 +69,13 @@ + + + + Stream Statistics + + + diff --git a/client/portswindow.cpp b/client/portswindow.cpp index c1bb4b7..0cef08e 100644 --- a/client/portswindow.cpp +++ b/client/portswindow.cpp @@ -726,6 +726,7 @@ void PortsWindow::on_actionPort_Configuration_triggered() // which says copy only modifiable fields //plm->port(current).protoDataCopyInto(&config); config.set_transmit_mode(port.transmitMode()); + config.set_track_stream_stats(port.trackStreamStats()); config.set_is_exclusive_control(port.hasExclusiveControl()); config.set_user_name(port.userName().toStdString()); diff --git a/server/abstractport.cpp b/server/abstractport.cpp index 977908a..d9d28c7 100644 --- a/server/abstractport.cpp +++ b/server/abstractport.cpp @@ -78,6 +78,12 @@ bool AbstractPort::canModify(const OstProto::Port &port, bool *dirty) allow = !isTransmitOn(); } + if (port.has_track_stream_stats() + && (port.track_stream_stats() != data_.track_stream_stats())) { + *dirty = true; + allow = !isTransmitOn(); + } + return allow; } @@ -98,6 +104,9 @@ bool AbstractPort::modify(const OstProto::Port &port) if (port.has_transmit_mode()) data_.set_transmit_mode(port.transmit_mode()); + if (port.has_track_stream_stats()) + setTrackStreamStats(port.track_stream_stats()); + if (port.has_user_name()) { data_.set_user_name(port.user_name()); } @@ -181,6 +190,11 @@ void AbstractPort::addNote(QString note) data_.set_notes(notes.toStdString()); } +bool AbstractPort::setTrackStreamStats(bool enable) +{ + data_.set_track_stream_stats(enable); +} + AbstractPort::Accuracy AbstractPort::rateAccuracy() { return rateAccuracy_; diff --git a/server/abstractport.h b/server/abstractport.h index 0324948..da346de 100644 --- a/server/abstractport.h +++ b/server/abstractport.h @@ -90,6 +90,8 @@ public: bool isDirty() { return isSendQueueDirty_; } void setDirty() { isSendQueueDirty_ = true; } + virtual bool setTrackStreamStats(bool enable); + Accuracy rateAccuracy(); virtual bool setRateAccuracy(Accuracy accuracy);