// SPDX-License-Identifier: GPL-3.0-or-later
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright (C) 2013 - 2024, nymea GmbH
* Copyright (C) 2024 - 2025, chargebyte austria GmbH
*
* This file is part of nymea-energy-plugin-nymea.
*
* nymea-energy-plugin-nymea.s free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* nymea-energy-plugin-nymea.s distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with nymea-energy-plugin-nymea. If not, see .
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef INTEGRATIONPLUGINENERGYMOCKS_H
#define INTEGRATIONPLUGINENERGYMOCKS_H
#include "integrations/integrationplugin.h"
#include
#include
#include
#include "extern-plugininfo.h"
class EnergyMockController;
class IntegrationPluginEnergyMocks: public IntegrationPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "io.nymea.IntegrationPlugin" FILE "integrationpluginenergymocks.json")
Q_INTERFACES(IntegrationPlugin)
public:
explicit IntegrationPluginEnergyMocks(QObject *parent = nullptr);
void setupThing(ThingSetupInfo *info) override;
void thingRemoved(Thing *thing) override;
void executeAction(ThingActionInfo *info) override;
private:
QHash m_controllers;
/*!
* \brief Intègre `currentPower` dans `totalEnergyConsumed`, pour TOUS les compteurs.
*
* \par Pourquoi le mock doit le faire
* Le compteur du banc valait **10 kWh depuis le 1er septembre** : une constante, pas un
* cumul. `deliveredWh` restait donc à 0 et `remainingWh` à 4 000 — l'étalement adaptatif
* n'était **jamais exercé**, et le comportement se confondait avec `unmeasurable` pour une
* raison entièrement différente et bénigne.
*
* **Un compteur figé est un compteur qui n'existe pas pour tout ce qui l'intègre.** Quatrième
* occurrence d'un mock plus homogène que la réalité (`docs/INVENTAIRE_MOCK.md`).
*
* \note `totalEnergyConsumed` est déclaré **`cached`** : c'est un compteur de VIE, il
* **continue** au redémarrage du mock et ne repart pas de zéro (\rule{LM-1014-b} : la
* question posée, et la réponse choisie explicitement). Repartir de zéro ferait reculer un
* cumul monotone, ce que la garde de sémantique traite justement comme une anomalie —
* le mock produirait alors un cas que le terrain ne produit pas.
*/
void integrerEnergie();
//! Instant de la dernière intégration, par Thing. Absent = première passe, qui n'intègre
//! rien : sans durée derrière elle, elle fabriquerait de l'énergie.
QHash m_derniereIntegration;
QTimer *m_integrateur = nullptr;
// Update the meter data of the charger based on the current max charging current, connected, power and plugged in state
void updateChargerMeter(Thing *thing);
};
#endif // INTEGRATIONPLUGINENERGYMOCKS_H