Skip to content
Snippets Groups Projects
Commit e163d25e authored by Peter Altenbernd's avatar Peter Altenbernd
Browse files

InfoListe eingefügt

parent d26fc71d
No related branches found
No related tags found
No related merge requests found
...@@ -9,9 +9,9 @@ SHsensor * SHsensor::S[SHNodeIdSize * SHSensorIdSize] = {nullptr}; ...@@ -9,9 +9,9 @@ SHsensor * SHsensor::S[SHNodeIdSize * SHSensorIdSize] = {nullptr};
QMap<QString,int> SHsensor::NID; QMap<QString,int> SHsensor::NID;
QNetworkAccessManager * SHsensor::m_tasmota = nullptr; QNetworkAccessManager * SHsensor::m_tasmota = nullptr;
QString SHsensor::m_supply = NOVALUE; QString SHsensor::m_brutto = NOVALUE;
QString SHsensor::m_difference = NOVALUE; QString SHsensor::m_netto = NOVALUE;
QString SHsensor::m_maxDiff = NOVALUE; QStringList SHsensor::m_info = {};
QString SHsensor::m_errcnt_total = NOVALUE; QString SHsensor::m_errcnt_total = NOVALUE;
QString SHsensor::m_errcnt_current = NOVALUE; QString SHsensor::m_errcnt_current = NOVALUE;
...@@ -801,11 +801,11 @@ SHsensor::SensorType SHsensor::type() const ...@@ -801,11 +801,11 @@ SHsensor::SensorType SHsensor::type() const
/* /*
* *
*/ */
void SHsensor::setSolarInfo(int newSupply, int newDifference, int newMaxDiff) void SHsensor::setSolarInfo(int newBrutto, int newNetto, const QStringList &newInfo)
{ {
SHsensor::m_supply = QString::number(newSupply); SHsensor::m_brutto = QString::number(newBrutto);
SHsensor::m_difference = QString::number(newDifference); SHsensor::m_netto = QString::number(newNetto);
SHsensor::m_maxDiff = QString::number(newMaxDiff); SHsensor::m_info = newInfo;
} }
...@@ -830,7 +830,7 @@ void SHsensor::setErrorInfo(int errcnt_total, int errcnt_current, bool err_solar ...@@ -830,7 +830,7 @@ void SHsensor::setErrorInfo(int errcnt_total, int errcnt_current, bool err_solar
*/ */
QStringList SHsensor::getInfo() { QStringList SHsensor::getInfo() {
QStringList qsl = { QStringList qsl = {
SHsensor::m_supply, SHsensor::m_difference, SHsensor::m_maxDiff, // solar SHsensor::m_brutto, SHsensor::m_netto, SHsensor::m_info.join(";"), // solar
SHsensor::m_errcnt_total, SHsensor::m_errcnt_current, SHsensor::m_err_solar // errors SHsensor::m_errcnt_total, SHsensor::m_errcnt_current, SHsensor::m_err_solar // errors
}; };
......
...@@ -122,9 +122,9 @@ private: ...@@ -122,9 +122,9 @@ private:
static QMap<QString,int> NID; // Zur Suche nach Namen static QMap<QString,int> NID; // Zur Suche nach Namen
// solar info: // solar info:
static QString m_supply; static QString m_brutto;
static QString m_difference; static QString m_netto;
static QString m_maxDiff; static QStringList m_info;
static QString m_errcnt_total; static QString m_errcnt_total;
static QString m_errcnt_current; static QString m_errcnt_current;
...@@ -143,7 +143,7 @@ public: ...@@ -143,7 +143,7 @@ public:
static void initStatics(QNetworkAccessManager * tasmota); // für NID Map und Tasmota Manager static void initStatics(QNetworkAccessManager * tasmota); // für NID Map und Tasmota Manager
static int nid(QString name); static int nid(QString name);
static void setSolarInfo(int newSupply, int newDifference, int newMaxDiff); static void setSolarInfo(int newBrutto, int newNetto, const QStringList & newInfo);
static void setErrorInfo(int errcnt_total, int errcnt_current, bool err_solar); static void setErrorInfo(int errcnt_total, int errcnt_current, bool err_solar);
static QStringList getInfo(); static QStringList getInfo();
......
...@@ -33,32 +33,14 @@ void SolarControl::process() { ...@@ -33,32 +33,14 @@ void SolarControl::process() {
// vorhandene Strommenge berechnen (supply) berechnung und dabei Anzeige vorbereiten: // vorhandene Strommenge berechnen (supply) berechnung und dabei Anzeige vorbereiten:
int autoUsed = 0; int autoSmartUsed = 0;
int smartBelowTempUsed = 0;
int supply = m_producer->value().toInt(); int supply = m_producer->value().toInt();
for (auto swtch : m_S) // dynamische Verbraucher dazu rechnen: for (auto swtch : m_S) // dynamische Verbraucher dazu rechnen:
if (swtch->state() == SHactuator::State::ON) if (swtch->state() == SHactuator::State::ON and (swtch->mode() == HeatControl::Mode::Auto or swtch->mode() == HeatControl::Mode::Smart))
switch (swtch->mode()) { autoSmartUsed += swtch->demand();
case HeatControl::Mode::Auto:
autoUsed += swtch->demand();
break;
case HeatControl::Mode::Smart:
if (swtch->minReached())
autoUsed += swtch->demand();
else
smartBelowTempUsed += swtch->demand();
break;
default:
break;
}
supply += autoUsed; // + smartBelowTempUsed;
// SHsensor::setSolarInfo(supply /* solar */ , supply-autoUsed /* rest */, supply /* brutto */); supply += autoSmartUsed; // das braucht der Algorithmus unten
supply += smartBelowTempUsed; // das braucht der Algorithmus unten
// richtige Reihenfolge herstellen: // richtige Reihenfolge herstellen:
...@@ -139,13 +121,23 @@ void SolarControl::process() { ...@@ -139,13 +121,23 @@ void SolarControl::process() {
// TODO: hier brutto und netto setzen: // TODO: hier brutto und netto setzen:
// Danach kann die Schleife bzw. das Switch Case oben vereinfacht werden // - ggf. Mutex setzen, damit sich nicht zwischenzeitlich was ändert
// ggf. Mutex setzen, damit sich nicht zwischenzeitlich was ändert // - aktuelle Verbrauchswerte in Liste (ON, MAN_ON, AUTO_ON, SMART_ON bzw. einfach ON und demand>0) für erweiterte Info-Anzeige (als dann 3. Paramenter) -> HIER <-
// aktuelle Verbraucher
QStringList infoList;
for (auto swtch : m_S)
if (swtch->state() == SHactuator::State::ON) {
infoList << swtch->name() << QString::number(swtch->demand());
}
SHsensor::setSolarInfo(supply /* solar */ , netto /* rest */, supply /* brutto */); SHsensor::setSolarInfo(supply /* brutto */ , netto, infoList);
if (supply > 0 and netto < 0) // if ((supply > 0 and netto < 0) or (supply <= 0 and netto != supply))
qDebug() << "brutto / netto FEHLER" << supply << netto; // qDebug() << "brutto / netto FEHLER" << supply << netto;
qDebug() << "===> SolarControl::process" << s_output << " <==="; qDebug() << "===> SolarControl::process" << s_output << " <===";
// SHsensor::displayMem("SolarControl::process ENDE"); // SHsensor::displayMem("SolarControl::process ENDE");
......
...@@ -60,9 +60,9 @@ public: ...@@ -60,9 +60,9 @@ public:
QString sensorValue() const; QString sensorValue() const;
QString nodeName() const; QString nodeName() const;
QString supply() const; QString brutto() const;
QString difference() const; QString netto() const;
QString maxDiff() const; QString info() const;
QString errcntTotal() const; QString errcntTotal() const;
QString errcntCurrent() const; QString errcntCurrent() const;
...@@ -83,9 +83,9 @@ private: ...@@ -83,9 +83,9 @@ private:
QString m_nodeName; QString m_nodeName;
// solar info: // solar info:
QString m_supply; QString m_brutto;
QString m_difference; QString m_netto;
QString m_maxDiff; QString m_info;
QString m_errcntTotal; QString m_errcntTotal;
QString m_errcntCurrent; QString m_errcntCurrent;
......
...@@ -261,9 +261,9 @@ webSocketMsg::webSocketMsg(QString jsonMSG) ...@@ -261,9 +261,9 @@ webSocketMsg::webSocketMsg(QString jsonMSG)
// Reihenfolge: m_supply, m_difference, m_maxDiff, m_errcnt_total, m_errcnt_current, m_err_solar // Reihenfolge: m_supply, m_difference, m_maxDiff, m_errcnt_total, m_errcnt_current, m_err_solar
m_supply = qsl[0]; m_brutto = qsl[0];
m_difference = qsl[1]; m_netto = qsl[1];
m_maxDiff = qsl[2]; m_info = qsl[2];
m_errcntTotal= qsl[3]; m_errcntTotal= qsl[3];
m_errcntCurrent = qsl[4]; m_errcntCurrent = qsl[4];
m_errSolar = qsl[5]; m_errSolar = qsl[5];
...@@ -454,7 +454,7 @@ QJsonObject webSocketMsg::toJSON() const ...@@ -454,7 +454,7 @@ QJsonObject webSocketMsg::toJSON() const
case OPcode::getInfo: case OPcode::getInfo:
if (not m_request) { if (not m_request) {
::toJSON(jsonObj, webSocketMsg::c_value, "solar info"); // hier muss irgendwas stehen, da mit "" m_request auf true gesetzt wird ::toJSON(jsonObj, webSocketMsg::c_value, "solar info"); // hier muss irgendwas stehen, da mit "" m_request auf true gesetzt wird
QStringList qsl = {m_supply, m_difference, m_maxDiff, m_errcntTotal, m_errcntCurrent, m_errSolar}; QStringList qsl = {m_brutto, m_netto, m_info, m_errcntTotal, m_errcntCurrent, m_errSolar};
::toJSON(jsonObj, webSocketMsg::c_infos, qsl.join(",")); ::toJSON(jsonObj, webSocketMsg::c_infos, qsl.join(","));
} }
...@@ -596,9 +596,9 @@ QJsonObject webSocketMsg::processGet() ...@@ -596,9 +596,9 @@ QJsonObject webSocketMsg::processGet()
// Reihenfolge: m_supply, m_difference, m_maxDiff, m_errcnt_total, m_errcnt_current, m_err_solar // Reihenfolge: m_supply, m_difference, m_maxDiff, m_errcnt_total, m_errcnt_current, m_err_solar
m_supply = qsl[0]; m_brutto = qsl[0];
m_difference = qsl[1]; m_netto = qsl[1];
m_maxDiff = qsl[2]; m_info = qsl[2];
m_errcntTotal = qsl[3]; m_errcntTotal = qsl[3];
m_errcntCurrent = qsl[4]; m_errcntCurrent = qsl[4];
...@@ -726,9 +726,9 @@ QString webSocketMsg::nodeName() const ...@@ -726,9 +726,9 @@ QString webSocketMsg::nodeName() const
/* /*
* *
*/ */
QString webSocketMsg::supply() const QString webSocketMsg::brutto() const
{ {
return m_supply; return m_brutto;
} }
...@@ -736,9 +736,9 @@ QString webSocketMsg::supply() const ...@@ -736,9 +736,9 @@ QString webSocketMsg::supply() const
/* /*
* *
*/ */
QString webSocketMsg::difference() const QString webSocketMsg::netto() const
{ {
return m_difference; return m_netto;
} }
...@@ -746,9 +746,9 @@ QString webSocketMsg::difference() const ...@@ -746,9 +746,9 @@ QString webSocketMsg::difference() const
/* /*
* *
*/ */
QString webSocketMsg::maxDiff() const QString webSocketMsg::info() const
{ {
return m_maxDiff; return m_info;
} }
QString webSocketMsg::errcntTotal() const QString webSocketMsg::errcntTotal() const
...@@ -779,7 +779,7 @@ void webSocketMsg::setDefaults() ...@@ -779,7 +779,7 @@ void webSocketMsg::setDefaults()
m_temp = -42.0; m_temp = -42.0;
m_time = QTime::fromString("0:00"); m_time = QTime::fromString("0:00");
m_nodeName = "---"; m_nodeName = "---";
m_supply = m_difference = m_maxDiff = NOVALUE; m_brutto = m_netto = m_info = NOVALUE;
m_errcntTotal= m_errcntCurrent = m_errSolar = NOVALUE; m_errcntTotal= m_errcntCurrent = m_errSolar = NOVALUE;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment