From: Jérôme Benoit Date: Mon, 14 Jun 2021 20:01:39 +0000 (+0200) Subject: Use ConnectionTineOut OCPP parameter as WS timeout X-Git-Tag: v1.0.20~3 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=147d0e0f63942b395dabf86ab7488f6f270cf027;p=e-mobility-charging-stations-simulator.git Use ConnectionTineOut OCPP parameter as WS timeout Signed-off-by: Jérôme Benoit --- diff --git a/README.md b/README.md index 5246171d..db22f0e1 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,6 @@ numberOfConnectors | | | integer\|integer[] | charging stations number of connec useConnectorId0 | true/false | true | boolean | use connector id 0 definition from the template randomConnectors | true/false | false | boolean | randomize runtime connector id affectation from the connector id definition in template resetTime | | 60 | integer | seconds to wait before the charging stations come back at reset -connectionTimeout | | 30 | integer | connection timeout to the OCPP-J server autoReconnectMaxRetries | | -1 (unlimited) | integer | connection retries to the OCPP-J server reconnectExponentialDelay | true/false | false | boolean | connection delay retry to the OCPP-J server registrationMaxRetries | | -1 (unlimited) | integer | charging stations boot notification retries diff --git a/package-lock.json b/package-lock.json index c7d3bee1..a7732ebb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1897,13 +1897,13 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "4.26.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.26.1.tgz", - "integrity": "sha512-aoIusj/8CR+xDWmZxARivZjbMBQTT9dImUtdZ8tVCVRXgBUuuZyM5Of5A9D9arQPxbi/0rlJLcuArclz/rCMJw==", + "version": "4.27.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.27.0.tgz", + "integrity": "sha512-DsLqxeUfLVNp3AO7PC3JyaddmEHTtI9qTSAs+RB6ja27QvIM0TA8Cizn1qcS6vOu+WDLFJzkwkgweiyFhssDdQ==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "4.26.1", - "@typescript-eslint/scope-manager": "4.26.1", + "@typescript-eslint/experimental-utils": "4.27.0", + "@typescript-eslint/scope-manager": "4.27.0", "debug": "^4.3.1", "functional-red-black-tree": "^1.0.1", "lodash": "^4.17.21", @@ -1954,15 +1954,15 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "4.26.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.26.1.tgz", - "integrity": "sha512-sQHBugRhrXzRCs9PaGg6rowie4i8s/iD/DpTB+EXte8OMDfdCG5TvO73XlO9Wc/zi0uyN4qOmX9hIjQEyhnbmQ==", + "version": "4.27.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.27.0.tgz", + "integrity": "sha512-n5NlbnmzT2MXlyT+Y0Jf0gsmAQzCnQSWXKy4RGSXVStjDvS5we9IWbh7qRVKdGcxT0WYlgcCYUK/HRg7xFhvjQ==", "dev": true, "requires": { "@types/json-schema": "^7.0.7", - "@typescript-eslint/scope-manager": "4.26.1", - "@typescript-eslint/types": "4.26.1", - "@typescript-eslint/typescript-estree": "4.26.1", + "@typescript-eslint/scope-manager": "4.27.0", + "@typescript-eslint/types": "4.27.0", + "@typescript-eslint/typescript-estree": "4.27.0", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0" }, @@ -1979,14 +1979,14 @@ } }, "@typescript-eslint/parser": { - "version": "4.26.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.26.1.tgz", - "integrity": "sha512-q7F3zSo/nU6YJpPJvQveVlIIzx9/wu75lr6oDbDzoeIRWxpoc/HQ43G4rmMoCc5my/3uSj2VEpg/D83LYZF5HQ==", + "version": "4.27.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.27.0.tgz", + "integrity": "sha512-XpbxL+M+gClmJcJ5kHnUpBGmlGdgNvy6cehgR6ufyxkEJMGP25tZKCaKyC0W/JVpuhU3VU1RBn7SYUPKSMqQvQ==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "4.26.1", - "@typescript-eslint/types": "4.26.1", - "@typescript-eslint/typescript-estree": "4.26.1", + "@typescript-eslint/scope-manager": "4.27.0", + "@typescript-eslint/types": "4.27.0", + "@typescript-eslint/typescript-estree": "4.27.0", "debug": "^4.3.1" }, "dependencies": { @@ -2008,29 +2008,29 @@ } }, "@typescript-eslint/scope-manager": { - "version": "4.26.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.26.1.tgz", - "integrity": "sha512-TW1X2p62FQ8Rlne+WEShyd7ac2LA6o27S9i131W4NwDSfyeVlQWhw8ylldNNS8JG6oJB9Ha9Xyc+IUcqipvheQ==", + "version": "4.27.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.27.0.tgz", + "integrity": "sha512-DY73jK6SEH6UDdzc6maF19AHQJBFVRf6fgAXHPXCGEmpqD4vYgPEzqpFz1lf/daSbOcMpPPj9tyXXDPW2XReAw==", "dev": true, "requires": { - "@typescript-eslint/types": "4.26.1", - "@typescript-eslint/visitor-keys": "4.26.1" + "@typescript-eslint/types": "4.27.0", + "@typescript-eslint/visitor-keys": "4.27.0" } }, "@typescript-eslint/types": { - "version": "4.26.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.26.1.tgz", - "integrity": "sha512-STyMPxR3cS+LaNvS8yK15rb8Y0iL0tFXq0uyl6gY45glyI7w0CsyqyEXl/Fa0JlQy+pVANeK3sbwPneCbWE7yg==", + "version": "4.27.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.27.0.tgz", + "integrity": "sha512-I4ps3SCPFCKclRcvnsVA/7sWzh7naaM/b4pBO2hVxnM3wrU51Lveybdw5WoIktU/V4KfXrTt94V9b065b/0+wA==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "4.26.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.26.1.tgz", - "integrity": "sha512-l3ZXob+h0NQzz80lBGaykdScYaiEbFqznEs99uwzm8fPHhDjwaBFfQkjUC/slw6Sm7npFL8qrGEAMxcfBsBJUg==", + "version": "4.27.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.27.0.tgz", + "integrity": "sha512-KH03GUsUj41sRLLEy2JHstnezgpS5VNhrJouRdmh6yNdQ+yl8w5LrSwBkExM+jWwCJa7Ct2c8yl8NdtNRyQO6g==", "dev": true, "requires": { - "@typescript-eslint/types": "4.26.1", - "@typescript-eslint/visitor-keys": "4.26.1", + "@typescript-eslint/types": "4.27.0", + "@typescript-eslint/visitor-keys": "4.27.0", "debug": "^4.3.1", "globby": "^11.0.3", "is-glob": "^4.0.1", @@ -2100,12 +2100,12 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "4.26.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.26.1.tgz", - "integrity": "sha512-IGouNSSd+6x/fHtYRyLOM6/C+QxMDzWlDtN41ea+flWuSF9g02iqcIlX8wM53JkfljoIjP0U+yp7SiTS1onEkw==", + "version": "4.27.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.27.0.tgz", + "integrity": "sha512-es0GRYNZp0ieckZ938cEANfEhsfHrzuLrePukLKtY3/KPXcq1Xd555Mno9/GOgXhKzn0QfkDLVgqWO3dGY80bg==", "dev": true, "requires": { - "@typescript-eslint/types": "4.26.1", + "@typescript-eslint/types": "4.27.0", "eslint-visitor-keys": "^2.0.0" } }, diff --git a/package.json b/package.json index a51052c1..1da708ac 100644 --- a/package.json +++ b/package.json @@ -78,8 +78,8 @@ "@types/node": "^14.17.3", "@types/uuid": "^8.3.0", "@types/ws": "^7.4.4", - "@typescript-eslint/eslint-plugin": "^4.26.1", - "@typescript-eslint/parser": "^4.26.1", + "@typescript-eslint/eslint-plugin": "^4.27.0", + "@typescript-eslint/parser": "^4.27.0", "auto-changelog": "^2.3.0", "clinic": "^9.0.0", "cross-env": "^7.0.3", diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index e0845e75..ed9b79f0 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -503,6 +503,19 @@ export default class ChargingStation { break; } // OCPP parameters + this.initOCPPParameters(); + this.stationInfo.powerDivider = this.getPowerDivider(); + if (this.getEnableStatistics()) { + this.performanceStatistics = new PerformanceStatistics(this.stationInfo.chargingStationId); + this.performanceObserver = new PerformanceObserver((list) => { + const entry = list.getEntries()[0]; + this.performanceStatistics.logPerformance(entry, Constants.ENTITY_CHARGING_STATION); + this.performanceObserver.disconnect(); + }); + } + } + + private initOCPPParameters(): void { if (!this.getConfigurationKey(StandardParametersKey.SupportedFeatureProfiles)) { this.addConfigurationKey(StandardParametersKey.SupportedFeatureProfiles, `${SupportedFeatureProfiles.Core},${SupportedFeatureProfiles.Local_Auth_List_Management},${SupportedFeatureProfiles.Smart_Charging}`); } @@ -534,14 +547,8 @@ export default class ChargingStation { && this.getConfigurationKey(StandardParametersKey.SupportedFeatureProfiles).value.includes(SupportedFeatureProfiles.Local_Auth_List_Management)) { this.addConfigurationKey(StandardParametersKey.LocalAuthListEnabled, 'false'); } - this.stationInfo.powerDivider = this.getPowerDivider(); - if (this.getEnableStatistics()) { - this.performanceStatistics = new PerformanceStatistics(this.stationInfo.chargingStationId); - this.performanceObserver = new PerformanceObserver((list) => { - const entry = list.getEntries()[0]; - this.performanceStatistics.logPerformance(entry, Constants.ENTITY_CHARGING_STATION); - this.performanceObserver.disconnect(); - }); + if (!this.getConfigurationKey(StandardParametersKey.ConnectionTimeOut)) { + this.addConfigurationKey(StandardParametersKey.ConnectionTimeOut, Constants.DEFAULT_CONNECTION_TIMEOUT.toString()); } } @@ -710,12 +717,6 @@ export default class ChargingStation { if (this.getConfigurationKey(StandardParametersKey.ConnectionTimeOut)) { return parseInt(this.getConfigurationKey(StandardParametersKey.ConnectionTimeOut).value) ?? Constants.DEFAULT_CONNECTION_TIMEOUT; } - if (!Utils.isUndefined(this.stationInfo.connectionTimeout)) { - return this.stationInfo.connectionTimeout; - } - if (!Utils.isUndefined(Configuration.getConnectionTimeout())) { - return Configuration.getConnectionTimeout(); - } return Constants.DEFAULT_CONNECTION_TIMEOUT; } diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index ebc8a391..4b436c47 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -22,8 +22,8 @@ export default class Configuration { } static getConnectionTimeout(): number { - Configuration.deprecateConfigurationKey('autoReconnectTimeout', 'Use \'connectionTimeout\' in charging station instead'); - Configuration.deprecateConfigurationKey('connectionTimeout', 'Use it in charging station template instead'); + Configuration.deprecateConfigurationKey('autoReconnectTimeout', 'Use \'ConnectionTimeOut\' OCPP parameter in charging station template instead'); + Configuration.deprecateConfigurationKey('connectionTimeout', 'Use \'ConnectionTimeOut\' OCPP parameter in charging station template instead'); // Read conf if (Configuration.objectHasOwnProperty(Configuration.getConfig(), 'connectionTimeout')) { return Configuration.getConfig().connectionTimeout; diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 7485b14f..293b7184 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -4,6 +4,10 @@ import { WorkerProcessType } from '../types/Worker'; import { v4 as uuid } from 'uuid'; export default class Utils { + static logPrefix(prefixString = ''): string { + return new Date().toLocaleString() + prefixString; + } + static generateUUID(): string { return uuid(); } @@ -121,10 +125,6 @@ export default class Utils { return Utils.roundTo(Utils.getRandomFloat(max), scale); } - static logPrefix(prefixString = ''): string { - return new Date().toLocaleString() + prefixString; - } - static cloneObject(object: T): T { return JSON.parse(JSON.stringify(object)) as T; }