From 8f77f58afd5fd41d745e370d6b2f1b69066715b9 Mon Sep 17 00:00:00 2001 From: c-jimenez <18682655+c-jimenez@users.noreply.github.com> Date: Mon, 20 May 2024 13:33:47 +0200 Subject: [PATCH] [localcontroller] Remove dual notification from IRtc::ISpy interface when LocalController::ChargePointProxy has been instanciated from CentralSystem::ChargePointProxy --- src/centralsystem/chargepoint/ChargePointProxy.cpp | 6 ++++++ src/centralsystem/chargepoint/ChargePointProxy.h | 3 +++ src/localcontroller/chargepoint/ChargePointProxy.cpp | 3 +++ 3 files changed, 12 insertions(+) diff --git a/src/centralsystem/chargepoint/ChargePointProxy.cpp b/src/centralsystem/chargepoint/ChargePointProxy.cpp index fe61281d..56be03be 100644 --- a/src/centralsystem/chargepoint/ChargePointProxy.cpp +++ b/src/centralsystem/chargepoint/ChargePointProxy.cpp @@ -78,6 +78,12 @@ ChargePointProxy::ChargePointProxy(ICentralSystem& /** @brief Destructor */ ChargePointProxy::~ChargePointProxy() +{ + unregisterFromRpcSpy(); +} + +/** @brief Unregister to the IRpc::ISpy interface messages */ +void ChargePointProxy::unregisterFromRpcSpy() { m_rpc->unregisterSpy(*this); } diff --git a/src/centralsystem/chargepoint/ChargePointProxy.h b/src/centralsystem/chargepoint/ChargePointProxy.h index 39ac625a..01ffe5fc 100644 --- a/src/centralsystem/chargepoint/ChargePointProxy.h +++ b/src/centralsystem/chargepoint/ChargePointProxy.h @@ -58,6 +58,9 @@ class ChargePointProxy : public ICentralSystem::IChargePoint, public ocpp::rpc:: /** @brief Destructor */ virtual ~ChargePointProxy(); + /** @brief Unregister to the IRpc::ISpy interface messages */ + void unregisterFromRpcSpy(); + // ICentralSystem::IChargePoint interface /** @copydoc ICentralSystem&& ICentralSystem::IChargePoint::centralSystem() */ diff --git a/src/localcontroller/chargepoint/ChargePointProxy.cpp b/src/localcontroller/chargepoint/ChargePointProxy.cpp index f45ee90f..f87a4c27 100644 --- a/src/localcontroller/chargepoint/ChargePointProxy.cpp +++ b/src/localcontroller/chargepoint/ChargePointProxy.cpp @@ -56,6 +56,9 @@ std::shared_ptr IChargePointProxy::createFrom( // Associate both centralsystem->setChargePointProxy(proxy); + + // Unregister old proxy from RPC spy events + cs_proxy->unregisterFromRpcSpy(); } return proxy;