refactor: cleanup comments formatting
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 21 Aug 2024 14:24:49 +0000 (16:24 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 21 Aug 2024 14:24:49 +0000 (16:24 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/charging-station/AutomaticTransactionGenerator.ts
src/charging-station/ChargingStation.ts
src/charging-station/Helpers.ts
src/charging-station/ocpp/OCPPConstants.ts
src/charging-station/ocpp/OCPPServiceUtils.ts

index 8f442f46dfd62fb6f9150d310a1d683a2b467aea..e760b5f0623150e81ee0ea478043e52193588c47 100644 (file)
@@ -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
index 866302b0ba783980c653805b4842105a9a728c23..cdf6930493a6b87de466ee2960943e7ae9c192e2 100644 (file)
@@ -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)
index 9b2d83700a2cb260eb04975baff7ce4375ec50d4..27d397a37dfdc1594d1c2087d86b5a15461841f9 100644 (file)
@@ -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) {
index 404ee83413e3d09c582570196ab306828d42934e..4b4d92566c81d1495ecf287c079cee8c29301158 100644 (file)
@@ -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
index de635c50d60fc538c2d89a0c48f8304a7f948c22..8737521b84a94d8ec16fa16b04c2b013e045b7e1 100644 (file)
@@ -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`
           )
         }
       }