From: Jérôme Benoit Date: Fri, 5 Feb 2021 19:37:58 +0000 (+0100) Subject: Cleanups. X-Git-Tag: v1.0.1-0~104^2~18 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=eb87fe879ce448deb447b8fdd453dac8eb33b8e1;p=e-mobility-charging-stations-simulator.git Cleanups. Signed-off-by: Jérôme Benoit --- diff --git a/package-lock.json b/package-lock.json index 4a5aa116..d64f14ff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -665,9 +665,9 @@ "dev": true }, "@types/node": { - "version": "14.14.22", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.22.tgz", - "integrity": "sha512-g+f/qj/cNcqKkc3tFqlXOYjrmZA+jNBiDzbP3kH+B+otKFqAdPgVTGP1IeKRdMml/aE69as5S4FqtxAbl+LaMw==", + "version": "14.14.25", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.25.tgz", + "integrity": "sha512-EPpXLOVqDvisVxtlbvzfyqSsFeQxltFbluZNRndIb8tr9KiBnYNLzrc1N3pyKUCww2RNrfHDViqDWWE1LCJQtQ==", "dev": true }, "@types/offscreencanvas": { diff --git a/package.json b/package.json index c59ab198..ed2067c5 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "utf-8-validate": "^5.0.4" }, "devDependencies": { - "@types/node": "^14.14.22", + "@types/node": "^14.14.25", "@types/uuid": "^8.3.0", "@types/ws": "^7.4.0", "@typescript-eslint/eslint-plugin": "^4.14.2", diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 13fb957f..bf776f9e 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -7,12 +7,12 @@ import { isMainThread } from 'worker_threads'; export default class Bootstrap { private static instance: Bootstrap; - private isStarted: boolean; + private started: boolean; private workerScript: string; private workerImplementationInstance: Wrk; private constructor() { - this.isStarted = false; + this.started = false; this.workerScript = './dist/charging-station/StationWorker.js'; } @@ -24,7 +24,7 @@ export default class Bootstrap { } public async start(): Promise { - if (isMainThread && !this.isStarted) { + if (isMainThread && !this.started) { try { let numStationsTotal = 0; await this.getWorkerImplementationInstance().start(); @@ -54,7 +54,7 @@ export default class Bootstrap { } else { console.log(`Charging station simulator started with ${numStationsTotal.toString()} charging station(s) and ${Utils.workerDynamicPoolInUse() ? `${Configuration.getWorkerPoolMinSize().toString()}/` : ''}${this.getWorkerImplementationInstance().size}${Utils.workerPoolInUse() ? `/${Configuration.getWorkerPoolMaxSize().toString()}` : ''} worker(s) concurrently running in '${Configuration.getWorkerProcess()}' mode (${this.getWorkerImplementationInstance().maxElementsPerWorker} charging station(s) per worker)`); } - this.isStarted = true; + this.started = true; } catch (error) { // eslint-disable-next-line no-console console.error('Bootstrap start error ', error); @@ -63,14 +63,14 @@ export default class Bootstrap { } public async stop(): Promise { - if (isMainThread && this.isStarted) { + if (isMainThread && this.started) { await this.getWorkerImplementationInstance().stop(); if (this.getWorkerImplementationInstance()) { // Nullify to force worker implementation instance creation this.workerImplementationInstance = null; } } - this.isStarted = false; + this.started = false; } public async restart(): Promise { diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 2d9e9a63..f60fc79e 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -223,7 +223,7 @@ export default class ChargingStation { } }, interval); } else { - logger.error(`${this.logPrefix()} Charging station ${StandardParametersKey.MeterValueSampleInterval} configuration set to ${Utils.milliSecondsToHHMMSS(interval)}, not sending MeterValues`); + logger.error(`${this.logPrefix()} Charging station ${StandardParametersKey.MeterValueSampleInterval} configuration set to ${interval ? Utils.milliSecondsToHHMMSS(interval) : interval}, not sending MeterValues`); } }