mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
coding standard
This commit is contained in:
parent
e779a55e22
commit
82b8595af8
4 changed files with 83 additions and 67 deletions
|
@ -25,22 +25,22 @@ BandwidthChannelDisplay::BandwidthChannelDisplay(QVector<NodeType_t> nodeTypesTo
|
|||
QFormLayout* form,
|
||||
char const* const caption, char const* unitCaption,
|
||||
const float unitScale, unsigned colorRGBA) :
|
||||
nodeTypesToFollow(nodeTypesToFollow),
|
||||
caption(caption),
|
||||
unitCaption(unitCaption),
|
||||
unitScale(unitScale),
|
||||
colorRGBA(colorRGBA)
|
||||
_nodeTypesToFollow(nodeTypesToFollow),
|
||||
_caption(caption),
|
||||
_unitCaption(unitCaption),
|
||||
_unitScale(unitScale),
|
||||
_colorRGBA(colorRGBA)
|
||||
{
|
||||
label = new QLabel();
|
||||
label->setAlignment(Qt::AlignRight);
|
||||
_label = new QLabel();
|
||||
_label->setAlignment(Qt::AlignRight);
|
||||
|
||||
QPalette palette = label->palette();
|
||||
QPalette palette = _label->palette();
|
||||
unsigned rgb = colorRGBA >> 8;
|
||||
rgb = ((rgb & 0xfefefeu) >> 1) + ((rgb & 0xf8f8f8) >> 3);
|
||||
palette.setColor(QPalette::WindowText, QColor::fromRgb(rgb));
|
||||
label->setPalette(palette);
|
||||
_label->setPalette(palette);
|
||||
|
||||
form->addRow(QString(" ") + caption + " Bandwidth In/Out:", label);
|
||||
form->addRow(QString(" ") + _caption + " Bandwidth In/Out:", _label);
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,19 +51,19 @@ void BandwidthChannelDisplay::bandwidthAverageUpdated() {
|
|||
|
||||
QSharedPointer<BandwidthRecorder> bandwidthRecorder = DependencyManager::get<BandwidthRecorder>();
|
||||
|
||||
for (int i = 0; i < nodeTypesToFollow.size(); ++i) {
|
||||
inTotal += bandwidthRecorder->getAverageInputKilobitsPerSecond(nodeTypesToFollow.at(i));
|
||||
outTotal += bandwidthRecorder->getAverageOutputKilobitsPerSecond(nodeTypesToFollow.at(i));
|
||||
for (int i = 0; i < _nodeTypesToFollow.size(); ++i) {
|
||||
inTotal += bandwidthRecorder->getAverageInputKilobitsPerSecond(_nodeTypesToFollow.at(i));
|
||||
outTotal += bandwidthRecorder->getAverageOutputKilobitsPerSecond(_nodeTypesToFollow.at(i));
|
||||
}
|
||||
|
||||
strBuf =
|
||||
QString("").setNum((int) (inTotal * unitScale)) + "/" +
|
||||
QString("").setNum((int) (outTotal * unitScale)) + " " + unitCaption;
|
||||
_strBuf =
|
||||
QString("").setNum((int) (inTotal * _unitScale)) + "/" +
|
||||
QString("").setNum((int) (outTotal * _unitScale)) + " " + _unitCaption;
|
||||
}
|
||||
|
||||
|
||||
void BandwidthChannelDisplay::Paint() {
|
||||
label->setText(strBuf);
|
||||
void BandwidthChannelDisplay::paint() {
|
||||
_label->setText(_strBuf);
|
||||
}
|
||||
|
||||
|
||||
|
@ -83,12 +83,14 @@ BandwidthDialog::BandwidthDialog(QWidget* parent) :
|
|||
_allChannelDisplays[1] = _avatarsChannelDisplay =
|
||||
new BandwidthChannelDisplay({NodeType::Agent, NodeType::AvatarMixer}, form, "Avatars", "Kbps", 1.0, COLOR1);
|
||||
_allChannelDisplays[2] = _octreeChannelDisplay =
|
||||
new BandwidthChannelDisplay({NodeType::DomainServer, NodeType::EntityServer}, form, "Octree", "Kbps", 1.0, COLOR2);
|
||||
_allChannelDisplays[3] = _metavoxelsChannelDisplay =
|
||||
new BandwidthChannelDisplay({NodeType::EntityServer}, form, "Octree", "Kbps", 1.0, COLOR2);
|
||||
_allChannelDisplays[3] = _octreeChannelDisplay =
|
||||
new BandwidthChannelDisplay({NodeType::DomainServer}, form, "Domain", "Kbps", 1.0, COLOR2);
|
||||
_allChannelDisplays[4] = _metavoxelsChannelDisplay =
|
||||
new BandwidthChannelDisplay({NodeType::MetavoxelServer, NodeType::EnvironmentServer}, form, "Metavoxels", "Kbps", 1.0, COLOR2);
|
||||
_allChannelDisplays[4] = _otherChannelDisplay =
|
||||
_allChannelDisplays[5] = _otherChannelDisplay =
|
||||
new BandwidthChannelDisplay({NodeType::Unassigned}, form, "Other", "Kbps", 1.0, COLOR2);
|
||||
_allChannelDisplays[5] = _totalChannelDisplay =
|
||||
_allChannelDisplays[6] = _totalChannelDisplay =
|
||||
new BandwidthChannelDisplay({NodeType::DomainServer, NodeType::EntityServer, NodeType::MetavoxelServer,
|
||||
NodeType::EnvironmentServer, NodeType::AudioMixer, NodeType::Agent,
|
||||
NodeType::AvatarMixer, NodeType::Unassigned},
|
||||
|
@ -100,20 +102,22 @@ BandwidthDialog::BandwidthDialog(QWidget* parent) :
|
|||
|
||||
|
||||
BandwidthDialog::~BandwidthDialog() {
|
||||
for (unsigned int i=0; i<_CHANNELCOUNT; i++)
|
||||
for (unsigned int i = 0; i < _CHANNELCOUNT; i++) {
|
||||
delete _allChannelDisplays[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BandwidthDialog::updateTimerTimeout() {
|
||||
for (unsigned int i=0; i<_CHANNELCOUNT; i++)
|
||||
for (unsigned int i = 0; i < _CHANNELCOUNT; i++) {
|
||||
_allChannelDisplays[i]->bandwidthAverageUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BandwidthDialog::paintEvent(QPaintEvent* event) {
|
||||
for (unsigned int i=0; i<_CHANNELCOUNT; i++)
|
||||
_allChannelDisplays[i]->Paint();
|
||||
_allChannelDisplays[i]->paint();
|
||||
this->QDialog::paintEvent(event);
|
||||
this->setFixedSize(this->width(), this->height());
|
||||
}
|
||||
|
|
|
@ -33,16 +33,16 @@ class BandwidthChannelDisplay : public QObject {
|
|||
BandwidthChannelDisplay(QVector<NodeType_t> nodeTypesToFollow,
|
||||
QFormLayout* form,
|
||||
char const* const caption, char const* unitCaption, float unitScale, unsigned colorRGBA);
|
||||
void Paint();
|
||||
void paint();
|
||||
|
||||
private:
|
||||
QVector<NodeType_t> nodeTypesToFollow;
|
||||
QLabel* label;
|
||||
QString strBuf;
|
||||
char const* const caption;
|
||||
char const* unitCaption;
|
||||
float const unitScale;
|
||||
unsigned colorRGBA;
|
||||
QVector<NodeType_t> _nodeTypesToFollow;
|
||||
QLabel* _label;
|
||||
QString _strBuf;
|
||||
char const* const _caption;
|
||||
char const* _unitCaption;
|
||||
float const _unitScale;
|
||||
unsigned _colorRGBA;
|
||||
|
||||
|
||||
public slots:
|
||||
|
@ -62,12 +62,13 @@ private:
|
|||
BandwidthChannelDisplay* _audioChannelDisplay;
|
||||
BandwidthChannelDisplay* _avatarsChannelDisplay;
|
||||
BandwidthChannelDisplay* _octreeChannelDisplay;
|
||||
BandwidthChannelDisplay* _domainChannelDisplay;
|
||||
BandwidthChannelDisplay* _metavoxelsChannelDisplay;
|
||||
BandwidthChannelDisplay* _otherChannelDisplay;
|
||||
BandwidthChannelDisplay* _totalChannelDisplay; // sums of all the other channels
|
||||
|
||||
static const unsigned int _CHANNELCOUNT = 6;
|
||||
BandwidthChannelDisplay *_allChannelDisplays[_CHANNELCOUNT];
|
||||
static const unsigned int _CHANNELCOUNT = 7;
|
||||
BandwidthChannelDisplay* _allChannelDisplays[_CHANNELCOUNT];
|
||||
|
||||
|
||||
signals:
|
||||
|
|
|
@ -21,16 +21,18 @@ BandwidthRecorder::Channel::Channel() {
|
|||
|
||||
float BandwidthRecorder::Channel::getAverageInputPacketsPerSecond() {
|
||||
float delt = _input.getEventDeltaAverage();
|
||||
if (delt > 0.)
|
||||
if (delt > 0.) {
|
||||
return (1.0 / delt);
|
||||
return 0.;
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
float BandwidthRecorder::Channel::getAverageOutputPacketsPerSecond() {
|
||||
float delt = _input.getEventDeltaAverage();
|
||||
if (delt > 0.)
|
||||
if (delt > 0.) {
|
||||
return (1.0 / _output.getEventDeltaAverage());
|
||||
return 0.;
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
float BandwidthRecorder::Channel::getAverageInputKilobitsPerSecond() {
|
||||
|
@ -62,87 +64,97 @@ BandwidthRecorder::~BandwidthRecorder() {
|
|||
|
||||
void BandwidthRecorder::updateInboundData(const quint8 channelType, const int sample) {
|
||||
Q_ASSERT(channelType < CHANNEL_COUNT);
|
||||
if (! _channels[channelType])
|
||||
if (! _channels[channelType]) {
|
||||
_channels[channelType] = new Channel();
|
||||
}
|
||||
_channels[channelType]->updateInputAverage(sample);
|
||||
}
|
||||
|
||||
void BandwidthRecorder::updateOutboundData(const quint8 channelType, const int sample) {
|
||||
Q_ASSERT(channelType < CHANNEL_COUNT);
|
||||
if (! _channels[channelType])
|
||||
if (! _channels[channelType]) {
|
||||
_channels[channelType] = new Channel();
|
||||
}
|
||||
_channels[channelType]->updateOutputAverage(sample);
|
||||
}
|
||||
|
||||
float BandwidthRecorder::getAverageInputPacketsPerSecond(const quint8 channelType) {
|
||||
Q_ASSERT(channelType < CHANNEL_COUNT);
|
||||
if (! _channels[channelType])
|
||||
return 0.;
|
||||
if (! _channels[channelType]) {
|
||||
return 0.0f;
|
||||
}
|
||||
return _channels[channelType]->getAverageInputPacketsPerSecond();
|
||||
}
|
||||
|
||||
float BandwidthRecorder::getAverageOutputPacketsPerSecond(const quint8 channelType) {
|
||||
Q_ASSERT(channelType < CHANNEL_COUNT);
|
||||
if (! _channels[channelType])
|
||||
return 0.;
|
||||
if (! _channels[channelType]) {
|
||||
return 0.0f;
|
||||
}
|
||||
return _channels[channelType]->getAverageOutputPacketsPerSecond();
|
||||
}
|
||||
|
||||
float BandwidthRecorder::getAverageInputKilobitsPerSecond(const quint8 channelType) {
|
||||
Q_ASSERT(channelType < CHANNEL_COUNT);
|
||||
if (! _channels[channelType])
|
||||
return 0.;
|
||||
if (! _channels[channelType]) {
|
||||
return 0.0f;
|
||||
}
|
||||
return _channels[channelType]->getAverageInputKilobitsPerSecond();
|
||||
}
|
||||
|
||||
float BandwidthRecorder::getAverageOutputKilobitsPerSecond(const quint8 channelType) {
|
||||
Q_ASSERT(channelType < CHANNEL_COUNT);
|
||||
if (! _channels[channelType])
|
||||
return 0.;
|
||||
if (! _channels[channelType]) {
|
||||
return 0.0f;
|
||||
}
|
||||
return _channels[channelType]->getAverageOutputKilobitsPerSecond();
|
||||
}
|
||||
|
||||
float BandwidthRecorder::getTotalAverageInputPacketsPerSecond() {
|
||||
float result = 0.;
|
||||
float result = 0.0f;
|
||||
for (uint i=0; i<CHANNEL_COUNT; i++) {
|
||||
if (_channels[i])
|
||||
if (_channels[i]) {
|
||||
result += _channels[i]->getAverageInputPacketsPerSecond();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
float BandwidthRecorder::getTotalAverageOutputPacketsPerSecond() {
|
||||
float result = 0.;
|
||||
float result = 0.0f;
|
||||
for (uint i=0; i<CHANNEL_COUNT; i++) {
|
||||
if (_channels[i])
|
||||
if (_channels[i]) {
|
||||
result += _channels[i]->getAverageOutputPacketsPerSecond();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
float BandwidthRecorder::getTotalAverageInputKilobitsPerSecond(){
|
||||
float result = 0.;
|
||||
float result = 0.0f;
|
||||
for (uint i=0; i<CHANNEL_COUNT; i++) {
|
||||
if (_channels[i])
|
||||
if (_channels[i]) {
|
||||
result += _channels[i]->getAverageInputKilobitsPerSecond();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
float BandwidthRecorder::getTotalAverageOutputKilobitsPerSecond(){
|
||||
float result = 0.;
|
||||
float result = 0.0f;
|
||||
for (uint i=0; i<CHANNEL_COUNT; i++) {
|
||||
if (_channels[i])
|
||||
if (_channels[i]) {
|
||||
result += _channels[i]->getAverageOutputKilobitsPerSecond();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
float BandwidthRecorder::getCachedTotalAverageInputPacketsPerSecond() {
|
||||
static qint64 lastCalculated = 0;
|
||||
static float cachedValue = 0.;
|
||||
static float cachedValue = 0.0f;
|
||||
qint64 now = QDateTime::currentMSecsSinceEpoch();
|
||||
if (now - lastCalculated > 1000.) {
|
||||
if (now - lastCalculated > 1000.0f) {
|
||||
lastCalculated = now;
|
||||
cachedValue = getTotalAverageInputPacketsPerSecond();
|
||||
}
|
||||
|
@ -151,9 +163,9 @@ float BandwidthRecorder::getCachedTotalAverageInputPacketsPerSecond() {
|
|||
|
||||
float BandwidthRecorder::getCachedTotalAverageOutputPacketsPerSecond() {
|
||||
static qint64 lastCalculated = 0;
|
||||
static float cachedValue = 0.;
|
||||
static float cachedValue = 0.0f;
|
||||
qint64 now = QDateTime::currentMSecsSinceEpoch();
|
||||
if (now - lastCalculated > 1000.) {
|
||||
if (now - lastCalculated > 1000.0f) {
|
||||
lastCalculated = now;
|
||||
cachedValue = getTotalAverageOutputPacketsPerSecond();
|
||||
}
|
||||
|
@ -162,9 +174,9 @@ float BandwidthRecorder::getCachedTotalAverageOutputPacketsPerSecond() {
|
|||
|
||||
float BandwidthRecorder::getCachedTotalAverageInputKilobitsPerSecond() {
|
||||
static qint64 lastCalculated = 0;
|
||||
static float cachedValue = 0.;
|
||||
static float cachedValue = 0.0f;
|
||||
qint64 now = QDateTime::currentMSecsSinceEpoch();
|
||||
if (now - lastCalculated > 1000.) {
|
||||
if (now - lastCalculated > 1000.0f) {
|
||||
lastCalculated = now;
|
||||
cachedValue = getTotalAverageInputKilobitsPerSecond();
|
||||
}
|
||||
|
@ -173,9 +185,9 @@ float BandwidthRecorder::getCachedTotalAverageInputKilobitsPerSecond() {
|
|||
|
||||
float BandwidthRecorder::getCachedTotalAverageOutputKilobitsPerSecond() {
|
||||
static qint64 lastCalculated = 0;
|
||||
static float cachedValue = 0.;
|
||||
static float cachedValue = 0.0f;
|
||||
qint64 now = QDateTime::currentMSecsSinceEpoch();
|
||||
if (now - lastCalculated > 1000.) {
|
||||
if (now - lastCalculated > 1000.0f) {
|
||||
lastCalculated = now;
|
||||
cachedValue = getTotalAverageOutputKilobitsPerSecond();
|
||||
}
|
||||
|
|
|
@ -214,8 +214,7 @@ qint64 LimitedNodeList::readDatagram(QByteArray& incomingPacket, QHostAddress* a
|
|||
SharedNodePointer sendingNode = sendingNodeForPacket(incomingPacket);
|
||||
if (sendingNode) {
|
||||
emit dataReceived(sendingNode->getType(), incomingPacket.size());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
emit dataReceived(NodeType::Unassigned, incomingPacket.size());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue