Skip to content

Commit

Permalink
fix: ensure updated CS event is emitted on all possible changes
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Benoit <[email protected]>
  • Loading branch information
Jérôme Benoit committed Nov 22, 2023
1 parent f01a4e6 commit 8baae8e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/charging-station/ChargingStation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,7 @@ export class ChargingStation extends EventEmitter {
commandName,
commandPayload,
);
this.emit(ChargingStationEvents.updated);
}

private handleResponseMessage(response: Response): void {
Expand Down Expand Up @@ -1929,7 +1930,6 @@ export class ChargingStation extends EventEmitter {
logger.error(`${this.logPrefix()} ${errorMsg}`);
throw new OCPPError(ErrorType.PROTOCOL_ERROR, errorMsg);
}
this.emit(ChargingStationEvents.updated);
} else {
throw new OCPPError(
ErrorType.PROTOCOL_ERROR,
Expand Down
3 changes: 0 additions & 3 deletions src/charging-station/ocpp/1.6/OCPP16ResponseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
import { OCPPError } from '../../../exception';
import {
type ChangeConfigurationResponse,
ChargingStationEvents,
type ClearChargingProfileResponse,
ErrorType,
type GenericResponse,
Expand Down Expand Up @@ -693,7 +692,6 @@ export class OCPP16ResponseService extends OCPPResponseService {
OCPP16ChargePointStatus.Available,
);
}
chargingStation.emit(ChargingStationEvents.updated);
}

private async handleResponseStopTransaction(
Expand Down Expand Up @@ -750,7 +748,6 @@ export class OCPP16ResponseService extends OCPPResponseService {
}
resetConnectorStatus(chargingStation.getConnectorStatus(transactionConnectorId!)!);
chargingStation.stopMeterValues(transactionConnectorId!);
chargingStation.emit(ChargingStationEvents.updated);
const logMsg = `${chargingStation.logPrefix()} Transaction with id ${
requestPayload.transactionId
} STOPPED on ${
Expand Down
3 changes: 3 additions & 0 deletions src/charging-station/ocpp/OCPPRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { ChargingStation } from '../../charging-station';
import { OCPPError } from '../../exception';
import { PerformanceStatistics } from '../../performance';
import {
ChargingStationEvents,
type ErrorCallback,
type ErrorResponse,
ErrorType,
Expand Down Expand Up @@ -346,6 +347,7 @@ export abstract class OCPPRequestService {
.catch(reject)
.finally(() => {
chargingStation.requests.delete(messageId);
chargingStation.emit(ChargingStationEvents.updated);
});
};

Expand All @@ -370,6 +372,7 @@ export abstract class OCPPRequestService {
ocppError,
);
chargingStation.requests.delete(messageId);
chargingStation.emit(ChargingStationEvents.updated);
reject(ocppError);
};

Expand Down

0 comments on commit 8baae8e

Please sign in to comment.