Patrick Schurig 3084b885d8 test : reproductions du lot délestage V2C (rouges sur b054780)
Mock : classe chargerUnmetered, une borne qui mesure sa puissance mais
publie ses courants sous currentL1..3 (comme le plugin V2C Trydan), jamais
sous currentPhaseX. EvCharger::meteredPhases() y est vide ; aucune borne du
mock ne produisait ce cas.

- testOffPeakUnmeteredChargerSettlesUnderThePhaseLimit : heures creuses,
  limite 25 A, marge 10 %, borne non mesurée (mono sur A, tri) ; rouge :
  16, 6, 13, 6, 13… A, et 6 A tenus avec le lave-vaisselle.
- testUnmeteredChargerGivesNothingBackWhenUnsure : triphasée avec voiture
  monophasée, courants par phase publiés et nuls ; vert (témoin).
- testWaterfallChargerSettlesUnderThePhaseLimit (question 5) : hors heures
  creuses ; rouge : 16, 9, 16, 9… A (maison légère), 16 A puis coupée par
  L4 à 26 A pour 25 (maison chargée).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 14:16:36 +01:00

86 lines
3.4 KiB
C++

// 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 <https://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef INTEGRATIONPLUGINENERGYMOCKS_H
#define INTEGRATIONPLUGINENERGYMOCKS_H
#include "integrations/integrationplugin.h"
#include <QTimer>
#include <QDateTime>
#include <QObject>
#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<Thing*, EnergyMockController *> 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<Thing*, QDateTime> 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);
void updateUnmeteredChargerMeter(Thing *thing);
};
#endif // INTEGRATIONPLUGINENERGYMOCKS_H