From: Jérôme Benoit Date: Tue, 21 May 2024 17:37:38 +0000 (+0200) Subject: refactor: code formatting X-Git-Tag: v1.3.4~53 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=48847bc0d5e594c3e4c0b81c580ac6df48052668;p=e-mobility-charging-stations-simulator.git refactor: code formatting Signed-off-by: Jérôme Benoit --- diff --git a/skip-preinstall.js b/skip-preinstall.js index e181f0e0..fb2477d7 100644 --- a/skip-preinstall.js +++ b/skip-preinstall.js @@ -1,6 +1,6 @@ import { env, exit } from 'node:process' -const skipPreinstall = parseInt(env.SKIP_PREINSTALL) || env.VCAP_APPLICATION != null +const skipPreinstall = Number.parseInt(env.SKIP_PREINSTALL) || env.VCAP_APPLICATION != null if (skipPreinstall) { // eslint-disable-next-line n/no-process-exit exit() diff --git a/src/assets/ui-protocol/Insomnia-CSSimulatorUIHTTPProtocol.json b/src/assets/ui-protocol/Insomnia-CSSimulatorUIHTTPProtocol.json index da32bbcb..e172ad29 100644 --- a/src/assets/ui-protocol/Insomnia-CSSimulatorUIHTTPProtocol.json +++ b/src/assets/ui-protocol/Insomnia-CSSimulatorUIHTTPProtocol.json @@ -892,7 +892,9 @@ "username": "admin", "password": "admin" }, - "dataPropertyOrder": { "&": ["baseUrl", "protocol", "version", "username", "password"] }, + "dataPropertyOrder": { + "&": ["baseUrl", "protocol", "version", "username", "password"] + }, "color": null, "isPrivate": false, "metaSortKey": 1661789025528, diff --git a/src/assets/ui-protocol/Insomnia-CSSimulatorUIWSProtocol.json b/src/assets/ui-protocol/Insomnia-CSSimulatorUIWSProtocol.json index 1312150c..3d9a5405 100644 --- a/src/assets/ui-protocol/Insomnia-CSSimulatorUIWSProtocol.json +++ b/src/assets/ui-protocol/Insomnia-CSSimulatorUIWSProtocol.json @@ -657,7 +657,9 @@ "protocol": "ui", "version": "0.0.1" }, - "dataPropertyOrder": { "&": ["baseUrl", "username", "password", "protocol", "version"] }, + "dataPropertyOrder": { + "&": ["baseUrl", "username", "password", "protocol", "version"] + }, "color": null, "isPrivate": false, "metaSortKey": 1671183662529, diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index 4b9b8f6c..0e081f77 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -333,9 +333,9 @@ 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 ${connectorStatus.transactionId} is already started on connector ${connectorId}` + `${this.logPrefix(connectorId)} entered in transaction loop while a transaction ${ + connectorStatus.transactionId + } is already started on connector ${connectorId}` ) return false } @@ -378,9 +378,9 @@ export class AutomaticTransactionGenerator { while (connectorStatus?.transactionStarted === true) { if (!logged) { logger.info( - `${this.logPrefix( - connectorId - )} transaction loop waiting for started transaction ${connectorStatus.transactionId} on connector ${connectorId} to be stopped` + `${this.logPrefix(connectorId)} transaction loop waiting for started transaction ${ + connectorStatus.transactionId + } on connector ${connectorId} to be stopped` ) logged = true } @@ -416,7 +416,9 @@ export class AutomaticTransactionGenerator { ) } else if (this.chargingStation.getAutomaticTransactionGeneratorStatuses() != null) { logger.warn( - `${this.logPrefix(connectorId)} no status found for connector #${connectorId} in charging station configuration file. New status will be created` + `${this.logPrefix( + connectorId + )} no status found for connector #${connectorId} in charging station configuration file. New status will be created` ) } if (connectorStatus != null) { @@ -507,7 +509,9 @@ export class AutomaticTransactionGenerator { startResponse = await this.chargingStation.ocppRequestService.requestHandler< Partial, StartTransactionResponse - >(this.chargingStation, RequestCommand.START_TRANSACTION, { connectorId }) + >(this.chargingStation, RequestCommand.START_TRANSACTION, { + connectorId + }) this.handleStartTransactionResponse(connectorId, startResponse) PerformanceStatistics.endMeasure(measureId, beginId) return startResponse diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 5293a9a8..d12f78f9 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -225,9 +225,13 @@ export class Bootstrap extends EventEmitter { ) console.info( chalk.green( - `Charging stations simulator ${ - this.version - } started with ${this.numberOfConfiguredChargingStations} configured and ${this.numberOfProvisionedChargingStations} provisioned charging station(s) from ${this.numberOfChargingStationTemplates} charging station template(s) and ${ + `Charging stations simulator ${this.version} started with ${ + this.numberOfConfiguredChargingStations + } configured and ${ + this.numberOfProvisionedChargingStations + } provisioned charging station(s) from ${ + this.numberOfChargingStationTemplates + } charging station template(s) and ${ Configuration.workerDynamicPoolInUse() ? `${workerConfiguration.poolMinSize}/` : '' }${this.workerImplementation?.size}${ Configuration.workerPoolInUse() ? `/${workerConfiguration.poolMaxSize}` : '' @@ -373,7 +377,9 @@ export class Bootstrap extends EventEmitter { poolOptions: { messageHandler: this.messageHandler.bind(this) as MessageHandler, ...(workerConfiguration.resourceLimits != null && { - workerOptions: { resourceLimits: workerConfiguration.resourceLimits } + workerOptions: { + resourceLimits: workerConfiguration.resourceLimits + } }) } } @@ -418,7 +424,11 @@ export class Bootstrap extends EventEmitter { break default: throw new BaseError( - `Unknown charging station worker message event: '${event}' received with data: ${JSON.stringify(data, undefined, 2)}` + `Unknown charging station worker message event: '${event}' received with data: ${JSON.stringify( + data, + undefined, + 2 + )}` ) } } catch (error) { @@ -436,7 +446,9 @@ export class Bootstrap extends EventEmitter { data.stationInfo.chargingStationId } (hashId: ${data.stationInfo.hashId}) added (${ this.numberOfAddedChargingStations - } added from ${this.numberOfConfiguredChargingStations} configured and ${this.numberOfProvisionedChargingStations} provisioned charging station(s))` + } added from ${this.numberOfConfiguredChargingStations} configured and ${ + this.numberOfProvisionedChargingStations + } provisioned charging station(s))` ) } @@ -451,7 +463,9 @@ export class Bootstrap extends EventEmitter { data.stationInfo.chargingStationId } (hashId: ${data.stationInfo.hashId}) deleted (${ this.numberOfAddedChargingStations - } added from ${this.numberOfConfiguredChargingStations} configured and ${this.numberOfProvisionedChargingStations} provisioned charging station(s))` + } added from ${this.numberOfConfiguredChargingStations} configured and ${ + this.numberOfProvisionedChargingStations + } provisioned charging station(s))` ) } diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 978bcbd3..7df0a35f 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -269,7 +269,9 @@ export class ChargingStation extends EventEmitter { : this.configuredSupervisionUrl.href }` return new URL( - `${wsConnectionBaseUrlStr}${!wsConnectionBaseUrlStr.endsWith('/') ? '/' : ''}${this.stationInfo?.chargingStationId}` + `${wsConnectionBaseUrlStr}${ + !wsConnectionBaseUrlStr.endsWith('/') ? '/' : '' + }${this.stationInfo?.chargingStationId}` ) } @@ -1362,7 +1364,9 @@ export class ChargingStation extends EventEmitter { addConfigurationKey(this, StandardParametersKey.HeartbeatInterval, '0') } if (getConfigurationKey(this, StandardParametersKey.HeartBeatInterval) == null) { - addConfigurationKey(this, StandardParametersKey.HeartBeatInterval, '0', { visible: false }) + addConfigurationKey(this, StandardParametersKey.HeartBeatInterval, '0', { + visible: false + }) } if ( this.stationInfo?.supervisionUrlOcppConfiguration === true && @@ -1380,7 +1384,9 @@ export class ChargingStation extends EventEmitter { isNotEmptyString(this.stationInfo.supervisionUrlOcppKey) && getConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey) != null ) { - deleteConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey, { save: false }) + deleteConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey, { + save: false + }) } if ( isNotEmptyString(this.stationInfo?.amperageLimitationOcppKey) && @@ -1739,7 +1745,9 @@ export class ChargingStation extends EventEmitter { ...(this.connectors.size > 0 && { connectorsStatus: configurationData.connectorsStatus }), - ...(this.evses.size > 0 && { evsesStatus: configurationData.evsesStatus }) + ...(this.evses.size > 0 && { + evsesStatus: configurationData.evsesStatus + }) } satisfies ChargingStationConfiguration) ) .digest('hex') @@ -1816,7 +1824,9 @@ export class ChargingStation extends EventEmitter { if (this.isWebSocketConnectionOpened()) { this.emit(ChargingStationEvents.updated) logger.info( - `${this.logPrefix()} Connection to OCPP server through ${this.wsConnectionUrl.href} succeeded` + `${this.logPrefix()} Connection to OCPP server through ${ + this.wsConnectionUrl.href + } succeeded` ) let registrationRetryCount = 0 if (!this.isRegistered()) { @@ -2075,7 +2085,9 @@ export class ChargingStation extends EventEmitter { // eslint-disable-next-line @typescript-eslint/no-base-to-string }' message '${data.toString()}'${ this.requests.has(messageId) - ? ` matching cached request '${JSON.stringify(this.getCachedRequest(messageType, messageId))}'` + ? ` matching cached request '${JSON.stringify( + this.getCachedRequest(messageType, messageId) + )}'` : '' } processing error:`, error diff --git a/src/charging-station/Helpers.ts b/src/charging-station/Helpers.ts index 735a0b39..15ba379b 100644 --- a/src/charging-station/Helpers.ts +++ b/src/charging-station/Helpers.ts @@ -306,7 +306,11 @@ export const checkConnectorsConfiguration = ( ) stationTemplate.randomConnectors = true } - return { configuredMaxConnectors, templateMaxConnectors, templateMaxAvailableConnectors } + return { + configuredMaxConnectors, + templateMaxConnectors, + templateMaxAvailableConnectors + } } export const checkStationInfoConnectorStatus = ( @@ -524,7 +528,10 @@ export const createSerialNumber = ( randomSerialNumber?: boolean } ): void => { - params = { ...{ randomSerialNumberUpperCase: true, randomSerialNumber: true }, ...params } + params = { + ...{ randomSerialNumberUpperCase: true, randomSerialNumber: true }, + ...params + } const serialNumberSuffix = params.randomSerialNumber === true ? getRandomSerialNumberSuffix({ diff --git a/src/charging-station/ocpp/1.6/OCPP16Constants.ts b/src/charging-station/ocpp/1.6/OCPP16Constants.ts index 4a604f1c..214c5a85 100644 --- a/src/charging-station/ocpp/1.6/OCPP16Constants.ts +++ b/src/charging-station/ocpp/1.6/OCPP16Constants.ts @@ -7,15 +7,33 @@ export class OCPP16Constants extends OCPPConstants { > = Object.freeze([ { to: OCPP16ChargePointStatus.Available }, // { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Available }, - { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Faulted }, + { + from: OCPP16ChargePointStatus.Available, + to: OCPP16ChargePointStatus.Unavailable + }, + { + from: OCPP16ChargePointStatus.Available, + to: OCPP16ChargePointStatus.Faulted + }, { to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Available }, + { + from: OCPP16ChargePointStatus.Unavailable, + to: OCPP16ChargePointStatus.Available + }, // { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Faulted }, + { + from: OCPP16ChargePointStatus.Unavailable, + to: OCPP16ChargePointStatus.Faulted + }, { to: OCPP16ChargePointStatus.Faulted }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Available }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Unavailable } + { + from: OCPP16ChargePointStatus.Faulted, + to: OCPP16ChargePointStatus.Available + }, + { + from: OCPP16ChargePointStatus.Faulted, + to: OCPP16ChargePointStatus.Unavailable + } // { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Faulted } ]) @@ -23,93 +41,252 @@ export class OCPP16Constants extends OCPPConstants { Object.freeze([ { to: OCPP16ChargePointStatus.Available }, // { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Available }, - { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Preparing }, - { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Charging }, - { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.SuspendedEV }, - { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.SuspendedEVSE }, + { + from: OCPP16ChargePointStatus.Available, + to: OCPP16ChargePointStatus.Preparing + }, + { + from: OCPP16ChargePointStatus.Available, + to: OCPP16ChargePointStatus.Charging + }, + { + from: OCPP16ChargePointStatus.Available, + to: OCPP16ChargePointStatus.SuspendedEV + }, + { + from: OCPP16ChargePointStatus.Available, + to: OCPP16ChargePointStatus.SuspendedEVSE + }, // { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Finishing }, - { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Reserved }, - { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Faulted }, + { + from: OCPP16ChargePointStatus.Available, + to: OCPP16ChargePointStatus.Reserved + }, + { + from: OCPP16ChargePointStatus.Available, + to: OCPP16ChargePointStatus.Unavailable + }, + { + from: OCPP16ChargePointStatus.Available, + to: OCPP16ChargePointStatus.Faulted + }, // { to: OCPP16ChargePointStatus.Preparing }, - { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Available }, + { + from: OCPP16ChargePointStatus.Preparing, + to: OCPP16ChargePointStatus.Available + }, // { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Preparing }, - { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Charging }, - { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.SuspendedEV }, - { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.SuspendedEVSE }, - { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Finishing }, + { + from: OCPP16ChargePointStatus.Preparing, + to: OCPP16ChargePointStatus.Charging + }, + { + from: OCPP16ChargePointStatus.Preparing, + to: OCPP16ChargePointStatus.SuspendedEV + }, + { + from: OCPP16ChargePointStatus.Preparing, + to: OCPP16ChargePointStatus.SuspendedEVSE + }, + { + from: OCPP16ChargePointStatus.Preparing, + to: OCPP16ChargePointStatus.Finishing + }, // { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Reserved }, // { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Faulted }, + { + from: OCPP16ChargePointStatus.Preparing, + to: OCPP16ChargePointStatus.Faulted + }, // { to: OCPP16ChargePointStatus.Charging }, - { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Available }, + { + from: OCPP16ChargePointStatus.Charging, + to: OCPP16ChargePointStatus.Available + }, // { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Preparing }, // { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Charging }, - { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.SuspendedEV }, - { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.SuspendedEVSE }, - { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Finishing }, + { + from: OCPP16ChargePointStatus.Charging, + to: OCPP16ChargePointStatus.SuspendedEV + }, + { + from: OCPP16ChargePointStatus.Charging, + to: OCPP16ChargePointStatus.SuspendedEVSE + }, + { + from: OCPP16ChargePointStatus.Charging, + to: OCPP16ChargePointStatus.Finishing + }, // { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Reserved }, - { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Faulted }, + { + from: OCPP16ChargePointStatus.Charging, + to: OCPP16ChargePointStatus.Unavailable + }, + { + from: OCPP16ChargePointStatus.Charging, + to: OCPP16ChargePointStatus.Faulted + }, // { to: OCPP16ChargePointStatus.SuspendedEV }, - { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Available }, + { + from: OCPP16ChargePointStatus.SuspendedEV, + to: OCPP16ChargePointStatus.Available + }, // { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Preparing }, - { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Charging }, + { + from: OCPP16ChargePointStatus.SuspendedEV, + to: OCPP16ChargePointStatus.Charging + }, // { from: OCPP16ChargePointStatus.SuspendedEV, OCPP16ChargePointStatus.SuspendedEV }, - { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.SuspendedEVSE }, - { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Finishing }, + { + from: OCPP16ChargePointStatus.SuspendedEV, + to: OCPP16ChargePointStatus.SuspendedEVSE + }, + { + from: OCPP16ChargePointStatus.SuspendedEV, + to: OCPP16ChargePointStatus.Finishing + }, // { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Reserved }, - { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Faulted }, + { + from: OCPP16ChargePointStatus.SuspendedEV, + to: OCPP16ChargePointStatus.Unavailable + }, + { + from: OCPP16ChargePointStatus.SuspendedEV, + to: OCPP16ChargePointStatus.Faulted + }, // { to: OCPP16ChargePointStatus.SuspendedEVSE }, - { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Available }, + { + from: OCPP16ChargePointStatus.SuspendedEVSE, + to: OCPP16ChargePointStatus.Available + }, // { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Preparing }, - { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Charging }, - { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.SuspendedEV }, + { + from: OCPP16ChargePointStatus.SuspendedEVSE, + to: OCPP16ChargePointStatus.Charging + }, + { + from: OCPP16ChargePointStatus.SuspendedEVSE, + to: OCPP16ChargePointStatus.SuspendedEV + }, // { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.SuspendedEVSE }, - { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Finishing }, + { + from: OCPP16ChargePointStatus.SuspendedEVSE, + to: OCPP16ChargePointStatus.Finishing + }, // { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Reserved }, - { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Faulted }, + { + from: OCPP16ChargePointStatus.SuspendedEVSE, + to: OCPP16ChargePointStatus.Unavailable + }, + { + from: OCPP16ChargePointStatus.SuspendedEVSE, + to: OCPP16ChargePointStatus.Faulted + }, // { to: OCPP16ChargePointStatus.Finishing}, - { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Available }, - { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Preparing }, + { + from: OCPP16ChargePointStatus.Finishing, + to: OCPP16ChargePointStatus.Available + }, + { + from: OCPP16ChargePointStatus.Finishing, + to: OCPP16ChargePointStatus.Preparing + }, // { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Charging }, // { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.SuspendedEV }, // { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.SuspendedEVSE }, // { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Finishing }, // { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Reserved }, - { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Faulted }, + { + from: OCPP16ChargePointStatus.Finishing, + to: OCPP16ChargePointStatus.Unavailable + }, + { + from: OCPP16ChargePointStatus.Finishing, + to: OCPP16ChargePointStatus.Faulted + }, // { to: OCPP16ChargePointStatus.Reserved }, - { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Available }, - { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Preparing }, + { + from: OCPP16ChargePointStatus.Reserved, + to: OCPP16ChargePointStatus.Available + }, + { + from: OCPP16ChargePointStatus.Reserved, + to: OCPP16ChargePointStatus.Preparing + }, // { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Charging }, // { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.SuspendedEV }, // { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.SuspendedEVSE }, // { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Finishing }, // { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Reserved }, - { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Faulted }, + { + from: OCPP16ChargePointStatus.Reserved, + to: OCPP16ChargePointStatus.Unavailable + }, + { + from: OCPP16ChargePointStatus.Reserved, + to: OCPP16ChargePointStatus.Faulted + }, { to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Available }, - { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Preparing }, - { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Charging }, - { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.SuspendedEV }, - { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.SuspendedEVSE }, + { + from: OCPP16ChargePointStatus.Unavailable, + to: OCPP16ChargePointStatus.Available + }, + { + from: OCPP16ChargePointStatus.Unavailable, + to: OCPP16ChargePointStatus.Preparing + }, + { + from: OCPP16ChargePointStatus.Unavailable, + to: OCPP16ChargePointStatus.Charging + }, + { + from: OCPP16ChargePointStatus.Unavailable, + to: OCPP16ChargePointStatus.SuspendedEV + }, + { + from: OCPP16ChargePointStatus.Unavailable, + to: OCPP16ChargePointStatus.SuspendedEVSE + }, // { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Finishing }, // { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Reserved }, // { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Faulted }, + { + from: OCPP16ChargePointStatus.Unavailable, + to: OCPP16ChargePointStatus.Faulted + }, { to: OCPP16ChargePointStatus.Faulted }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Available }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Preparing }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Charging }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.SuspendedEV }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.SuspendedEVSE }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Finishing }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Reserved }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Unavailable } + { + from: OCPP16ChargePointStatus.Faulted, + to: OCPP16ChargePointStatus.Available + }, + { + from: OCPP16ChargePointStatus.Faulted, + to: OCPP16ChargePointStatus.Preparing + }, + { + from: OCPP16ChargePointStatus.Faulted, + to: OCPP16ChargePointStatus.Charging + }, + { + from: OCPP16ChargePointStatus.Faulted, + to: OCPP16ChargePointStatus.SuspendedEV + }, + { + from: OCPP16ChargePointStatus.Faulted, + to: OCPP16ChargePointStatus.SuspendedEVSE + }, + { + from: OCPP16ChargePointStatus.Faulted, + to: OCPP16ChargePointStatus.Finishing + }, + { + from: OCPP16ChargePointStatus.Faulted, + to: OCPP16ChargePointStatus.Reserved + }, + { + from: OCPP16ChargePointStatus.Faulted, + to: OCPP16ChargePointStatus.Unavailable + } // { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Faulted } ]) } diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 84fb39c1..0c8db60c 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -433,11 +433,15 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { .then(response => { if (response.status === OCPP16AuthorizationStatus.ACCEPTED) { logger.debug( - `${chargingStation.logPrefix()} Remote start transaction ACCEPTED on ${chargingStation.stationInfo?.chargingStationId}#${connectorId} for idTag '${idTag}'` + `${chargingStation.logPrefix()} Remote start transaction ACCEPTED on ${ + chargingStation.stationInfo?.chargingStationId + }#${connectorId} for idTag '${idTag}'` ) } else { logger.debug( - `${chargingStation.logPrefix()} Remote start transaction REJECTED on ${chargingStation.stationInfo?.chargingStationId}#${connectorId} for idTag '${idTag}'` + `${chargingStation.logPrefix()} Remote start transaction REJECTED on ${ + chargingStation.stationInfo?.chargingStationId + }#${connectorId} for idTag '${idTag}'` ) } }) @@ -465,11 +469,15 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { .then(response => { if (response.status === GenericStatus.Accepted) { logger.debug( - `${chargingStation.logPrefix()} Remote stop transaction ACCEPTED on ${chargingStation.stationInfo?.chargingStationId}#${connectorId} for transaction '${transactionId}'` + `${chargingStation.logPrefix()} Remote stop transaction ACCEPTED on ${ + chargingStation.stationInfo?.chargingStationId + }#${connectorId} for transaction '${transactionId}'` ) } else { logger.debug( - `${chargingStation.logPrefix()} Remote stop transaction REJECTED on ${chargingStation.stationInfo?.chargingStationId}#${connectorId} for transaction '${transactionId}'` + `${chargingStation.logPrefix()} Remote stop transaction REJECTED on ${ + chargingStation.stationInfo?.chargingStationId + }#${connectorId} for transaction '${transactionId}'` ) } }) @@ -1196,7 +1204,9 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { ) } logger.debug( - `${chargingStation.logPrefix()} Remote start transaction ACCEPTED on ${chargingStation.stationInfo?.chargingStationId}#${transactionConnectorId}}, idTag '${idTag}'` + `${chargingStation.logPrefix()} Remote start transaction ACCEPTED on ${ + chargingStation.stationInfo?.chargingStationId + }#${transactionConnectorId}}, idTag '${idTag}'` ) return OCPP16Constants.OCPP_RESPONSE_ACCEPTED } @@ -1208,7 +1218,11 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { ): GenericResponse { const connectorStatus = chargingStation.getConnectorStatus(connectorId) logger.debug( - `${chargingStation.logPrefix()} Remote start transaction REJECTED on ${chargingStation.stationInfo?.chargingStationId}#${connectorId}, idTag '${idTag}', availability '${connectorStatus?.availability}', status '${connectorStatus?.status}'` + `${chargingStation.logPrefix()} Remote start transaction REJECTED on ${ + chargingStation.stationInfo?.chargingStationId + }#${connectorId}, idTag '${idTag}', availability '${ + connectorStatus?.availability + }', status '${connectorStatus?.status}'` ) return OCPP16Constants.OCPP_RESPONSE_REJECTED } @@ -1221,7 +1235,9 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { if (chargingProfile.chargingProfilePurpose === OCPP16ChargingProfilePurposeType.TX_PROFILE) { OCPP16ServiceUtils.setChargingProfile(chargingStation, connectorId, chargingProfile) logger.debug( - `${chargingStation.logPrefix()} Charging profile(s) set at remote start transaction on ${chargingStation.stationInfo?.chargingStationId}#${connectorId}`, + `${chargingStation.logPrefix()} Charging profile(s) set at remote start transaction on ${ + chargingStation.stationInfo?.chargingStationId + }#${connectorId}`, chargingProfile ) return true @@ -1717,7 +1733,9 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { chargingStation, OCPP16IncomingRequestCommand.CANCEL_RESERVATION, error as Error, - { errorResponse: OCPP16Constants.OCPP_CANCEL_RESERVATION_RESPONSE_REJECTED } + { + errorResponse: OCPP16Constants.OCPP_CANCEL_RESERVATION_RESPONSE_REJECTED + } )! } } diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index e6c3b434..64e33061 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -583,9 +583,9 @@ export class OCPP16ResponseService extends OCPPResponseService { authorizeConnectorStatus.idTagAuthorized = false delete authorizeConnectorStatus.authorizeIdTag logger.debug( - `${chargingStation.logPrefix()} idTag '${requestPayload.idTag}' rejected with status '${ - payload.idTagInfo.status - }'` + `${chargingStation.logPrefix()} idTag '${ + requestPayload.idTag + }' rejected with status '${payload.idTagInfo.status}'` ) } } else { @@ -698,7 +698,9 @@ export class OCPP16ResponseService extends OCPPResponseService { connectorStatus?.status !== OCPP16ChargePointStatus.Preparing ) { logger.error( - `${chargingStation.logPrefix()} Trying to start a transaction on connector id ${connectorId} with status ${connectorStatus?.status}` + `${chargingStation.logPrefix()} Trying to start a transaction on connector id ${connectorId} with status ${ + connectorStatus?.status + }` ) return } @@ -733,9 +735,9 @@ export class OCPP16ResponseService extends OCPPResponseService { logger.warn( `${chargingStation.logPrefix()} Reserved transaction ${ payload.transactionId - } started with a different idTag ${requestPayload.idTag} than the reservation one ${ - reservation.idTag - }` + } started with a different idTag ${ + requestPayload.idTag + } than the reservation one ${reservation.idTag}` ) } if (hasReservationExpired(reservation)) { @@ -774,11 +776,9 @@ export class OCPP16ResponseService extends OCPPResponseService { OCPP16ChargePointStatus.Charging ) logger.info( - `${chargingStation.logPrefix()} Transaction with id ${ - payload.transactionId - } STARTED on ${chargingStation.stationInfo?.chargingStationId}#${connectorId} for idTag '${ - requestPayload.idTag - }'` + `${chargingStation.logPrefix()} Transaction with id ${payload.transactionId} STARTED on ${ + chargingStation.stationInfo?.chargingStationId + }#${connectorId} for idTag '${requestPayload.idTag}'` ) if (chargingStation.stationInfo?.powerSharedByConnectors === true) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion diff --git a/src/charging-station/ocpp/2.0/OCPP20Constants.ts b/src/charging-station/ocpp/2.0/OCPP20Constants.ts index 7acf7aef..b4c73bc2 100644 --- a/src/charging-station/ocpp/2.0/OCPP20Constants.ts +++ b/src/charging-station/ocpp/2.0/OCPP20Constants.ts @@ -13,7 +13,10 @@ export class OCPP20Constants extends OCPPConstants { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Unavailable }, - { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Faulted }, + { + from: OCPP20ConnectorStatusEnumType.Available, + to: OCPP20ConnectorStatusEnumType.Faulted + }, { to: OCPP20ConnectorStatusEnumType.Unavailable }, { from: OCPP20ConnectorStatusEnumType.Unavailable, @@ -28,7 +31,10 @@ export class OCPP20Constants extends OCPPConstants { to: OCPP20ConnectorStatusEnumType.Faulted }, { to: OCPP20ConnectorStatusEnumType.Faulted }, - { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Available }, + { + from: OCPP20ConnectorStatusEnumType.Faulted, + to: OCPP20ConnectorStatusEnumType.Available + }, { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Unavailable @@ -40,31 +46,55 @@ export class OCPP20Constants extends OCPPConstants { [ { to: OCPP20ConnectorStatusEnumType.Available }, // { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Available }, - { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Occupied }, - { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Reserved }, + { + from: OCPP20ConnectorStatusEnumType.Available, + to: OCPP20ConnectorStatusEnumType.Occupied + }, + { + from: OCPP20ConnectorStatusEnumType.Available, + to: OCPP20ConnectorStatusEnumType.Reserved + }, { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Unavailable }, - { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Faulted }, + { + from: OCPP20ConnectorStatusEnumType.Available, + to: OCPP20ConnectorStatusEnumType.Faulted + }, // { to: OCPP20ConnectorStatusEnumType.Occupied }, - { from: OCPP20ConnectorStatusEnumType.Occupied, to: OCPP20ConnectorStatusEnumType.Available }, + { + from: OCPP20ConnectorStatusEnumType.Occupied, + to: OCPP20ConnectorStatusEnumType.Available + }, // { from: OCPP20ConnectorStatusEnumType.Occupied, to: OCPP20ConnectorStatusEnumType.Occupied }, // { from: OCPP20ConnectorStatusEnumType.Occupied, to: OCPP20ConnectorStatusEnumType.Reserved }, { from: OCPP20ConnectorStatusEnumType.Occupied, to: OCPP20ConnectorStatusEnumType.Unavailable }, - { from: OCPP20ConnectorStatusEnumType.Occupied, to: OCPP20ConnectorStatusEnumType.Faulted }, + { + from: OCPP20ConnectorStatusEnumType.Occupied, + to: OCPP20ConnectorStatusEnumType.Faulted + }, // { to: OCPP20ConnectorStatusEnumType.Reserved }, - { from: OCPP20ConnectorStatusEnumType.Reserved, to: OCPP20ConnectorStatusEnumType.Available }, - { from: OCPP20ConnectorStatusEnumType.Reserved, to: OCPP20ConnectorStatusEnumType.Occupied }, + { + from: OCPP20ConnectorStatusEnumType.Reserved, + to: OCPP20ConnectorStatusEnumType.Available + }, + { + from: OCPP20ConnectorStatusEnumType.Reserved, + to: OCPP20ConnectorStatusEnumType.Occupied + }, // { from: OCPP20ConnectorStatusEnumType.Reserved, to: OCPP20ConnectorStatusEnumType.Reserved }, { from: OCPP20ConnectorStatusEnumType.Reserved, to: OCPP20ConnectorStatusEnumType.Unavailable }, - { from: OCPP20ConnectorStatusEnumType.Reserved, to: OCPP20ConnectorStatusEnumType.Faulted }, + { + from: OCPP20ConnectorStatusEnumType.Reserved, + to: OCPP20ConnectorStatusEnumType.Faulted + }, { to: OCPP20ConnectorStatusEnumType.Unavailable }, { from: OCPP20ConnectorStatusEnumType.Unavailable, @@ -81,9 +111,18 @@ export class OCPP20Constants extends OCPPConstants { to: OCPP20ConnectorStatusEnumType.Faulted }, { to: OCPP20ConnectorStatusEnumType.Faulted }, - { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Available }, - { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Occupied }, - { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Reserved }, + { + from: OCPP20ConnectorStatusEnumType.Faulted, + to: OCPP20ConnectorStatusEnumType.Available + }, + { + from: OCPP20ConnectorStatusEnumType.Faulted, + to: OCPP20ConnectorStatusEnumType.Occupied + }, + { + from: OCPP20ConnectorStatusEnumType.Faulted, + to: OCPP20ConnectorStatusEnumType.Reserved + }, { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Unavailable diff --git a/src/charging-station/ocpp/OCPPConstants.ts b/src/charging-station/ocpp/OCPPConstants.ts index b0367387..2abb1978 100644 --- a/src/charging-station/ocpp/OCPPConstants.ts +++ b/src/charging-station/ocpp/OCPPConstants.ts @@ -26,8 +26,13 @@ export class OCPPConstants { static readonly OCPP_REQUEST_EMPTY = Constants.EMPTY_FROZEN_OBJECT static readonly OCPP_RESPONSE_EMPTY = Constants.EMPTY_FROZEN_OBJECT - static readonly OCPP_RESPONSE_ACCEPTED = Object.freeze({ status: GenericStatus.Accepted }) - static readonly OCPP_RESPONSE_REJECTED = Object.freeze({ status: GenericStatus.Rejected }) + static readonly OCPP_RESPONSE_ACCEPTED = Object.freeze({ + status: GenericStatus.Accepted + }) + + static readonly OCPP_RESPONSE_REJECTED = Object.freeze({ + status: GenericStatus.Rejected + }) static readonly OCPP_CONFIGURATION_RESPONSE_ACCEPTED = Object.freeze({ status: ConfigurationStatus.ACCEPTED @@ -65,7 +70,10 @@ export class OCPPConstants { status: ClearChargingProfileStatus.UNKNOWN }) - static readonly OCPP_RESPONSE_UNLOCKED = Object.freeze({ status: UnlockStatus.UNLOCKED }) + static readonly OCPP_RESPONSE_UNLOCKED = Object.freeze({ + status: UnlockStatus.UNLOCKED + }) + static readonly OCPP_RESPONSE_UNLOCK_FAILED = Object.freeze({ status: UnlockStatus.UNLOCK_FAILED }) diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 3a27a192..a3eca070 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -383,7 +383,11 @@ export abstract class OCPPRequestService { params.skipBufferingOnError === false ? '' : 'non ' }buffered message id '${messageId}' with content '${messageToSend}'`, commandName, - { name: error.name, message: error.message, stack: error.stack } + { + name: error.name, + message: error.message, + stack: error.stack + } ) ) } diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index 256544fa..9b2fee9c 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -297,7 +297,7 @@ export const buildMeterValue = ( const socMinimumValue = socSampledValueTemplate.minimumValue ?? 0 const socSampledValueTemplateValue = isNotEmptyString(socSampledValueTemplate.value) ? getRandomFloatFluctuatedRounded( - parseInt(socSampledValueTemplate.value), + Number.parseInt(socSampledValueTemplate.value), socSampledValueTemplate.fluctuationPercent ?? Constants.DEFAULT_FLUCTUATION_PERCENT ) : randomInt(socMinimumValue, socMaximumValue) @@ -314,7 +314,9 @@ export const buildMeterValue = ( `${chargingStation.logPrefix()} MeterValues measurand ${ meterValue.sampledValue[sampledValuesIndex].measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER - }: connector id ${connectorId}, transaction id ${connector?.transactionId}, value: ${socMinimumValue}/${ + }: connector id ${connectorId}, transaction id ${ + connector?.transactionId + }, value: ${socMinimumValue}/${ meterValue.sampledValue[sampledValuesIndex].value }/${socMaximumValue}` ) @@ -328,7 +330,7 @@ export const buildMeterValue = ( ) if (voltageSampledValueTemplate != null) { const voltageSampledValueTemplateValue = isNotEmptyString(voltageSampledValueTemplate.value) - ? parseInt(voltageSampledValueTemplate.value) + ? Number.parseInt(voltageSampledValueTemplate.value) : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion chargingStation.stationInfo.voltageOut! const fluctuationPercent = @@ -363,7 +365,7 @@ export const buildMeterValue = ( const voltagePhaseLineToNeutralSampledValueTemplateValue = isNotEmptyString( voltagePhaseLineToNeutralSampledValueTemplate.value ) - ? parseInt(voltagePhaseLineToNeutralSampledValueTemplate.value) + ? Number.parseInt(voltagePhaseLineToNeutralSampledValueTemplate.value) : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion chargingStation.stationInfo.voltageOut! const fluctuationPhaseToNeutralPercent = @@ -405,7 +407,7 @@ export const buildMeterValue = ( const voltagePhaseLineToLineSampledValueTemplateValue = isNotEmptyString( voltagePhaseLineToLineSampledValueTemplate.value ) - ? parseInt(voltagePhaseLineToLineSampledValueTemplate.value) + ? Number.parseInt(voltagePhaseLineToLineSampledValueTemplate.value) : voltagePhaseLineToLineValueRounded const fluctuationPhaseLineToLinePercent = voltagePhaseLineToLineSampledValueTemplate.fluctuationPercent ?? @@ -646,7 +648,9 @@ export const buildMeterValue = ( `${chargingStation.logPrefix()} MeterValues measurand ${ meterValue.sampledValue[sampledValuesIndex].measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER - }: connector id ${connectorId}, transaction id ${connector?.transactionId}, value: ${connectorMinimumPowerRounded}/${ + }: connector id ${connectorId}, transaction id ${ + connector?.transactionId + }, value: ${connectorMinimumPowerRounded}/${ meterValue.sampledValue[sampledValuesIndex].value }/${connectorMaximumPowerRounded}` ) @@ -689,7 +693,9 @@ export const buildMeterValue = ( MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER }: phase ${ meterValue.sampledValue[sampledValuesPerPhaseIndex].phase - }, connector id ${connectorId}, transaction id ${connector?.transactionId}, value: ${connectorMinimumPowerPerPhaseRounded}/${ + }, connector id ${connectorId}, transaction id ${ + connector?.transactionId + }, value: ${connectorMinimumPowerPerPhaseRounded}/${ meterValue.sampledValue[sampledValuesPerPhaseIndex].value }/${connectorMaximumPowerPerPhaseRounded}` ) @@ -901,7 +907,9 @@ export const buildMeterValue = ( `${chargingStation.logPrefix()} MeterValues measurand ${ meterValue.sampledValue[sampledValuesIndex].measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER - }: connector id ${connectorId}, transaction id ${connector?.transactionId}, value: ${connectorMinimumAmperage}/${ + }: connector id ${connectorId}, transaction id ${ + connector?.transactionId + }, value: ${connectorMinimumAmperage}/${ meterValue.sampledValue[sampledValuesIndex].value }/${connectorMaximumAmperage}` ) @@ -936,7 +944,9 @@ export const buildMeterValue = ( MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER }: phase ${ meterValue.sampledValue[sampledValuesPerPhaseIndex].phase - }, connector id ${connectorId}, transaction id ${connector?.transactionId}, value: ${connectorMinimumAmperage}/${ + }, connector id ${connectorId}, transaction id ${ + connector?.transactionId + }, value: ${connectorMinimumAmperage}/${ meterValue.sampledValue[sampledValuesPerPhaseIndex].value }/${connectorMaximumAmperage}` ) @@ -1009,7 +1019,9 @@ export const buildMeterValue = ( `${chargingStation.logPrefix()} MeterValues measurand ${ meterValue.sampledValue[sampledValuesIndex].measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER - }: connector id ${connectorId}, transaction id ${connector?.transactionId}, value: ${connectorMinimumEnergyRounded}/${energyValueRounded}/${connectorMaximumEnergyRounded}, duration: ${interval}ms` + }: connector id ${connectorId}, transaction id ${ + connector?.transactionId + }, value: ${connectorMinimumEnergyRounded}/${energyValueRounded}/${connectorMaximumEnergyRounded}, duration: ${interval}ms` ) } } @@ -1081,7 +1093,11 @@ const getLimitFromSampledValueTemplateCustomValue = ( value: string | undefined, maxLimit: number, minLimit: number, - options?: { limitationEnabled?: boolean, fallbackValue?: number, unitMultiplier?: number } + options?: { + limitationEnabled?: boolean + fallbackValue?: number + unitMultiplier?: number + } ): number => { options = { ...{ @@ -1091,11 +1107,14 @@ const getLimitFromSampledValueTemplateCustomValue = ( }, ...options } - const parsedValue = parseInt(value ?? '') + const parsedValue = Number.parseInt(value ?? '') if (options.limitationEnabled === true) { return max( - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - min((!isNaN(parsedValue) ? parsedValue : Infinity) * options.unitMultiplier!, maxLimit), + min( + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + (!isNaN(parsedValue) ? parsedValue : Number.POSITIVE_INFINITY) * options.unitMultiplier!, + maxLimit + ), minLimit ) } diff --git a/src/charging-station/ui-server/AbstractUIServer.ts b/src/charging-station/ui-server/AbstractUIServer.ts index 9d2705f2..a786fbbd 100644 --- a/src/charging-station/ui-server/AbstractUIServer.ts +++ b/src/charging-station/ui-server/AbstractUIServer.ts @@ -166,7 +166,9 @@ export abstract class AbstractUIServer { const authorizationProtocol = req.headers['sec-websocket-protocol']?.split(/,\s+/).pop() const [username, password] = getUsernameAndPasswordFromAuthorizationToken( // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - `${authorizationProtocol}${Array(((4 - (authorizationProtocol!.length % 4)) % 4) + 1).join('=')}` + `${authorizationProtocol}${Array(((4 - (authorizationProtocol!.length % 4)) % 4) + 1).join( + '=' + )}` .split('.') .pop() ?? '', next diff --git a/src/charging-station/ui-server/UIServerFactory.ts b/src/charging-station/ui-server/UIServerFactory.ts index 34138e02..cf176bdc 100644 --- a/src/charging-station/ui-server/UIServerFactory.ts +++ b/src/charging-station/ui-server/UIServerFactory.ts @@ -68,8 +68,10 @@ export class UIServerFactory { uiServerConfiguration.type as ApplicationProtocol ) ) { - // eslint-disable-next-line @typescript-eslint/no-base-to-string - const logMsg = `Unknown application protocol type '${uiServerConfiguration.type}' in '${ConfigurationSection.uiServer}' configuration section from values '${ApplicationProtocol.toString()}', defaulting to '${ + const logMsg = `Unknown application protocol type '${uiServerConfiguration.type}' in '${ + ConfigurationSection.uiServer + // eslint-disable-next-line @typescript-eslint/no-base-to-string + }' configuration section from values '${ApplicationProtocol.toString()}', defaulting to '${ ApplicationProtocol.WS }'` logger.warn(`${UIServerFactory.logPrefix()} ${logMsg}`) diff --git a/src/performance/PerformanceStatistics.ts b/src/performance/PerformanceStatistics.ts index f05a4182..07893578 100644 --- a/src/performance/PerformanceStatistics.ts +++ b/src/performance/PerformanceStatistics.ts @@ -179,9 +179,9 @@ export class PerformanceStatistics { ) if (performanceStorageConfiguration.enabled === true) { logger.info( - `${this.logPrefix()} storage enabled: type ${performanceStorageConfiguration.type}, uri: ${ - performanceStorageConfiguration.uri - }` + `${this.logPrefix()} storage enabled: type ${ + performanceStorageConfiguration.type + }, uri: ${performanceStorageConfiguration.uri}` ) } } @@ -290,9 +290,10 @@ export class PerformanceStatistics { Constants.DEFAULT_CIRCULAR_BUFFER_CAPACITY ) } - this.statistics.statisticsData - .get(entry.name) - ?.measurementTimeSeries?.push({ timestamp: entry.startTime, value: entry.duration }) + this.statistics.statisticsData.get(entry.name)?.measurementTimeSeries?.push({ + timestamp: entry.startTime, + value: entry.duration + }) const timeMeasurementValues = extractTimeSeriesValues( // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this.statistics.statisticsData.get(entry.name)!.measurementTimeSeries! diff --git a/src/performance/storage/MongoDBStorage.ts b/src/performance/storage/MongoDBStorage.ts index c3c98022..3d99284f 100644 --- a/src/performance/storage/MongoDBStorage.ts +++ b/src/performance/storage/MongoDBStorage.ts @@ -25,7 +25,9 @@ export class MongoDBStorage extends Storage { await this.client ?.db(this.dbName) .collection(Constants.PERFORMANCE_RECORDS_TABLE) - .replaceOne({ id: performanceStatistics.id }, performanceStatistics, { upsert: true }) + .replaceOne({ id: performanceStatistics.id }, performanceStatistics, { + upsert: true + }) } catch (error) { this.handleDBError(StorageType.MONGO_DB, error as Error, Constants.PERFORMANCE_RECORDS_TABLE) } diff --git a/src/performance/storage/Storage.ts b/src/performance/storage/Storage.ts index aee3ae9e..46a3a6db 100644 --- a/src/performance/storage/Storage.ts +++ b/src/performance/storage/Storage.ts @@ -26,7 +26,10 @@ export abstract class Storage { type: StorageType, error: Error, table?: string, - params: HandleErrorParams = { throwError: false, consoleOut: false } + params: HandleErrorParams = { + throwError: false, + consoleOut: false + } ): void { setDefaultErrorParams(params, { throwError: false, consoleOut: false }) const inTableOrCollectionStr = table != null && ` in table or collection '${table}'` diff --git a/src/scripts/deleteChargingStations.cjs b/src/scripts/deleteChargingStations.cjs index 19fd7185..34538142 100755 --- a/src/scripts/deleteChargingStations.cjs +++ b/src/scripts/deleteChargingStations.cjs @@ -14,7 +14,7 @@ const config = JSON.parse(fs.readFileSync('scriptConfig.json', 'utf8')) // Mongo Connection and Query if (config?.mongoConnectionString) { // eslint-disable-next-line n/handle-callback-err - MongoClient.connect(config.mongoConnectionString, async function (_err, client) { + MongoClient.connect(config.mongoConnectionString, async (_err, client) => { const db = client.db() for await (const tenantID of config.tenantIDs) { diff --git a/src/scripts/setCSPublicFlag.cjs b/src/scripts/setCSPublicFlag.cjs index d41dc166..09e5873b 100755 --- a/src/scripts/setCSPublicFlag.cjs +++ b/src/scripts/setCSPublicFlag.cjs @@ -15,7 +15,7 @@ const config = JSON.parse(fs.readFileSync('scriptConfig.json', 'utf8')) // Mongo Connection and Query if (config?.mongoConnectionString) { // eslint-disable-next-line n/handle-callback-err - MongoClient.connect(config.mongoConnectionString, async function (_err, client) { + MongoClient.connect(config.mongoConnectionString, async (_err, client) => { const db = client.db() for await (const tenantID of config.tenantIDs) { diff --git a/src/utils/ChargingStationConfigurationUtils.ts b/src/utils/ChargingStationConfigurationUtils.ts index 7b5346d5..c5330a0d 100644 --- a/src/utils/ChargingStationConfigurationUtils.ts +++ b/src/utils/ChargingStationConfigurationUtils.ts @@ -25,7 +25,7 @@ export const buildConnectorsStatus = (chargingStation: ChargingStation): Connect ) } -export const enum OutputFormat { +export enum OutputFormat { configuration = 'configuration', worker = 'worker' } diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index 25a1475b..cd3e0e8a 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -171,7 +171,7 @@ export class Configuration { if (isCFEnvironment()) { delete uiServerConfiguration.options?.host // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - uiServerConfiguration.options!.port = parseInt(env.PORT!) + uiServerConfiguration.options!.port = Number.parseInt(env.PORT!) } return uiServerConfiguration } diff --git a/src/utils/ErrorUtils.ts b/src/utils/ErrorUtils.ts index 9c243a29..36a5f04c 100644 --- a/src/utils/ErrorUtils.ts +++ b/src/utils/ErrorUtils.ts @@ -80,7 +80,10 @@ export const handleSendMessageError = ( chargingStation: ChargingStation, commandName: RequestCommand | IncomingRequestCommand, error: Error, - params: HandleErrorParams = { throwError: false, consoleOut: false } + params: HandleErrorParams = { + throwError: false, + consoleOut: false + } ): void => { setDefaultErrorParams(params, { throwError: false, consoleOut: false }) logger.error(`${chargingStation.logPrefix()} Request command '${commandName}' error:`, error) diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index fe059e06..9d021ecb 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -113,7 +113,7 @@ export const convertToInt = (value: unknown): number => { } let changedValue: number = value as number if (typeof value === 'string') { - changedValue = parseInt(value) + changedValue = Number.parseInt(value) } if (isNaN(changedValue)) { throw new Error(`Cannot convert to integer: '${String(value)}'`) @@ -127,7 +127,7 @@ export const convertToFloat = (value: unknown): number => { } let changedValue: number = value as number if (typeof value === 'string') { - changedValue = parseFloat(value) + changedValue = Number.parseFloat(value) } if (isNaN(changedValue)) { throw new Error(`Cannot convert to float: '${String(value)}'`) @@ -282,7 +282,9 @@ export const JSONStringify = < if (is(Map, value)) { switch (mapFormat) { case MapStringifyFormat.object: - return { ...Object.fromEntries>>(value.entries()) } + return { + ...Object.fromEntries>>(value.entries()) + } case MapStringifyFormat.array: default: return [...value] diff --git a/src/worker/WorkerSet.ts b/src/worker/WorkerSet.ts index c45e6a61..1774c24a 100644 --- a/src/worker/WorkerSet.ts +++ b/src/worker/WorkerSet.ts @@ -130,7 +130,11 @@ export class WorkerSet extends Worke data: elementData } satisfies WorkerMessage workerSetElement.worker.postMessage(message) - this.promiseResponseMap.set(message.uuid, { resolve, reject, workerSetElement }) + this.promiseResponseMap.set(message.uuid, { + resolve, + reject, + workerSetElement + }) }) const response = await sendMessageToWorker // Add element sequentially to optimize memory at startup @@ -199,7 +203,10 @@ export class WorkerSet extends Worke worker.once('exit', () => { this.removeWorkerSetElement(this.getWorkerSetElementByWorker(worker)) }) - const workerSetElement: WorkerSetElement = { worker, numberOfWorkerElements: 0 } + const workerSetElement: WorkerSetElement = { + worker, + numberOfWorkerElements: 0 + } this.workerSet.add(workerSetElement) this.workerStartup = false return workerSetElement diff --git a/tests/utils/Utils.test.ts b/tests/utils/Utils.test.ts index 8ab1332b..de5b1fd7 100644 --- a/tests/utils/Utils.test.ts +++ b/tests/utils/Utils.test.ts @@ -232,7 +232,7 @@ await describe('Utils test suite', async () => { expect(isAsyncFunction([])).toBe(false) expect(isAsyncFunction(new Date())).toBe(false) // eslint-disable-next-line prefer-regex-literals - expect(isAsyncFunction(new RegExp('[a-z]', 'i'))).toBe(false) + expect(isAsyncFunction(/[a-z]/i)).toBe(false) expect(isAsyncFunction(new Error())).toBe(false) expect(isAsyncFunction(new Map())).toBe(false) expect(isAsyncFunction(new Set())).toBe(false) diff --git a/ui/web/src/composables/UIClient.ts b/ui/web/src/composables/UIClient.ts index 9522c592..04587e2d 100644 --- a/ui/web/src/composables/UIClient.ts +++ b/ui/web/src/composables/UIClient.ts @@ -105,7 +105,9 @@ export class UIClient { } public async deleteChargingStation(hashId: string): Promise { - return this.sendRequest(ProcedureName.DELETE_CHARGING_STATIONS, { hashIds: [hashId] }) + return this.sendRequest(ProcedureName.DELETE_CHARGING_STATIONS, { + hashIds: [hashId] + }) } public async setSupervisionUrl(hashId: string, supervisionUrl: string): Promise { @@ -116,11 +118,15 @@ export class UIClient { } public async startChargingStation(hashId: string): Promise { - return this.sendRequest(ProcedureName.START_CHARGING_STATION, { hashIds: [hashId] }) + return this.sendRequest(ProcedureName.START_CHARGING_STATION, { + hashIds: [hashId] + }) } public async stopChargingStation(hashId: string): Promise { - return this.sendRequest(ProcedureName.STOP_CHARGING_STATION, { hashIds: [hashId] }) + return this.sendRequest(ProcedureName.STOP_CHARGING_STATION, { + hashIds: [hashId] + }) } public async openConnection(hashId: string): Promise { @@ -183,11 +189,17 @@ export class UIClient { this.uiServerConfiguration.authentication?.type === AuthenticationType.PROTOCOL_BASIC_AUTH ? [ `${this.uiServerConfiguration.protocol}${this.uiServerConfiguration.version}`, - `authorization.basic.${btoa(`${this.uiServerConfiguration.authentication.username}:${this.uiServerConfiguration.authentication.password}`).replace(/={1,2}$/, '')}` + `authorization.basic.${btoa( + `${this.uiServerConfiguration.authentication.username}:${this.uiServerConfiguration.authentication.password}` + ).replace(/={1,2}$/, '')}` ] : `${this.uiServerConfiguration.protocol}${this.uiServerConfiguration.version}` this.ws = new WebSocket( - `${this.uiServerConfiguration.secure === true ? ApplicationProtocol.WSS : ApplicationProtocol.WS}://${this.uiServerConfiguration.host}:${this.uiServerConfiguration.port}`, + `${ + this.uiServerConfiguration.secure === true + ? ApplicationProtocol.WSS + : ApplicationProtocol.WS + }://${this.uiServerConfiguration.host}:${this.uiServerConfiguration.port}`, protocols ) this.ws.onopen = () => { diff --git a/ui/web/src/composables/Utils.ts b/ui/web/src/composables/Utils.ts index 0c8a8399..b1bebc92 100644 --- a/ui/web/src/composables/Utils.ts +++ b/ui/web/src/composables/Utils.ts @@ -27,7 +27,7 @@ export const convertToInt = (value: unknown): number => { } let changedValue: number = value as number if (typeof value === 'string') { - changedValue = parseInt(value) + changedValue = Number.parseInt(value) } if (isNaN(changedValue)) { throw new Error(`Cannot convert to integer: '${String(value)}'`) diff --git a/ui/web/src/shims-vue.d.ts b/ui/web/src/shims-vue.d.ts index 6f0d76e3..48265c5a 100644 --- a/ui/web/src/shims-vue.d.ts +++ b/ui/web/src/shims-vue.d.ts @@ -1,4 +1,4 @@ -export {} +export type {} declare module 'vue' { export interface GlobalComponents { diff --git a/ui/web/src/views/ChargingStationsView.vue b/ui/web/src/views/ChargingStationsView.vue index 695b8860..af6fbe99 100644 --- a/ui/web/src/views/ChargingStationsView.vue +++ b/ui/web/src/views/ChargingStationsView.vue @@ -142,7 +142,9 @@ const simulatorButtonClass = computed(() => ) const simulatorButtonMessage = computed( () => - `${simulatorState.value?.started === true ? 'Stop' : 'Start'} Simulator${simulatorState.value?.version != null ? ` (${simulatorState.value.version})` : ''}` + `${simulatorState.value?.started === true ? 'Stop' : 'Start'} Simulator${ + simulatorState.value?.version != null ? ` (${simulatorState.value.version})` : '' + }` ) const state = ref<{ @@ -286,7 +288,10 @@ onUnmounted(() => { unregisterWSEventListeners() }) -const uiServerConfigurations: { index: number; configuration: UIServerConfigurationSection }[] = ( +const uiServerConfigurations: { + index: number + configuration: UIServerConfigurationSection +}[] = ( app?.appContext.config.globalProperties.$configuration.value .uiServer as UIServerConfigurationSection[] ).map((configuration: UIServerConfigurationSection, index: number) => ({ diff --git a/ui/web/start.js b/ui/web/start.js index 46a8bb75..3eb2838e 100644 --- a/ui/web/start.js +++ b/ui/web/start.js @@ -7,7 +7,7 @@ import finalhandler from 'finalhandler' import serveStatic from 'serve-static' const isCFEnvironment = env.VCAP_APPLICATION != null -const PORT = isCFEnvironment ? parseInt(env.PORT) : 3030 +const PORT = isCFEnvironment ? Number.parseInt(env.PORT) : 3030 const uiPath = join(dirname(fileURLToPath(import.meta.url)), './dist') const serve = serveStatic(uiPath)