From: Jérôme Benoit Date: Fri, 12 May 2023 20:34:41 +0000 (+0200) Subject: refactor: cleanup method namaspace X-Git-Tag: v1.2.14~59 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=f7c2994d6d3bd83aac94fec10def8730562d3c8f;p=e-mobility-charging-stations-simulator.git refactor: cleanup method namaspace Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index 8b9ae7ce..948b375e 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -172,7 +172,7 @@ export class AutomaticTransactionGenerator extends AsyncResource { this.stopConnector(connectorId); break; } - if (this.chargingStation.isInAcceptedState() === false) { + if (this.chargingStation.inAcceptedState() === false) { logger.error( `${this.logPrefix( connectorId diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 9f1fa7de..0ae3be5f 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -222,26 +222,26 @@ export class ChargingStation { return this?.bootNotificationResponse?.status; } - public isInUnknownState(): boolean { + public inUnknownState(): boolean { return Utils.isNullOrUndefined(this?.bootNotificationResponse?.status); } - public isInPendingState(): boolean { + public inPendingState(): boolean { return this?.bootNotificationResponse?.status === RegistrationStatusEnumType.PENDING; } - public isInAcceptedState(): boolean { + public inAcceptedState(): boolean { return this?.bootNotificationResponse?.status === RegistrationStatusEnumType.ACCEPTED; } - public isInRejectedState(): boolean { + public inRejectedState(): boolean { return this?.bootNotificationResponse?.status === RegistrationStatusEnumType.REJECTED; } public isRegistered(): boolean { return ( - this.isInUnknownState() === false && - (this.isInAcceptedState() === true || this.isInPendingState() === true) + this.inUnknownState() === false && + (this.inAcceptedState() === true || this.inPendingState() === true) ); } @@ -1690,7 +1690,7 @@ export class ChargingStation { ); } if (this.isRegistered() === true) { - if (this.isInAcceptedState() === true) { + if (this.inAcceptedState() === true) { await this.startMessageSequence(); } } else { diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index b1785a13..a7d02dca 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -275,7 +275,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { let response: JsonType; if ( chargingStation.getOcppStrictCompliance() === true && - chargingStation.isInPendingState() === true && + chargingStation.inPendingState() === true && (commandName === OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION || commandName === OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION) ) { @@ -293,7 +293,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { if ( chargingStation.isRegistered() === true || (chargingStation.getOcppStrictCompliance() === false && - chargingStation.isInUnknownState() === true) + chargingStation.inUnknownState() === true) ) { if ( this.incomingRequestHandlers.has(commandName) === true && diff --git a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts index 2d1ebd4d..3ca4d3cf 100644 --- a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts @@ -56,7 +56,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { let response: JsonType; if ( chargingStation.getOcppStrictCompliance() === true && - chargingStation.isInPendingState() === true && + chargingStation.inPendingState() === true && (commandName === OCPP20IncomingRequestCommand.REQUEST_START_TRANSACTION || commandName === OCPP20IncomingRequestCommand.REQUEST_STOP_TRANSACTION) ) { @@ -74,7 +74,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { if ( chargingStation.isRegistered() === true || (chargingStation.getOcppStrictCompliance() === false && - chargingStation.isInUnknownState() === true) + chargingStation.inUnknownState() === true) ) { if ( this.incomingRequestHandlers.has(commandName) === true && diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index a50500dc..3eb85e30 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -266,12 +266,12 @@ export abstract class OCPPRequestService { } ): Promise { if ( - (chargingStation.isInUnknownState() === true && + (chargingStation.inUnknownState() === true && commandName === RequestCommand.BOOT_NOTIFICATION) || (chargingStation.getOcppStrictCompliance() === false && - chargingStation.isInUnknownState() === true) || - chargingStation.isInAcceptedState() === true || - (chargingStation.isInPendingState() === true && + chargingStation.inUnknownState() === true) || + chargingStation.inAcceptedState() === true || + (chargingStation.inPendingState() === true && (params.triggerMessage === true || messageType === MessageType.CALL_RESULT_MESSAGE)) ) { // eslint-disable-next-line @typescript-eslint/no-this-alias