diff --git a/energyplugin/etm/energyarbitrator.cpp b/energyplugin/etm/energyarbitrator.cpp index c4ae348..2433946 100644 --- a/energyplugin/etm/energyarbitrator.cpp +++ b/energyplugin/etm/energyarbitrator.cpp @@ -97,7 +97,8 @@ void EnergyArbitrator::update(const QDateTime ¤tDateTime) } // 7 : dispatch matériel (même position que l'amont — m_chargingActions rempli par getPlan()) - adjustEvChargers(currentDateTime); + applyActionsToAdapters(slot); // ECS (kind==Stage) → m_ecsAdapters + adjustEvChargers(currentDateTime); // EV (kind==Setpoint) → proxy amont jusqu'à 3g } SurplusContext EnergyArbitrator::buildContext(const QDateTime &now) const @@ -146,3 +147,20 @@ void EnergyArbitrator::syncAdapters() m_adapters.take(id)->deleteLater(); } } + +void EnergyArbitrator::applyActionsToAdapters(const Slot &slot) +{ + for (const LoadAction &action : slot.actions) { + // EV (Setpoint) : dispatché par adjustEvChargers() amont jusqu'à 3g. + if (action.kind != LoadAction::Stage) + continue; + + EcsRelayAdapter *adapter = m_ecsAdapters.value(action.loadId); + if (!adapter) { + qCWarning(dcNymeaEnergy()) << "[Arbitre] action Stage sans adaptateur ECS:" << action.loadId; + continue; + } + // L'adaptateur applique, écrête et verrouille (anti-rebond) — il ne décide pas. + adapter->applyAction(action); + } +} diff --git a/energyplugin/etm/energyarbitrator.h b/energyplugin/etm/energyarbitrator.h index 27dac63..de0d948 100644 --- a/energyplugin/etm/energyarbitrator.h +++ b/energyplugin/etm/energyarbitrator.h @@ -89,7 +89,7 @@ protected: * 2. prepareInformation() * 3. verifyOverloadProtection() + verifyOverloadProtectionRecovery() * 4. m_scheduler->getPlan() → log des decisionReason - * 5. adjustEvChargers() → dispatch matériel + mise à jour états + * 5. applyActionsToAdapters() (ECS Stage) + adjustEvChargers() (EV) → dispatch matériel * * \param currentDateTime Instant courant (timer ou simulation). */ @@ -112,6 +112,18 @@ private: */ void syncAdapters(); + /*! + * \brief Applique les actions d'un Slot aux LoadAdapters non-EV (ECS en 3c). + * + * Itère \c slot.actions et dispatche chaque action \c kind==Stage vers le + * EcsRelayAdapter correspondant (\c m_ecsAdapters[action.loadId]). Les actions EV + * (\c kind==Setpoint) restent dispatchées par \c adjustEvChargers() amont jusqu'à 3g. + * L'adaptateur écrête/verrouille lui-même (anti-rebond) et ignore toute action sans + * \c reason ou de kind non supporté — aucune décision ici (règle 2). + * \param slot Créneau courant retourné par le scheduler. + */ + void applyActionsToAdapters(const Slot &slot); + RuleBasedScheduler *m_scheduler = nullptr; QHash m_adapters; //!< loadId (ThingId string) → EvAdapter*. QHash m_ecsAdapters; //!< loadId → EcsRelayAdapter*.