From: Jérôme Benoit Date: Sat, 9 Dec 2023 10:39:27 +0000 (+0100) Subject: refactor: factor out default station info X-Git-Tag: v1.2.30~33 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=4f03d842f671fc918bc8b51ae126e109339f1784;p=e-mobility-charging-stations-simulator.git refactor: factor out default station info Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 622eef71..4b387bc7 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -113,7 +113,6 @@ import { type StopTransactionResponse, SupervisionUrlDistribution, SupportedFeatureProfiles, - VendorParametersKey, Voltage, type WSError, WebSocketCloseEventStatusCode, @@ -1141,29 +1140,7 @@ export class ChargingStation extends EventEmitter { } private getStationInfo(): ChargingStationInfo { - const defaultStationInfo: Partial = { - enableStatistics: false, - remoteAuthorization: true, - currentOutType: CurrentType.AC, - mainVoltageMeterValues: true, - phaseLineToLineVoltageMeterValues: false, - customValueLimitationMeterValues: true, - ocppStrictCompliance: true, - outOfOrderEndMeterValues: false, - beginEndMeterValues: false, - meteringPerTransaction: true, - transactionDataMeterValues: false, - supervisionUrlOcppConfiguration: false, - supervisionUrlOcppKey: VendorParametersKey.ConnectionUrl, - ocppVersion: OCPPVersion.VERSION_16, - ocppPersistentConfiguration: true, - stationInfoPersistentConfiguration: true, - automaticTransactionGeneratorPersistentConfiguration: true, - autoReconnectMaxRetries: -1, - registrationMaxRetries: -1, - reconnectExponentialDelay: false, - stopTransactionsOnStopped: true, - }; + const defaultStationInfo = Constants.DEFAULT_STATION_INFO; const stationInfoFromTemplate: ChargingStationInfo = this.getStationInfoFromTemplate(); const stationInfoFromFile: ChargingStationInfo | undefined = this.getStationInfoFromFile( stationInfoFromTemplate?.stationInfoPersistentConfiguration, diff --git a/src/utils/Constants.ts b/src/utils/Constants.ts index a17b56a8..d704c15d 100644 --- a/src/utils/Constants.ts +++ b/src/utils/Constants.ts @@ -1,6 +1,36 @@ -import type { AutomaticTransactionGeneratorConfiguration } from '../types'; +import { + type AutomaticTransactionGeneratorConfiguration, + type ChargingStationInfo, + CurrentType, + OCPPVersion, + VendorParametersKey, +} from '../types'; export class Constants { + static readonly DEFAULT_STATION_INFO: Partial = Object.freeze({ + enableStatistics: false, + remoteAuthorization: true, + currentOutType: CurrentType.AC, + mainVoltageMeterValues: true, + phaseLineToLineVoltageMeterValues: false, + customValueLimitationMeterValues: true, + ocppStrictCompliance: true, + outOfOrderEndMeterValues: false, + beginEndMeterValues: false, + meteringPerTransaction: true, + transactionDataMeterValues: false, + supervisionUrlOcppConfiguration: false, + supervisionUrlOcppKey: VendorParametersKey.ConnectionUrl, + ocppVersion: OCPPVersion.VERSION_16, + ocppPersistentConfiguration: true, + stationInfoPersistentConfiguration: true, + automaticTransactionGeneratorPersistentConfiguration: true, + autoReconnectMaxRetries: -1, + registrationMaxRetries: -1, + reconnectExponentialDelay: false, + stopTransactionsOnStopped: true, + }); + static readonly DEFAULT_BOOT_NOTIFICATION_INTERVAL = 60000; // Ms static readonly DEFAULT_HEARTBEAT_INTERVAL = 60000; // Ms static readonly DEFAULT_METER_VALUES_INTERVAL = 60000; // Ms