X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStation.ts;h=6be15b83e980656b237a7a1586078134dd17ae54;hb=caad9d6b03dbfc507da6d8e79ccbbaf74593e981;hp=565bdb895af476237584c66c86a6592d4c0e9772;hpb=323e7c9ca1769c7caa98efe25983930e26d4a6a8;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 565bdb89..6be15b83 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -122,10 +122,22 @@ export default class ChargingStation { return this?.wsConnection?.readyState === OPEN; } - public isRegistered(): boolean { + public isInPendingState(): boolean { + return this?.bootNotificationResponse?.status === RegistrationStatus.PENDING; + } + + public isInAcceptedState(): boolean { return this?.bootNotificationResponse?.status === RegistrationStatus.ACCEPTED; } + public isInRejectedState(): boolean { + return this?.bootNotificationResponse?.status === RegistrationStatus.REJECTED; + } + + public isRegistered(): boolean { + return this.isInAcceptedState() || this.isInPendingState(); + } + public isChargingStationAvailable(): boolean { return this.getConnectorStatus(0).availability === AvailabilityType.OPERATIVE; } @@ -644,7 +656,17 @@ export default class ChargingStation { await this.ocppRequestService.sendBootNotification(this.bootNotificationRequest.chargePointModel, this.bootNotificationRequest.chargePointVendor, this.bootNotificationRequest.chargeBoxSerialNumber, this.bootNotificationRequest.firmwareVersion); } - if (this.isRegistered()) { + if (this.isInAcceptedState()) { + await this.startMessageSequence(); + this.stopped && (this.stopped = false); + if (this.wsConnectionRestarted && this.isWebSocketConnectionOpened()) { + this.flushMessageBuffer(); + } + } else if (this.isInPendingState()) { + // The central server shall issue a TriggerMessage to the charging station for the boot notification at the end of its configuration process + while (!this.isInAcceptedState()) { + await Utils.sleep(Constants.CHARGING_STATION_DEFAULT_START_SEQUENCE_DELAY); + } await this.startMessageSequence(); this.stopped && (this.stopped = false); if (this.wsConnectionRestarted && this.isWebSocketConnectionOpened()) {