From 4f03d842f671fc918bc8b51ae126e109339f1784 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 9 Dec 2023 11:39:27 +0100 Subject: [PATCH] refactor: factor out default station info MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStation.ts | 25 +------------------ src/utils/Constants.ts | 32 ++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 25 deletions(-) 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 -- 2.34.1