refactor(simulator): consolidate connector status transition
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / OCPPIncomingRequestService.ts
index de036e707237bf1393f537abddd62b58cebd0e1f..80857cc795b7941bb5a2b8e571c28dc2e3a73661 100644 (file)
@@ -1,4 +1,4 @@
-import { AsyncResource } from 'async_hooks';
+import { AsyncResource } from 'node:async_hooks';
 
 import Ajv, { type JSONSchemaType } from 'ajv';
 import ajvFormats from 'ajv-formats';
@@ -14,7 +14,7 @@ import type {
   JsonType,
   OCPPVersion,
 } from '../../types';
-import { logger } from '../../utils/Logger';
+import { logger } from '../../utils';
 
 const moduleName = 'OCPPIncomingRequestService';
 
@@ -32,8 +32,20 @@ export abstract class OCPPIncomingRequestService extends AsyncResource {
       multipleOfPrecision: 2,
     });
     ajvFormats(this.ajv);
-    this.incomingRequestHandler.bind(this);
-    this.validateIncomingRequestPayload.bind(this);
+    this.incomingRequestHandler = this.incomingRequestHandler.bind(this) as (
+      chargingStation: ChargingStation,
+      messageId: string,
+      commandName: IncomingRequestCommand,
+      commandPayload: JsonType
+    ) => Promise<void>;
+    this.validateIncomingRequestPayload = this.validateIncomingRequestPayload.bind(this) as <
+      T extends JsonType
+    >(
+      chargingStation: ChargingStation,
+      commandName: IncomingRequestCommand,
+      schema: JSONSchemaType<T>,
+      payload: T
+    ) => boolean;
   }
 
   public static getInstance<T extends OCPPIncomingRequestService>(this: new () => T): T {
@@ -90,8 +102,8 @@ export abstract class OCPPIncomingRequestService extends AsyncResource {
   }
 
   protected handleRequestClearCache(chargingStation: ChargingStation): ClearCacheResponse {
-    chargingStation.authorizedTagsCache.deleteAuthorizedTags(
-      ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo)
+    chargingStation.idTagsCache.deleteIdTags(
+      ChargingStationUtils.getIdTagsFile(chargingStation.stationInfo)
     );
     return OCPPConstants.OCPP_RESPONSE_ACCEPTED;
   }