From: Jérôme Benoit Date: Sat, 8 Jun 2024 16:26:51 +0000 (+0200) Subject: fix: restart metervalues interval if MeterValueSampleInterval is changed X-Git-Tag: v1.3.5~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b8e3363a179fcf79d8bb66f47724b377d4d38a75;p=e-mobility-charging-stations-simulator.git fix: restart metervalues interval if MeterValueSampleInterval is changed Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 5fad6d15..47e911a4 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -671,6 +671,11 @@ export class ChargingStation extends EventEmitter { } } + public restartMeterValues (connectorId: number, interval: number): void { + this.stopMeterValues(connectorId) + this.startMeterValues(connectorId, interval) + } + private add (): void { this.emit(ChargingStationEvents.added) } diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 64cefe58..4ab585ff 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -840,6 +840,25 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { ) { chargingStation.restartWebSocketPing() } + if ( + (keyToChange.key as OCPP16StandardParametersKey) === + OCPP16StandardParametersKey.MeterValueSampleInterval && + chargingStation.getNumberOfRunningTransactions() > 0 && + valueChanged + ) { + for ( + let connectorId = 1; + connectorId <= chargingStation.getNumberOfConnectors(); + connectorId++ + ) { + if (chargingStation.getConnectorStatus(connectorId)?.transactionStarted === true) { + chargingStation.restartMeterValues( + connectorId, + secondsToMilliseconds(convertToInt(value)) + ) + } + } + } if (keyToChange.reboot === true) { return OCPP16Constants.OCPP_CONFIGURATION_RESPONSE_REBOOT_REQUIRED }