repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Convert Statistics interface to type
[e-mobility-charging-stations-simulator.git]
/
src
/
performance
/
PerformanceStatistics.ts
diff --git
a/src/performance/PerformanceStatistics.ts
b/src/performance/PerformanceStatistics.ts
index 8dda0253198e30f69de4fa925aff324ffb02a065..d3a174c076a2642ccaad247f4653d78bd48b8350 100644
(file)
--- a/
src/performance/PerformanceStatistics.ts
+++ b/
src/performance/PerformanceStatistics.ts
@@
-1,13
+1,13
@@
// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
import { PerformanceEntry, PerformanceObserver, performance } from 'perf_hooks';
// 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 { parentPort } from 'worker_threads';
-import {
ChargingStationWorkerMessageEvents } from '../types/ChargingStationWorker
';
+import {
MessageChannelUtils } from '../charging-station/MessageChannelUtils
';
import { MessageType } from '../types/ocpp/MessageType';
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,
StatisticsData, TimeSeries } from '../types/Statistics';
import { CircularArray, DEFAULT_CIRCULAR_ARRAY_SIZE } from '../utils/CircularArray';
import Configuration from '../utils/Configuration';
import logger from '../utils/Logger';
import { CircularArray, DEFAULT_CIRCULAR_ARRAY_SIZE } from '../utils/CircularArray';
import Configuration from '../utils/Configuration';
import logger from '../utils/Logger';
@@
-38,7
+38,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));
}
if (!PerformanceStatistics.instances.has(objId)) {
PerformanceStatistics.instances.set(objId, new PerformanceStatistics(objId, objName, uri));
}
@@
-216,12
+220,7
@@
export default class PerformanceStatistics {
}
private addPerformanceEntryToStatistics(entry: PerformanceEntry): void {
}
private addPerformanceEntryToStatistics(entry: PerformanceEntry): void {
- let entryName = entry.name;
- // Rename entry name
- const MAP_NAME: Record<string, string> = {};
- if (MAP_NAME[entryName]) {
- entryName = MAP_NAME[entryName];
- }
+ const entryName = entry.name;
// Initialize command statistics
if (!this.statistics.statisticsData.has(entryName)) {
this.statistics.statisticsData.set(entryName, {});
// Initialize command statistics
if (!this.statistics.statisticsData.has(entryName)) {
this.statistics.statisticsData.set(entryName, {});
@@
-279,10
+278,9
@@
export default class PerformanceStatistics {
)
);
if (Configuration.getPerformanceStorage().enabled) {
)
);
if (Configuration.getPerformanceStorage().enabled) {
- parentPort.postMessage({
- id: ChargingStationWorkerMessageEvents.PERFORMANCE_STATISTICS,
- data: this.statistics,
- });
+ parentPort.postMessage(
+ MessageChannelUtils.buildPerformanceStatisticsMessage(this.statistics)
+ );
}
}
}
}