Changeset 1981 in ntrip
- Timestamp:
- Nov 18, 2009, 11:30:06 AM (15 years ago)
- Location:
- trunk/BNC
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncfigure.cpp
r1965 r1981 178 178 179 179 int xx = xMin+70+anchor*12; 180 int yy = int(yLength * (it.value()->_mean / _maxRate));181 180 182 181 painter.save(); … … 187 186 188 187 if(_maxRate > 0.0) { 188 int yy = int(yLength * (it.value()->_mean / _maxRate)); 189 189 QColor color = QColor::fromRgb(_rgb[0][anchor],_rgb[1][anchor],_rgb[2][anchor]); 190 190 painter.fillRect(xx-13, int((yMax-yMin)*xLine)-yy, 9, yy, -
trunk/BNC/bncfigurelate.cpp
r1980 r1981 68 68 QMutexLocker locker(&_mutex); 69 69 70 _counter = 0;71 70 _maxLate = 0; 72 73 QMapIterator<QByteArray, sumAndMean*> it1(_bytes); 74 while (it1.hasNext()) { 75 it1.next(); 76 delete it1.value(); 77 } 78 _bytes.clear(); 71 _latency.clear(); 79 72 80 73 bncSettings settings; … … 84 77 QUrl url(hlp[0]); 85 78 QByteArray staID = url.path().mid(1).toAscii(); 86 _ bytes[staID] = new sumAndMean();79 _latency[staID] = 0.0; 87 80 } 88 81 } … … 92 85 void bncFigureLate::slotNewLatency(const QByteArray staID, double clate) { 93 86 QMutexLocker locker(&_mutex); 94 QMap<QByteArray, sumAndMean*>::const_iterator it = _bytes.find(staID); 95 if (it != _bytes.end()) { 96 it.value()->_sum += fabs(clate)*1000.; 87 if (_latency.find(staID) != _latency.end()) { 88 double ms = fabs(clate)*1000.0; 89 _latency[staID] = ms; 90 if (ms > _maxLate) { 91 _maxLate = ms; 92 } 97 93 } 98 94 } … … 102 98 void bncFigureLate::slotNextAnimationFrame() { 103 99 QMutexLocker locker(&_mutex); 104 105 const static int MAXCOUNTER = 10;106 107 ++_counter;108 109 // If counter reaches its maximal value, compute the mean value110 // ------------------------------------------------------------111 if (_counter == MAXCOUNTER) {112 _maxLate = 0.0;113 QMapIterator<QByteArray, sumAndMean*> it(_bytes);114 while (it.hasNext()) {115 it.next();116 it.value()->_mean = it.value()->_sum / _counter;117 it.value()->_sum = 0.0;118 if (it.value()->_mean > _maxLate) {119 _maxLate = it.value()->_mean;120 }121 }122 _counter = 0;123 }124 125 100 update(); 126 127 101 QTimer::singleShot(1000, this, SLOT(slotNextAnimationFrame())); 128 102 } … … 162 136 163 137 int anchor = 0; 164 QMapIterator<QByteArray, sumAndMean*> it(_bytes);138 QMapIterator<QByteArray, double> it(_latency); 165 139 while (it.hasNext()) { 166 140 it.next(); … … 168 142 169 143 int xx = xMin+70+anchor*12; 170 int yy = int(yLength * (it.value()->_mean / _maxLate));171 144 172 145 painter.save(); … … 177 150 178 151 if(_maxLate > 0.0) { 152 int yy = int(yLength * (it.value() / _maxLate)); 179 153 QColor color = QColor::fromRgb(_rgb[0][anchor],_rgb[1][anchor],_rgb[2][anchor]); 180 154 painter.fillRect(xx-13, int((yMax-yMin)*xLine)-yy, 9, yy, -
trunk/BNC/bncfigurelate.h
r1976 r1981 41 41 void slotNextAnimationFrame(); 42 42 private: 43 class sumAndMean { 44 public: 45 sumAndMean() {_mean = 0.0; _sum = 0.0;} 46 ~sumAndMean() {} 47 double _mean; 48 double _sum; 49 }; 50 QMap<QByteArray, sumAndMean*> _bytes; 51 QMutex _mutex; 52 int _counter; 53 int _counter1; 54 double _maxLate; 55 int _rgb[3][1001]; 43 QMap<QByteArray, double> _latency; 44 QMutex _mutex; 45 double _maxLate; 46 int _rgb[3][1001]; 56 47 }; 57 48
Note:
See TracChangeset
for help on using the changeset viewer.