fix: only send UI server response when needed
[e-mobility-charging-stations-simulator.git] / src / charging-station / ChargingStationUtils.ts
index 2a60bb41958c85048833a0b95b2b5b75370f40b4..f86c5d783b82657c483183f9bf43c562e2c11de1 100644 (file)
@@ -29,15 +29,7 @@ import {
   RecurrencyKindType,
   Voltage,
 } from '../types';
-import {
-  ACElectricUtils,
-  Configuration,
-  Constants,
-  DCElectricUtils,
-  Utils,
-  logger,
-} from '../utils';
-import { WorkerProcessType } from '../worker';
+import { ACElectricUtils, Constants, DCElectricUtils, Utils, logger } from '../utils';
 
 const moduleName = 'ChargingStationUtils';
 
@@ -153,7 +145,7 @@ export class ChargingStationUtils {
     return connectorBootStatus;
   }
 
-  public static checkTemplateFile(
+  public static checkTemplate(
     stationTemplate: ChargingStationTemplate,
     logPrefix: string,
     templateFile: string
@@ -169,18 +161,18 @@ export class ChargingStationUtils {
       throw new BaseError(errorMsg);
     }
     if (Utils.isEmptyObject(stationTemplate.AutomaticTransactionGenerator)) {
-      stationTemplate.AutomaticTransactionGenerator = {
-        enable: false,
-        minDuration: 60,
-        maxDuration: 120,
-        minDelayBetweenTwoTransactions: 15,
-        maxDelayBetweenTwoTransactions: 30,
-        probabilityOfStart: 1,
-        stopAfterHours: 0.3,
-        stopOnConnectionFailure: true,
-      };
+      stationTemplate.AutomaticTransactionGenerator = Constants.DEFAULT_ATG_CONFIGURATION;
+      logger.warn(
+        `${logPrefix} Empty automatic transaction generator configuration from template file ${templateFile}, set to default: %j`,
+        Constants.DEFAULT_ATG_CONFIGURATION
+      );
+    }
+    if (
+      Utils.isNullOrUndefined(stationTemplate.idTagsFile) ||
+      Utils.isEmptyString(stationTemplate.idTagsFile)
+    ) {
       logger.warn(
-        `${logPrefix} Empty automatic transaction generator configuration from template file ${templateFile}, set to default values`
+        `${logPrefix} Missing id tags file in template file ${templateFile}. That can lead to issues with the Automatic Transaction Generator`
       );
     }
   }
@@ -351,16 +343,6 @@ export class ChargingStationUtils {
     }
   }
 
-  public static workerPoolInUse(): boolean {
-    return [WorkerProcessType.dynamicPool, WorkerProcessType.staticPool].includes(
-      Configuration.getWorker().processType
-    );
-  }
-
-  public static workerDynamicPoolInUse(): boolean {
-    return Configuration.getWorker().processType === WorkerProcessType.dynamicPool;
-  }
-
   public static warnTemplateKeysDeprecation(
     stationTemplate: ChargingStationTemplate,
     logPrefix: string,
@@ -550,7 +532,7 @@ export class ChargingStationUtils {
     return (
       stationInfo.idTagsFile &&
       path.join(
-        path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../'),
+        path.dirname(fileURLToPath(import.meta.url)),
         'assets',
         path.basename(stationInfo.idTagsFile)
       )