From 57939a9da57b9ed1780ec63a2ecceaf44a107b17 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 12 Aug 2021 22:50:28 +0200 Subject: [PATCH] Cleanups: performance statistics, URI handling. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- package-lock.json | 364 +++++++++--------- package.json | 18 +- .../AutomaticTransactionGenerator.ts | 36 +- src/charging-station/ChargingStation.ts | 39 +- .../ocpp/1.6/OCCP16IncomingRequestService.ts | 14 +- src/utils/PerformanceStatistics.ts | 17 +- 6 files changed, 232 insertions(+), 256 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5b2ada44..5d51b64c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1540,18 +1540,18 @@ } }, "@octokit/openapi-types": { - "version": "9.4.0", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-9.4.0.tgz", - "integrity": "sha512-rKRkXikOJgDNImPl49IJuECLVXjj+t4qOXHhl8SBjMQCGGp1w4m5Ud/0kfdUx+zCpTvBN8vaOUDF4nnboZoOtQ==", + "version": "9.7.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-9.7.0.tgz", + "integrity": "sha512-TUJ16DJU8mekne6+KVcMV5g6g/rJlrnIKn7aALG9QrNpnEipFc1xjoarh0PKaAWf2Hf+HwthRKYt+9mCm5RsRg==", "dev": true }, "@octokit/plugin-paginate-rest": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.15.0.tgz", - "integrity": "sha512-/vjcb0w6ggVRtsb8OJBcRR9oEm+fpdo8RJk45khaWw/W0c8rlB2TLCLyZt/knmC17NkX7T9XdyQeEY7OHLSV1g==", + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.15.1.tgz", + "integrity": "sha512-47r52KkhQDkmvUKZqXzA1lKvcyJEfYh3TKAIe5+EzMeyDM3d+/s5v11i2gTk8/n6No6DPi3k5Ind6wtDbo/AEg==", "dev": true, "requires": { - "@octokit/types": "^6.23.0" + "@octokit/types": "^6.24.0" } }, "@octokit/plugin-request-log": { @@ -1561,19 +1561,19 @@ "dev": true }, "@octokit/plugin-rest-endpoint-methods": { - "version": "5.5.1", - "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.5.1.tgz", - "integrity": "sha512-Al57+OZmO65JpiPk4JS6u6kQ2y9qjoZtY1IWiSshc4N+F7EcrK8Rgy/cUJBB4WIcSFUQyF66EJQK1oKgXWeRNw==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.7.0.tgz", + "integrity": "sha512-G7sgccWRYQMwcHJXkDY/sDxbXeKiZkFQqUtzBCwmrzCNj2GQf3VygQ4T/BFL2crLVpIbenkE/c0ErhYOte2MPw==", "dev": true, "requires": { - "@octokit/types": "^6.21.1", + "@octokit/types": "^6.24.0", "deprecation": "^2.3.1" } }, "@octokit/request": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.0.tgz", - "integrity": "sha512-4cPp/N+NqmaGQwbh3vUsYqokQIzt7VjsgTYVXiwpUP2pxd5YiZB2XuTedbb0SPtv9XS7nzAKjAuQxmY8/aZkiA==", + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.1.tgz", + "integrity": "sha512-Ls2cfs1OfXaOKzkcxnqw5MR6drMA/zWX/LIS/p8Yjdz7QKTPQLMsB3R+OvoxE6XnXeXEE2X7xe4G4l4X0gRiKQ==", "dev": true, "requires": { "@octokit/endpoint": "^6.0.1", @@ -1610,24 +1610,24 @@ } }, "@octokit/rest": { - "version": "18.7.1", - "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-18.7.1.tgz", - "integrity": "sha512-790Yv8Xpbqs3BtnMAO5hlOftVICHPdgZ/3qlTmeOoqrQGzT25BIpHkg/KKMeKG9Fg8d598PLxGhf80RswElv9g==", + "version": "18.9.0", + "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-18.9.0.tgz", + "integrity": "sha512-VrmrE8gjpuOoDAGjrQq2j9ZhOE6LxaqxaQg0yMrrEnnQZy2ZcAnr5qbVfKsMF0up/48PRV/VFS/2GSMhA7nTdA==", "dev": true, "requires": { "@octokit/core": "^3.5.0", "@octokit/plugin-paginate-rest": "^2.6.2", "@octokit/plugin-request-log": "^1.0.2", - "@octokit/plugin-rest-endpoint-methods": "5.5.1" + "@octokit/plugin-rest-endpoint-methods": "5.7.0" } }, "@octokit/types": { - "version": "6.24.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.24.0.tgz", - "integrity": "sha512-MfEimJeQ8AV1T2nI5kOfHqsqPHaAnG0Dw3MVoHSEsEq6iLKx2N91o+k2uAgXhPYeSE76LVBqjgTShnFFgNwe0A==", + "version": "6.25.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.25.0.tgz", + "integrity": "sha512-bNvyQKfngvAd/08COlYIN54nRgxskmejgywodizQNyiKoXmWRAjKup2/LYwm+T9V0gsKH6tuld1gM0PzmOiB4Q==", "dev": true, "requires": { - "@octokit/openapi-types": "^9.4.0" + "@octokit/openapi-types": "^9.5.0" } }, "@rollup/plugin-json": { @@ -1925,13 +1925,13 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.29.0.tgz", - "integrity": "sha512-eiREtqWRZ8aVJcNru7cT/AMVnYd9a2UHsfZT8MR1dW3UUEg6jDv9EQ9Cq4CUPZesyQ58YUpoAADGv71jY8RwgA==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.29.1.tgz", + "integrity": "sha512-AHqIU+SqZZgBEiWOrtN94ldR3ZUABV5dUG94j8Nms9rQnHFc8fvDOue/58K4CFz6r8OtDDc35Pw9NQPWo0Ayrw==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "4.29.0", - "@typescript-eslint/scope-manager": "4.29.0", + "@typescript-eslint/experimental-utils": "4.29.1", + "@typescript-eslint/scope-manager": "4.29.1", "debug": "^4.3.1", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.1.0", @@ -1981,15 +1981,15 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.29.0.tgz", - "integrity": "sha512-FpNVKykfeaIxlArLUP/yQfv/5/3rhl1ov6RWgud4OgbqWLkEq7lqgQU9iiavZRzpzCRQV4XddyFz3wFXdkiX9w==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.29.1.tgz", + "integrity": "sha512-kl6QG6qpzZthfd2bzPNSJB2YcZpNOrP6r9jueXupcZHnL74WiuSjaft7WSu17J9+ae9zTlk0KJMXPUj0daBxMw==", "dev": true, "requires": { "@types/json-schema": "^7.0.7", - "@typescript-eslint/scope-manager": "4.29.0", - "@typescript-eslint/types": "4.29.0", - "@typescript-eslint/typescript-estree": "4.29.0", + "@typescript-eslint/scope-manager": "4.29.1", + "@typescript-eslint/types": "4.29.1", + "@typescript-eslint/typescript-estree": "4.29.1", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0" }, @@ -2006,14 +2006,14 @@ } }, "@typescript-eslint/parser": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.29.0.tgz", - "integrity": "sha512-+92YRNHFdXgq+GhWQPT2bmjX09X7EH36JfgN2/4wmhtwV/HPxozpCNst8jrWcngLtEVd/4zAwA6BKojAlf+YqA==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.29.1.tgz", + "integrity": "sha512-3fL5iN20hzX3Q4OkG7QEPFjZV2qsVGiDhEwwh+EkmE/w7oteiOvUNzmpu5eSwGJX/anCryONltJ3WDmAzAoCMg==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "4.29.0", - "@typescript-eslint/types": "4.29.0", - "@typescript-eslint/typescript-estree": "4.29.0", + "@typescript-eslint/scope-manager": "4.29.1", + "@typescript-eslint/types": "4.29.1", + "@typescript-eslint/typescript-estree": "4.29.1", "debug": "^4.3.1" }, "dependencies": { @@ -2035,29 +2035,29 @@ } }, "@typescript-eslint/scope-manager": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.29.0.tgz", - "integrity": "sha512-HPq7XAaDMM3DpmuijxLV9Io8/6pQnliiXMQUcAdjpJJSR+fdmbD/zHCd7hMkjJn04UQtCQBtshgxClzg6NIS2w==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.29.1.tgz", + "integrity": "sha512-Hzv/uZOa9zrD/W5mftZa54Jd5Fed3tL6b4HeaOpwVSabJK8CJ+2MkDasnX/XK4rqP5ZTWngK1ZDeCi6EnxPQ7A==", "dev": true, "requires": { - "@typescript-eslint/types": "4.29.0", - "@typescript-eslint/visitor-keys": "4.29.0" + "@typescript-eslint/types": "4.29.1", + "@typescript-eslint/visitor-keys": "4.29.1" } }, "@typescript-eslint/types": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.29.0.tgz", - "integrity": "sha512-2YJM6XfWfi8pgU2HRhTp7WgRw78TCRO3dOmSpAvIQ8MOv4B46JD2chnhpNT7Jq8j0APlIbzO1Bach734xxUl4A==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.29.1.tgz", + "integrity": "sha512-Jj2yu78IRfw4nlaLtKjVaGaxh/6FhofmQ/j8v3NXmAiKafbIqtAPnKYrf0sbGjKdj0hS316J8WhnGnErbJ4RCA==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.29.0.tgz", - "integrity": "sha512-8ZpNHDIOyqzzgZrQW9+xQ4k5hM62Xy2R4RPO3DQxMc5Rq5QkCdSpk/drka+DL9w6sXNzV5nrdlBmf8+x495QXQ==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.29.1.tgz", + "integrity": "sha512-lIkkrR9E4lwZkzPiRDNq0xdC3f2iVCUjw/7WPJ4S2Sl6C3nRWkeE1YXCQ0+KsiaQRbpY16jNaokdWnm9aUIsfw==", "dev": true, "requires": { - "@typescript-eslint/types": "4.29.0", - "@typescript-eslint/visitor-keys": "4.29.0", + "@typescript-eslint/types": "4.29.1", + "@typescript-eslint/visitor-keys": "4.29.1", "debug": "^4.3.1", "globby": "^11.0.3", "is-glob": "^4.0.1", @@ -2127,12 +2127,12 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.29.0.tgz", - "integrity": "sha512-LoaofO1C/jAJYs0uEpYMXfHboGXzOJeV118X4OsZu9f7rG7Pr9B3+4HTU8+err81rADa4xfQmAxnRnPAI2jp+Q==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.29.1.tgz", + "integrity": "sha512-zLqtjMoXvgdZY/PG6gqA73V8BjqPs4af1v2kiiETBObp+uC6gRYnJLmJHxC0QyUrrHDLJPIWNYxoBV3wbcRlag==", "dev": true, "requires": { - "@typescript-eslint/types": "4.29.0", + "@typescript-eslint/types": "4.29.1", "eslint-visitor-keys": "^2.0.0" } }, @@ -2711,40 +2711,6 @@ "unzip-stream": "^0.3.0" }, "dependencies": { - "chownr": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", - "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", - "dev": true - }, - "fs-minipass": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", - "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", - "dev": true, - "requires": { - "minipass": "^2.6.0" - } - }, - "minipass": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", - "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", - "dev": true, - "requires": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" - } - }, - "minizlib": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz", - "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", - "dev": true, - "requires": { - "minipass": "^2.9.0" - } - }, "mkdirp": { "version": "0.5.5", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", @@ -2754,19 +2720,25 @@ "minimist": "^1.2.5" } }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true + }, "tar": { - "version": "4.4.15", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.15.tgz", - "integrity": "sha512-ItbufpujXkry7bHH9NpQyTXPbJ72iTlXgkBAYsAjDXk3Ds8t/3NfO5P4xZGy7u+sYuQUbimgzswX4uQIEeNVOA==", + "version": "4.4.17", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.17.tgz", + "integrity": "sha512-q7OwXq6NTdcYIa+k58nEMV3j1euhDhGCs/VRw9ymx/PbH0jtIM2+VTgDE/BW3rbLkrBUXs5fzEKgic5oUciu7g==", "dev": true, "requires": { - "chownr": "^1.1.1", - "fs-minipass": "^1.2.5", - "minipass": "^2.8.6", - "minizlib": "^1.2.1", - "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.2", - "yallist": "^3.0.3" + "chownr": "^1.1.4", + "fs-minipass": "^1.2.7", + "minipass": "^2.9.0", + "minizlib": "^1.3.3", + "mkdirp": "^0.5.5", + "safe-buffer": "^5.2.1", + "yallist": "^3.1.1" } }, "yallist": { @@ -3417,9 +3389,10 @@ } }, "chownr": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", - "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==" + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", + "dev": true }, "ci-info": { "version": "1.6.0", @@ -4820,12 +4793,6 @@ "integrity": "sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ==", "dev": true }, - "define-lazy-prop": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", - "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", - "dev": true - }, "define-properties": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", @@ -6019,9 +5986,9 @@ } }, "eslint-plugin-jsdoc": { - "version": "36.0.6", - "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-36.0.6.tgz", - "integrity": "sha512-vOm27rI2SMfi1bOAYmzzGkanMCD/boquKwvN5ECi8EF9ASsXJwlnCzYtiOYpsDpbC2+6JXEHAmWMkqYNA3BWRw==", + "version": "36.0.7", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-36.0.7.tgz", + "integrity": "sha512-x73l/WCRQ1qCjLq46Ca7csuGd5o3y3vbJIa3cktg11tdf3UZleBdIXKN9Cf0xjs3tXYPEy2SoNXowT8ydnjNDQ==", "dev": true, "requires": { "@es-joy/jsdoccomment": "0.10.7", @@ -6736,11 +6703,12 @@ } }, "fs-minipass": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", - "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", + "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", + "dev": true, "requires": { - "minipass": "^3.0.0" + "minipass": "^2.6.0" } }, "fs.realpath": { @@ -9042,9 +9010,9 @@ "dev": true }, "mbt": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/mbt/-/mbt-1.2.2.tgz", - "integrity": "sha512-ZjkAm/4hZiLrlMUqacr2awcxwvoG5pGjRwW7pYC7sC5oCCVKs0F/l9Kbuf6AE1dWqiQV19x6a9q184Z72Hp3LQ==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/mbt/-/mbt-1.2.3.tgz", + "integrity": "sha512-gQuq1yYKUNg4IVVBsJ35YVqIHJOaKY2FMoselaZpHA6rxU0A6kijyBrHsT82uAXBoIUUQyxZcLfa6az0XJPcbA==", "dev": true, "requires": { "binwrap": "0.2.2" @@ -9234,34 +9202,30 @@ "dev": true }, "minipass": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.3.tgz", - "integrity": "sha512-Mgd2GdMVzY+x3IJ+oHnVM+KG3lA5c8tnabyJKmHSaG2kAGpudxuOf8ToDkhumF7UzME7DecbQE9uOZhNm7PuJg==", + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", + "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", + "dev": true, "requires": { - "yallist": "^4.0.0" + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" }, "dependencies": { "yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true } } }, "minizlib": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", - "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz", + "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", + "dev": true, "requires": { - "minipass": "^3.0.0", - "yallist": "^4.0.0" - }, - "dependencies": { - "yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - } + "minipass": "^2.9.0" } }, "mkdirp": { @@ -12076,15 +12040,15 @@ "dev": true }, "release-it": { - "version": "14.11.0", - "resolved": "https://registry.npmjs.org/release-it/-/release-it-14.11.0.tgz", - "integrity": "sha512-JS4THLhJyNvjSj3jKZzjLe0Va8RKbf2FdrxL3rhLMug8zGERNxhDdsd52cbKTdhnxKo/OxntjdnK92xyZbnxTw==", + "version": "14.11.3", + "resolved": "https://registry.npmjs.org/release-it/-/release-it-14.11.3.tgz", + "integrity": "sha512-dE7x/p4BGVpEYQynwXFEPMCezH1XNGhXI3tczjlbX8rHNOnV8F08+q/SPaqmwfjca667/FGxbLbi1dIkc9qOPw==", "dev": true, "requires": { "@iarna/toml": "2.2.5", - "@octokit/rest": "18.7.1", + "@octokit/rest": "18.9.0", "async-retry": "1.3.1", - "chalk": "4.1.1", + "chalk": "4.1.2", "cosmiconfig": "7.0.0", "debug": "4.3.2", "deprecated-obj": "2.0.0", @@ -12098,11 +12062,11 @@ "inquirer": "8.1.2", "is-ci": "3.0.0", "lodash": "4.17.21", - "mime-types": "2.1.31", + "mime-types": "2.1.32", "new-github-release-url": "1.0.0", - "open": "8.2.1", + "open": "7.4.2", "ora": "5.4.1", - "os-name": "4.0.0", + "os-name": "4.0.1", "parse-json": "5.2.0", "semver": "7.3.5", "shelljs": "0.8.4", @@ -12285,9 +12249,9 @@ "dev": true }, "chalk": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", - "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -12590,15 +12554,6 @@ "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", "dev": true }, - "is-wsl": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", - "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", - "dev": true, - "requires": { - "is-docker": "^2.0.0" - } - }, "json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", @@ -12647,6 +12602,12 @@ "yallist": "^4.0.0" } }, + "macos-release": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/macos-release/-/macos-release-2.5.0.tgz", + "integrity": "sha512-EIgv+QZ9r+814gjJj0Bt5vSLJLzswGmSUbUpbi9AIr/fsN2IWFBl2NucV9PAiek+U1STK468tEkxmVYUtuAN3g==", + "dev": true + }, "make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -12665,18 +12626,18 @@ } }, "mime-db": { - "version": "1.48.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.48.0.tgz", - "integrity": "sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ==", + "version": "1.49.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.49.0.tgz", + "integrity": "sha512-CIc8j9URtOVApSFCQIF+VBkX1RwXp/oMMOrqdyXSBXq5RWNEsRfyj1kiRnQgmNXmHxPoFIxOroKA3zcU9P+nAA==", "dev": true }, "mime-types": { - "version": "2.1.31", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.31.tgz", - "integrity": "sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==", + "version": "2.1.32", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.32.tgz", + "integrity": "sha512-hJGaVS4G4c9TSMYh2n6SQAGrC4RnfU+daP8G7cSCmaqNjiOoUY0VHCMS42pxnQmVF1GWwFhbHWn3RIxCqTmZ9A==", "dev": true, "requires": { - "mime-db": "1.48.0" + "mime-db": "1.49.0" } }, "mimic-fn": { @@ -12727,17 +12688,6 @@ "mimic-fn": "^2.1.0" } }, - "open": { - "version": "8.2.1", - "resolved": "https://registry.npmjs.org/open/-/open-8.2.1.tgz", - "integrity": "sha512-rXILpcQlkF/QuFez2BJDf3GsqpjGKbkUUToAIGo9A0Q6ZkoSGogZJulrUdwRkrAsoQvoZsrjCYt8+zblOk7JQQ==", - "dev": true, - "requires": { - "define-lazy-prop": "^2.0.0", - "is-docker": "^2.1.1", - "is-wsl": "^2.2.0" - } - }, "ora": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", @@ -12756,12 +12706,12 @@ } }, "os-name": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/os-name/-/os-name-4.0.0.tgz", - "integrity": "sha512-caABzDdJMbtykt7GmSogEat3faTKQhmZf0BS5l/pZGmP0vPWQjXWqOhbLyK+b6j2/DQPmEvYdzLXJXXLJNVDNg==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/os-name/-/os-name-4.0.1.tgz", + "integrity": "sha512-xl9MAoU97MH1Xt5K9ERft2YfCAoaO6msy1OBA0ozxEC0x0TmIoE6K3QvgJMMZA9yKGLmHXNY/YZoDbiGDj4zYw==", "dev": true, "requires": { - "macos-release": "^2.2.0", + "macos-release": "^2.5.0", "windows-release": "^4.0.0" } }, @@ -13543,9 +13493,9 @@ } }, "rollup": { - "version": "2.56.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.56.1.tgz", - "integrity": "sha512-KkrsNjeiTfGJMUFBi/PNfj3fnt70akqdoNXOjlzwo98uA1qrlkmgt6SGaK5OwhyDYCVnJb6jb2Xa2wbI47P4Nw==", + "version": "2.56.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.56.2.tgz", + "integrity": "sha512-s8H00ZsRi29M2/lGdm1u8DJpJ9ML8SUOpVVBd33XNeEeL3NVaTiUcSBHzBdF3eAyR0l7VSpsuoVUGrRHq7aPwQ==", "dev": true, "requires": { "fsevents": "~2.3.2" @@ -14627,9 +14577,9 @@ "dev": true }, "tar": { - "version": "6.1.6", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.6.tgz", - "integrity": "sha512-oaWyu5dQbHaYcyZCTfyPpC+VmI62/OM2RTUYavTk1MDr1cwW5Boi3baeYQKiZbY2uSQJGr+iMOzb/JFxLrft+g==", + "version": "6.1.8", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.8.tgz", + "integrity": "sha512-sb9b0cp855NbkMJcskdSYA7b11Q8JsX4qe4pyUAfHp+Y6jBjJeek2ZVlwEfWayshEIwlIzXx0Fain3QG9JPm2A==", "requires": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", @@ -14639,6 +14589,36 @@ "yallist": "^4.0.0" }, "dependencies": { + "chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==" + }, + "fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "requires": { + "minipass": "^3.0.0" + } + }, + "minipass": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.3.tgz", + "integrity": "sha512-Mgd2GdMVzY+x3IJ+oHnVM+KG3lA5c8tnabyJKmHSaG2kAGpudxuOf8ToDkhumF7UzME7DecbQE9uOZhNm7PuJg==", + "requires": { + "yallist": "^4.0.0" + } + }, + "minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "requires": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + } + }, "yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", @@ -14918,9 +14898,9 @@ } }, "tslib": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", - "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==" + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", + "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" }, "tsutils": { "version": "3.21.0", @@ -15580,9 +15560,9 @@ } }, "ws": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.0.0.tgz", - "integrity": "sha512-6AcSIXpBlS0QvCVKk+3cWnWElLsA6SzC0lkQ43ciEglgXJXiCWK3/CGFEJ+Ybgp006CMibamAsqOlxE9s4AvYA==" + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.1.0.tgz", + "integrity": "sha512-0UWlCD2s3RSclw8FN+D0zDTUyMO+1kHwJQQJzkgUh16S8d3NYON0AKCEQPffE0ez4JyRFu76QDA9KR5bOG/7jw==" }, "xdg-basedir": { "version": "3.0.0", diff --git a/package.json b/package.json index 390442ee..6c40cb46 100644 --- a/package.json +++ b/package.json @@ -61,12 +61,12 @@ "mongodb": "^3.6.11", "poolifier": "^2.0.2", "source-map-support": "^0.5.19", - "tar": "^6.1.6", - "tslib": "^2.3.0", + "tar": "^6.1.8", + "tslib": "^2.3.1", "uuid": "^8.3.2", "winston": "^3.3.3", "winston-daily-rotate-file": "^4.5.5", - "ws": "^8.0.0" + "ws": "^8.1.0" }, "optionalDependencies": { "bufferutil": "^4.0.3", @@ -81,24 +81,24 @@ "@types/tar": "^4.0.5", "@types/uuid": "^8.3.1", "@types/ws": "^7.4.7", - "@typescript-eslint/eslint-plugin": "^4.29.0", - "@typescript-eslint/parser": "^4.29.0", + "@typescript-eslint/eslint-plugin": "^4.29.1", + "@typescript-eslint/parser": "^4.29.1", "auto-changelog": "^2.3.0", "clinic": "^9.0.0", "cross-env": "^7.0.3", "eslint": "^7.32.0", "eslint-plugin-import": "^2.24.0", - "eslint-plugin-jsdoc": "^36.0.6", + "eslint-plugin-jsdoc": "^36.0.7", "eslint-plugin-node": "^11.1.0", "expect": "^27.0.6", - "mbt": "^1.2.2", + "mbt": "^1.2.3", "mocha": "^9.0.3", "mochawesome": "^6.2.2", "npm-check": "^5.9.2", "nyc": "^15.1.0", - "release-it": "^14.11.0", + "release-it": "^14.11.3", "robohydra": "^0.6.9", - "rollup": "^2.56.1", + "rollup": "^2.56.2", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-copy": "^3.4.0", "rollup-plugin-delete": "^2.0.0", diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index 44a48794..0f923a96 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -1,8 +1,9 @@ import { AuthorizationStatus, AuthorizeResponse, StartTransactionResponse, StopTransactionReason, StopTransactionResponse } from '../types/ocpp/Transaction'; -import { PerformanceObserver, performance } from 'perf_hooks'; import ChargingStation from './ChargingStation'; import Constants from '../utils/Constants'; +import { PerformanceObserver } from 'perf_hooks'; +import PerformanceStatistics from '../utils/PerformanceStatistics'; import Utils from '../utils/Utils'; import logger from '../utils/Logger'; @@ -15,11 +16,8 @@ export default class AutomaticTransactionGenerator { this.chargingStation = chargingStation; this.timeToStop = true; if (this.chargingStation.getEnableStatistics()) { - this.performanceObserver = new PerformanceObserver((list) => { - const entry = list.getEntries()[0]; - this.chargingStation.performanceStatistics.logPerformance(entry, Constants.ENTITY_AUTOMATIC_TRANSACTION_GENERATOR); - this.performanceObserver.disconnect(); - }); + this.performanceObserver = PerformanceStatistics.initPerformanceObserver(Constants.ENTITY_AUTOMATIC_TRANSACTION_GENERATOR, this.chargingStation.performanceStatistics, + this.performanceObserver); } } @@ -85,16 +83,14 @@ export default class AutomaticTransactionGenerator { const start = Math.random(); let skip = 0; if (start < this.chargingStation.stationInfo.AutomaticTransactionGenerator.probabilityOfStart) { - skip = 0; // Start transaction - let startResponse: StartTransactionResponse | AuthorizeResponse; + let startTransaction: (connectorId: number, self: AutomaticTransactionGenerator) => Promise; if (this.chargingStation.getEnableStatistics()) { - const startTransaction = performance.timerify(this.startTransaction); - this.performanceObserver.observe({ entryTypes: ['function'] }); - startResponse = await startTransaction(connectorId, this); + startTransaction = PerformanceStatistics.timedFunction(this.startTransaction.bind(this), this.performanceObserver); } else { - startResponse = await this.startTransaction(connectorId, this); + startTransaction = this.startTransaction.bind(this); } + const startResponse = await startTransaction(connectorId, this); if (startResponse?.idTagInfo?.status !== AuthorizationStatus.ACCEPTED) { logger.warn(this.logPrefix(connectorId) + ' transaction rejected'); await Utils.sleep(Constants.CHARGING_STATION_ATG_WAIT_TIME); @@ -107,13 +103,13 @@ export default class AutomaticTransactionGenerator { // Stop transaction if (this.chargingStation.getConnector(connectorId)?.transactionStarted) { logger.info(this.logPrefix(connectorId) + ' stop transaction ' + this.chargingStation.getConnector(connectorId).transactionId.toString()); + let stopTransaction: (connectorId: number, self: AutomaticTransactionGenerator) => Promise; if (this.chargingStation.getEnableStatistics()) { - const stopTransaction = performance.timerify(this.stopTransaction); - this.performanceObserver.observe({ entryTypes: ['function'] }); - await stopTransaction(connectorId, this); + stopTransaction = PerformanceStatistics.timedFunction(this.stopTransaction.bind(this), this.performanceObserver); } else { - await this.stopTransaction(connectorId, this); + stopTransaction = this.stopTransaction.bind(this); } + await stopTransaction(connectorId, this); } } } else { @@ -134,22 +130,22 @@ export default class AutomaticTransactionGenerator { if (authorizeResponse?.idTagInfo?.status === AuthorizationStatus.ACCEPTED) { logger.info(self.logPrefix(connectorId) + ' start transaction for tagID ' + tagId); // Start transaction - return await self.chargingStation.ocppRequestService.sendStartTransaction(connectorId, tagId); + return self.chargingStation.ocppRequestService.sendStartTransaction(connectorId, tagId); } return authorizeResponse; } logger.info(self.logPrefix(connectorId) + ' start transaction for tagID ' + tagId); // Start transaction - return await self.chargingStation.ocppRequestService.sendStartTransaction(connectorId, tagId); + return self.chargingStation.ocppRequestService.sendStartTransaction(connectorId, tagId); } logger.info(self.logPrefix(connectorId) + ' start transaction without a tagID'); - return await self.chargingStation.ocppRequestService.sendStartTransaction(connectorId); + return self.chargingStation.ocppRequestService.sendStartTransaction(connectorId); } // eslint-disable-next-line consistent-this private async stopTransaction(connectorId: number, self: AutomaticTransactionGenerator): Promise { const transactionId = self.chargingStation.getConnector(connectorId).transactionId; - return await self.chargingStation.ocppRequestService.sendStopTransaction(transactionId, self.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId), + return self.chargingStation.ocppRequestService.sendStopTransaction(transactionId, self.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId), self.chargingStation.getTransactionIdTag(transactionId)); } diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index bd25116b..aed980c8 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -4,7 +4,6 @@ import ChargingStationTemplate, { CurrentType, PowerUnits, Voltage } from '../ty import { ConnectorPhaseRotation, StandardParametersKey, SupportedFeatureProfiles } from '../types/ocpp/Configuration'; import Connectors, { Connector, SampledValueTemplate } from '../types/Connectors'; import { MeterValueMeasurand, MeterValuePhase } from '../types/ocpp/MeterValues'; -import { PerformanceObserver, performance } from 'perf_hooks'; import Requests, { AvailabilityType, BootNotificationRequest, IncomingRequest, IncomingRequestCommand } from '../types/ocpp/Requests'; import WebSocket, { MessageEvent } from 'ws'; @@ -23,8 +22,10 @@ import OCPPError from './OCPPError'; import OCPPIncomingRequestService from './ocpp/OCPPIncomingRequestService'; import OCPPRequestService from './ocpp/OCPPRequestService'; import { OCPPVersion } from '../types/ocpp/OCPPVersion'; +import { PerformanceObserver } from 'perf_hooks'; import PerformanceStatistics from '../utils/PerformanceStatistics'; import { StopTransactionReason } from '../types/ocpp/Transaction'; +import { URL } from 'url'; import Utils from '../utils/Utils'; import { WebSocketCloseEventStatusCode } from '../types/WebSocket'; import crypto from 'crypto'; @@ -50,8 +51,7 @@ export default class ChargingStation { private bootNotificationRequest!: BootNotificationRequest; private bootNotificationResponse!: BootNotificationResponse | null; private connectorsConfigurationHash!: string; - private supervisionUrl!: string; - private wsConnectionUrl!: string; + private wsConnectionUrl!: URL; private hasSocketRestarted: boolean; private autoReconnectRetryCount: number; private automaticTransactionGeneration!: AutomaticTransactionGenerator; @@ -292,15 +292,7 @@ export default class ChargingStation { if (interval > 0) { // eslint-disable-next-line @typescript-eslint/no-misused-promises this.getConnector(connectorId).transactionSetInterval = setInterval(async (): Promise => { - if (this.getEnableStatistics()) { - const sendMeterValues = performance.timerify(this.ocppRequestService.sendMeterValues); - this.performanceObserver.observe({ - entryTypes: ['function'], - }); - await sendMeterValues(connectorId, this.getConnector(connectorId).transactionId, interval, this.ocppRequestService); - } else { - await this.ocppRequestService.sendMeterValues(connectorId, this.getConnector(connectorId).transactionId, interval, this.ocppRequestService); - } + await this.ocppRequestService.sendMeterValues(connectorId, this.getConnector(connectorId).transactionId, interval, this.ocppRequestService); }, interval); } else { logger.error(`${this.logPrefix()} Charging station ${StandardParametersKey.MeterValueSampleInterval} configuration set to ${interval ? Utils.milliSecondsToHHMMSS(interval) : interval}, not sending MeterValues`); @@ -485,8 +477,7 @@ export default class ChargingStation { ...!Utils.isUndefined(this.stationInfo.firmwareVersion) && { firmwareVersion: this.stationInfo.firmwareVersion }, }; this.configuration = this.getTemplateChargingStationConfiguration(); - this.supervisionUrl = this.getSupervisionURL(); - this.wsConnectionUrl = this.supervisionUrl + '/' + this.stationInfo.chargingStationId; + this.wsConnectionUrl = new URL(this.getSupervisionURL().href + '/' + this.stationInfo.chargingStationId); // Build connectors if needed const maxConnectors = this.getMaxNumberOfConnectors(); if (maxConnectors <= 0) { @@ -560,11 +551,7 @@ export default class ChargingStation { 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(); - }); + this.performanceObserver = PerformanceStatistics.initPerformanceObserver(Constants.ENTITY_CHARGING_STATION, this.performanceStatistics, this.performanceObserver); } } @@ -606,7 +593,7 @@ export default class ChargingStation { } private async onOpen(): Promise { - logger.info(`${this.logPrefix()} Is connected to server through ${this.wsConnectionUrl}`); + logger.info(`${this.logPrefix()} Connected to server through ${this.wsConnectionUrl.toString()}`); if (!this.isRegistered()) { // Send BootNotification let registrationRetryCount = 0; @@ -714,11 +701,11 @@ export default class ChargingStation { } private onPing(): void { - logger.debug(this.logPrefix() + ' Has received a WS ping (rfc6455) from the server'); + logger.debug(this.logPrefix() + ' Received a WS ping (rfc6455) from the server'); } private onPong(): void { - logger.debug(this.logPrefix() + ' Has received a WS pong (rfc6455) from the server'); + logger.debug(this.logPrefix() + ' Received a WS pong (rfc6455) from the server'); } private async onError(errorEvent: any): Promise { @@ -917,7 +904,7 @@ export default class ChargingStation { } } - private getSupervisionURL(): string { + private getSupervisionURL(): URL { const supervisionUrls = Utils.cloneObject(this.stationInfo.supervisionURL ? this.stationInfo.supervisionURL : Configuration.getSupervisionURLs()); let indexUrl = 0; if (!Utils.isEmptyArray(supervisionUrls)) { @@ -927,9 +914,9 @@ export default class ChargingStation { // Get a random url indexUrl = Math.floor(Math.random() * supervisionUrls.length); } - return supervisionUrls[indexUrl]; + return new URL(supervisionUrls[indexUrl]); } - return supervisionUrls as string; + return new URL(supervisionUrls as string); } private getHeartbeatInterval(): number | undefined { @@ -967,7 +954,7 @@ export default class ChargingStation { break; } this.wsConnection = new WebSocket(this.wsConnectionUrl, protocol, options); - logger.info(this.logPrefix() + ' Will communicate through URL ' + this.supervisionUrl); + logger.info(this.logPrefix() + ' Open connection to URL ' + this.wsConnectionUrl.toString()); } private stopMeterValues(connectorId: number) { diff --git a/src/charging-station/ocpp/1.6/OCCP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCCP16IncomingRequestService.ts index 58814495..40f80a2c 100644 --- a/src/charging-station/ocpp/1.6/OCCP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCCP16IncomingRequestService.ts @@ -291,11 +291,11 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer logger.debug(this.chargingStation.logPrefix() + ' Transaction remotely STARTED on ' + this.chargingStation.stationInfo.chargingStationId + '#' + transactionConnectorId.toString() + ' for idTag ' + commandPayload.idTag); return Constants.OCPP_RESPONSE_ACCEPTED; } - return await this.notifyRemoteStartTransactionRejected(transactionConnectorId, commandPayload.idTag); + return this.notifyRemoteStartTransactionRejected(transactionConnectorId, commandPayload.idTag); } - return await this.notifyRemoteStartTransactionRejected(transactionConnectorId, commandPayload.idTag); + return this.notifyRemoteStartTransactionRejected(transactionConnectorId, commandPayload.idTag); } - return await this.notifyRemoteStartTransactionRejected(transactionConnectorId, commandPayload.idTag); + return this.notifyRemoteStartTransactionRejected(transactionConnectorId, commandPayload.idTag); } // No authorization check required, start transaction if (this.setRemoteStartTransactionChargingProfile(transactionConnectorId, commandPayload.chargingProfile)) { @@ -303,13 +303,13 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer logger.debug(this.chargingStation.logPrefix() + ' Transaction remotely STARTED on ' + this.chargingStation.stationInfo.chargingStationId + '#' + transactionConnectorId.toString() + ' for idTag ' + commandPayload.idTag); return Constants.OCPP_RESPONSE_ACCEPTED; } - return await this.notifyRemoteStartTransactionRejected(transactionConnectorId, commandPayload.idTag); + return this.notifyRemoteStartTransactionRejected(transactionConnectorId, commandPayload.idTag); } - return await this.notifyRemoteStartTransactionRejected(transactionConnectorId, commandPayload.idTag); + return this.notifyRemoteStartTransactionRejected(transactionConnectorId, commandPayload.idTag); } - return await this.notifyRemoteStartTransactionRejected(transactionConnectorId, commandPayload.idTag); + return this.notifyRemoteStartTransactionRejected(transactionConnectorId, commandPayload.idTag); } - return await this.notifyRemoteStartTransactionRejected(transactionConnectorId, commandPayload.idTag); + return this.notifyRemoteStartTransactionRejected(transactionConnectorId, commandPayload.idTag); } private async notifyRemoteStartTransactionRejected(connectorId: number, idTag: string): Promise { diff --git a/src/utils/PerformanceStatistics.ts b/src/utils/PerformanceStatistics.ts index 0c68fa73..fe17f040 100644 --- a/src/utils/PerformanceStatistics.ts +++ b/src/utils/PerformanceStatistics.ts @@ -1,10 +1,10 @@ import { CircularArray, DEFAULT_CIRCULAR_ARRAY_SIZE } from './CircularArray'; import CommandStatistics, { CommandStatisticsData, PerfEntry } from '../types/CommandStatistics'; import { IncomingRequestCommand, RequestCommand } from '../types/ocpp/Requests'; +import { PerformanceEntry, PerformanceObserver, performance } from 'perf_hooks'; import Configuration from './Configuration'; import { MessageType } from '../types/ocpp/MessageType'; -import { PerformanceEntry } from 'perf_hooks'; import Utils from './Utils'; import logger from './Logger'; @@ -17,6 +17,19 @@ export default class PerformanceStatistics { this.commandsStatistics = { id: this.objId ? this.objId : 'Object id not specified', commandsStatisticsData: {} }; } + public static initPerformanceObserver(entity: string, performanceStatistics: PerformanceStatistics, performanceObserver: PerformanceObserver): PerformanceObserver { + return new PerformanceObserver((list) => { + const entry = list.getEntries()[0]; + performanceStatistics.logPerformance(entry, entity); + performanceObserver && performanceObserver.disconnect(); + }); + } + + public static timedFunction(method: (...optionalParams: any[]) => any, performanceObserver: PerformanceObserver): (...optionalParams: any[]) => any { + performanceObserver.observe({ entryTypes: ['function'] }); + return performance.timerify(method); + } + public addMessage(command: RequestCommand | IncomingRequestCommand, messageType: MessageType): void { switch (messageType) { case MessageType.CALL_MESSAGE: @@ -64,7 +77,7 @@ export default class PerformanceStatistics { entryType: entry.entryType, startTime: entry.startTime, duration: entry.duration - } ; + }; logger.info(`${this.logPrefix()} ${className} method(s) entry: %j`, perfEntry); } -- 2.34.1