feat: add initial support get composite schedule OCPP 1.6 command
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / 1.6 / OCPP16ResponseService.ts
index 2c92b6bd4b19c2e1444922444f1579ff830b5a48..68e9f7c66cae6febf94318a5a5523ef5ee4d6e3d 100644 (file)
@@ -24,6 +24,7 @@ import {
   type OCPP16DataTransferResponse,
   type OCPP16DiagnosticsStatusNotificationResponse,
   type OCPP16FirmwareStatusNotificationResponse,
+  type OCPP16GetCompositeScheduleResponse,
   type OCPP16HeartbeatResponse,
   OCPP16IncomingRequestCommand,
   type OCPP16MeterValuesRequest,
@@ -59,9 +60,9 @@ export class OCPP16ResponseService extends OCPPResponseService {
   private jsonSchemas: Map<OCPP16RequestCommand, JSONSchemaType<JsonObject>>;
 
   public constructor() {
-    if (new.target?.name === moduleName) {
-      throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
-    }
+    // if (new.target?.name === moduleName) {
+    //   throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
+    // }
     super(OCPPVersion.VERSION_16);
     this.responseHandlers = new Map<OCPP16RequestCommand, ResponseHandler>([
       [OCPP16RequestCommand.BOOT_NOTIFICATION, this.handleResponseBootNotification.bind(this)],
@@ -206,6 +207,14 @@ export class OCPP16ResponseService extends OCPPResponseService {
           'constructor'
         ),
       ],
+      [
+        OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE,
+        OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16GetCompositeScheduleResponse>(
+          '../../../assets/json-schemas/ocpp/1.6/GetCompositeScheduleResponse.json',
+          moduleName,
+          'constructor'
+        ),
+      ],
       [
         OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
         OCPP16ServiceUtils.parseJsonSchemaFile<SetChargingProfileResponse>(
@@ -353,7 +362,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
         chargingStation,
         OCPP16StandardParametersKey.HeartbeatInterval,
         payload.interval.toString(),
-        Constants.EMPTY_OBJECT,
+        {},
         { overwrite: true, save: true }
       );
       ChargingStationConfigurationUtils.addConfigurationKey(
@@ -363,9 +372,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
         { visible: false },
         { overwrite: true, save: true }
       );
-      chargingStation.heartbeatSetInterval
-        ? chargingStation.restartHeartbeat()
-        : chargingStation.startHeartbeat();
+      OCPP16ServiceUtils.startHeartbeatInterval(chargingStation, payload.interval);
     }
     if (Object.values(RegistrationStatusEnumType).includes(payload.status)) {
       const logMsg = `${chargingStation.logPrefix()} Charging station in '${
@@ -443,7 +450,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
       chargingStation.getConnectorStatus(connectorId)?.transactionRemoteStarted === true &&
       chargingStation.getAuthorizeRemoteTxRequests() === true &&
       chargingStation.getLocalAuthListEnabled() === true &&
-      chargingStation.hasAuthorizedTags() &&
+      chargingStation.hasIdTags() &&
       chargingStation.getConnectorStatus(connectorId)?.idTagLocalAuthorized === false
     ) {
       logger.error(