Clean up code
This commit is contained in:
parent
7042751703
commit
eba8d91f36
3 changed files with 23 additions and 35 deletions
|
@ -21,6 +21,7 @@ Battery::Battery(Settings* newSettings, Logger* newLogger, QObject* parent) : QO
|
||||||
{
|
{
|
||||||
settings = newSettings;
|
settings = newSettings;
|
||||||
logger = newLogger;
|
logger = newLogger;
|
||||||
|
const QString notFound = "not found";
|
||||||
|
|
||||||
QStringList filenames;
|
QStringList filenames;
|
||||||
|
|
||||||
|
@ -34,8 +35,7 @@ Battery::Battery(Settings* newSettings, Logger* newLogger, QObject* parent) : QO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chargeFile) logL("Battery charge file: " + chargeFile->fileName());
|
logL("Battery charge file: " + (chargeFile ? chargeFile->fileName() : notFound));
|
||||||
else logL("Battery charge file: not found!");
|
|
||||||
|
|
||||||
// Number: battery/charging current, e.g. -1450000 (-145mA)
|
// Number: battery/charging current, e.g. -1450000 (-145mA)
|
||||||
filenames.clear();
|
filenames.clear();
|
||||||
|
@ -49,8 +49,7 @@ Battery::Battery(Settings* newSettings, Logger* newLogger, QObject* parent) : QO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentFile) logL("Charging/discharging current file: " + currentFile->fileName());
|
logL("Charging/discharging current file: " + (currentFile ? currentFile->fileName() : notFound));
|
||||||
else logL("Charging/discharging current file: not found!");
|
|
||||||
|
|
||||||
// String: charging, discharging, full, empty, unknown (others?)
|
// String: charging, discharging, full, empty, unknown (others?)
|
||||||
filenames.clear();
|
filenames.clear();
|
||||||
|
@ -64,8 +63,7 @@ Battery::Battery(Settings* newSettings, Logger* newLogger, QObject* parent) : QO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stateFile) logL("Status file: " + stateFile->fileName());
|
logL("Status file: " + (stateFile ? stateFile->fileName() : notFound));
|
||||||
else logL("Status file: not found!");
|
|
||||||
|
|
||||||
// Number: 0 or 1
|
// Number: 0 or 1
|
||||||
filenames.clear();
|
filenames.clear();
|
||||||
|
@ -79,8 +77,7 @@ Battery::Battery(Settings* newSettings, Logger* newLogger, QObject* parent) : QO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chargerConnectedFile) logL("Charger status file: " + chargerConnectedFile->fileName());
|
logL("Charger status file: " + (chargerConnectedFile ? chargerConnectedFile->fileName() : notFound));
|
||||||
else logL("Charger status file: not found!");
|
|
||||||
|
|
||||||
// Number: temperature
|
// Number: temperature
|
||||||
filenames.clear();
|
filenames.clear();
|
||||||
|
@ -94,8 +91,7 @@ Battery::Battery(Settings* newSettings, Logger* newLogger, QObject* parent) : QO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(temperatureFile) logL("Battery temperature file: " + temperatureFile->fileName());
|
logL("Battery temperature file: " + (temperatureFile ? temperatureFile->fileName() : notFound));
|
||||||
else logL("Battery temperature file: not found!");
|
|
||||||
|
|
||||||
// String: health state
|
// String: health state
|
||||||
filenames.clear();
|
filenames.clear();
|
||||||
|
@ -108,8 +104,7 @@ Battery::Battery(Settings* newSettings, Logger* newLogger, QObject* parent) : QO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(healthFile) logL("Battery health file: " + healthFile->fileName());
|
logL("Battery health file: " + (healthFile ? healthFile->fileName() : notFound));
|
||||||
else logL("Battery health file: not found!");
|
|
||||||
|
|
||||||
// Charger control file
|
// Charger control file
|
||||||
filenames.clear();
|
filenames.clear();
|
||||||
|
@ -143,11 +138,10 @@ Battery::Battery(Settings* newSettings, Logger* newLogger, QObject* parent) : QO
|
||||||
chargingEnabledFile = Q_NULLPTR;
|
chargingEnabledFile = Q_NULLPTR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!QSysInfo::machineHostName().contains("SailfishEmul")) {
|
else {
|
||||||
logL("Charger control file not found!");
|
logL("Charger control file: " + notFound);
|
||||||
logL("Please contact the developer with your device model!");
|
logL("Please contact the developer with your device model!");
|
||||||
}
|
}
|
||||||
else logL("Charger control file: not found!");
|
|
||||||
|
|
||||||
updateData();
|
updateData();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ Battery::Battery(Logger* newLogger, bool loglevelSet, QCoreApplication *app, QOb
|
||||||
{
|
{
|
||||||
logger = newLogger;
|
logger = newLogger;
|
||||||
settings = new Settings(logger, this);
|
settings = new Settings(logger, this);
|
||||||
|
const QString notFound = "not found";
|
||||||
|
|
||||||
// Read log level from config - if not already set
|
// Read log level from config - if not already set
|
||||||
if(!loglevelSet) {
|
if(!loglevelSet) {
|
||||||
|
@ -45,8 +46,7 @@ Battery::Battery(Logger* newLogger, bool loglevelSet, QCoreApplication *app, QOb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chargeFile) logL("Battery charge file: " + chargeFile->fileName());
|
logL("Battery charge file: " + (chargeFile ? chargeFile->fileName() : notFound));
|
||||||
else logL("Battery charge file: not found!");
|
|
||||||
|
|
||||||
// Charging/discharging current in microamps, e.g. -1450000 (-145mA)
|
// Charging/discharging current in microamps, e.g. -1450000 (-145mA)
|
||||||
filenames.clear();
|
filenames.clear();
|
||||||
|
@ -60,8 +60,7 @@ Battery::Battery(Logger* newLogger, bool loglevelSet, QCoreApplication *app, QOb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentFile) logL("Charging/discharging current file: " + currentFile->fileName());
|
logL("Charging/discharging current file: " + (currentFile ? currentFile->fileName() : notFound));
|
||||||
else logL("Charging/discharging current file: not found!");
|
|
||||||
|
|
||||||
// Maximum charge current in microamps, e.g. 3500000 (3500mA)
|
// Maximum charge current in microamps, e.g. 3500000 (3500mA)
|
||||||
filenames.clear();
|
filenames.clear();
|
||||||
|
@ -91,7 +90,7 @@ Battery::Battery(Logger* newLogger, bool loglevelSet, QCoreApplication *app, QOb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logL("Max charge current file: not found!");
|
logL("Max charge current file: " + notFound);
|
||||||
}
|
}
|
||||||
settings->setMaxSupportedChargeCurrent(maxSupportedChargeCurrent);
|
settings->setMaxSupportedChargeCurrent(maxSupportedChargeCurrent);
|
||||||
|
|
||||||
|
@ -107,8 +106,7 @@ Battery::Battery(Logger* newLogger, bool loglevelSet, QCoreApplication *app, QOb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stateFile) logL("Status file: " + stateFile->fileName());
|
logL("Status file: " + (stateFile ? stateFile->fileName() : notFound));
|
||||||
else logL("Status file: not found!");
|
|
||||||
|
|
||||||
// Charger connected, bool (number): 0 or 1
|
// Charger connected, bool (number): 0 or 1
|
||||||
filenames.clear();
|
filenames.clear();
|
||||||
|
@ -122,8 +120,7 @@ Battery::Battery(Logger* newLogger, bool loglevelSet, QCoreApplication *app, QOb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chargerConnectedFile) logL("Charger status file: " + chargerConnectedFile->fileName());
|
logL("Charger status file: " + (chargerConnectedFile ? chargerConnectedFile->fileName() : notFound));
|
||||||
else logL("Charger status file: not found!");
|
|
||||||
|
|
||||||
// Number: temperature
|
// Number: temperature
|
||||||
filenames.clear();
|
filenames.clear();
|
||||||
|
@ -137,8 +134,7 @@ Battery::Battery(Logger* newLogger, bool loglevelSet, QCoreApplication *app, QOb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(temperatureFile) logL("Battery temperature file: " + temperatureFile->fileName());
|
logL("Battery temperature file: " + (temperatureFile ? temperatureFile->fileName() : notFound));
|
||||||
else logL("Battery temperature file: not found!");
|
|
||||||
|
|
||||||
// String: health state
|
// String: health state
|
||||||
filenames.clear();
|
filenames.clear();
|
||||||
|
@ -151,8 +147,7 @@ Battery::Battery(Logger* newLogger, bool loglevelSet, QCoreApplication *app, QOb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(healthFile) logL("Battery health file: " + healthFile->fileName());
|
logL("Battery health file: " + (healthFile ? healthFile->fileName() : notFound));
|
||||||
else logL("Battery health file: not found!");
|
|
||||||
|
|
||||||
// Charger control file
|
// Charger control file
|
||||||
filenames.clear();
|
filenames.clear();
|
||||||
|
@ -186,11 +181,10 @@ Battery::Battery(Logger* newLogger, bool loglevelSet, QCoreApplication *app, QOb
|
||||||
chargingEnabledFile = Q_NULLPTR;
|
chargingEnabledFile = Q_NULLPTR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!QSysInfo::machineHostName().contains("SailfishEmul")) {
|
else {
|
||||||
logL("Charger control file not found!");
|
logL("Charger control file not found!");
|
||||||
logL("Please contact the developer with your device model!");
|
logL("Please contact the developer with your device model!");
|
||||||
}
|
}
|
||||||
else logL("Charger control file: not found!");
|
|
||||||
|
|
||||||
connect(settings, SIGNAL(resetTimers()), this, SLOT(resetTimers()));
|
connect(settings, SIGNAL(resetTimers()), this, SLOT(resetTimers()));
|
||||||
connect(settings, SIGNAL(setMaxChargeCurrent(int)), this, SLOT(setMaxChargeCurrent(int)));
|
connect(settings, SIGNAL(setMaxChargeCurrent(int)), this, SLOT(setMaxChargeCurrent(int)));
|
||||||
|
|
Loading…
Reference in a new issue