Convert sendTransactionBeginMeterValues to OCPP message sending handler
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 8 Mar 2022 10:52:55 +0000 (11:52 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 8 Mar 2022 10:52:55 +0000 (11:52 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
src/charging-station/ocpp/1.6/OCPP16ResponseService.ts
src/charging-station/ocpp/OCPPRequestService.ts

index 87d7710460bd651e4e6dd5e7a591510232952860..acc7fd2eb532131ada1f72ff243cf39d438fe2b7 100644 (file)
@@ -57,19 +57,6 @@ export default class OCPP16RequestService extends OCPPRequestService {
     );
   }
 
-  public async sendTransactionBeginMeterValues(
-    connectorId: number,
-    transactionId: number,
-    beginMeterValue: OCPP16MeterValue
-  ): Promise<void> {
-    const payload: MeterValuesRequest = {
-      connectorId,
-      transactionId,
-      meterValue: [beginMeterValue],
-    };
-    await this.sendMessage(Utils.generateUUID(), payload, OCPP16RequestCommand.METER_VALUES);
-  }
-
   public async sendTransactionEndMeterValues(
     connectorId: number,
     transactionId: number,
index 759f3705700d0765af848e7596f71ed05251f255..e4cc057ce9124ef408e3fa1357ab07c1b528b8fd 100644 (file)
@@ -310,10 +310,14 @@ export default class OCPP16ResponseService extends OCPPResponseService {
           requestPayload.meterStart
         );
       this.chargingStation.getBeginEndMeterValues() &&
-        (await this.chargingStation.ocppRequestService.sendTransactionBeginMeterValues(
-          connectorId,
-          payload.transactionId,
-          this.chargingStation.getConnectorStatus(connectorId).transactionBeginMeterValue
+        (await this.chargingStation.ocppRequestService.sendMessageHandler(
+          OCPP16RequestCommand.METER_VALUES,
+          {
+            connectorId,
+            transactionId: payload.transactionId,
+            meterValue:
+              this.chargingStation.getConnectorStatus(connectorId).transactionBeginMeterValue,
+          }
         ));
       await this.chargingStation.ocppRequestService.sendMessageHandler(
         OCPP16RequestCommand.STATUS_NOTIFICATION,
index dc5bf9b507f4270fadf0e060c579b1333e296e29..3be275f162a979dc04842d4f1859267139c1ab95 100644 (file)
@@ -324,12 +324,6 @@ export default abstract class OCPPRequestService {
     params?: SendParams
   ): Promise<ResponseType>;
 
-  public abstract sendTransactionBeginMeterValues(
-    connectorId: number,
-    transactionId: number,
-    beginMeterValue: MeterValue
-  ): Promise<void>;
-
   public abstract sendTransactionEndMeterValues(
     connectorId: number,
     transactionId: number,