Use ConnectionTineOut OCPP parameter as WS timeout
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 14 Jun 2021 20:01:39 +0000 (22:01 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 14 Jun 2021 20:01:39 +0000 (22:01 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
README.md
package-lock.json
package.json
src/charging-station/ChargingStation.ts
src/utils/Configuration.ts
src/utils/Utils.ts

index 5246171d9711bc5fb2458f8ade8af532cdfd9434..db22f0e1a73dad0a6e57f8d79cfb40a53256d867 100644 (file)
--- 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
index c7d3bee1fb8c637ca50294f17156cd64e7b30913..a7732ebb0249502c861b23447a57006956ed9331 100644 (file)
       "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",
       }
     },
     "@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"
       },
       }
     },
     "@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": {
       }
     },
     "@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",
       }
     },
     "@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"
       }
     },
index a51052c134f359a95711b8d13d00e6287085a2e5..1da708ac46a49f0a4b741217dea6c26cb6276575 100644 (file)
@@ -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",
index e0845e756af24f66e3abac85bcbc636a572949be..ed9b79f07c9f7c419489d60130b1a75f5e5bb4e7 100644 (file)
@@ -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;
   }
 
index ebc8a391d3fd6a8c331ed4d9bcf119ffc8c02978..4b436c4793b7c77618b5e6df23c60a7e854ec16f 100644 (file)
@@ -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;
index 7485b14f3162e89fbc75456f8228995c54170d04..293b718485350d35f1b8dd06e7c97ab42ff795d7 100644 (file)
@@ -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<T>(object: T): T {
     return JSON.parse(JSON.stringify(object)) as T;
   }