Fix charging station initialization order
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 30 Aug 2022 20:06:36 +0000 (22:06 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 30 Aug 2022 20:06:36 +0000 (22:06 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts

index 66146be92afc4f80224893752037f611e9b7fc79..3129ae556daa5b639cfc654a02a2070e92b5e70d 100644 (file)
@@ -116,15 +116,15 @@ export default class ChargingStation {
   constructor(index: number, templateFile: string) {
     this.index = index;
     this.templateFile = templateFile;
-    this.stopped = false;
-    this.wsConnectionRestarted = false;
-    this.autoReconnectRetryCount = 0;
-    this.sharedLRUCache = SharedLRUCache.getInstance();
-    this.authorizedTagsCache = AuthorizedTagsCache.getInstance();
     this.connectors = new Map<number, ConnectorStatus>();
     this.requests = new Map<string, CachedRequest>();
     this.messageBuffer = new Set<string>();
+    this.sharedLRUCache = SharedLRUCache.getInstance();
+    this.authorizedTagsCache = AuthorizedTagsCache.getInstance();
     this.chargingStationWorkerBroadcastChannel = new ChargingStationWorkerBroadcastChannel(this);
+    this.stopped = false;
+    this.wsConnectionRestarted = false;
+    this.autoReconnectRetryCount = 0;
 
     this.initialize();
   }
@@ -950,13 +950,13 @@ export default class ChargingStation {
   }
 
   private initialize(): void {
-    this.stationInfo = this.getStationInfo();
-    this.saveStationInfo();
-    logger.info(`${this.logPrefix()} Charging station hashId '${this.stationInfo.hashId}'`);
     this.configurationFile = path.join(
       path.dirname(this.templateFile.replace('station-templates', 'configurations')),
-      this.stationInfo.hashId + '.json'
+      ChargingStationUtils.getHashId(this.index, this.getTemplateFromFile()) + '.json'
     );
+    this.stationInfo = this.getStationInfo();
+    this.saveStationInfo();
+    logger.info(`${this.logPrefix()} Charging station hashId '${this.stationInfo.hashId}'`);
     // Avoid duplication of connectors related information in RAM
     this.stationInfo?.Connectors && delete this.stationInfo.Connectors;
     this.configuredSupervisionUrl = this.getConfiguredSupervisionUrl();