debug sauvegarde\naffichage fleche
This commit is contained in:
@@ -30,10 +30,19 @@ public:
|
||||
m_timestamps.reserve(360 + 16);
|
||||
restoreHistory();
|
||||
// Sauvegarde automatique toutes les 10 minutes
|
||||
connect(&m_saveTimer, &QTimer::timeout, this, &BarometerTrend::saveHistory);
|
||||
m_saveTimer.start(10 * 60 * 1000);
|
||||
m_saveTimer = new QTimer(this);
|
||||
connect(m_saveTimer, &QTimer::timeout, this, &BarometerTrend::saveHistory);
|
||||
m_saveTimer->start(10 * 60 * 1000);
|
||||
if (!m_saveTimer->isActive())
|
||||
{
|
||||
debug(DEBUGMACRO, "Le timer n'est pas démarré", ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
~BarometerTrend()
|
||||
{
|
||||
saveHistory();
|
||||
}
|
||||
void addPressure(double pressure_hPa)
|
||||
{
|
||||
debug(DEBUGMACRO, "adding pressure " + QByteArray::number(pressure_hPa), DEBUG);
|
||||
@@ -349,7 +358,7 @@ public:
|
||||
private:
|
||||
QVector<double> m_values;
|
||||
QVector<QDateTime> m_timestamps;
|
||||
QTimer m_saveTimer;
|
||||
QTimer *m_saveTimer;
|
||||
|
||||
private slots:
|
||||
void saveHistory()
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <QHttpServerResponse>
|
||||
#include "pws2mqtt.h"
|
||||
#include "mqtt.h"
|
||||
#include "src/barometertrend.h"
|
||||
#include "version.h"
|
||||
#include <curl/curl.h>
|
||||
#include <sys/types.h>
|
||||
@@ -36,6 +37,7 @@ using namespace std;
|
||||
Pws2mqtt *pws2mqtt;
|
||||
MqttClient *mqttClient;
|
||||
QHttpServer *httpServer;
|
||||
BarometerTrend *baro;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -59,8 +61,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
//declaration of debug level
|
||||
pws2mqtt = new Pws2mqtt;
|
||||
baro = new BarometerTrend;
|
||||
|
||||
pws2mqtt->listeningHttp();
|
||||
|
||||
|
||||
|
||||
//notify (QString("Program started"), "default");
|
||||
a.exec();
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
extern MqttClient *mqttClient;
|
||||
extern Pws2mqtt *pws2mqtt;
|
||||
extern QHttpServer *httpServer;
|
||||
extern BarometerTrend *baro;
|
||||
UtciCalculator calc;
|
||||
BarometerTrend baro;
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -229,17 +229,18 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
|
||||
debug (DEBUGMACRO, name + " : " + QByteArray::number(propertyValue), DEBUG);
|
||||
propertyList[name] = formatNotifString(propertyName[name].first, propertyName[name].second, QByteArray::number(propertyValue));
|
||||
propertiesValue[name] = propertyValue;
|
||||
}else if (name == "windspeedmph" or name == "windgustmph")
|
||||
}else if (name == "windspeedmph")
|
||||
{
|
||||
QString msg = "";
|
||||
static QDateTime timeWind = QDateTime::currentDateTime().addSecs(-600);
|
||||
quint8 i;
|
||||
static QDateTime timeWind = QDateTime::currentDateTime().addSecs(-600);
|
||||
quint8 windPriority = 1;
|
||||
|
||||
propertiesValue["vent"] = round(mphTokmh(value.toFloat()));
|
||||
|
||||
debug (DEBUGMACRO, name + " : " + QByteArray::number(propertiesValue["vent"]), DEBUG);
|
||||
|
||||
for (quint8 i=0; i<forceVent.size();i++)
|
||||
for (i=0; i<forceVent.size();i++)
|
||||
{
|
||||
if (propertiesValue["vent"] <= forceVent[i][0].toDouble())
|
||||
{
|
||||
@@ -249,21 +250,34 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
|
||||
}
|
||||
}
|
||||
|
||||
if (propertyList["forcevent"] != msg or propertyList["rafales"] != msg)
|
||||
{
|
||||
if (name == "windspeedmph")
|
||||
{
|
||||
//propertyList["forcevent"] = msg;
|
||||
propertyList[name] = formatNotifString ("Vent - " + msg, propertyName[name].second , QByteArray::number(propertiesValue["vent"]));
|
||||
}else
|
||||
{
|
||||
propertyList[name] = formatNotifString (propertyName[name].first, propertyName[name].second , QByteArray::number(propertiesValue["vent"]));
|
||||
}
|
||||
priority = setPriority(priority, windPriority);
|
||||
propertyList[name] = formatNotifString ("Vent - " + msg, propertyName[name].second , QByteArray::number(propertiesValue["vent"]));
|
||||
propertiesValue["forcevent"] = i;
|
||||
if (i >= 5)
|
||||
{
|
||||
attachment = this->outputPath;
|
||||
}
|
||||
|
||||
attachment = this->outputPath;
|
||||
if (propertiesValue["forcevent"] != i or propertiesValue["rafales"] != i)
|
||||
{
|
||||
priority = qMax(priority, windPriority);
|
||||
}
|
||||
debug (DEBUGMACRO, "priority = " + QString::number(priority), DEBUG);
|
||||
}else if (name == "windgustmph")
|
||||
{
|
||||
QString msg = "";
|
||||
static QDateTime timeWind = QDateTime::currentDateTime().addSecs(-600);
|
||||
|
||||
propertiesValue[name] = round(mphTokmh(value.toFloat()));
|
||||
|
||||
debug (DEBUGMACRO, name + " : " + QByteArray::number(propertiesValue["rafale"]), DEBUG);
|
||||
|
||||
propertyList[name] = formatNotifString (propertyName[name].first, propertyName[name].second , QByteArray::number(propertiesValue[name]));
|
||||
|
||||
if (propertiesValue["rafales"] > 50)
|
||||
{
|
||||
priority = qMax(priority, (quint8)4);
|
||||
}
|
||||
debug (DEBUGMACRO, "priority = " + QString::number(priority), DEBUG);
|
||||
}else if (name == "rainin")
|
||||
{
|
||||
static double ecart;
|
||||
@@ -312,12 +326,12 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
|
||||
|
||||
propertyValue = round(tohPa(pair.second.toFloat()) * 100) / 100;
|
||||
debug (DEBUGMACRO, "Barometre en hPa : " + QByteArray::number(propertyValue), DEBUG);
|
||||
baro.addPressure(propertyValue);
|
||||
baro->addPressure(propertyValue);
|
||||
propertyList[name] = formatNotifString(propertyName[name].first, "", QByteArray::number(propertyValue));
|
||||
propertiesValue[name] = propertyValue;
|
||||
|
||||
static QString prevision;
|
||||
auto ret = baro.forecast(propertiesValue["tempf"], propertiesValue["humidity"]);
|
||||
auto ret = baro->forecast(propertiesValue["tempf"], propertiesValue["humidity"]);
|
||||
|
||||
QString newPrevision = ret.message;
|
||||
if (prevision != newPrevision)
|
||||
|
||||
Reference in New Issue
Block a user