add loadsource for testing needs

This commit is contained in:
arcan1s 2015-09-30 00:16:57 +03:00
parent 79d2b07d57
commit befdf0519f
4 changed files with 127 additions and 0 deletions

View File

@ -500,6 +500,12 @@ QStringList AWKeysAggregator::registerSource(const QString source, const QString
key.remove(QString("weather/"));
m_map[source] = key;
m_formater[key] = NoFormat;
} else if (source.startsWith(QString("load/load"))) {
// load source
QString key = source;
key.remove(QString("load/"));
m_map[source] = key;
m_formater[key] = Temperature;
}
return keysFromSource(source);

View File

@ -18,12 +18,14 @@
#include "extsysmonaggregator.h"
#include "awdebug.h"
#include "version.h"
#include "sources/batterysource.h"
#include "sources/customsource.h"
#include "sources/desktopsource.h"
#include "sources/gpuloadsource.h"
#include "sources/gputempsource.h"
#include "sources/hddtempsource.h"
#include "sources/loadsource.h"
#include "sources/networksource.h"
#include "sources/playersource.h"
#include "sources/processessource.h"
@ -152,4 +154,10 @@ void ExtSysMonAggregator::init(const QHash<QString, QString> config)
AbstractExtSysMonSource *weatherItem = new WeatherSource(this, QStringList());
foreach(QString source, weatherItem->sources())
m_map[source] = weatherItem;
#ifdef BUILD_TEST
// additional load source
AbstractExtSysMonSource *loadItem = new LoadSource(this, QStringList());
foreach(QString source, loadItem->sources())
m_map[source] = loadItem;
#endif /* BUILD_TEST */
}

View File

@ -0,0 +1,75 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "loadsource.h"
#include "awdebug.h"
LoadSource::LoadSource(QObject *parent, const QStringList args)
: AbstractExtSysMonSource(parent, args)
{
Q_ASSERT(args.count() == 0);
qCDebug(LOG_ESM);
}
LoadSource::~LoadSource()
{
qCDebug(LOG_ESM);
}
QVariant LoadSource::data(QString source)
{
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Source" << source;
source.remove(QString("load/load"));
return source.toInt();
}
QVariantMap LoadSource::initialData(QString source) const
{
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Source" << source;
QVariantMap data;
if (source.startsWith(QString("load/load"))) {
data[QString("min")] = 0;
data[QString("max")] = 0;
data[QString("name")] = QString("Simple sources for load tests");
data[QString("type")] = QString("int");
data[QString("units")] = QString("");
}
return data;
}
QStringList LoadSource::sources() const
{
qCDebug(LOG_ESM);
QStringList sources;
for (int i=0; i<1000; i++)
sources.append(QString("load/load%1").arg(i));
return sources;
}

View File

@ -0,0 +1,38 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef LOADSOURCE_H
#define LOADSOURCE_H
#include <QObject>
#include "abstractextsysmonsource.h"
class LoadSource : public AbstractExtSysMonSource
{
public:
explicit LoadSource(QObject *parent, const QStringList args);
virtual ~LoadSource();
QVariant data(QString source);
QVariantMap initialData(QString source) const;
void run() {};
QStringList sources() const;
};
#endif /* LOADSOURCE_H */