Changeset 80406 in vbox
- Timestamp:
- Aug 23, 2019 9:06:48 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 132877
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/information
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.cpp
r80384 r80406 23 23 #include <QGridLayout> 24 24 #include <QStyle> 25 #include <QXmlStreamReader> 25 26 #include <QTableWidget> 26 27 #include <QTimer> … … 38 39 #include "CVRDEServerInfo.h" 39 40 40 #define DATA_SERIES_SIZE 2 41 41 42 const ULONG iPeriod = 1; 42 43 const int iMaximumQueueSize = 120; … … 60 61 }; 61 62 63 64 62 65 /********************************************************************************************************************************* 63 66 * UIRuntimeInfoWidget definition. * … … 78 81 private: 79 82 80 UITextTablerunTimeAttributes();83 void runTimeAttributes(); 81 84 void insertInfoLine(InfoLine enmInfoLine, const QString& strLabel, const QString &strInfo); 82 85 … … 142 145 virtual void computeFontSize(); 143 146 void drawXAxisLabels(QPainter &painter, int iXSubAxisCount); 144 void drawPieCharts(QPainter &painter, ULONGiMaximum);147 void drawPieCharts(QPainter &painter, qulonglong iMaximum); 145 148 void insertInfoLine(InfoLine enmInfoLine, const QString& strLabel, const QString &strInfo); 146 149 … … 224 227 } 225 228 226 UITextTable UIRuntimeInfoWidget::runTimeAttributes() 227 { 228 UITextTable textTable; 229 229 void UIRuntimeInfoWidget::runTimeAttributes() 230 { 230 231 ULONG cGuestScreens = m_machine.GetMonitorCount(); 231 232 QVector<QString> aResolutions(cGuestScreens); … … 362 363 resizeColumnToContents(0); 363 364 resizeColumnToContents(1); 364 365 return textTable;366 365 } 367 366 … … 547 546 return; 548 547 549 ULONGiMaximum = m_pSubMetric->maximum();548 qulonglong iMaximum = m_pSubMetric->maximum(); 550 549 if (iMaximum == 0) 551 550 return; … … 563 562 } 564 563 565 const QQueue< ULONG> *data = m_pSubMetric->data(k);564 const QQueue<qulonglong> *data = m_pSubMetric->data(k); 566 565 if (!m_fUseGradientLineColor) 567 566 painter.setPen(QPen(m_dataSeriesColor[k], 2.5)); … … 584 583 int iTextY = 0.5 * iFontHeight + m_iMarginTop + i * iChartHeight / (float) (iYSubAxisCount + 1); 585 584 QString strValue; 586 ULONGiValue = (iYSubAxisCount + 1 - i) * (iMaximum / (float) (iYSubAxisCount + 1));585 qulonglong iValue = (iYSubAxisCount + 1 - i) * (iMaximum / (float) (iYSubAxisCount + 1)); 587 586 if (m_pSubMetric->unit().compare("%", Qt::CaseInsensitive) == 0) 588 587 strValue = QString::number(iValue); … … 620 619 } 621 620 622 void UIChart::drawPieCharts(QPainter &painter, ULONGiMaximum)621 void UIChart::drawPieCharts(QPainter &painter, qulonglong iMaximum) 623 622 { 624 623 for (int i = 0; i < DATA_SERIES_SIZE; ++i) 625 624 { 626 625 /* Draw the pie chart for the 0th data series only: */ 627 const QQueue< ULONG> *data = m_pSubMetric->data(i);626 const QQueue<qulonglong> *data = m_pSubMetric->data(i); 628 627 if (!data || data->isEmpty()) 629 628 continue; … … 673 672 , m_fRequiresGuestAdditions(false) 674 673 { 674 m_iTotal[0] = 0; 675 m_iTotal[1] = 0; 675 676 } 676 677 … … 685 686 } 686 687 687 void UISubMetric::setMaximum( ULONGiMaximum)688 void UISubMetric::setMaximum(qulonglong iMaximum) 688 689 { 689 690 m_iMaximum = iMaximum; 690 691 } 691 692 692 ULONGUISubMetric::maximum() const693 qulonglong UISubMetric::maximum() const 693 694 { 694 695 return m_iMaximum; … … 705 706 } 706 707 707 void UISubMetric::addData(int iDataSeriesIndex, ULONGfData)708 void UISubMetric::addData(int iDataSeriesIndex, qulonglong fData) 708 709 { 709 710 if (iDataSeriesIndex >= DATA_SERIES_SIZE) … … 714 715 } 715 716 716 const QQueue< ULONG> *UISubMetric::data(int iDataSeriesIndex) const717 const QQueue<qulonglong> *UISubMetric::data(int iDataSeriesIndex) const 717 718 { 718 719 if (iDataSeriesIndex >= DATA_SERIES_SIZE) … … 721 722 } 722 723 724 void UISubMetric::setTotal(int iDataSeriesIndex, qulonglong iTotal) 725 { 726 if (iDataSeriesIndex >= DATA_SERIES_SIZE) 727 return; 728 m_iTotal[iDataSeriesIndex] = iTotal; 729 } 730 731 qulonglong UISubMetric::total(int iDataSeriesIndex) const 732 { 733 if (iDataSeriesIndex >= DATA_SERIES_SIZE) 734 return 0; 735 return m_iTotal[iDataSeriesIndex]; 736 } 737 723 738 bool UISubMetric::requiresGuestAdditions() const 724 739 { … … 730 745 m_fRequiresGuestAdditions = fRequiresGAs; 731 746 } 747 748 const QStringList &UISubMetric::deviceTypeList() const 749 { 750 return m_deviceTypeList; 751 } 752 753 void UISubMetric::setDeviceTypeList(const QStringList &list) 754 { 755 m_deviceTypeList = list; 756 composeQueryString(); 757 } 758 759 const QStringList &UISubMetric::metricDataSubString() const 760 { 761 return m_metricDataSubString; 762 } 763 764 void UISubMetric::setMetricDataSubString(const QStringList &list) 765 { 766 m_metricDataSubString = list; 767 composeQueryString(); 768 } 769 770 const QString &UISubMetric::queryString() const 771 { 772 return m_strQueryString; 773 } 774 775 void UISubMetric::composeQueryString() 776 { 777 /* Compose of if both m_metricDataSubString and m_deviceTypeList are not empty: */ 778 if (m_deviceTypeList.isEmpty() || m_metricDataSubString.isEmpty()) 779 return; 780 m_strQueryString.clear(); 781 foreach (const QString &strDeviceName, m_deviceTypeList) 782 { 783 foreach (const QString &strSubString, m_metricDataSubString) 784 { 785 m_strQueryString += QString("*Devices*%1*%2*|").arg(strDeviceName).arg(strSubString); 786 } 787 } 788 } 789 732 790 733 791 /********************************************************************************************************************************* … … 747 805 , m_strDiskMetricName("Disk Usage") 748 806 , m_strNetMetricName("Net") 807 , m_strNetDebuggerMetricName("NetDebugger") 808 749 809 { 750 810 if (!m_console.isNull()) … … 753 813 754 814 connect(pSession, &UISession::sigAdditionsStateChange, this, &UIInformationRuntime::sltGuestAdditionsStateChange); 755 prepare PerformaceCollector();815 prepareMetrics(); 756 816 prepareObjects(); 757 817 enableDisableGuestAdditionDependedWidgets(m_fGuestAdditionsAvailable); … … 786 846 m_strNetInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "Network"); 787 847 iMaximum = qMax(iMaximum, m_strNetInfoLabelTitle.length()); 788 m_strNetInfoLabelReceived = QApplication::translate("UIVMInformationDialog", "Receive d");848 m_strNetInfoLabelReceived = QApplication::translate("UIVMInformationDialog", "Receive Rate"); 789 849 iMaximum = qMax(iMaximum, m_strNetInfoLabelReceived.length()); 790 m_strNetInfoLabelTransmitted = QApplication::translate("UIVMInformationDialog", "Transmit ted");850 m_strNetInfoLabelTransmitted = QApplication::translate("UIVMInformationDialog", "Transmit Rate"); 791 851 iMaximum = qMax(iMaximum, m_strNetInfoLabelTransmitted.length()); 792 852 m_strNetInfoLabelMaximum = QApplication::translate("UIVMInformationDialog", "Maximum"); … … 830 890 831 891 QStringList chartOder; 832 chartOder << m_strCPUMetricName << m_strRAMMetricName << m_strDiskMetricName << m_strNetMetricName ;892 chartOder << m_strCPUMetricName << m_strRAMMetricName << m_strDiskMetricName << m_strNetMetricName << m_strNetDebuggerMetricName; 833 893 int iRow = 0; 834 894 foreach (const QString &strMetricName, chartOder) … … 854 914 m_charts[m_strNetMetricName]->setUseGradientLineColor(false); 855 915 } 916 if (m_charts.contains(m_strNetDebuggerMetricName) && m_charts[m_strNetDebuggerMetricName]) 917 { 918 m_charts[m_strNetDebuggerMetricName]->setDrawPieChart(false); 919 m_charts[m_strNetDebuggerMetricName]->setUseGradientLineColor(false); 920 } 921 856 922 if (m_charts.contains(m_strCPUMetricName) && m_charts[m_strCPUMetricName]) 857 923 m_charts[m_strCPUMetricName]->setUseGradientLineColor(false); … … 862 928 bottomSpacerWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); 863 929 bottomSpacerWidget->setVisible(true); 864 QPalette pal = bottomSpacerWidget->palette();865 pal.setColor(QPalette::Background, Qt::green);866 bottomSpacerWidget->setAutoFillBackground(true);867 bottomSpacerWidget->setPalette(pal);930 // QPalette pal = bottomSpacerWidget->palette(); 931 // pal.setColor(QPalette::Background, Qt::green); 932 // bottomSpacerWidget->setAutoFillBackground(true); 933 // bottomSpacerWidget->setPalette(pal); 868 934 869 935 m_pMainLayout->addWidget(bottomSpacerWidget, iRow, 1, 1, 2); … … 921 987 } 922 988 } 923 924 (void)iReceiveRate; 925 (void)iTransmitRate; 989 if (m_subMetrics.contains(m_strRAMMetricName)) 990 updateRAMGraphsAndMetric(iTotalRAM, iFreeRAM); 991 if (m_subMetrics.contains(m_strNetMetricName)) 992 updateNetworkGraphsAndMetric(iReceiveRate, iTransmitRate); 993 926 994 /* Update the CPU load chart with values we get from IMachineDebugger::getCPULoad(..): */ 927 995 if (m_subMetrics.contains(m_strCPUMetricName)) … … 934 1002 } 935 1003 936 if (m_subMetrics.contains(m_strRAMMetricName)) 937 updateRAMGraphsAndMetric(iTotalRAM, iFreeRAM); 938 if (m_subMetrics.contains(m_strNetMetricName)) 939 updateNewGraphsAndMetric(iReceiveRate, iTransmitRate); 940 1004 /* Collect the data from IMachineDebugger::getStats(..): */ 1005 qulonglong uNetworkTotalReceive = 0; 1006 qulonglong uNetworkTotalTransmit = 0; 1007 QVector<DebuggerMetricData> xmlData = getTotalCounterFromDegugger(m_strQueryString); 1008 for (QMap<QString, UISubMetric>::iterator iterator = m_subMetrics.begin(); 1009 iterator != m_subMetrics.end(); ++iterator) 1010 { 1011 UISubMetric &metric = iterator.value(); 1012 const QStringList &deviceTypeList = metric.deviceTypeList(); 1013 foreach (const QString &strDeviceType, deviceTypeList) 1014 { 1015 foreach (const DebuggerMetricData &data, xmlData) 1016 { 1017 if (data.m_strName.contains(strDeviceType, Qt::CaseInsensitive)) 1018 { 1019 if (metric.name() == m_strNetDebuggerMetricName) 1020 { 1021 if (data.m_strName.contains("receive", Qt::CaseInsensitive)) 1022 uNetworkTotalReceive += data.m_counter; 1023 else if (data.m_strName.contains("transmit", Qt::CaseInsensitive)) 1024 uNetworkTotalTransmit += data.m_counter; 1025 } 1026 1027 } 1028 } 1029 1030 } 1031 } 1032 updateNetworkDebuggerGraphsAndMetric(uNetworkTotalReceive, uNetworkTotalTransmit); 941 1033 } 942 1034 … … 950 1042 } 951 1043 952 void UIInformationRuntime::prepare PerformaceCollector()1044 void UIInformationRuntime::prepareMetrics() 953 1045 { 954 1046 m_performanceMonitor = uiCommon().virtualBox().GetPerformanceCollector(); … … 987 1079 } 988 1080 } 1081 989 1082 m_subMetrics.insert(m_strCPUMetricName, UISubMetric(m_strCPUMetricName, "%", iMaximumQueueSize)); 1083 1084 UISubMetric networkMetric(m_strNetDebuggerMetricName, "B", iMaximumQueueSize); 1085 QStringList networkDeviceList; 1086 networkDeviceList << "E1k" <<"VNet" << "PCNet"; 1087 networkMetric.setDeviceTypeList(networkDeviceList); 1088 QStringList networkMetricDataSubStringList; 1089 networkMetricDataSubStringList << "ReceiveBytes" << "TransmitBytes"; 1090 networkMetric.setMetricDataSubString(networkMetricDataSubStringList); 1091 m_subMetrics.insert(m_strNetDebuggerMetricName, networkMetric); 1092 1093 for (QMap<QString, UISubMetric>::const_iterator iterator = m_subMetrics.begin(); 1094 iterator != m_subMetrics.end(); ++iterator) 1095 { 1096 if (iterator.value().queryString().isEmpty()) 1097 continue; 1098 m_strQueryString += iterator.value().queryString(); 1099 } 990 1100 } 991 1101 … … 1075 1185 } 1076 1186 1077 void UIInformationRuntime::updateNe wGraphsAndMetric(ULONG iReceiveRate, ULONGiTransmitRate)1078 { 1079 UISubMetric &NetMetric = m_subMetrics[m_strNetMetricName];1080 1081 NetMetric.addData(0, iReceiveRate);1082 NetMetric.addData(1, iTransmitRate);1083 1084 ULONG iMaximum = qMax(NetMetric.maximum(), (ULONG)qMax(iReceiveRate, iTransmitRate));1085 NetMetric.setMaximum(iMaximum);1187 void UIInformationRuntime::updateNetworkGraphsAndMetric(qulonglong iReceiveRate, qulonglong iTransmitRate) 1188 { 1189 UISubMetric &NetMetric = m_subMetrics[m_strNetMetricName]; 1190 1191 NetMetric.addData(0, iReceiveRate); 1192 NetMetric.addData(1, iTransmitRate); 1193 1194 ULONG iMaximum = qMax(NetMetric.maximum(), qMax(iReceiveRate, iTransmitRate)); 1195 NetMetric.setMaximum(iMaximum); 1086 1196 1087 1197 if (m_infoLabels.contains(m_strNetMetricName) && m_infoLabels[m_strNetMetricName]) … … 1101 1211 m_infoLabels[m_strNetMetricName]->setText(strInfo); 1102 1212 } 1103 if (m_charts.contains(m_strNetMetricName)) 1104 m_charts[m_strNetMetricName]->update(); 1105 1106 } 1213 if (m_charts.contains(m_strNetMetricName)) 1214 m_charts[m_strNetMetricName]->update(); 1215 } 1216 1217 void UIInformationRuntime::updateNetworkDebuggerGraphsAndMetric(qulonglong iReceiveTotal, qulonglong iTransmitTotal) 1218 { 1219 UISubMetric &NetMetric = m_subMetrics[m_strNetDebuggerMetricName]; 1220 1221 qulonglong iReceiveRate = iReceiveTotal - NetMetric.total(0); 1222 qulonglong iTransmitRate = iTransmitTotal - NetMetric.total(1); 1223 1224 NetMetric.setTotal(0, iReceiveTotal); 1225 NetMetric.setTotal(1, iTransmitTotal); 1226 1227 NetMetric.addData(0, iReceiveRate); 1228 NetMetric.addData(1, iTransmitRate); 1229 ULONG iMaximum = qMax(NetMetric.maximum(), qMax(iReceiveRate, iTransmitRate)); 1230 NetMetric.setMaximum(iMaximum); 1231 1232 } 1233 1107 1234 1108 1235 QString UIInformationRuntime::dataColorString(const QString &strChartName, int iDataIndex) … … 1116 1243 } 1117 1244 1245 QVector<DebuggerMetricData> UIInformationRuntime::getTotalCounterFromDegugger(const QString &strQuery) 1246 { 1247 QVector<DebuggerMetricData> xmlData; 1248 if (strQuery.isEmpty()) 1249 return xmlData; 1250 CMachineDebugger debugger = m_console.GetDebugger(); 1251 1252 QString strStats = debugger.GetStats(strQuery, false); 1253 QXmlStreamReader xmlReader; 1254 xmlReader.addData(strStats); 1255 qulonglong iTotal = 0; 1256 if (xmlReader.readNextStartElement()) 1257 { 1258 while (xmlReader.readNextStartElement()) 1259 { 1260 if (xmlReader.name() == "Counter") 1261 { 1262 QXmlStreamAttributes attributes = xmlReader.attributes(); 1263 qulonglong iCounter = attributes.value("c").toULongLong(); 1264 iTotal += iCounter; 1265 xmlReader.skipCurrentElement(); 1266 xmlData.push_back(DebuggerMetricData(*(attributes.value("name").string()), iCounter)); 1267 } 1268 else 1269 xmlReader.skipCurrentElement(); 1270 1271 } 1272 } 1273 return xmlData; 1274 } 1118 1275 #include "UIInformationRuntime.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.h
r80384 r80406 48 48 class UIRuntimeInfoWidget; 49 49 50 #define DATA_SERIES_SIZE 2 51 52 struct DebuggerMetricData 53 { 54 DebuggerMetricData() 55 : m_counter(0){} 56 DebuggerMetricData(const QString & strName, qulonglong counter) 57 :m_strName(strName) 58 , m_counter(counter){} 59 QString m_strName; 60 qulonglong m_counter; 61 }; 62 50 63 class UISubMetric 51 64 { … … 56 69 const QString &name() const; 57 70 58 void setMaximum( ULONGiMaximum);59 ULONGmaximum() const;71 void setMaximum(qulonglong iMaximum); 72 qulonglong maximum() const; 60 73 61 74 void setUnit(QString strUnit); 62 75 const QString &unit() const; 63 76 64 void addData(int iDataSeriesIndex, ULONG fData); 65 const QQueue<ULONG> *data(int iDataSeriesIndex) const; 77 void addData(int iDataSeriesIndex, qulonglong fData); 78 const QQueue<qulonglong> *data(int iDataSeriesIndex) const; 79 80 void setTotal(int iDataSeriesIndex, qulonglong iTotal); 81 qulonglong total(int iDataSeriesIndex) const; 82 83 66 84 67 85 bool requiresGuestAdditions() const; 68 86 void setRequiresGuestAdditions(bool fRequiresGAs); 69 87 88 const QStringList &deviceTypeList() const; 89 void setDeviceTypeList(const QStringList &list); 90 91 const QStringList &metricDataSubString() const; 92 void setMetricDataSubString(const QStringList &list); 93 94 const QString &queryString() const; 95 70 96 private: 97 98 void composeQueryString(); 99 100 /** This list is used to differentiate xml data we get from the IMachineDebugger. */ 101 QStringList m_deviceTypeList; 102 /** This is used to select data series of the metric. For example, for network metric 103 * it is ReceiveBytes/TransmitBytes */ 104 QStringList m_metricDataSubString; 71 105 72 106 QString m_strName; 73 107 QString m_strUnit; 74 ULONG m_iMaximum; 75 QQueue<ULONG> m_data[2]; 108 /** This string is used while calling IMachineDebugger::getStats(..). It is composed of 109 * m_deviceTypeList and m_metricDataSubString. */ 110 QString m_strQueryString; 111 qulonglong m_iMaximum; 112 QQueue<qulonglong> m_data[DATA_SERIES_SIZE]; 113 /** The total data (the counter value we get from IMachineDebugger API). For the metrics 114 * we get from IMachineDebugger m_data values are computed as deltas of total values t - (t-1) */ 115 qulonglong m_iTotal[DATA_SERIES_SIZE]; 76 116 int m_iMaximumQueueSize; 77 117 bool m_fRequiresGuestAdditions; 118 78 119 }; 79 120 … … 105 146 /** Prepares layout. */ 106 147 void prepareObjects(); 107 void prepare PerformaceCollector();148 void prepareMetrics(); 108 149 bool guestAdditionsAvailable(int iMinimumMajorVersion); 109 150 void enableDisableGuestAdditionDependedWidgets(bool fEnable); 110 151 void updateCPUGraphsAndMetric(ULONG iLoadPercentage, ULONG iOtherPercentage); 111 152 void updateRAMGraphsAndMetric(quint64 iTotalRAM, quint64 iFreeRAM); 112 void updateNewGraphsAndMetric(ULONG iReceiveRate, ULONG iTransmitRate); 153 void updateNetworkGraphsAndMetric(qulonglong iReceiveRate, qulonglong iTransmitRate); 154 void updateNetworkDebuggerGraphsAndMetric(qulonglong iReceiveTotal, qulonglong iTransmitTotal); 155 113 156 QString dataColorString(const QString &strChartName, int iDataIndex); 114 UITextTable runTimeAttributes(); 157 void runTimeAttributes(); 158 159 QVector<DebuggerMetricData> getTotalCounterFromDegugger(const QString &strQuery); 115 160 116 161 bool m_fGuestAdditionsAvailable; … … 139 184 QString m_strDiskMetricName; 140 185 QString m_strNetMetricName; 186 QString m_strNetDebuggerMetricName; 141 187 /** @} */ 142 188 … … 158 204 QString m_strNetInfoLabelMaximum; 159 205 /** @} */ 160 161 206 /** The following string is used while querrying CMachineDebugger. */ 207 QString m_strQueryString; 162 208 }; 163 209
Note:
See TracChangeset
for help on using the changeset viewer.