| 121 | } |
| 122 | |
| 123 | void TrafficGraphWidget::updateRates() |
| 124 | { |
| 125 | if(!clientModel) return; |
| 126 | |
| 127 | quint64 bytesIn = clientModel->node().getTotalBytesRecv(), |
| 128 | bytesOut = clientModel->node().getTotalBytesSent(); |
| 129 | float inRate = (bytesIn - nLastBytesIn) / 1024.0f * 1000 / timer->interval(); |
| 130 | float outRate = (bytesOut - nLastBytesOut) / 1024.0f * 1000 / timer->interval(); |
| 131 | vSamplesIn.push_front(inRate); |
| 132 | vSamplesOut.push_front(outRate); |
| 133 | nLastBytesIn = bytesIn; |
| 134 | nLastBytesOut = bytesOut; |
| 135 | |
| 136 | while(vSamplesIn.size() > DESIRED_SAMPLES) { |
| 137 | vSamplesIn.pop_back(); |
| 138 | } |
| 139 | while(vSamplesOut.size() > DESIRED_SAMPLES) { |
| 140 | vSamplesOut.pop_back(); |
| 141 | } |
| 142 | |
| 143 | float tmax = 0.0f; |
| 144 | for (float f : vSamplesIn) { |
| 145 | if(f > tmax) tmax = f; |
| 146 | } |
| 147 | for (float f : vSamplesOut) { |
| 148 | if(f > tmax) tmax = f; |
| 149 | } |
| 150 | fMax = tmax; |
| 151 | update(); |
| 152 | } |
| 153 | |
| 154 | void TrafficGraphWidget::setGraphRangeMins(int mins) |
| 155 | { |
nothing calls this directly
no test coverage detected