From: Jérôme Benoit Date: Thu, 26 Feb 2026 23:52:32 +0000 (+0100) Subject: refactor(ocpp2): remove duplicate EVSE transaction check, use helper X-Git-Tag: ocpp-server@v3.0.0~140 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c0491afb2a95d86470472f132360513b76f65680;p=e-mobility-charging-stations-simulator.git refactor(ocpp2): remove duplicate EVSE transaction check, use helper --- diff --git a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts index 3fe7feda..f9d08f6f 100644 --- a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts @@ -1326,17 +1326,11 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { const hasActiveTransactions = chargingStation.getNumberOfRunningTransactions() > 0 // Check for EVSE-specific active transactions if evseId is provided - let hasEvseActiveTransactions = false + let evseHasActiveTransactions = false if (evseId !== undefined && evseId > 0) { - // Check if there are active transactions on the specific EVSE const evse = chargingStation.evses.get(evseId) - if (evse) { - for (const [, connector] of evse.connectors) { - if (connector.transactionId !== undefined) { - hasEvseActiveTransactions = true - break - } - } + if (evse != null) { + evseHasActiveTransactions = this.hasEvseActiveTransactions(evse) } } @@ -1344,7 +1338,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { if (type === ResetEnumType.Immediate) { if (evseId !== undefined) { // EVSE-specific immediate reset - if (hasEvseActiveTransactions) { + if (evseHasActiveTransactions) { logger.info( `${chargingStation.logPrefix()} ${moduleName}.handleRequestReset: Immediate EVSE reset with active transaction, will terminate transaction and reset EVSE ${evseId.toString()}` )