X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStation.ts;h=23724e79014584cdf9d5dc042cd29b0fcce0f249;hb=1185579a331f3484e8ed7882203d2e58466635dd;hp=29119f92cf35d85f449fdf7d360f20b66af63e50;hpb=17bc43d765c22c8d8c132484f8dc9c3edd370d91;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 29119f92..23724e79 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -4,30 +4,36 @@ import crypto from 'node:crypto'; import fs from 'node:fs'; import path from 'node:path'; import { URL } from 'node:url'; -import { parentPort } from 'worker_threads'; +import { parentPort } from 'node:worker_threads'; import merge from 'just-merge'; import WebSocket, { type RawData } from 'ws'; -import { AuthorizedTagsCache } from './AuthorizedTagsCache'; -import { AutomaticTransactionGenerator } from './AutomaticTransactionGenerator'; -import { ChargingStationConfigurationUtils } from './ChargingStationConfigurationUtils'; -import { ChargingStationUtils } from './ChargingStationUtils'; -import { ChargingStationWorkerBroadcastChannel } from './ChargingStationWorkerBroadcastChannel'; -import { MessageChannelUtils } from './MessageChannelUtils'; import { - OCPP16IncomingRequestService, + AuthorizedTagsCache, + AutomaticTransactionGenerator, + ChargingStationConfigurationUtils, + ChargingStationUtils, + ChargingStationWorkerBroadcastChannel, + MessageChannelUtils, + SharedLRUCache, +} from './internal'; +import { + // OCPP16IncomingRequestService, OCPP16RequestService, - OCPP16ResponseService, + // OCPP16ResponseService, OCPP16ServiceUtils, OCPP20IncomingRequestService, OCPP20RequestService, - OCPP20ResponseService, + // OCPP20ResponseService, type OCPPIncomingRequestService, type OCPPRequestService, - OCPPServiceUtils, + // OCPPServiceUtils, } from './ocpp'; -import { SharedLRUCache } from './SharedLRUCache'; +import { OCPP16IncomingRequestService } from './ocpp/1.6/OCPP16IncomingRequestService'; +import { OCPP16ResponseService } from './ocpp/1.6/OCPP16ResponseService'; +import { OCPP20ResponseService } from './ocpp/2.0/OCPP20ResponseService'; +import { OCPPServiceUtils } from './ocpp/OCPPServiceUtils'; import { BaseError, OCPPError } from '../exception'; import { PerformanceStatistics } from '../performance'; import { @@ -77,17 +83,20 @@ import { type StopTransactionResponse, SupervisionUrlDistribution, SupportedFeatureProfiles, - VendorDefaultParametersKey, + VendorParametersKey, type WSError, WebSocketCloseEventStatusCode, type WsOptions, } from '../types'; -import { Configuration } from '../utils/Configuration'; -import { Constants } from '../utils/Constants'; -import { ACElectricUtils, DCElectricUtils } from '../utils/ElectricUtils'; -import { FileUtils } from '../utils/FileUtils'; -import { logger } from '../utils/Logger'; -import { Utils } from '../utils/Utils'; +import { + ACElectricUtils, + Configuration, + Constants, + DCElectricUtils, + FileUtils, + Utils, + logger, +} from '../utils'; export class ChargingStation { public readonly index: number; @@ -794,7 +803,7 @@ export class ChargingStation { } private getSupervisionUrlOcppKey(): string { - return this.stationInfo.supervisionUrlOcppKey ?? VendorDefaultParametersKey.ConnectionUrl; + return this.stationInfo.supervisionUrlOcppKey ?? VendorParametersKey.ConnectionUrl; } private getTemplateFromFile(): ChargingStationTemplate | undefined { @@ -1353,7 +1362,7 @@ export class ChargingStation { fs.mkdirSync(path.dirname(this.configurationFile), { recursive: true }); } const configurationData: ChargingStationConfiguration = - this.getConfigurationFromFile() ?? {}; + Utils.cloneObject(this.getConfigurationFromFile()) ?? {}; this.ocppConfiguration?.configurationKey && (configurationData.configurationKey = this.ocppConfiguration.configurationKey); this.stationInfo && (configurationData.stationInfo = this.stationInfo); @@ -1405,7 +1414,10 @@ export class ChargingStation { const configurationFromFile = this.getConfigurationFromFile(); configuration = configurationFromFile?.configurationKey && configurationFromFile; } - configuration && delete configuration.stationInfo; + if (!Utils.isNullOrUndefined(configuration)) { + delete configuration.stationInfo; + delete configuration.configurationHash; + } return configuration; }