From: Jérôme Benoit Date: Tue, 8 Mar 2022 11:32:22 +0000 (+0100) Subject: Convert sendTransactionEndMeterValues to OCPP message sending handler X-Git-Tag: v1.1.52~6 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=3a33b6a907a44aabd721d3c63e6c5984f4f60c28;p=e-mobility-charging-stations-simulator.git Convert sendTransactionEndMeterValues to OCPP message sending handler Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index a916000f..2162078b 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -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( diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index c0501b76..ebd77f83 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -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, diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index b791f713..a86e995e 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -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( diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index acc7fd2e..8ba3c086 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -57,19 +57,6 @@ export default class OCPP16RequestService extends OCPPRequestService { ); } - public async sendTransactionEndMeterValues( - connectorId: number, - transactionId: number, - endMeterValue: OCPP16MeterValue - ): Promise { - const payload: MeterValuesRequest = { - connectorId, - transactionId, - meterValue: [endMeterValue], - }; - await this.sendMessage(Utils.generateUUID(), payload, OCPP16RequestCommand.METER_VALUES); - } - public async sendDiagnosticsStatusNotification( diagnosticsStatus: OCPP16DiagnosticsStatus ): Promise { diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index e4cc057c..27f252e1 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -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() || diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 3be275f1..1430de07 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -324,12 +324,6 @@ export default abstract class OCPPRequestService { params?: SendParams ): Promise; - public abstract sendTransactionEndMeterValues( - connectorId: number, - transactionId: number, - endMeterValue: MeterValue - ): Promise; - public abstract sendDiagnosticsStatusNotification( diagnosticsStatus: DiagnosticsStatus ): Promise;