Changeset 1981 in ntrip


Ignore:
Timestamp:
Nov 18, 2009, 11:30:06 AM (14 years ago)
Author:
mervart
Message:

* empty log message *

Location:
trunk/BNC
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncfigure.cpp

    r1965 r1981  
    178178
    179179    int xx = xMin+70+anchor*12;
    180     int yy = int(yLength * (it.value()->_mean / _maxRate));
    181180
    182181    painter.save();
     
    187186
    188187    if(_maxRate > 0.0) {
     188      int yy = int(yLength * (it.value()->_mean / _maxRate));
    189189      QColor color = QColor::fromRgb(_rgb[0][anchor],_rgb[1][anchor],_rgb[2][anchor]);
    190190      painter.fillRect(xx-13, int((yMax-yMin)*xLine)-yy, 9, yy,
  • trunk/BNC/bncfigurelate.cpp

    r1980 r1981  
    6868  QMutexLocker locker(&_mutex);
    6969
    70   _counter = 0;
    7170  _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();
    7972
    8073  bncSettings settings;
     
    8477    QUrl        url(hlp[0]);
    8578    QByteArray  staID = url.path().mid(1).toAscii();
    86     _bytes[staID] = new sumAndMean();
     79    _latency[staID] = 0.0;
    8780  }
    8881}
     
    9285void bncFigureLate::slotNewLatency(const QByteArray staID, double clate) {
    9386  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    }
    9793  }
    9894}
     
    10298void bncFigureLate::slotNextAnimationFrame() {
    10399  QMutexLocker locker(&_mutex);
    104 
    105   const static int MAXCOUNTER = 10;
    106 
    107   ++_counter;
    108 
    109   // If counter reaches its maximal value, compute the mean value
    110   // ------------------------------------------------------------
    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 
    125100  update();
    126 
    127101  QTimer::singleShot(1000, this, SLOT(slotNextAnimationFrame()));
    128102}
     
    162136
    163137  int anchor = 0;
    164   QMapIterator<QByteArray, sumAndMean*> it(_bytes);
     138  QMapIterator<QByteArray, double> it(_latency);
    165139  while (it.hasNext()) {
    166140    it.next();
     
    168142
    169143    int xx = xMin+70+anchor*12;
    170     int yy = int(yLength * (it.value()->_mean / _maxLate));
    171144
    172145    painter.save();
     
    177150
    178151    if(_maxLate > 0.0) {
     152      int yy = int(yLength * (it.value() / _maxLate));
    179153      QColor color = QColor::fromRgb(_rgb[0][anchor],_rgb[1][anchor],_rgb[2][anchor]);
    180154      painter.fillRect(xx-13, int((yMax-yMin)*xLine)-yy, 9, yy,
  • trunk/BNC/bncfigurelate.h

    r1976 r1981  
    4141  void slotNextAnimationFrame();
    4242 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];
    5647};
    5748
Note: See TracChangeset for help on using the changeset viewer.