Strong type OCPP message sending
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 27 Mar 2022 18:47:01 +0000 (20:47 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 27 Mar 2022 18:47:01 +0000 (20:47 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/AutomaticTransactionGenerator.ts
src/charging-station/ChargingStation.ts
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
src/charging-station/ocpp/1.6/OCPP16ResponseService.ts
src/charging-station/ocpp/OCPPRequestService.ts
src/types/ocpp/1.6/MeterValues.ts
src/types/ocpp/1.6/Requests.ts
src/types/ocpp/1.6/Transaction.ts
src/types/ocpp/Requests.ts
src/types/ocpp/Transaction.ts

index 32d9897380b261ce1338bfe84c1e82e96cd156e7..a8bd79ac06d846ac6d3f0313a25de57c234856a3 100644 (file)
@@ -2,18 +2,21 @@
 
 import {
   AuthorizationStatus,
+  AuthorizeRequest,
   AuthorizeResponse,
+  StartTransactionRequest,
   StartTransactionResponse,
   StopTransactionReason,
+  StopTransactionRequest,
   StopTransactionResponse,
 } from '../types/ocpp/Transaction';
+import { MeterValuesRequest, RequestCommand } from '../types/ocpp/Requests';
 
 import type ChargingStation from './ChargingStation';
 import Constants from '../utils/Constants';
 import { MeterValuesResponse } from '../types/ocpp/Responses';
 import { OCPP16ServiceUtils } from './ocpp/1.6/OCPP16ServiceUtils';
 import PerformanceStatistics from '../performance/PerformanceStatistics';
-import { RequestCommand } from '../types/ocpp/Requests';
 import { Status } from '../types/AutomaticTransactionGenerator';
 import Utils from '../utils/Utils';
 import logger from '../utils/Logger';
@@ -275,25 +278,24 @@ export default class AutomaticTransactionGenerator {
         this.chargingStation.getConnectorStatus(connectorId).authorizeIdTag = idTag;
         // Authorize idTag
         const authorizeResponse: AuthorizeResponse =
-          await this.chargingStation.ocppRequestService.sendMessageHandler<AuthorizeResponse>(
-            RequestCommand.AUTHORIZE,
-            {
-              idTag,
-            }
-          );
+          await this.chargingStation.ocppRequestService.sendMessageHandler<
+            AuthorizeRequest,
+            AuthorizeResponse
+          >(RequestCommand.AUTHORIZE, {
+            idTag,
+          });
         this.connectorsStatus.get(connectorId).authorizeRequests++;
         if (authorizeResponse?.idTagInfo?.status === AuthorizationStatus.ACCEPTED) {
           this.connectorsStatus.get(connectorId).acceptedAuthorizeRequests++;
           logger.info(this.logPrefix(connectorId) + ' start transaction for idTag ' + idTag);
           // Start transaction
-          startResponse =
-            await this.chargingStation.ocppRequestService.sendMessageHandler<StartTransactionResponse>(
-              RequestCommand.START_TRANSACTION,
-              {
-                connectorId,
-                idTag,
-              }
-            );
+          startResponse = await this.chargingStation.ocppRequestService.sendMessageHandler<
+            StartTransactionRequest,
+            StartTransactionResponse
+          >(RequestCommand.START_TRANSACTION, {
+            connectorId,
+            idTag,
+          });
           PerformanceStatistics.endMeasure(measureId, beginId);
           return startResponse;
         }
@@ -303,23 +305,21 @@ export default class AutomaticTransactionGenerator {
       }
       logger.info(this.logPrefix(connectorId) + ' start transaction for idTag ' + idTag);
       // Start transaction
-      startResponse =
-        await this.chargingStation.ocppRequestService.sendMessageHandler<StartTransactionResponse>(
-          RequestCommand.START_TRANSACTION,
-          {
-            connectorId,
-            idTag,
-          }
-        );
+      startResponse = await this.chargingStation.ocppRequestService.sendMessageHandler<
+        StartTransactionRequest,
+        StartTransactionResponse
+      >(RequestCommand.START_TRANSACTION, {
+        connectorId,
+        idTag,
+      });
       PerformanceStatistics.endMeasure(measureId, beginId);
       return startResponse;
     }
     logger.info(this.logPrefix(connectorId) + ' start transaction without an idTag');
-    startResponse =
-      await this.chargingStation.ocppRequestService.sendMessageHandler<StartTransactionResponse>(
-        RequestCommand.START_TRANSACTION,
-        { connectorId }
-      );
+    startResponse = await this.chargingStation.ocppRequestService.sendMessageHandler<
+      StartTransactionRequest,
+      StartTransactionResponse
+    >(RequestCommand.START_TRANSACTION, { connectorId });
     PerformanceStatistics.endMeasure(measureId, beginId);
     return startResponse;
   }
@@ -345,26 +345,24 @@ export default class AutomaticTransactionGenerator {
           connectorId,
           this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId)
         );
-        await this.chargingStation.ocppRequestService.sendMessageHandler<MeterValuesResponse>(
-          RequestCommand.METER_VALUES,
-          {
-            connectorId,
-            transactionId,
-            meterValue: transactionEndMeterValue,
-          }
-        );
+        await this.chargingStation.ocppRequestService.sendMessageHandler<
+          MeterValuesRequest,
+          MeterValuesResponse
+        >(RequestCommand.METER_VALUES, {
+          connectorId,
+          transactionId,
+          meterValue: transactionEndMeterValue,
+        });
       }
