X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fperformance%2FPerformanceStatistics.ts;h=6a5b454f9c5d868f74ad3bc62c606324adfebe9e;hb=18057587414006953ed112f315807d64ddb11bfd;hp=8dda0253198e30f69de4fa925aff324ffb02a065;hpb=8114d10e3893e96bb725ce2fca9744429ee4b75b;p=e-mobility-charging-stations-simulator.git diff --git a/src/performance/PerformanceStatistics.ts b/src/performance/PerformanceStatistics.ts index 8dda0253..6a5b454f 100644 --- a/src/performance/PerformanceStatistics.ts +++ b/src/performance/PerformanceStatistics.ts @@ -1,13 +1,15 @@ // Partial Copyright Jerome Benoit. 2021. All Rights Reserved. import { PerformanceEntry, PerformanceObserver, performance } from 'perf_hooks'; -import { URL } from 'url'; +import type { URL } from 'url'; import { parentPort } from 'worker_threads'; -import { ChargingStationWorkerMessageEvents } from '../types/ChargingStationWorker'; +import { MessageChannelUtils } from '../charging-station/MessageChannelUtils'; import { MessageType } from '../types/ocpp/MessageType'; -import { IncomingRequestCommand, RequestCommand } from '../types/ocpp/Requests'; -import Statistics, { StatisticsData, TimeSeries } from '../types/Statistics'; +import type { IncomingRequestCommand, RequestCommand } from '../types/ocpp/Requests'; +import type Statistics from '../types/Statistics'; +// eslint-disable-next-line no-duplicate-imports +import type { StatisticsData, TimeSeries } from '../types/Statistics'; import { CircularArray, DEFAULT_CIRCULAR_ARRAY_SIZE } from '../utils/CircularArray'; import Configuration from '../utils/Configuration'; import logger from '../utils/Logger'; @@ -38,7 +40,11 @@ export default class PerformanceStatistics { }; } - public static getInstance(objId: string, objName: string, uri: URL): PerformanceStatistics { + public static getInstance( + objId: string, + objName: string, + uri: URL + ): PerformanceStatistics | undefined { if (!PerformanceStatistics.instances.has(objId)) { PerformanceStatistics.instances.set(objId, new PerformanceStatistics(objId, objName, uri)); } @@ -279,10 +285,9 @@ export default class PerformanceStatistics { ) ); if (Configuration.getPerformanceStorage().enabled) { - parentPort.postMessage({ - id: ChargingStationWorkerMessageEvents.PERFORMANCE_STATISTICS, - data: this.statistics, - }); + parentPort.postMessage( + MessageChannelUtils.buildPerformanceStatisticsMessage(this.statistics) + ); } }