From f46aabbfb98e55c0b6d4bec15a2f2e9ba92a8e14 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 21 Aug 2024 16:24:49 +0200 Subject: [PATCH] refactor: cleanup comments formatting MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../AutomaticTransactionGenerator.ts | 22 ++++++++++--------- src/charging-station/ChargingStation.ts | 4 ++-- src/charging-station/Helpers.ts | 6 +++-- src/charging-station/ocpp/OCPPConstants.ts | 21 ++++++++++++------ src/charging-station/ocpp/OCPPServiceUtils.ts | 22 +++++++++---------- 5 files changed, 43 insertions(+), 32 deletions(-) diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index 8f442f46..e760b5f0 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -233,8 +233,8 @@ export class AutomaticTransactionGenerator { ) ) logger.info( - `${this.logPrefix(connectorId)} transaction started with id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions - this.chargingStation + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `${this.logPrefix(connectorId)} transaction started with id ${this.chargingStation .getConnectorStatus(connectorId) ?.transactionId?.toString()} and will stop in ${formatDurationMilliSeconds(waitTrxEnd)}` ) @@ -247,8 +247,8 @@ export class AutomaticTransactionGenerator { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion ++this.connectorsStatus.get(connectorId)!.skippedTransactions logger.info( - `${this.logPrefix(connectorId)} skipped consecutively ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions - this.connectorsStatus + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `${this.logPrefix(connectorId)} skipped consecutively ${this.connectorsStatus .get(connectorId) ?.skippedConsecutiveTransactions.toString() // eslint-disable-next-line @typescript-eslint/restrict-template-expressions @@ -344,8 +344,8 @@ export class AutomaticTransactionGenerator { const connectorStatus = this.chargingStation.getConnectorStatus(connectorId) if (connectorStatus?.transactionStarted === true) { logger.info( - `${this.logPrefix(connectorId)} entered in transaction loop while a transaction ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions - connectorStatus.transactionId?.toString()} is already started on connector ${connectorId.toString()}` + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `${this.logPrefix(connectorId)} entered in transaction loop while a transaction ${connectorStatus.transactionId?.toString()} is already started on connector ${connectorId.toString()}` ) return false } @@ -388,8 +388,8 @@ export class AutomaticTransactionGenerator { while (connectorStatus?.transactionStarted === true) { if (!logged) { logger.info( - `${this.logPrefix(connectorId)} transaction loop waiting for started transaction ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions - connectorStatus.transactionId?.toString()} on connector ${connectorId.toString()} to be stopped` + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `${this.logPrefix(connectorId)} transaction loop waiting for started transaction ${connectorStatus.transactionId?.toString()} on connector ${connectorId.toString()} to be stopped` ) logged = true } @@ -539,8 +539,10 @@ export class AutomaticTransactionGenerator { let stopResponse: StopTransactionResponse | undefined if (this.chargingStation.getConnectorStatus(connectorId)?.transactionStarted === true) { logger.info( - `${this.logPrefix(connectorId)} stop transaction with id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions - this.chargingStation.getConnectorStatus(connectorId)?.transactionId?.toString()}` + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `${this.logPrefix(connectorId)} stop transaction with id ${this.chargingStation + .getConnectorStatus(connectorId) + ?.transactionId?.toString()}` ) stopResponse = await this.chargingStation.stopTransactionOnConnector(connectorId, reason) // eslint-disable-next-line @typescript-eslint/no-non-null-assertion diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 866302b0..cdf69304 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1885,8 +1885,8 @@ export class ChargingStation extends EventEmitter { } if (!this.isRegistered()) { logger.error( - `${this.logPrefix()} Registration failure: maximum retries reached (${registrationRetryCount.toString()}) or retry disabled (${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions - this.stationInfo?.registrationMaxRetries?.toString()})` + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `${this.logPrefix()} Registration failure: maximum retries reached (${registrationRetryCount.toString()}) or retry disabled (${this.stationInfo?.registrationMaxRetries?.toString()})` ) } this.emit(ChargingStationEvents.updated) diff --git a/src/charging-station/Helpers.ts b/src/charging-station/Helpers.ts index 9b2d8370..27d397a3 100644 --- a/src/charging-station/Helpers.ts +++ b/src/charging-station/Helpers.ts @@ -448,8 +448,10 @@ export const initializeConnectorsMapStatus = ( for (const connectorId of connectors.keys()) { if (connectorId > 0 && connectors.get(connectorId)?.transactionStarted === true) { logger.warn( - `${logPrefix} Connector id ${connectorId.toString()} at initialization has a transaction started with id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions - connectors.get(connectorId)?.transactionId?.toString()}` + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `${logPrefix} Connector id ${connectorId.toString()} at initialization has a transaction started with id ${connectors + .get(connectorId) + ?.transactionId?.toString()}` ) } if (connectorId === 0) { diff --git a/src/charging-station/ocpp/OCPPConstants.ts b/src/charging-station/ocpp/OCPPConstants.ts index 404ee834..4b4d9256 100644 --- a/src/charging-station/ocpp/OCPPConstants.ts +++ b/src/charging-station/ocpp/OCPPConstants.ts @@ -118,33 +118,40 @@ export class OCPPConstants { status: DataTransferStatus.UNKNOWN_VENDOR_ID, }) + // Reservation has been made static readonly OCPP_RESERVATION_RESPONSE_ACCEPTED = Object.freeze({ status: ReservationStatus.ACCEPTED, - }) // Reservation has been made + }) + // Reservation has not been made, because of connector in FAULTED state static readonly OCPP_RESERVATION_RESPONSE_FAULTED = Object.freeze({ status: ReservationStatus.FAULTED, - }) // Reservation has not been made, because of connector in FAULTED state + }) + // Reservation has not been made, because all connectors are OCCUPIED static readonly OCPP_RESERVATION_RESPONSE_OCCUPIED = Object.freeze({ status: ReservationStatus.OCCUPIED, - }) // Reservation has not been made, because all connectors are OCCUPIED + }) + // Reservation has not been made, because charging station is not configured to accept reservations static readonly OCPP_RESERVATION_RESPONSE_REJECTED = Object.freeze({ status: ReservationStatus.REJECTED, - }) // Reservation has not been made, because charging station is not configured to accept reservations + }) + // Reservation has not been made, because connector is in UNAVAILABLE state static readonly OCPP_RESERVATION_RESPONSE_UNAVAILABLE = Object.freeze({ status: ReservationStatus.UNAVAILABLE, - }) // Reservation has not been made, because connector is in UNAVAILABLE state + }) + // Reservation for id has been cancelled static readonly OCPP_CANCEL_RESERVATION_RESPONSE_ACCEPTED = Object.freeze({ status: GenericStatus.Accepted, - }) // Reservation for id has been cancelled + }) + // Reservation could not be cancelled, because there is no reservation active for id static readonly OCPP_CANCEL_RESERVATION_RESPONSE_REJECTED = Object.freeze({ status: GenericStatus.Rejected, - }) // Reservation could not be cancelled, because there is no reservation active for id + }) protected constructor () { // This is intentional diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index de635c50..8737521b 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -348,8 +348,8 @@ export const buildMeterValue = ( `${chargingStation.logPrefix()} MeterValues measurand ${ meterValue.sampledValue[sampledValuesIndex].measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER - }: connector id ${connectorId.toString()}, transaction id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions - connector?.transactionId?.toString()}, value: ${socMinimumValue.toString()}/${ + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + }: connector id ${connectorId.toString()}, transaction id ${connector?.transactionId?.toString()}, value: ${socMinimumValue.toString()}/${ meterValue.sampledValue[sampledValuesIndex].value }/${socMaximumValue.toString()}` ) @@ -681,8 +681,8 @@ export const buildMeterValue = ( `${chargingStation.logPrefix()} MeterValues measurand ${ meterValue.sampledValue[sampledValuesIndex].measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER - }: connector id ${connectorId.toString()}, transaction id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions - connector?.transactionId?.toString()}, value: ${connectorMinimumPowerRounded.toString()}/${ + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + }: connector id ${connectorId.toString()}, transaction id ${connector?.transactionId?.toString()}, value: ${connectorMinimumPowerRounded.toString()}/${ meterValue.sampledValue[sampledValuesIndex].value }/${connectorMaximumPowerRounded.toString()}` ) @@ -728,8 +728,8 @@ export const buildMeterValue = ( }: phase ${ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions meterValue.sampledValue[sampledValuesPerPhaseIndex].phase - }, connector id ${connectorId.toString()}, transaction id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions - connector?.transactionId?.toString()}, value: ${connectorMinimumPowerPerPhaseRounded.toString()}/${ + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + }, connector id ${connectorId.toString()}, transaction id ${connector?.transactionId?.toString()}, value: ${connectorMinimumPowerPerPhaseRounded.toString()}/${ meterValue.sampledValue[sampledValuesPerPhaseIndex].value }/${connectorMaximumPowerPerPhaseRounded.toString()}` ) @@ -941,8 +941,8 @@ export const buildMeterValue = ( `${chargingStation.logPrefix()} MeterValues measurand ${ meterValue.sampledValue[sampledValuesIndex].measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER - }: connector id ${connectorId.toString()}, transaction id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions - connector?.transactionId?.toString()}, value: ${connectorMinimumAmperage.toString()}/${ + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + }: connector id ${connectorId.toString()}, transaction id ${connector?.transactionId?.toString()}, value: ${connectorMinimumAmperage.toString()}/${ meterValue.sampledValue[sampledValuesIndex].value }/${connectorMaximumAmperage.toString()}` ) @@ -978,7 +978,7 @@ export const buildMeterValue = ( }: phase ${ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions meterValue.sampledValue[sampledValuesPerPhaseIndex].phase - }, connector id ${connectorId.toString()}, transaction id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions + }, connector id ${connectorId.toString()}, transaction id $ connector?.transactionId?.toString()}, value: ${connectorMinimumAmperage.toString()}/${ meterValue.sampledValue[sampledValuesPerPhaseIndex].value }/${connectorMaximumAmperage.toString()}` @@ -1053,8 +1053,8 @@ export const buildMeterValue = ( `${chargingStation.logPrefix()} MeterValues measurand ${ meterValue.sampledValue[sampledValuesIndex].measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER - }: connector id ${connectorId.toString()}, transaction id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions - connector?.transactionId?.toString()}, value: ${connectorMinimumEnergyRounded.toString()}/${energyValueRounded.toString()}/${connectorMaximumEnergyRounded.toString()}, duration: ${interval.toString()}ms` + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + }: connector id ${connectorId.toString()}, transaction id ${connector?.transactionId?.toString()}, value: ${connectorMinimumEnergyRounded.toString()}/${energyValueRounded.toString()}/${connectorMaximumEnergyRounded.toString()}, duration: ${interval.toString()}ms` ) } } -- 2.34.1