X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FBootstrap.ts;h=bc0f87d7fba0f7d20ea5cab784c7bd0fd369f3c4;hb=5aefc345de84b04a0bd5529830948da4d5c2f547;hp=d6bf3f37da35a767ad70c3ae38d1c783c1daa73b;hpb=10d244c0aa14bb4839791eea27e1674d87ae4e20;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index d6bf3f37..bc0f87d7 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -26,7 +26,6 @@ import type WorkerAbstract from '../worker/WorkerAbstract'; import WorkerFactory from '../worker/WorkerFactory'; import { ChargingStationUtils } from './ChargingStationUtils'; import type { AbstractUIServer } from './ui-server/AbstractUIServer'; -import { UIServiceUtils } from './ui-server/ui-services/UIServiceUtils'; import UIServerFactory from './ui-server/UIServerFactory'; const moduleName = 'Bootstrap'; @@ -54,12 +53,13 @@ export class Bootstrap { 'ChargingStationWorker' + path.extname(fileURLToPath(import.meta.url)) ); this.initialize(); - Configuration.getUIServer().enabled && - (this.uiServer = UIServerFactory.getUIServerImplementation(Configuration.getUIServer().type, { - ...Configuration.getUIServer().options, - handleProtocols: UIServiceUtils.handleProtocols, - })); - Configuration.getPerformanceStorage().enabled && + if (Configuration.getUIServer().enabled === true) { + this.uiServer = UIServerFactory.getUIServerImplementation( + Configuration.getUIServer().type, + Configuration.getUIServer() + ); + } + Configuration.getPerformanceStorage().enabled === true && (this.storage = StorageFactory.getStorage( Configuration.getPerformanceStorage().type, Configuration.getPerformanceStorage().uri, @@ -76,7 +76,7 @@ export class Bootstrap { } public async start(): Promise { - if (isMainThread && !this.started) { + if (isMainThread && this.started === false) { try { this.initialize(); await this.storage?.open(); @@ -145,7 +145,7 @@ export class Bootstrap { } public async stop(): Promise { - if (isMainThread && this.started) { + if (isMainThread && this.started === true) { await this.workerImplementation.stop(); this.workerImplementation = null; this.uiServer?.stop(); @@ -223,17 +223,17 @@ export class Bootstrap { } private workerEventStarted(data: ChargingStationData) { - this.uiServer?.chargingStations.set(data.hashId, data); + this.uiServer?.chargingStations.set(data.stationInfo.hashId, data); ++this.numberOfStartedChargingStations; } private workerEventStopped(data: ChargingStationData) { - this.uiServer?.chargingStations.set(data.hashId, data); + this.uiServer?.chargingStations.set(data.stationInfo.hashId, data); --this.numberOfStartedChargingStations; } private workerEventUpdated(data: ChargingStationData) { - this.uiServer?.chargingStations.set(data.hashId, data); + this.uiServer?.chargingStations.set(data.stationInfo.hashId, data); } private workerEventPerformanceStatistics = (data: Statistics) => {