From: Jérôme Benoit Date: Sun, 2 Oct 2022 17:23:10 +0000 (+0200) Subject: Set connector status at start given its availability first X-Git-Tag: v1.1.75~9 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=45c0ae82dee8cf065f6303c4853c8adfe239dee1;p=e-mobility-charging-stations-simulator.git Set connector status at start given its availability first Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 05ef9252..7853d10e 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -535,19 +535,6 @@ export default class ChargingStation { if (this.stopping === false) { this.stopping = true; await this.stopMessageSequence(reason); - for (const connectorId of this.connectors.keys()) { - if (connectorId > 0) { - await this.ocppRequestService.requestHandler< - StatusNotificationRequest, - StatusNotificationResponse - >(this, RequestCommand.STATUS_NOTIFICATION, { - connectorId, - status: ChargePointStatus.UNAVAILABLE, - errorCode: ChargePointErrorCode.NO_ERROR, - }); - this.getConnectorStatus(connectorId).status = null; - } - } this.closeWSConnection(); this.wsConnectionRestarted = false; if (this.getEnableStatistics()) { @@ -1775,12 +1762,6 @@ export default class ChargingStation { let chargePointStatus: ChargePointStatus; if (connectorId === 0) { continue; - } else if ( - !this.getConnectorStatus(connectorId)?.status && - this.getConnectorStatus(connectorId)?.bootStatus - ) { - // Set boot status in template at startup - chargePointStatus = this.getConnectorStatus(connectorId).bootStatus; } else if ( !this.getConnectorStatus(connectorId)?.status && (this.isChargingStationAvailable() === false || @@ -1788,6 +1769,12 @@ export default class ChargingStation { this.isConnectorAvailable(connectorId) === false)) ) { chargePointStatus = ChargePointStatus.UNAVAILABLE; + } else if ( + !this.getConnectorStatus(connectorId)?.status && + this.getConnectorStatus(connectorId)?.bootStatus + ) { + // Set boot status in template at startup + chargePointStatus = this.getConnectorStatus(connectorId).bootStatus; } else if (this.getConnectorStatus(connectorId)?.status) { // Set previous status at startup chargePointStatus = this.getConnectorStatus(connectorId).status; @@ -1825,6 +1812,19 @@ export default class ChargingStation { } else { await this.stopRunningTransactions(reason); } + for (const connectorId of this.connectors.keys()) { + if (connectorId > 0) { + await this.ocppRequestService.requestHandler< + StatusNotificationRequest, + StatusNotificationResponse + >(this, RequestCommand.STATUS_NOTIFICATION, { + connectorId, + status: ChargePointStatus.UNAVAILABLE, + errorCode: ChargePointErrorCode.NO_ERROR, + }); + this.getConnectorStatus(connectorId).status = null; + } + } } private startWebSocketPing(): void {