Convert sendTransactionEndMeterValues to OCPP message sending handler
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 8 Mar 2022 11:32:22 +0000 (12:32 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 8 Mar 2022 11:32:22 +0000 (12:32 +0100)
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

index a916000f1634d73d27d2c01e8b1a61d27165ab78..2162078b362014ad735cd430dd9a214eec986e92 100644 (file)
@@ -341,10 +341,13 @@ export default class AutomaticTransactionGenerator {
           connectorId,
           this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId)
         );
-        await this.chargingStation.ocppRequestService.sendTransactionEndMeterValues(
-          connectorId,
-          transactionId,
-          transactionEndMeterValue
+        await this.chargingStation.ocppRequestService.sendMessageHandler(
+          RequestCommand.METER_VALUES,
+          {
+            connectorId,
+            transactionId,
+            meterValue: transactionEndMeterValue,
+          }
         );
       }
       stopResponse = (await this.chargingStation.ocppRequestService.sendMessageHandler(
index c0501b76089b10d36a705a9e799ecf77a3da6508..ebd77f83ac54a4d5303712ffcd69a5f78705e81c 100644 (file)
@@ -1356,11 +1356,11 @@ export default class ChargingStation {
               connectorId,
               this.getEnergyActiveImportRegisterByTransactionId(transactionId)
             );
-            await this.ocppRequestService.sendTransactionEndMeterValues(
+            await this.ocppRequestService.sendMessageHandler(RequestCommand.METER_VALUES, {
               connectorId,
               transactionId,
-              transactionEndMeterValue
-            );
+              meterValue: transactionEndMeterValue,
+            });
           }
           await this.ocppRequestService.sendMessageHandler(RequestCommand.STOP_TRANSACTION, {
             transactionId,
index b791f713ff954eb065534a5f10e561c9a8a24d3a..a86e995efb477d53675da0a458e7d9e37ca32b84 100644 (file)
@@ -217,10 +217,13 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
           connectorId,
           this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId)
         );
-        await this.chargingStation.ocppRequestService.sendTransactionEndMeterValues(
-          connectorId,
-          transactionId,
-          transactionEndMeterValue
+        await this.chargingStation.ocppRequestService.sendMessageHandler(
+          OCPP16RequestCommand.METER_VALUES,
+          {
+            connectorId,
+            transactionId,
+            meterValue: transactionEndMeterValue,
+          }
         );
       }
       const stopResponse = (await this.chargingStation.ocppRequestService.sendMessageHandler(
@@ -760,10 +763,13 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
             connectorId,
             this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId)
           );
-          await this.chargingStation.ocppRequestService.sendTransactionEndMeterValues(
-            connectorId,
-            transactionId,
-            transactionEndMeterValue
+          await this.chargingStation.ocppRequestService.sendMessageHandler(
+            OCPP16RequestCommand.METER_VALUES,
+            {
+              connectorId,
+              transactionId,
+              meterValue: transactionEndMeterValue,
+            }
           );
         }
         await this.chargingStation.ocppRequestService.sendMessageHandler(
index acc7fd2eb532131ada1f72ff243cf39d438fe2b7..8ba3c08617427baaab8538405a78e0b4de517c0f 100644 (file)
@@ -57,19 +57,6 @@ export default class OCPP16RequestService extends OCPPRequestService {
     );
   }
 
-  public async sendTransactionEndMeterValues(
-    connectorId: number,
-    transactionId: number,
-    endMeterValue: OCPP16MeterValue
-  ): Promise<void> {
-    const payload: MeterValuesRequest = {
-      connectorId,
-      transactionId,
-      meterValue: [endMeterValue],
-    };
-    await this.sendMessage(Utils.generateUUID(), payload, OCPP16RequestCommand.METER_VALUES);
-  }
-
   public async sendDiagnosticsStatusNotification(
     diagnosticsStatus: OCPP16DiagnosticsStatus
   ): Promise<void> {
index e4cc057ce9124ef408e3fa1357ab07c1b528b8fd..27f252e1fdf76b2bfe96806b7fd7e89e5f884b25 100644 (file)
@@ -412,14 +412,17 @@ export default class OCPP16ResponseService extends OCPPResponseService {
       this.chargingStation.getBeginEndMeterValues() &&
         !this.chargingStation.getOcppStrictCompliance() &&
         this.chargingStation.getOutOfOrderEndMeterValues() &&
-        (await this.chargingStation.ocppRequestService.sendTransactionEndMeterValues(
-          transactionConnectorId,
-          requestPayload.transactionId,
-          OCPP16ServiceUtils.buildTransactionEndMeterValue(
-            this.chargingStation,
-            transactionConnectorId,
-            requestPayload.meterStop
-          )
+        (await this.chargingStation.ocppRequestService.sendMessageHandler(
+          OCPP16RequestCommand.METER_VALUES,
+          {
+            connectorId: transactionConnectorId,
+            transactionId: requestPayload.transactionId,
+            meterValue: OCPP16ServiceUtils.buildTransactionEndMeterValue(
+              this.chargingStation,
+              transactionConnectorId,
+              requestPayload.meterStop
+            ),
+          }
         ));
       if (
         !this.chargingStation.isChargingStationAvailable() ||
index 3be275f162a979dc04842d4f1859267139c1ab95..1430de0701cf5bcb356b484adc8581c812ec7725 100644 (file)
@@ -324,12 +324,6 @@ export default abstract class OCPPRequestService {
     params?: SendParams
   ): Promise<ResponseType>;
 
-  public abstract sendTransactionEndMeterValues(
-    connectorId: number,
-    transactionId: number,
-    endMeterValue: MeterValue
-  ): Promise<void>;
-
   public abstract sendDiagnosticsStatusNotification(
     diagnosticsStatus: DiagnosticsStatus
   ): Promise<void>;