From: Jérôme Benoit Date: Wed, 10 May 2023 22:44:01 +0000 (+0200) Subject: refactor: group conditions in connector status change check X-Git-Tag: v1.2.14~63 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ff9d1031c851d206c3edca93754b93a8b238aabe;p=e-mobility-charging-stations-simulator.git refactor: group conditions in connector status change check Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index 1326cde4..ef678f31 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -205,16 +205,14 @@ export class OCPPServiceUtils { switch (chargingStation.stationInfo.ocppVersion) { case OCPPVersion.VERSION_16: if ( - connectorId === 0 && - OCPP16Constants.ChargePointStatusChargingStationTransitions.findIndex( - (transition) => transition.from === fromStatus && transition.to === status - ) !== -1 - ) { - transitionAllowed = true; - } else if ( - OCPP16Constants.ChargePointStatusConnectorTransitions.findIndex( - (transition) => transition.from === fromStatus && transition.to === status - ) !== -1 + (connectorId === 0 && + OCPP16Constants.ChargePointStatusChargingStationTransitions.findIndex( + (transition) => transition.from === fromStatus && transition.to === status + ) !== -1) || + (connectorId > 0 && + OCPP16Constants.ChargePointStatusConnectorTransitions.findIndex( + (transition) => transition.from === fromStatus && transition.to === status + ) !== -1) ) { transitionAllowed = true; } @@ -222,16 +220,14 @@ export class OCPPServiceUtils { case OCPPVersion.VERSION_20: case OCPPVersion.VERSION_201: if ( - connectorId === 0 && - OCPP20Constants.ChargingStationStatusTransitions.findIndex( - (transition) => transition.from === fromStatus && transition.to === status - ) !== -1 - ) { - transitionAllowed = true; - } else if ( - OCPP20Constants.ConnectorStatusTransitions.findIndex( - (transition) => transition.from === fromStatus && transition.to === status - ) !== -1 + (connectorId === 0 && + OCPP20Constants.ChargingStationStatusTransitions.findIndex( + (transition) => transition.from === fromStatus && transition.to === status + ) !== -1) || + (connectorId > 0 && + OCPP20Constants.ConnectorStatusTransitions.findIndex( + (transition) => transition.from === fromStatus && transition.to === status + ) !== -1) ) { transitionAllowed = true; }