public async addReservation(reservation: Reservation): Promise<void> {
const [exists, reservationFound] = this.doesReservationExists(reservation);
if (exists) {
- await this.removeReservation(reservationFound);
+ await this.removeReservation(reservationFound, ReservationTerminationReason.REPLACE_EXISTING);
}
this.getConnectorStatus(reservation.connectorId).reservation = reservation;
await OCPPServiceUtils.sendAndSetConnectorStatus(
delete connector.reservation;
break;
case ReservationTerminationReason.TRANSACTION_STARTED:
- case ReservationTerminationReason.EXPIRED:
- case ReservationTerminationReason.RESERVATION_CANCELED:
+ delete connector.reservation;
+ break;
+ case ReservationTerminationReason.RESERVATION_CANCELED ||
+ ReservationTerminationReason.REPLACE_EXISTING ||
+ ReservationTerminationReason.EXPIRED:
await OCPPServiceUtils.sendAndSetConnectorStatus(
this,
reservation.connectorId,
for (const evse of this.evses.values()) {
for (const connector of evse.connectors.values()) {
if (connector?.reservation?.expiryDate.toString() < new Date().toISOString()) {
- await this.removeReservation(connector.reservation);
+ await this.removeReservation(
+ connector.reservation,
+ ReservationTerminationReason.EXPIRED
+ );
}
}
}
} else {
for (const connector of this.connectors.values()) {
if (connector?.reservation?.expiryDate.toString() < new Date().toISOString()) {
- await this.removeReservation(connector.reservation);
+ await this.removeReservation(
+ connector.reservation,
+ ReservationTerminationReason.EXPIRED
+ );
}
}
}
);
return OCPP16Constants.OCPP_CANCEL_RESERVATION_RESPONSE_REJECTED;
}
- await chargingStation.removeReservation(reservation);
+ await chargingStation.removeReservation(
+ reservation,
+ ReservationTerminationReason.RESERVATION_CANCELED
+ );
return OCPP16Constants.OCPP_CANCEL_RESERVATION_RESPONSE_ACCEPTED;
} catch (error) {
return this.handleIncomingRequestError(
TRANSACTION_STARTED = 'TransactionStarted',
CONNECTOR_STATE_CHANGED = 'ConnectorStateChanged',
RESERVATION_CANCELED = 'ReservationCanceled',
+ REPLACE_EXISTING = 'ReplaceExisting',
}
export enum ReservationFilterKey {