-      stopResponse =
-        await this.chargingStation.ocppRequestService.sendMessageHandler<StopTransactionResponse>(
-          RequestCommand.STOP_TRANSACTION,
-          {
-            transactionId,
-            meterStop:
-              this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId),
-            idTag: this.chargingStation.getTransactionIdTag(transactionId),
-            reason,
-          }
-        );
+      stopResponse = await this.chargingStation.ocppRequestService.sendMessageHandler<
+        StopTransactionRequest,
+        StopTransactionResponse
+      >(RequestCommand.STOP_TRANSACTION, {
+        transactionId,
+        meterStop: this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId),
+        idTag: this.chargingStation.getTransactionIdTag(transactionId),
+        reason,
+      });
       this.connectorsStatus.get(connectorId).stopTransactionRequests++;
     } else {
       logger.warn(
index 418035a798685c6d82981320ea1ddf4574766b44..bceba844bf39cd51b38a5562a201de5e8ebdbd73 100644 (file)
@@ -5,9 +5,12 @@ import {
   AvailabilityType,
   BootNotificationRequest,
   CachedRequest,
+  HeartbeatRequest,
   IncomingRequest,
   IncomingRequestCommand,
+  MeterValuesRequest,
   RequestCommand,
+  StatusNotificationRequest,
 } from '../types/ocpp/Requests';
 import {
   BootNotificationResponse,
@@ -39,7 +42,11 @@ import {
   VendorDefaultParametersKey,
 } from '../types/ocpp/Configuration';
 import { MeterValue, MeterValueMeasurand, MeterValuePhase } from '../types/ocpp/MeterValues';
-import { StopTransactionReason, StopTransactionResponse } from '../types/ocpp/Transaction';
+import {
+  StopTransactionReason,
+  StopTransactionRequest,
+  StopTransactionResponse,
+} from '../types/ocpp/Transaction';
 import { WSError, WebSocketCloseEventStatusCode } from '../types/WebSocket';
 import WebSocket, { Data, OPEN, RawData } from 'ws';
 
@@ -437,7 +444,7 @@ export default class ChargingStation {
     ) {
       // eslint-disable-next-line @typescript-eslint/no-misused-promises
       this.heartbeatSetInterval = setInterval(async (): Promise<void> => {
-        await this.ocppRequestService.sendMessageHandler<HeartbeatResponse>(
+        await this.ocppRequestService.sendMessageHandler<HeartbeatRequest, HeartbeatResponse>(
           RequestCommand.HEARTBEAT
         );
       }, this.getHeartbeatInterval());
@@ -509,7 +516,7 @@ export default class ChargingStation {
             this.getConnectorStatus(connectorId).transactionId,
             interval
           );
-          await this.ocppRequestService.sendMessageHandler<MeterValuesResponse>(
+          await this.ocppRequestService.sendMessageHandler<MeterValuesRequest, MeterValuesResponse>(
             RequestCommand.METER_VALUES,
             {
               connectorId,
@@ -614,14 +621,14 @@ export default class ChargingStation {
     await this.stopMessageSequence(reason);
     for (const connectorId of this.connectors.keys()) {
       if (connectorId > 0) {
-        await this.ocppRequestService.sendMessageHandler<StatusNotificationResponse>(
-          RequestCommand.STATUS_NOTIFICATION,
-          {
-            connectorId,
-            status: ChargePointStatus.UNAVAILABLE,
-            errorCode: ChargePointErrorCode.NO_ERROR,
-          }
-        );
+        await this.ocppRequestService.sendMessageHandler<
+          StatusNotificationRequest,
+          StatusNotificationResponse
+        >(RequestCommand.STATUS_NOTIFICATION, {
+          connectorId,
+          status: ChargePointStatus.UNAVAILABLE,
+          errorCode: ChargePointErrorCode.NO_ERROR,
+        });
         this.getConnectorStatus(connectorId).status = ChargePointStatus.UNAVAILABLE;
       }
     }
@@ -1379,22 +1386,24 @@ export default class ChargingStation {
       // Send BootNotification
       let registrationRetryCount = 0;
       do {
-        this.bootNotificationResponse =
-          await this.ocppRequestService.sendMessageHandler<BootNotificationResponse>(
-            RequestCommand.BOOT_NOTIFICATION,
-            {
-              chargePointModel: this.bootNotificationRequest.chargePointModel,
-              chargePointVendor: this.bootNotificationRequest.chargePointVendor,
-              chargeBoxSerialNumber: this.bootNotificationRequest.chargeBoxSerialNumber,
-              firmwareVersion: this.bootNotificationRequest.firmwareVersion,
-              chargePointSerialNumber: this.bootNotificationRequest.chargePointSerialNumber,
-              iccid: this.bootNotificationRequest.iccid,
-              imsi: this.bootNotificationRequest.imsi,
-              meterSerialNumber: this.bootNotificationRequest.meterSerialNumber,
-              meterType: this.bootNotificationRequest.meterType,
-            },
-            { skipBufferingOnError: true }
-          );
+        this.bootNotificationResponse = await this.ocppRequestService.sendMessageHandler<
+          BootNotificationRequest,
+          BootNotificationResponse
+        >(
+          RequestCommand.BOOT_NOTIFICATION,
+          {
+            chargePointModel: this.bootNotificationRequest.chargePointModel,
+            chargePointVendor: this.bootNotificationRequest.chargePointVendor,
+            chargeBoxSerialNumber: this.bootNotificationRequest.chargeBoxSerialNumber,
+            firmwareVersion: this.bootNotificationRequest.firmwareVersion,
+            chargePointSerialNumber: this.bootNotificationRequest.chargePointSerialNumber,
+            iccid: this.bootNotificationRequest.iccid,
+            imsi: this.bootNotificationRequest.imsi,
+            meterSerialNumber: this.bootNotificationRequest.meterSerialNumber,
+            meterType: this.bootNotificationRequest.meterType,
+          },
+          { skipBufferingOnError: true }
+        );
         if (!this.isInAcceptedState()) {
           this.getRegistrationMaxRetries() !== -1 && registrationRetryCount++;
           await Utils.sleep(
@@ -1724,7 +1733,10 @@ export default class ChargingStation {
 
   private async startMessageSequence(): Promise<void> {
     if (this.stationInfo.autoRegister) {
-      await this.ocppRequestService.sendMessageHandler<BootNotificationResponse>(
+      await this.ocppRequestService.sendMessageHandler<
+        BootNotificationRequest,
+        BootNotificationResponse
+      >(
         RequestCommand.BOOT_NOTIFICATION,
         {
           chargePointModel: this.bootNotificationRequest.chargePointModel,
@@ -1754,14 +1766,14 @@ export default class ChargingStation {
         this.getConnectorStatus(connectorId)?.bootStatus
       ) {
         // Send status in template at startup
-        await this.ocppRequestService.sendMessageHandler<StatusNotificationResponse>(
-          RequestCommand.STATUS_NOTIFICATION,
-          {
-            connectorId,
-            status: this.getConnectorStatus(connectorId).bootStatus,
-            errorCode: ChargePointErrorCode.NO_ERROR,
-          }
-        );
+        await this.ocppRequestService.sendMessageHandler<
+          StatusNotificationRequest,
+          StatusNotificationResponse
+        >(RequestCommand.STATUS_NOTIFICATION, {
+          connectorId,
+          status: this.getConnectorStatus(connectorId).bootStatus,
+          errorCode: ChargePointErrorCode.NO_ERROR,
+        });
         this.getConnectorStatus(connectorId).status =
           this.getConnectorStatus(connectorId).bootStatus;
       } else if (
@@ -1770,36 +1782,36 @@ export default class ChargingStation {
         this.getConnectorStatus(connectorId)?.bootStatus
       ) {
         // Send status in template after reset
-        await this.ocppRequestService.sendMessageHandler<StatusNotificationResponse>(
-          RequestCommand.STATUS_NOTIFICATION,
-          {
-            connectorId,
-            status: this.getConnectorStatus(connectorId).bootStatus,
-            errorCode: ChargePointErrorCode.NO_ERROR,
-          }
-        );
+        await this.ocppRequestService.sendMessageHandler<
+          StatusNotificationRequest,
+          StatusNotificationResponse
+        >(RequestCommand.STATUS_NOTIFICATION, {
+          connectorId,
+          status: this.getConnectorStatus(connectorId).bootStatus,
+          errorCode: ChargePointErrorCode.NO_ERROR,
+        });
         this.getConnectorStatus(connectorId).status =
           this.getConnectorStatus(connectorId).bootStatus;
       } else if (!this.stopped && this.getConnectorStatus(connectorId)?.status) {
         // Send previous status at template reload
-        await this.ocppRequestService.sendMessageHandler<StatusNotificationResponse>(
-          RequestCommand.STATUS_NOTIFICATION,
-          {
-            connectorId,
-            status: this.getConnectorStatus(connectorId).status,
-            errorCode: ChargePointErrorCode.NO_ERROR,
-          }
-        );
+        await this.ocppRequestService.sendMessageHandler<
+          StatusNotificationRequest,
+          StatusNotificationResponse
+        >(RequestCommand.STATUS_NOTIFICATION, {
+          connectorId,
+          status: this.getConnectorStatus(connectorId).status,
+          errorCode: ChargePointErrorCode.NO_ERROR,
+        });
       } else {
         // Send default status
-        await this.ocppRequestService.sendMessageHandler<StatusNotificationResponse>(
-          RequestCommand.STATUS_NOTIFICATION,
-          {
-            connectorId,
-            status: ChargePointStatus.AVAILABLE,
-            errorCode: ChargePointErrorCode.NO_ERROR,
-          }
-        );
+        await this.ocppRequestService.sendMessageHandler<
+          StatusNotificationRequest,
+          StatusNotificationResponse
+        >(RequestCommand.STATUS_NOTIFICATION, {
+          connectorId,
+          status: ChargePointStatus.AVAILABLE,
+          errorCode: ChargePointErrorCode.NO_ERROR,
+        });
         this.getConnectorStatus(connectorId).status = ChargePointStatus.AVAILABLE;
       }
     }
@@ -1846,24 +1858,24 @@ export default class ChargingStation {
               connectorId,
               this.getEnergyActiveImportRegisterByTransactionId(transactionId)
             );
-            await this.ocppRequestService.sendMessageHandler<MeterValuesResponse>(
-              RequestCommand.METER_VALUES,
-              {
-                connectorId,
-                transactionId,
-                meterValue: transactionEndMeterValue,
-              }
-            );
-          }
-          await this.ocppRequestService.sendMessageHandler<StopTransactionResponse>(
-            RequestCommand.STOP_TRANSACTION,
-            {
+            await this.ocppRequestService.sendMessageHandler<
+              MeterValuesRequest,
+              MeterValuesResponse
+            >(RequestCommand.METER_VALUES, {
+              connectorId,
               transactionId,
-              meterStop: this.getEnergyActiveImportRegisterByTransactionId(transactionId),
-              idTag: this.getTransactionIdTag(transactionId),
-              reason,
-            }
-          );
+              meterValue: transactionEndMeterValue,
+            });
+          }
+          await this.ocppRequestService.sendMessageHandler<
+            StopTransactionRequest,
+            StopTransactionResponse
+          >(RequestCommand.STOP_TRANSACTION, {
+            transactionId,
+            meterStop: this.getEnergyActiveImportRegisterByTransactionId(transactionId),
+            idTag: this.getTransactionIdTag(transactionId),
+            reason,
+          });
         }
       }
     }
index 298e50da0f0ba524ac64ba4fa16bb76280b73cac..7e04e6bf4b6423e745682c2f7f6ff035a2590b01 100644 (file)
@@ -4,12 +4,16 @@ import {
   ChangeAvailabilityRequest,
   ChangeConfigurationRequest,
   ClearChargingProfileRequest,
+  DiagnosticsStatusNotificationRequest,
   GetConfigurationRequest,
   GetDiagnosticsRequest,
   MessageTrigger,
   OCPP16AvailabilityType,
+  OCPP16BootNotificationRequest,
+  OCPP16HeartbeatRequest,
   OCPP16IncomingRequestCommand,
   OCPP16RequestCommand,
+  OCPP16StatusNotificationRequest,
   OCPP16TriggerMessageRequest,
   RemoteStartTransactionRequest,
   RemoteStopTransactionRequest,
@@ -38,11 +42,18 @@ import {
 import { Client, FTPResponse } from 'basic-ftp';
 import {
   OCPP16AuthorizationStatus,
+  OCPP16AuthorizeRequest,
   OCPP16AuthorizeResponse,
+  OCPP16StartTransactionRequest,
   OCPP16StartTransactionResponse,
   OCPP16StopTransactionReason,
+  OCPP16StopTransactionRequest,
   OCPP16StopTransactionResponse,
 } from '../../../types/ocpp/1.6/Transaction';
+import {
+  OCPP16MeterValuesRequest,
+  OCPP16MeterValuesResponse,
+} from '../../../types/ocpp/1.6/MeterValues';
 
 import type ChargingStation from '../../ChargingStation';
 import Constants from '../../../utils/Constants';
@@ -53,7 +64,6 @@ import { JsonType } from '../../../types/JsonType';
 import { OCPP16ChargePointErrorCode } from '../../../types/ocpp/1.6/ChargePointErrorCode';
 import { OCPP16ChargePointStatus } from '../../../types/ocpp/1.6/ChargePointStatus';
 import { OCPP16DiagnosticsStatus } from '../../../types/ocpp/1.6/DiagnosticsStatus';
-import { OCPP16MeterValuesResponse } from '../../../types/ocpp/1.6/MeterValues';
 import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
 import { OCPP16StandardParametersKey } from '../../../types/ocpp/1.6/Configuration';
 import { OCPPConfigurationKey } from '../../../types/ocpp/Configuration';
@@ -222,39 +232,37 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
           connectorId,
           this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId)
         );
-        await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16MeterValuesResponse>(
-          OCPP16RequestCommand.METER_VALUES,
-          {
-            connectorId,
-            transactionId,
-            meterValue: transactionEndMeterValue,
-          }
-        );
+        await this.chargingStation.ocppRequestService.sendMessageHandler<
+          OCPP16MeterValuesRequest,
+          OCPP16MeterValuesResponse
+        >(OCPP16RequestCommand.METER_VALUES, {
+          connectorId,
+          transactionId,
+          meterValue: transactionEndMeterValue,
+        });
       }
-      const stopResponse =
-        await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16StopTransactionResponse>(
-          OCPP16RequestCommand.STOP_TRANSACTION,
-          {
-            transactionId,
-            meterStop:
-              this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId),
-            idTag: this.chargingStation.getTransactionIdTag(transactionId),
-            reason: OCPP16StopTransactionReason.UNLOCK_COMMAND,
-          }
-        );
+      const stopResponse = await this.chargingStation.ocppRequestService.sendMessageHandler<
+        OCPP16StopTransactionRequest,
+        OCPP16StopTransactionResponse
+      >(OCPP16RequestCommand.STOP_TRANSACTION, {
+        transactionId,
+        meterStop: this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId),
+        idTag: this.chargingStation.getTransactionIdTag(transactionId),
+        reason: OCPP16StopTransactionReason.UNLOCK_COMMAND,
+      });
       if (stopResponse.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED) {
         return Constants.OCPP_RESPONSE_UNLOCKED;
       }
       return Constants.OCPP_RESPONSE_UNLOCK_FAILED;
     }
-    await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16StatusNotificationResponse>(
-      OCPP16RequestCommand.STATUS_NOTIFICATION,
-      {
-        connectorId,
-        status: OCPP16ChargePointStatus.AVAILABLE,
-        errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
-      }
-    );
+    await this.chargingStation.ocppRequestService.sendMessageHandler<
+      OCPP16StatusNotificationRequest,
+      OCPP16StatusNotificationResponse
+    >(OCPP16RequestCommand.STATUS_NOTIFICATION, {
+      connectorId,
+      status: OCPP16ChargePointStatus.AVAILABLE,
+      errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
+    });
     this.chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.AVAILABLE;
     return Constants.OCPP_RESPONSE_UNLOCKED;
   }
@@ -501,14 +509,14 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
         }
         this.chargingStation.getConnectorStatus(id).availability = commandPayload.type;
         if (response === Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED) {
-          await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16StatusNotificationResponse>(
-            OCPP16RequestCommand.STATUS_NOTIFICATION,
-            {
-              connectorId: id,
-              status: chargePointStatus,
-              errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
-            }
-          );
+          await this.chargingStation.ocppRequestService.sendMessageHandler<
+            OCPP16StatusNotificationRequest,
+            OCPP16StatusNotificationResponse
+          >(OCPP16RequestCommand.STATUS_NOTIFICATION, {
+            connectorId: id,
+            status: chargePointStatus,
+            errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
+          });
           this.chargingStation.getConnectorStatus(id).status = chargePointStatus;
         }
       }
@@ -526,10 +534,14 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
         return Constants.OCPP_AVAILABILITY_RESPONSE_SCHEDULED;
       }
       this.chargingStation.getConnectorStatus(connectorId).availability = commandPayload.type;
-      await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16StatusNotificationResponse>(
-        OCPP16RequestCommand.STATUS_NOTIFICATION,
-        { connectorId, status: chargePointStatus, errorCode: OCPP16ChargePointErrorCode.NO_ERROR }
-      );
+      await this.chargingStation.ocppRequestService.sendMessageHandler<
+        OCPP16StatusNotificationRequest,
+        OCPP16StatusNotificationResponse
+      >(OCPP16RequestCommand.STATUS_NOTIFICATION, {
+        connectorId,
+        status: chargePointStatus,
+        errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
+      });
       this.chargingStation.getConnectorStatus(connectorId).status = chargePointStatus;
       return Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED;
     }
@@ -542,14 +554,14 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     const transactionConnectorId = commandPayload.connectorId;
     const connectorStatus = this.chargingStation.getConnectorStatus(transactionConnectorId);
     if (transactionConnectorId) {
-      await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16StatusNotificationResponse>(
-        OCPP16RequestCommand.STATUS_NOTIFICATION,
-        {
-          connectorId: transactionConnectorId,
-          status: OCPP16ChargePointStatus.PREPARING,
-          errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
-        }
-      );
+      await this.chargingStation.ocppRequestService.sendMessageHandler<
+        OCPP16StatusNotificationRequest,
+        OCPP16StatusNotificationResponse
+      >(OCPP16RequestCommand.STATUS_NOTIFICATION, {
+        connectorId: transactionConnectorId,
+        status: OCPP16ChargePointStatus.PREPARING,
+        errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
+      });
       connectorStatus.status = OCPP16ChargePointStatus.PREPARING;
       if (this.chargingStation.isChargingStationAvailable() && connectorStatus) {
         // Check if authorized
@@ -566,12 +578,12 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
           } else if (this.chargingStation.getMayAuthorizeAtRemoteStart()) {
             connectorStatus.authorizeIdTag = commandPayload.idTag;
             const authorizeResponse: OCPP16AuthorizeResponse =
-              await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16AuthorizeResponse>(
-                OCPP16RequestCommand.AUTHORIZE,
-                {
-                  idTag: commandPayload.idTag,
-                }
-              );
+              await this.chargingStation.ocppRequestService.sendMessageHandler<
+                OCPP16AuthorizeRequest,
+                OCPP16AuthorizeResponse
+              >(OCPP16RequestCommand.AUTHORIZE, {
+                idTag: commandPayload.idTag,
+              });
             if (authorizeResponse?.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED) {
               authorized = true;
             }
@@ -591,13 +603,13 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
               connectorStatus.transactionRemoteStarted = true;
               if (
                 (
-                  await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16StartTransactionResponse>(
-                    OCPP16RequestCommand.START_TRANSACTION,
-                    {
-                      connectorId: transactionConnectorId,
-                      idTag: commandPayload.idTag,
-                    }
-                  )
+                  await this.chargingStation.ocppRequestService.sendMessageHandler<
+                    OCPP16StartTransactionRequest,
+                    OCPP16StartTransactionResponse
+                  >(OCPP16RequestCommand.START_TRANSACTION, {
+                    connectorId: transactionConnectorId,
+                    idTag: commandPayload.idTag,
+                  })
                 ).idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED
               ) {
                 logger.debug(
@@ -636,13 +648,13 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
           connectorStatus.transactionRemoteStarted = true;
           if (
             (
-              await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16StartTransactionResponse>(
-                OCPP16RequestCommand.START_TRANSACTION,
-                {
-                  connectorId: transactionConnectorId,
-                  idTag: commandPayload.idTag,
-                }
-              )
+              await this.chargingStation.ocppRequestService.sendMessageHandler<
+                OCPP16StartTransactionRequest,
+                OCPP16StartTransactionResponse
+              >(OCPP16RequestCommand.START_TRANSACTION, {
+                connectorId: transactionConnectorId,
+                idTag: commandPayload.idTag,
+              })
             ).idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED
           ) {
             logger.debug(
@@ -682,14 +694,14 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
       this.chargingStation.getConnectorStatus(connectorId).status !==
       OCPP16ChargePointStatus.AVAILABLE
     ) {
-      await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16StatusNotificationResponse>(
-        OCPP16RequestCommand.STATUS_NOTIFICATION,
-        {
-          connectorId,
-          status: OCPP16ChargePointStatus.AVAILABLE,
-          errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
-        }
-      );
+      await this.chargingStation.ocppRequestService.sendMessageHandler<
+        OCPP16StatusNotificationRequest,
+        OCPP16StatusNotificationResponse
+      >(OCPP16RequestCommand.STATUS_NOTIFICATION, {
+        connectorId,
+        status: OCPP16ChargePointStatus.AVAILABLE,
+        errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
+      });
       this.chargingStation.getConnectorStatus(connectorId).status =
         OCPP16ChargePointStatus.AVAILABLE;
     }
@@ -739,14 +751,14 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
         connectorId > 0 &&
         this.chargingStation.getConnectorStatus(connectorId)?.transactionId === transactionId
       ) {
-        await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16StatusNotificationResponse>(
-          OCPP16RequestCommand.STATUS_NOTIFICATION,
-          {
-            connectorId,
-            status: OCPP16ChargePointStatus.FINISHING,
-            errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
-          }
-        );
+        await this.chargingStation.ocppRequestService.sendMessageHandler<
+          OCPP16StatusNotificationRequest,
+          OCPP16StatusNotificationResponse
+        >(OCPP16RequestCommand.STATUS_NOTIFICATION, {
+          connectorId,
+          status: OCPP16ChargePointStatus.FINISHING,
+          errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
+        });
         this.chargingStation.getConnectorStatus(connectorId).status =
           OCPP16ChargePointStatus.FINISHING;
         if (
@@ -760,24 +772,24 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
             connectorId,
             this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId)
           );
-          await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16MeterValuesResponse>(
-            OCPP16RequestCommand.METER_VALUES,
-            {
-              connectorId,
-              transactionId,
-              meterValue: transactionEndMeterValue,
-            }
-          );
-        }
-        await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16StopTransactionResponse>(
-          OCPP16RequestCommand.STOP_TRANSACTION,
-          {
+          await this.chargingStation.ocppRequestService.sendMessageHandler<
+            OCPP16MeterValuesRequest,
+            OCPP16MeterValuesResponse
+          >(OCPP16RequestCommand.METER_VALUES, {
+            connectorId,
             transactionId,
-            meterStop:
-              this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId),
-            idTag: this.chargingStation.getTransactionIdTag(transactionId),
-          }
-        );
+            meterValue: transactionEndMeterValue,
+          });
+        }
+        await this.chargingStation.ocppRequestService.sendMessageHandler<
+          OCPP16StopTransactionRequest,
+          OCPP16StopTransactionResponse
+        >(OCPP16RequestCommand.STOP_TRANSACTION, {
+          transactionId,
+          meterStop:
+            this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId),
+          idTag: this.chargingStation.getTransactionIdTag(transactionId),
+        });
         return Constants.OCPP_RESPONSE_ACCEPTED;
       }
     }
@@ -826,24 +838,24 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
                 info.bytes / 1024
               } bytes transferred from diagnostics archive ${info.name}`
             );
-            await this.chargingStation.ocppRequestService.sendMessageHandler<DiagnosticsStatusNotificationResponse>(
-              OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
-              {
-                status: OCPP16DiagnosticsStatus.Uploading,
-              }
-            );
+            await this.chargingStation.ocppRequestService.sendMessageHandler<
+              DiagnosticsStatusNotificationRequest,
+              DiagnosticsStatusNotificationResponse
+            >(OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
+              status: OCPP16DiagnosticsStatus.Uploading,
+            });
           });
           uploadResponse = await ftpClient.uploadFrom(
             path.join(path.resolve(__dirname, '../../../../'), diagnosticsArchive),
             uri.pathname + diagnosticsArchive
           );
           if (uploadResponse.code === 226) {
-            await this.chargingStation.ocppRequestService.sendMessageHandler<DiagnosticsStatusNotificationResponse>(
-              OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
-              {
-                status: OCPP16DiagnosticsStatus.Uploaded,
-              }
-            );
+            await this.chargingStation.ocppRequestService.sendMessageHandler<
+              DiagnosticsStatusNotificationRequest,
+              DiagnosticsStatusNotificationResponse
+            >(OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
+              status: OCPP16DiagnosticsStatus.Uploaded,
+            });
             if (ftpClient) {
               ftpClient.close();
             }
@@ -865,12 +877,12 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
           OCPP16IncomingRequestCommand.GET_DIAGNOSTICS
         );
       } catch (error) {
-        await this.chargingStation.ocppRequestService.sendMessageHandler<DiagnosticsStatusNotificationResponse>(
-          OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
-          {
-            status: OCPP16DiagnosticsStatus.UploadFailed,
-          }
-        );
+        await this.chargingStation.ocppRequestService.sendMessageHandler<
+          DiagnosticsStatusNotificationRequest,
+          DiagnosticsStatusNotificationResponse
+        >(OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
+          status: OCPP16DiagnosticsStatus.UploadFailed,
+        });
         if (ftpClient) {
           ftpClient.close();
         }
@@ -886,12 +898,12 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
           uri.protocol
         } to transfer the diagnostic logs archive`
       );
-      await this.chargingStation.ocppRequestService.sendMessageHandler<DiagnosticsStatusNotificationResponse>(
-        OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
-        {
-          status: OCPP16DiagnosticsStatus.UploadFailed,
-        }
-      );
+      await this.chargingStation.ocppRequestService.sendMessageHandler<
+        DiagnosticsStatusNotificationRequest,
+        DiagnosticsStatusNotificationResponse
+      >(OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
+        status: OCPP16DiagnosticsStatus.UploadFailed,
+      });
       return Constants.OCPP_RESPONSE_EMPTY;
     }
   }
