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