From: Jérôme Benoit Date: Wed, 31 Jan 2024 10:06:38 +0000 (+0100) Subject: feat: expose template name used in stationInfo X-Git-Tag: v1.2.34~12 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1fdb60b661afed4d26796cb0a2ed15e78f3b40a7;p=e-mobility-charging-stations-simulator.git feat: expose template name used in stationInfo Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 5c3c13c7..aa68abdf 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -3,7 +3,7 @@ import { createHash } from 'node:crypto' import { EventEmitter } from 'node:events' import { type FSWatcher, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs' -import { dirname, join } from 'node:path' +import { dirname, join, parse } from 'node:path' import { URL } from 'node:url' import { parentPort } from 'node:worker_threads' @@ -1126,6 +1126,7 @@ export class ChargingStation extends EventEmitter { } const stationInfo = stationTemplateToStationInfo(stationTemplate) stationInfo.hashId = getHashId(this.index, stationTemplate) + stationInfo.templateName = parse(this.templateFile).name stationInfo.chargingStationId = getChargingStationId(this.index, stationTemplate) stationInfo.ocppVersion = stationTemplate.ocppVersion ?? OCPPVersion.VERSION_16 createSerialNumber(stationTemplate, stationInfo) @@ -1180,6 +1181,10 @@ export class ChargingStation extends EventEmitter { stationInfo = this.getConfigurationFromFile()?.stationInfo if (stationInfo != null) { delete stationInfo.infoHash + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (stationInfo.templateName == null) { + stationInfo.templateName = parse(this.templateFile).name + } } } return stationInfo diff --git a/src/types/ChargingStationInfo.ts b/src/types/ChargingStationInfo.ts index 0f4fe97d..d4e4f8db 100644 --- a/src/types/ChargingStationInfo.ts +++ b/src/types/ChargingStationInfo.ts @@ -14,6 +14,7 @@ ChargingStationTemplate, | 'meterSerialNumberPrefix' > & { hashId: string + templateName: string /** @deprecated Use hashId instead */ infoHash?: string chargingStationId?: string