@@ -904,7 +916,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
         case MessageTrigger.BootNotification:
           setTimeout(() => {
             this.chargingStation.ocppRequestService
-              .sendMessageHandler<OCPP16BootNotificationResponse>(
+              .sendMessageHandler<OCPP16BootNotificationRequest, OCPP16BootNotificationResponse>(
                 OCPP16RequestCommand.BOOT_NOTIFICATION,
                 {
                   chargePointModel:
@@ -936,9 +948,13 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
         case MessageTrigger.Heartbeat:
           setTimeout(() => {
             this.chargingStation.ocppRequestService
-              .sendMessageHandler<OCPP16HeartbeatResponse>(OCPP16RequestCommand.HEARTBEAT, null, {
-                triggerMessage: true,
-              })
+              .sendMessageHandler<OCPP16HeartbeatRequest, OCPP16HeartbeatResponse>(
+                OCPP16RequestCommand.HEARTBEAT,
+                null,
+                {
+                  triggerMessage: true,
+                }
+              )
               .catch(() => {
                 /* This is intentional */
               });
index 3d91576bb5b85b41e667e5354174ae2d815ac119..64ce459cb315b735f5e28ece254bfb96bb20e154 100644 (file)
@@ -22,7 +22,7 @@ export default class OCPP16RequestService extends OCPPRequestService {
     super(chargingStation, ocppResponseService);
   }
 
-  public async sendMessageHandler<Response extends JsonType>(
+  public async sendMessageHandler<Request extends JsonType, Response extends JsonType>(
     commandName: OCPP16RequestCommand,
     commandParams?: JsonType,
     params?: SendParams
@@ -30,7 +30,7 @@ export default class OCPP16RequestService extends OCPPRequestService {
     if (Object.values(OCPP16RequestCommand).includes(commandName)) {
       return (await this.sendMessage(
         Utils.generateUUID(),
-        this.buildCommandPayload(commandName, commandParams),
+        this.buildCommandPayload<Request>(commandName, commandParams),
         commandName,
         params
       )) as unknown as Response;
index 08197142faa633d4ab77166547d7d7c77cf57259..c7bf6fdb74dc592414aebbcba4f644e90cca494d 100644 (file)
@@ -1,26 +1,30 @@
 // Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
 
 import {
-  AuthorizeRequest,
   OCPP16AuthorizationStatus,
+  OCPP16AuthorizeRequest,
   OCPP16AuthorizeResponse,
+  OCPP16StartTransactionRequest,
   OCPP16StartTransactionResponse,
+  OCPP16StopTransactionRequest,
   OCPP16StopTransactionResponse,
-  StartTransactionRequest,
-  StopTransactionRequest,
 } from '../../../types/ocpp/1.6/Transaction';
 import {
-  HeartbeatRequest,
+  OCPP16BootNotificationRequest,
+  OCPP16HeartbeatRequest,
   OCPP16RequestCommand,
-  StatusNotificationRequest,
+  OCPP16StatusNotificationRequest,
 } from '../../../types/ocpp/1.6/Requests';
-import { MeterValuesRequest, OCPP16MeterValuesResponse } from '../../../types/ocpp/1.6/MeterValues';
 import {
   OCPP16BootNotificationResponse,
   OCPP16HeartbeatResponse,
   OCPP16RegistrationStatus,
   OCPP16StatusNotificationResponse,
 } from '../../../types/ocpp/1.6/Responses';
+import {
+  OCPP16MeterValuesRequest,
+  OCPP16MeterValuesResponse,
+} from '../../../types/ocpp/1.6/MeterValues';
 
 import type ChargingStation from '../../ChargingStation';
 import { ErrorType } from '../../../types/ocpp/ErrorType';
@@ -136,7 +140,7 @@ export default class OCPP16ResponseService extends OCPPResponseService {
 
   private handleResponseHeartbeat(
     payload: OCPP16HeartbeatResponse,
-    requestPayload: HeartbeatRequest
+    requestPayload: OCPP16HeartbeatRequest
   ): void {
     logger.debug(
       this.chargingStation.logPrefix() +
@@ -148,7 +152,7 @@ export default class OCPP16ResponseService extends OCPPResponseService {
 
   private handleResponseAuthorize(
     payload: OCPP16AuthorizeResponse,
-    requestPayload: AuthorizeRequest
+    requestPayload: OCPP16AuthorizeRequest
   ): void {
     let authorizeConnectorId: number;
     for (const connectorId of this.chargingStation.connectors.keys()) {
@@ -181,7 +185,7 @@ export default class OCPP16ResponseService extends OCPPResponseService {
 
   private async handleResponseStartTransaction(
     payload: OCPP16StartTransactionResponse,
-    requestPayload: StartTransactionRequest
+    requestPayload: OCPP16StartTransactionRequest
   ): Promise<void> {
     const connectorId = requestPayload.connectorId;
 
@@ -313,23 +317,23 @@ export default class OCPP16ResponseService extends OCPPResponseService {
           requestPayload.meterStart
         );
       this.chargingStation.getBeginEndMeterValues() &&
-        (await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16MeterValuesResponse>(
-          OCPP16RequestCommand.METER_VALUES,
-          {
-            connectorId,
-            transactionId: payload.transactionId,
-            meterValue:
-              this.chargingStation.getConnectorStatus(connectorId).transactionBeginMeterValue,
-          }
-        ));
-      await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16StatusNotificationResponse>(
-        OCPP16RequestCommand.STATUS_NOTIFICATION,
-        {
+        (await this.chargingStation.ocppRequestService.sendMessageHandler<
+          OCPP16MeterValuesRequest,
+          OCPP16MeterValuesResponse
+        >(OCPP16RequestCommand.METER_VALUES, {
           connectorId,
-          status: OCPP16ChargePointStatus.CHARGING,
-          errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
-        }
-      );
+          transactionId: payload.transactionId,
+          meterValue:
+            this.chargingStation.getConnectorStatus(connectorId).transactionBeginMeterValue,
+        }));
+      await this.chargingStation.ocppRequestService.sendMessageHandler<
+        OCPP16StatusNotificationRequest,
+        OCPP16StatusNotificationResponse
+      >(OCPP16RequestCommand.STATUS_NOTIFICATION, {
+        connectorId,
+        status: OCPP16ChargePointStatus.CHARGING,
+        errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
+      });
       this.chargingStation.getConnectorStatus(connectorId).status =
         OCPP16ChargePointStatus.CHARGING;
       logger.info(
@@ -375,14 +379,14 @@ export default class OCPP16ResponseService extends OCPPResponseService {
       this.chargingStation.getConnectorStatus(connectorId).status !==
       OCPP16ChargePointStatus.AVAILABLE
     ) {
-      await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16StatusNotificationResponse>(
-        OCPP16RequestCommand.STATUS_NOTIFICATION,
-        {
-          connectorId,
-          status: OCPP16ChargePointStatus.AVAILABLE,
-          errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
-        }
-      );
+      await this.chargingStation.ocppRequestService.sendMessageHandler<
+        OCPP16StatusNotificationRequest,
+        OCPP16StatusNotificationResponse
+      >(OCPP16RequestCommand.STATUS_NOTIFICATION, {
+        connectorId,
+        status: OCPP16ChargePointStatus.AVAILABLE,
+        errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
+      });
       this.chargingStation.getConnectorStatus(connectorId).status =
         OCPP16ChargePointStatus.AVAILABLE;
     }
@@ -390,7 +394,7 @@ export default class OCPP16ResponseService extends OCPPResponseService {
 
   private async handleResponseStopTransaction(
     payload: OCPP16StopTransactionResponse,
-    requestPayload: StopTransactionRequest
+    requestPayload: OCPP16StopTransactionRequest
   ): Promise<void> {
     const transactionConnectorId = this.chargingStation.getConnectorIdByTransactionId(
       requestPayload.transactionId
@@ -407,41 +411,41 @@ export default class OCPP16ResponseService extends OCPPResponseService {
       this.chargingStation.getBeginEndMeterValues() &&
         !this.chargingStation.getOcppStrictCompliance() &&
         this.chargingStation.getOutOfOrderEndMeterValues() &&
-        (await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16MeterValuesResponse>(
-          OCPP16RequestCommand.METER_VALUES,
-          {
-            connectorId: transactionConnectorId,
-            transactionId: requestPayload.transactionId,
-            meterValue: OCPP16ServiceUtils.buildTransactionEndMeterValue(
-              this.chargingStation,
-              transactionConnectorId,
-              requestPayload.meterStop
-            ),
-          }
-        ));
+        (await this.chargingStation.ocppRequestService.sendMessageHandler<
+          OCPP16MeterValuesRequest,
+          OCPP16MeterValuesResponse
+        >(OCPP16RequestCommand.METER_VALUES, {
+          connectorId: transactionConnectorId,
+          transactionId: requestPayload.transactionId,
+          meterValue: OCPP16ServiceUtils.buildTransactionEndMeterValue(
+            this.chargingStation,
+            transactionConnectorId,
+            requestPayload.meterStop
+          ),
+        }));
       if (
         !this.chargingStation.isChargingStationAvailable() ||
         !this.chargingStation.isConnectorAvailable(transactionConnectorId)
       ) {
-        await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16StatusNotificationResponse>(
-          OCPP16RequestCommand.STATUS_NOTIFICATION,
-          {
-            connectorId: transactionConnectorId,
-            status: OCPP16ChargePointStatus.UNAVAILABLE,
-            errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
-          }
-        );
+        await this.chargingStation.ocppRequestService.sendMessageHandler<
+          OCPP16StatusNotificationRequest,
+          OCPP16StatusNotificationResponse
+        >(OCPP16RequestCommand.STATUS_NOTIFICATION, {
+          connectorId: transactionConnectorId,
+          status: OCPP16ChargePointStatus.UNAVAILABLE,
+          errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
+        });
         this.chargingStation.getConnectorStatus(transactionConnectorId).status =
           OCPP16ChargePointStatus.UNAVAILABLE;
       } else {
-        await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16BootNotificationResponse>(
-          OCPP16RequestCommand.STATUS_NOTIFICATION,
-          {
-            connectorId: transactionConnectorId,
-            status: OCPP16ChargePointStatus.AVAILABLE,
-            errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
-          }
-        );
+        await this.chargingStation.ocppRequestService.sendMessageHandler<
+          OCPP16BootNotificationRequest,
+          OCPP16BootNotificationResponse
+        >(OCPP16RequestCommand.STATUS_NOTIFICATION, {
+          connectorId: transactionConnectorId,
+          status: OCPP16ChargePointStatus.AVAILABLE,
+          errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
+        });
         this.chargingStation.getConnectorStatus(transactionConnectorId).status =
           OCPP16ChargePointStatus.AVAILABLE;
       }
@@ -471,7 +475,7 @@ export default class OCPP16ResponseService extends OCPPResponseService {
   }
 
   private handleResponseStatusNotification(
-    payload: StatusNotificationRequest,
+    payload: OCPP16StatusNotificationRequest,
     requestPayload: OCPP16StatusNotificationResponse
   ): void {
     logger.debug(
@@ -483,7 +487,7 @@ export default class OCPP16ResponseService extends OCPPResponseService {
   }
 
   private handleResponseMeterValues(
-    payload: MeterValuesRequest,
+    payload: OCPP16MeterValuesRequest,
     requestPayload: OCPP16MeterValuesResponse
   ): void {
     logger.debug(
index 89766371dc935b63d1ca6925e51cf5ccb349e881..abef08086ade8629890df3403567cda2e9e5b4cc 100644 (file)
@@ -317,7 +317,8 @@ export default abstract class OCPPRequestService {
     }
   }
 
-  public abstract sendMessageHandler<Response extends JsonType>(
+  // eslint-disable-next-line @typescript-eslint/no-unused-vars
+  public abstract sendMessageHandler<Request extends JsonType, Response extends JsonType>(
     commandName: RequestCommand,
     commandParams?: JsonType,
     params?: SendParams
index 70967dde3175851c23777fcbaf3274414669ac28..54c283fbbeb4b39e0b9ca34c93ddc4523b76eb53 100644 (file)
@@ -97,7 +97,7 @@ export interface OCPP16MeterValue extends JsonType {
   sampledValue: OCPP16SampledValue[];
 }
 
-export interface MeterValuesRequest extends JsonType {
+export interface OCPP16MeterValuesRequest extends JsonType {
   connectorId: number;
   transactionId?: number;
   meterValue: OCPP16MeterValue[];
index 1b3dc4e7b919eb61d9c3cf22fc004343ad77553b..6518213c71042c8aca6f89dd57cbb57a6837b4cb 100644 (file)
@@ -33,7 +33,7 @@ export enum OCPP16IncomingRequestCommand {
   TRIGGER_MESSAGE = 'TriggerMessage',
 }
 
-export type HeartbeatRequest = EmptyObject;
+export type OCPP16HeartbeatRequest = EmptyObject;
 
 export interface OCPP16BootNotificationRequest extends JsonType {
   chargeBoxSerialNumber?: string;
@@ -47,7 +47,7 @@ export interface OCPP16BootNotificationRequest extends JsonType {
   meterType?: string;
 }
 
-export interface StatusNotificationRequest extends JsonType {
+export interface OCPP16StatusNotificationRequest extends JsonType {
   connectorId: number;
   errorCode: OCPP16ChargePointErrorCode;
   info?: string;
index 1b921d4ec01cd7aef1d771f8d2917e6038e12496..13d6df642d365fb2468a6cd97750b9f550f0e4dd 100644 (file)
@@ -30,7 +30,7 @@ export interface IdTagInfo extends JsonType {
   expiryDate?: Date;
 }
 
-export interface AuthorizeRequest extends JsonType {
+export interface OCPP16AuthorizeRequest extends JsonType {
   idTag: string;
 }
 
@@ -38,7 +38,7 @@ export interface OCPP16AuthorizeResponse extends JsonType {
   idTagInfo: IdTagInfo;
 }
 
-export interface StartTransactionRequest extends JsonType {
+export interface OCPP16StartTransactionRequest extends JsonType {
   connectorId: number;
   idTag: string;
   meterStart: number;
@@ -51,7 +51,7 @@ export interface OCPP16StartTransactionResponse extends JsonType {
   transactionId: number;
 }
 
-export interface StopTransactionRequest extends JsonType {
+export interface OCPP16StopTransactionRequest extends JsonType {
   idTag?: string;
   meterStop: number;
   timestamp: string;
index c5c813f22f154ef8349cb854d9718696e3e6956d..c8c4007d97aed2198343013fe7f82414f41c9c0e 100644 (file)
@@ -1,13 +1,16 @@
 import {
   OCPP16AvailabilityType,
   OCPP16BootNotificationRequest,
+  OCPP16HeartbeatRequest,
   OCPP16IncomingRequestCommand,
   OCPP16RequestCommand,
+  OCPP16StatusNotificationRequest,
 } from './1.6/Requests';
 
 import { JsonType } from '../JsonType';
 import { MessageType } from './MessageType';
 import { OCPP16DiagnosticsStatus } from './1.6/DiagnosticsStatus';
+import { OCPP16MeterValuesRequest } from './1.6/MeterValues';
 import OCPPError from '../../exception/OCPPError';
 
 export interface SendParams {
@@ -21,6 +24,12 @@ export type ResponseType = JsonType | OCPPError | string;
 
 export type BootNotificationRequest = OCPP16BootNotificationRequest;
 
+export type HeartbeatRequest = OCPP16HeartbeatRequest;
+
+export type StatusNotificationRequest = OCPP16StatusNotificationRequest;
+
+export type MeterValuesRequest = OCPP16MeterValuesRequest;
+
 export type AvailabilityType = OCPP16AvailabilityType;
 
 export const AvailabilityType = {
index cee8f3cf6d2663c48f8c78fbd57b843269182757..3dd499c992697fa53da594c9ab3fcb2dcc8d6c98 100644 (file)
@@ -1,8 +1,11 @@
 import {
   OCPP16AuthorizationStatus,
+  OCPP16AuthorizeRequest,
   OCPP16AuthorizeResponse,
+  OCPP16StartTransactionRequest,
   OCPP16StartTransactionResponse,
   OCPP16StopTransactionReason,
+  OCPP16StopTransactionRequest,
   OCPP16StopTransactionResponse,
 } from './1.6/Transaction';
 
@@ -12,6 +15,8 @@ export const AuthorizationStatus = {
   ...OCPP16AuthorizationStatus,
 };
 
+export type AuthorizeRequest = OCPP16AuthorizeRequest;
+
 export type AuthorizeResponse = OCPP16AuthorizeResponse;
 
 export type StopTransactionReason = OCPP16StopTransactionReason;
@@ -20,6 +25,10 @@ export const StopTransactionReason = {
   ...OCPP16StopTransactionReason,
 };
 
+export type StartTransactionRequest = OCPP16StartTransactionRequest;
+
 export type StartTransactionResponse = OCPP16StartTransactionResponse;
 
+export type StopTransactionRequest = OCPP16StopTransactionRequest;
+
 export type StopTransactionResponse = OCPP16StopTransactionResponse;