From: Jérôme Benoit Date: Wed, 19 Oct 2022 08:04:35 +0000 (+0200) Subject: Strict boolean checks X-Git-Tag: v1.1.85~11 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=3a13fc92f2bc5236dcde66fe5e79e0cea89f1c3d;p=e-mobility-charging-stations-simulator.git Strict boolean checks Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 1ad01827..aecc08f7 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -281,8 +281,8 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer ): Promise { let response: JsonType; if ( - chargingStation.getOcppStrictCompliance() && - chargingStation.isInPendingState() && + chargingStation.getOcppStrictCompliance() === true && + chargingStation.isInPendingState() === true && (commandName === OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION || commandName === OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION) ) { diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 4ba89706..b4d8eea2 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -338,8 +338,8 @@ export default class OCPP16ResponseService extends OCPPResponseService { } if ( chargingStation.getConnectorStatus(connectorId).transactionRemoteStarted === true && - chargingStation.getAuthorizeRemoteTxRequests() && - chargingStation.getLocalAuthListEnabled() && + chargingStation.getAuthorizeRemoteTxRequests() === true && + chargingStation.getLocalAuthListEnabled() === true && chargingStation.hasAuthorizedTags() && chargingStation.getConnectorStatus(connectorId).idTagLocalAuthorized === false ) { @@ -355,8 +355,8 @@ export default class OCPP16ResponseService extends OCPPResponseService { } if ( chargingStation.getConnectorStatus(connectorId).transactionRemoteStarted === true && - chargingStation.getAuthorizeRemoteTxRequests() && - chargingStation.getMustAuthorizeAtRemoteStart() && + chargingStation.getAuthorizeRemoteTxRequests() === true && + chargingStation.getMustAuthorizeAtRemoteStart() === true && chargingStation.getConnectorStatus(connectorId).idTagLocalAuthorized === false && chargingStation.getConnectorStatus(connectorId).idTagAuthorized === false ) { @@ -542,9 +542,9 @@ export default class OCPP16ResponseService extends OCPPResponseService { return; } if (payload.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED) { - chargingStation.getBeginEndMeterValues() && - !chargingStation.getOcppStrictCompliance() && - chargingStation.getOutOfOrderEndMeterValues() && + chargingStation.getBeginEndMeterValues() === true && + chargingStation.getOcppStrictCompliance() === false && + chargingStation.getOutOfOrderEndMeterValues() === true && (await chargingStation.ocppRequestService.requestHandler< OCPP16MeterValuesRequest, OCPP16MeterValuesResponse diff --git a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts index 741db1d3..25d8dcdf 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts @@ -641,9 +641,9 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { // Persist previous value on connector if ( connector && - !Utils.isNullOrUndefined(connector.energyActiveImportRegisterValue) && + Utils.isNullOrUndefined(connector.energyActiveImportRegisterValue) === false && connector.energyActiveImportRegisterValue >= 0 && - !Utils.isNullOrUndefined(connector.transactionEnergyActiveImportRegisterValue) && + Utils.isNullOrUndefined(connector.transactionEnergyActiveImportRegisterValue) === false && connector.transactionEnergyActiveImportRegisterValue >= 0 ) { connector.energyActiveImportRegisterValue += energyValueRounded; diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 9fa50b4f..29c740a1 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -159,11 +159,13 @@ export default abstract class OCPPRequestService { } ): Promise { if ( - (chargingStation.isInUnknownState() && commandName === RequestCommand.BOOT_NOTIFICATION) || - (!chargingStation.getOcppStrictCompliance() && chargingStation.isInUnknownState()) || - chargingStation.isInAcceptedState() || - (chargingStation.isInPendingState() && - (params.triggerMessage || messageType === MessageType.CALL_RESULT_MESSAGE)) + (chargingStation.isInUnknownState() === true && + commandName === RequestCommand.BOOT_NOTIFICATION) || + (chargingStation.getOcppStrictCompliance() === false && + chargingStation.isInUnknownState() === true) || + chargingStation.isInAcceptedState() === true || + (chargingStation.isInPendingState() === true && + (params.triggerMessage === true || messageType === MessageType.CALL_RESULT_MESSAGE)) ) { // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this;