refactor: factor out default station info
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 9 Dec 2023 10:39:27 +0000 (11:39 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 9 Dec 2023 10:39:27 +0000 (11:39 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts
src/utils/Constants.ts

index 622eef71becf56cc164977c27065a98522d3d4bc..4b387bc7b182bcd82390aced1a68d2b422d0fe50 100644 (file)
@@ -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<ChargingStationInfo> = {
-      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,
index a17b56a8b644b938c29a0f9eef68cfd1d53b1458..d704c15ddff2a377c9d39a6ca553f5a0409b85c9 100644 (file)
@@ -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<ChargingStationInfo> = 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