Changeset 102858 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jan 12, 2024 2:09:25 PM (11 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.cpp
r102810 r102858 70 70 const int g_iMetricSetupCount = 1; 71 71 const int g_iDecimalCount = 2; 72 73 72 const int g_iBackgroundTint = 104; 74 73 const quint64 uInvalidValueSentinel = ~0U; 75 74 76 75 /********************************************************************************************************************************* … … 523 522 { 524 523 QHelpEvent *pToolTipEvent = static_cast<QHelpEvent *>(pEvent); 525 // if (m_iDataIndexUnderCursor == -1)526 // QToolTip::hideText();527 // else528 // QToolTip::showText(pToolTipEvent->globalPos(), toolTipText(), this, m_lineChartRect);529 524 if (m_pMouseOverLabel) 530 525 { 531 if (m_iDataIndexUnderCursor == -1)526 if (m_iDataIndexUnderCursor < 0) 532 527 m_pMouseOverLabel->setVisible(false); 533 528 else 534 529 { 535 m_pMouseOverLabel->setText(toolTipText()); 536 537 //m_pMouseOverLabel->resize(m_pMouseOverLabel->fontMetrics().size(Qt::TextSingleLine, m_pMouseOverLabel->text())); 538 m_pMouseOverLabel->move(QPoint(pToolTipEvent->pos().x(), pToolTipEvent->pos().y() - m_pMouseOverLabel->height())); 539 m_pMouseOverLabel->setVisible(true); 530 QString strToolTip = toolTipText(); 531 if (!strToolTip.isEmpty()) 532 { 533 m_pMouseOverLabel->setText(strToolTip); 534 m_pMouseOverLabel->move(QPoint(pToolTipEvent->pos().x(), pToolTipEvent->pos().y() - m_pMouseOverLabel->height())); 535 m_pMouseOverLabel->setVisible(true); 536 } 537 else 538 m_pMouseOverLabel->setVisible(false); 540 539 } 541 540 } … … 676 675 { 677 676 int j = i + 1; 677 if (data->at(i) == uInvalidValueSentinel || data->at(j) == uInvalidValueSentinel) 678 continue; 679 678 680 float fHeight = fH * data->at(i); 679 681 float fX = (width() - m_iMarginRight) - ((data->size() - i - 1) * fBarWidth); … … 687 689 for (int i = 0; i < data->size(); ++i) 688 690 { 691 if (data->at(i) == uInvalidValueSentinel) 692 continue; 689 693 float fHeight = fH * data->at(i); 690 694 float fX = (width() - m_iMarginRight) - ((data->size() - i - 1) * fBarWidth); … … 726 730 QString UIChart::YAxisValueLabel(quint64 iValue) const 727 731 { 732 if (iValue == uInvalidValueSentinel) 733 return QString(); 728 734 if (m_pMetric->unit().compare("%", Qt::CaseInsensitive) == 0) 729 735 return QString::number(iValue).append("%"); … … 838 844 QString UIChart::toolTipText() const 839 845 { 840 if (m_iDataIndexUnderCursor == -1)846 if (m_iDataIndexUnderCursor < 0) 841 847 return QString(); 842 848 … … 844 850 return QString(); 845 851 QString strToolTip; 846 if (m_pMetric->data(1) && !m_pMetric->data(1)->isEmpty()) 852 QString strData0; 853 if (m_iDataIndexUnderCursor < m_pMetric->data(0)->size()) 854 strData0 = YAxisValueLabel(m_pMetric->data(0)->at(m_iDataIndexUnderCursor)); 855 QString strData1; 856 if (m_iDataIndexUnderCursor < m_pMetric->data(1)->size()) 857 strData1 = YAxisValueLabel(m_pMetric->data(1)->at(m_iDataIndexUnderCursor)); 858 if (!strData0.isEmpty() && !strData1.isEmpty()) 847 859 { 848 860 strToolTip = QString("<font color=\"%1\">%2</font> / <font color=\"%3\">%4</font>") 849 .arg(m_dataSeriesColor[0].name(QColor::HexRgb)).arg( YAxisValueLabel(m_pMetric->data(0)->at(m_iDataIndexUnderCursor)))850 .arg(m_dataSeriesColor[1].name(QColor::HexRgb)).arg( YAxisValueLabel(m_pMetric->data(1)->at(m_iDataIndexUnderCursor)));851 } 852 else 861 .arg(m_dataSeriesColor[0].name(QColor::HexRgb)).arg(strData0) 862 .arg(m_dataSeriesColor[1].name(QColor::HexRgb)).arg(strData1); 863 } 864 else if (!strData0.isEmpty()) 853 865 { 854 866 strToolTip = QString("<font color=\"%1\">%2</font>") 855 .arg(m_dataSeriesColor[0].name(QColor::HexRgb)).arg(YAxisValueLabel(m_pMetric->data(0)->at(m_iDataIndexUnderCursor))); 867 .arg(m_dataSeriesColor[0].name(QColor::HexRgb)).arg(strData0); 868 } 869 else if (!strData1.isEmpty()) 870 { 871 strToolTip = QString("<font color=\"%1\">%2</font>") 872 .arg(m_dataSeriesColor[1].name(QColor::HexRgb)).arg(strData1); 856 873 } 857 874 return strToolTip; 858 //m_dataSeriesColor[iDataIndex]);859 // return pChart->dataSeriesColor(iDataIndex).name(QColor::HexRgb);860 // QColor dataSeriesColor(int iDataSeriesIndex, int iDark = 0);861 //QString strInfo = QString("<b>%1</b></b><br/> <font color=\"%2\">%3: %4</font><br/> <font color=\"%5\">%6: %7</font>")862 863 // QStringList toolTipStrings;864 // for (int k = 0; k < DATA_SERIES_SIZE; ++k)865 // {866 // const QQueue<quint64> *data = m_pMetric->data(k);867 // if (data && data->size() > 0 && m_iDataIndexUnderCursor < data->size())868 // toolTipStrings << YAxisValueLabel(data->at(m_iDataIndexUnderCursor));869 // }870 // return toolTipStrings.join(" / ");871 //QString strInfo = QString("<b>%1</b></b><br/> <font color=\"%2\">%3: %4</font><br/> <font color=\"%5\">%6: %7</font>")872 875 } 873 876 … … 1025 1028 if (iDataSeriesIndex >= DATA_SERIES_SIZE) 1026 1029 return; 1030 1027 1031 m_data[iDataSeriesIndex].enqueue(iData); 1028 if (m_fAutoUpdateMaximum)1029 m_iMaximum = qMax(m_iMaximum, iData);1030 1032 1031 1033 /* dequeue if needed and update the maximum value: */ 1032 1034 if (m_data[iDataSeriesIndex].size() > m_iMaximumQueueSize) 1033 {1034 bool fSearchMax = false;1035 /* Check if the dequeued value is the Max value. In which case we will scan and find a new Max: */1036 if (m_fAutoUpdateMaximum && m_data[iDataSeriesIndex].head() >= m_iMaximum)1037 fSearchMax = true;1038 1035 m_data[iDataSeriesIndex].dequeue(); 1039 if (fSearchMax) 1036 1037 updateMax(); 1038 } 1039 1040 void UIMetric::updateMax() 1041 { 1042 if (!m_fAutoUpdateMaximum) 1043 return; 1044 m_iMaximum = 0; 1045 for (int k = 0; k < DATA_SERIES_SIZE; ++k) 1046 { 1047 for (int i = 0; i < m_data[k].size(); ++i) 1040 1048 { 1041 m_iMaximum = 0; 1042 foreach (quint64 iVal, m_data[iDataSeriesIndex]) 1043 m_iMaximum = qMax(m_iMaximum, iVal); 1049 if (m_data[k].at(i) != uInvalidValueSentinel) 1050 m_iMaximum = qMax(m_iMaximum, m_data[k].at(i)); 1044 1051 } 1045 1052 } … … 1764 1771 } 1765 1772 1766 void UIVMActivityMonitorLocal::updateCPUChart( ULONGiExecutingPercentage, ULONG iOtherPercentage)1773 void UIVMActivityMonitorLocal::updateCPUChart(quint64 iExecutingPercentage, ULONG iOtherPercentage) 1767 1774 { 1768 1775 UIMetric &CPUMetric = m_metrics[m_strCPUMetricName]; … … 2065 2072 if (data.size() != timeStamps.size()) 2066 2073 return; 2074 /* Hack alert!! I am told that time series' interval is `guaranteed` to be 1 min. although it is clearly 2075 * parametrized in OCI API. I would much prefer to have some way of deermining the said interval via our API 2076 * but it looks like Christmas is over: */ 2077 const int iInterval = 60; 2067 2078 QVector<QString> newTimeStamps; 2068 foreach (const QString &strTimeStamp, timeStamps) 2069 { 2070 if (strTimeStamp.isEmpty()) 2079 QVector<quint64> newData; 2080 for (int i = 0; i < timeStamps.size() - 1; ++i) 2081 { 2082 if (timeStamps[i].isEmpty()) 2071 2083 continue; 2072 Q DateTime dateTime = QDateTime::fromString(strTimeStamp, Qt::RFC2822Date);2073 if (! dateTime.isValid())2084 QTime time = QDateTime::fromString(timeStamps[i], Qt::RFC2822Date).time(); 2085 if (!time.isValid()) 2074 2086 continue; 2075 newTimeStamps << dateTime.time().toString("hh:mm"); 2076 } 2077 2078 for (int i = 0; i < data.size(); ++i) 2087 newTimeStamps << time.toString("hh:mm"); 2088 /* It looks like in some cases OCI sends us negative values: */ 2089 if (data[i].toFloat() < 0) 2090 newData << 0U; 2091 else 2092 newData << (quint64)data[i].toFloat(); 2093 2094 QTime nextTime = QDateTime::fromString(timeStamps[i + 1], Qt::RFC2822Date).time(); 2095 while(time.secsTo(nextTime) > iInterval) 2096 { 2097 time = time.addSecs(iInterval); 2098 newTimeStamps << time.toString("hh:mm"); 2099 newData << uInvalidValueSentinel; 2100 } 2101 } 2102 if (!data.isEmpty()) 2103 { 2104 if (!timeStamps.last().isEmpty()) 2105 newTimeStamps << QDateTime::fromString(timeStamps.last(), Qt::RFC2822Date).time().toString("hh:mm"); 2106 newData << (quint64)data.last().toFloat(); 2107 } 2108 AssertReturnVoid(newData.size() == newTimeStamps.size()); 2109 2110 if (enmMetricType == KMetricType_NetworksBytesIn) 2111 { 2112 m_networkReceiveCache.clear(); 2113 m_metrics[m_strNetworkMetricName].reset(); 2114 } 2115 else if (enmMetricType == KMetricType_NetworksBytesOut) 2116 { 2117 m_networkTransmitCache.clear(); 2118 m_metrics[m_strNetworkMetricName].reset(); 2119 } 2120 else if (enmMetricType == KMetricType_DiskBytesRead) 2121 { 2122 m_diskReadCache.clear(); 2123 m_metrics[m_strDiskIOMetricName].reset(); 2124 } 2125 else if (enmMetricType == KMetricType_DiskBytesWritten) 2126 { 2127 m_diskWriteCache.clear(); 2128 m_metrics[m_strDiskIOMetricName].reset(); 2129 2130 } 2131 else if (enmMetricType == KMetricType_CpuUtilization) 2132 m_metrics[m_strCPUMetricName].reset(); 2133 else if (enmMetricType == KMetricType_MemoryUtilization) 2134 m_metrics[m_strRAMMetricName].reset(); 2135 2136 2137 for (int i = 0; i < newData.size(); ++i) 2079 2138 { 2080 2139 if (enmMetricType == KMetricType_CpuUtilization) 2081 2140 { 2082 float fValue = data[i].toFloat(); 2083 updateCPUChart((ULONG) fValue, newTimeStamps[i]); 2141 updateCPUChart(newData[i], newTimeStamps[i]); 2084 2142 } 2085 2143 else if (enmMetricType == KMetricType_NetworksBytesOut) 2086 cacheNetworkTransmit(newTimeStamps[i], (int)data[i].toFloat());2144 cacheNetworkTransmit(newTimeStamps[i], newData[i]); 2087 2145 else if (enmMetricType == KMetricType_NetworksBytesIn) 2088 cacheNetworkReceive(newTimeStamps[i], (int)data[i].toFloat());2146 cacheNetworkReceive(newTimeStamps[i], newData[i]); 2089 2147 else if (enmMetricType == KMetricType_DiskBytesRead) 2090 cacheDiskRead(newTimeStamps[i], (int)data[i].toFloat());2148 cacheDiskRead(newTimeStamps[i], newData[i]); 2091 2149 else if (enmMetricType == KMetricType_DiskBytesWritten) 2092 cacheDiskWrite(newTimeStamps[i], (int)data[i].toFloat());2150 cacheDiskWrite(newTimeStamps[i], newData[i]); 2093 2151 else if (enmMetricType == KMetricType_MemoryUtilization) 2094 2152 { … … 2096 2154 { 2097 2155 /* calculate used RAM amount in kb: */ 2098 quint64 iUsedRAM = data[i].toFloat() * (m_iTotalRAM / 100.f); 2099 updateRAMChart(iUsedRAM, newTimeStamps[i]); 2156 if (newData[i] != uInvalidValueSentinel) 2157 { 2158 quint64 iUsedRAM = newData[i] * (m_iTotalRAM / 100.f); 2159 updateRAMChart(iUsedRAM, newTimeStamps[i]); 2160 } 2161 else 2162 updateRAMChart(newData[i], newTimeStamps[i]); 2100 2163 } 2101 2164 } … … 2137 2200 if (iDataSeriesIndex >= DATA_SERIES_SIZE) 2138 2201 continue; 2202 #if 0 2139 2203 int iDataSize = 1; 2140 2204 if (metric.dataSize(iDataSeriesIndex) == 0) 2141 2205 iDataSize = 60; 2142 2206 #endif 2207 /* Request the whole time series (all 60 values) at each iteration to detect time points with no 2208 * data (due to stop and restart). We sanitize the data when we receive it and mark time points 2209 * with no data with sentinel value: */ 2210 int iDataSize = 60; 2143 2211 UIProgressTaskReadCloudMachineMetricData *pTask = new UIProgressTaskReadCloudMachineMetricData(this, m_comMachine, 2144 2212 enmMetricType, iDataSize); … … 2191 2259 } 2192 2260 2193 void UIVMActivityMonitorCloud::updateCPUChart( ULONGiLoadPercentage, const QString &strLabel)2261 void UIVMActivityMonitorCloud::updateCPUChart(quint64 iLoadPercentage, const QString &strLabel) 2194 2262 { 2195 2263 UIMetric &CPUMetric = m_metrics[m_strCPUMetricName]; … … 2367 2435 } 2368 2436 2369 void UIVMActivityMonitorCloud::cacheDiskWrite(const QString &strTimeStamp, intiValue)2437 void UIVMActivityMonitorCloud::cacheDiskWrite(const QString &strTimeStamp, quint64 iValue) 2370 2438 { 2371 2439 /* Make sure this is the first time we receieve write for this time stap: */ … … 2381 2449 } 2382 2450 2383 void UIVMActivityMonitorCloud::cacheDiskRead(const QString &strTimeStamp, intiValue)2451 void UIVMActivityMonitorCloud::cacheDiskRead(const QString &strTimeStamp, quint64 iValue) 2384 2452 { 2385 2453 /* Make sure this is the first time we receieve read for this time stap: */ … … 2395 2463 } 2396 2464 2397 void UIVMActivityMonitorCloud::cacheNetworkReceive(const QString &strTimeStamp, intiValue)2465 void UIVMActivityMonitorCloud::cacheNetworkReceive(const QString &strTimeStamp, quint64 iValue) 2398 2466 { 2399 2467 AssertReturnVoid(!m_networkReceiveCache.contains(strTimeStamp)); … … 2409 2477 2410 2478 2411 void UIVMActivityMonitorCloud::cacheNetworkTransmit(const QString &strTimeStamp, intiValue)2479 void UIVMActivityMonitorCloud::cacheNetworkTransmit(const QString &strTimeStamp, quint64 iValue) 2412 2480 { 2413 2481 AssertReturnVoid(!m_networkTransmitCache.contains(strTimeStamp)); -
trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.h
r102810 r102858 115 115 116 116 private: 117 void updateMax(); 117 118 118 119 QString m_strName; … … 287 288 bool guestAdditionsAvailable(const char *pszMinimumVersion); 288 289 void enableDisableGuestAdditionDependedWidgets(bool fEnable); 289 void updateCPUChart( ULONGiLoadPercentage, ULONG iOtherPercentage);290 void updateCPUChart(quint64 iLoadPercentage, ULONG iOtherPercentage); 290 291 void updateRAMGraphsAndMetric(quint64 iTotalRAM, quint64 iFreeRAM); 291 292 void updateNetworkChart(quint64 uReceiveTotal, quint64 uTransmitTotal); … … 340 341 /** @name The following functions update corresponding metric charts and labels with new values 341 342 * @{ */ 342 void updateCPUChart( ULONGiLoadPercentage, const QString &strLabel);343 void updateCPUChart(quint64 iLoadPercentage, const QString &strLabel); 343 344 void updateNetworkChart(quint64 uReceive, quint64 uTransmit, const QString &strLabel); 344 345 void updateDiskIOChart(quint64 uWriteRate, quint64 uReadRate, const QString &strLabel); … … 351 352 /* Since we have a single UIMetric instance for disk IO we cache write and/or read until the other value arrives. Then update 352 353 * the corresponding chart. */ 353 void cacheDiskWrite(const QString &strTimeStamp, intiValue);354 void cacheDiskRead(const QString &strTimeStamp, intiValue);355 356 void cacheNetworkReceive(const QString &strTimeStamp, intiValue);357 void cacheNetworkTransmit(const QString &strTimeStamp, intiValue);354 void cacheDiskWrite(const QString &strTimeStamp, quint64 iValue); 355 void cacheDiskRead(const QString &strTimeStamp, quint64 iValue); 356 357 void cacheNetworkReceive(const QString &strTimeStamp, quint64 iValue); 358 void cacheNetworkTransmit(const QString &strTimeStamp, quint64 iValue); 358 359 359 360 bool findMetric(KMetricType enmMetricType, UIMetric &metric, int &iDataSeriesIndex) const;
Note:
See TracChangeset
for help on using the changeset viewer.