129 lines
5.8 KiB
C++
129 lines
5.8 KiB
C++
// ============================================================
|
|
// energypluginnymea_extension_diff.cpp
|
|
//
|
|
// DIFF — Modifications à apporter dans energypluginnymea.cpp
|
|
// pour intégrer HeatPumpManager et EnergyPriorityManager.
|
|
//
|
|
// Le fichier d'origine init() fait 12 lignes.
|
|
// Ci-dessous : la version étendue complète.
|
|
// ============================================================
|
|
|
|
// ─────────────────────────────────────────────────────────────
|
|
// energypluginnymea.h — Ajout des includes
|
|
// ─────────────────────────────────────────────────────────────
|
|
|
|
/*
|
|
AVANT :
|
|
#include <energyplugin.h>
|
|
|
|
APRÈS :
|
|
#include <energyplugin.h>
|
|
#include "heatpumpmanager.h"
|
|
#include "energyprioritymanager.h"
|
|
|
|
Aucun nouveau membre privé nécessaire : les managers sont
|
|
propriétés du parent (this) via QObject parent-child.
|
|
*/
|
|
|
|
// ─────────────────────────────────────────────────────────────
|
|
// energypluginnymea.cpp — Nouvelle version de init()
|
|
// ─────────────────────────────────────────────────────────────
|
|
|
|
void EnergyPluginNymea::init()
|
|
{
|
|
qCDebug(dcNymeaEnergy()) << "Initializing nymea.energy plugin (ETM extended)";
|
|
|
|
// ── Configuration & réseau ──────────────────────────────
|
|
EnergyManagerConfiguration *configuration = new EnergyManagerConfiguration(this);
|
|
QNetworkAccessManager *networkManager = new QNetworkAccessManager(this);
|
|
|
|
// ── Spot market ─────────────────────────────────────────
|
|
SpotMarketManager *spotMarketManager = new SpotMarketManager(networkManager, this);
|
|
|
|
// ── Smart charging VE ────────────────────────────────────
|
|
SmartChargingManager *chargingManager = new SmartChargingManager(
|
|
energyManager(), thingManager(), spotMarketManager, configuration, this);
|
|
|
|
// ── [NOUVEAU] Pompe à chaleur + ECS ─────────────────────
|
|
HeatPumpManager *heatPumpManager = new HeatPumpManager(
|
|
energyManager(), thingManager(), this);
|
|
|
|
// ── [NOUVEAU] Gestionnaire de priorité énergétique ──────
|
|
EnergyPriorityManager *priorityManager = new EnergyPriorityManager(
|
|
energyManager(), thingManager(), this);
|
|
|
|
// Enregistrement automatique des charges connues
|
|
// (les managers écoutent ThingManager::thingAdded en interne)
|
|
|
|
// ── JSON-RPC — handler étendu ────────────────────────────
|
|
// Passe les nouveaux managers au handler pour exposition API
|
|
auto *handler = new NymeaEnergyJsonHandler(
|
|
spotMarketManager,
|
|
chargingManager,
|
|
heatPumpManager, // [NOUVEAU]
|
|
priorityManager, // [NOUVEAU]
|
|
this
|
|
);
|
|
jsonRpcServer()->registerExperienceHandler(handler, 0, 9); // Version incrémentée : 9
|
|
}
|
|
|
|
// ─────────────────────────────────────────────────────────────
|
|
// Modification correspondante du constructeur NymeaEnergyJsonHandler
|
|
// ─────────────────────────────────────────────────────────────
|
|
|
|
/*
|
|
AVANT :
|
|
NymeaEnergyJsonHandler::NymeaEnergyJsonHandler(
|
|
SpotMarketManager *spotMarketManager,
|
|
SmartChargingManager *smartChargingManager,
|
|
QObject *parent)
|
|
|
|
APRÈS :
|
|
NymeaEnergyJsonHandler::NymeaEnergyJsonHandler(
|
|
SpotMarketManager *spotMarketManager,
|
|
SmartChargingManager *smartChargingManager,
|
|
HeatPumpManager *heatPumpManager,
|
|
EnergyPriorityManager *priorityManager,
|
|
QObject *parent)
|
|
: JsonHandler{parent},
|
|
m_spotMarketManager{spotMarketManager},
|
|
m_smartChargingManager{smartChargingManager},
|
|
m_heatPumpManager{heatPumpManager},
|
|
m_priorityManager{priorityManager}
|
|
{
|
|
// ... méthodes existantes ...
|
|
|
|
// Appel d'enregistrement des nouvelles méthodes :
|
|
registerHeatPumpAndDHWMethods(this);
|
|
|
|
// Connexion des notifications PAC
|
|
connect(m_heatPumpManager, &HeatPumpManager::heatPumpStateChanged,
|
|
this, [this](const ThingId &id, const QString &name, const QVariant &val) {
|
|
emit HeatPumpStateChanged({{"thingId", id}, {"stateName", name}, {"value", val}});
|
|
});
|
|
|
|
// Connexion des notifications ECS
|
|
connect(m_heatPumpManager, &HeatPumpManager::dhwStateChanged,
|
|
this, [this](const ThingId &id, const QString &name, const QVariant &val) {
|
|
emit DHWStateChanged({{"thingId", id}, {"stateName", name}, {"value", val}});
|
|
});
|
|
|
|
// Connexion des notifications gestion énergie
|
|
connect(m_priorityManager, &EnergyPriorityManager::managedLoadChanged,
|
|
this, [this](const ThingId &id) {
|
|
const auto load = m_priorityManager->managedLoad(id);
|
|
emit ManagedLoadChanged({
|
|
{"thingId", id},
|
|
{"priority", enumValueName(load.priority)},
|
|
{"allocatedPower", load.allocatedPower},
|
|
{"active", load.active}
|
|
});
|
|
});
|
|
|
|
connect(m_priorityManager, &EnergyPriorityManager::totalAvailablePowerChanged,
|
|
this, [this](double watts) {
|
|
emit TotalAvailablePowerChanged({{"totalAvailablePower", watts}});
|
|
});
|
|
}
|
|
*/
|