X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStation.ts;h=5b5ac56e4d79e8ced4d3e15758f7b554f331550e;hb=98dc07faaf264c0263d2c8de382efa9db59cd5b4;hp=79336707c621f0785e14baa78f860f4bbb260a9a;hpb=a472cf2bed2330c2a1a485e5b5a9703806d7d140;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 79336707..5b5ac56e 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -84,7 +84,7 @@ export default class ChargingStation { return this.bootNotificationRequest; } - public getRandomTagId(): string { + public getRandomIdTag(): string { const index = Math.floor(Utils.secureRandom() * this.authorizedTags.length); return this.authorizedTags[index]; } @@ -525,7 +525,7 @@ export default class ChargingStation { // Generate all connectors if ((this.stationInfo.Connectors[0] ? templateMaxConnectors - 1 : templateMaxConnectors) > 0) { for (let index = 1; index <= maxConnectors; index++) { - const randConnectorId = this.stationInfo.randomConnectors ? Utils.getRandomInt(Utils.convertToInt(lastConnector), 1) : index; + const randConnectorId = this.stationInfo.randomConnectors ? Utils.getRandomInteger(Utils.convertToInt(lastConnector), 1) : index; this.connectors[index] = Utils.cloneObject(this.stationInfo.Connectors[randConnectorId]); this.connectors[index].availability = AvailabilityType.OPERATIVE; if (Utils.isUndefined(this.connectors[lastConnector]?.chargingProfiles)) { @@ -538,7 +538,7 @@ export default class ChargingStation { delete this.stationInfo.Connectors; // Initialize transaction attributes on connectors for (const connector in this.connectors) { - if (Utils.convertToInt(connector) > 0 && !this.getConnector(Utils.convertToInt(connector)).transactionStarted) { + if (Utils.convertToInt(connector) > 0 && !this.getConnector(Utils.convertToInt(connector))?.transactionStarted) { this.initTransactionAttributesOnConnector(Utils.convertToInt(connector)); } } @@ -766,7 +766,7 @@ export default class ChargingStation { private getNumberOfRunningTransactions(): number { let trxCount = 0; for (const connector in this.connectors) { - if (Utils.convertToInt(connector) > 0 && this.getConnector(Utils.convertToInt(connector)).transactionStarted) { + if (Utils.convertToInt(connector) > 0 && this.getConnector(Utils.convertToInt(connector))?.transactionStarted) { trxCount++; } } @@ -880,10 +880,10 @@ export default class ChargingStation { if (this.stationInfo.AutomaticTransactionGenerator.enable && this.automaticTransactionGenerator && this.automaticTransactionGenerator.started) { - await this.automaticTransactionGenerator.stop(reason); + this.automaticTransactionGenerator.stop(); } else { for (const connector in this.connectors) { - if (Utils.convertToInt(connector) > 0 && this.getConnector(Utils.convertToInt(connector)).transactionStarted) { + if (Utils.convertToInt(connector) > 0 && this.getConnector(Utils.convertToInt(connector))?.transactionStarted) { const transactionId = this.getConnector(Utils.convertToInt(connector)).transactionId; await this.ocppRequestService.sendStopTransaction(transactionId, this.getEnergyActiveImportRegisterByTransactionId(transactionId), this.getTransactionIdTag(transactionId), reason); @@ -1003,7 +1003,7 @@ export default class ChargingStation { private startStationTemplateFileMonitoring(): void { try { - fs.watch(this.stationTemplateFile, async (event, filename): Promise => { + fs.watch(this.stationTemplateFile, (event, filename): void => { if (filename && event === 'change') { try { logger.debug(this.logPrefix() + ' Template file ' + this.stationTemplateFile + ' have changed, reload'); @@ -1012,7 +1012,7 @@ export default class ChargingStation { // Restart the ATG if (!this.stationInfo.AutomaticTransactionGenerator.enable && this.automaticTransactionGenerator) { - await this.automaticTransactionGenerator.stop(); + this.automaticTransactionGenerator.stop(); } this.startAutomaticTransactionGenerator(); if (this.getEnableStatistics()) { @@ -1045,7 +1045,7 @@ export default class ChargingStation { this.stationInfo.AutomaticTransactionGenerator.stopOnConnectionFailure && this.automaticTransactionGenerator && this.automaticTransactionGenerator.started) { - await this.automaticTransactionGenerator.stop(); + this.automaticTransactionGenerator.stop(); } if (this.autoReconnectRetryCount < this.getAutoReconnectMaxRetries() || this.getAutoReconnectMaxRetries() === -1) { this.autoReconnectRetryCount++;