RegistrationStatusEnumType,
RequestCommand,
type Reservation,
- ReservationFilterKey,
+ type ReservationFilterKey,
ReservationTerminationReason,
type Response,
StandardParametersKey,
}
public async addReservation(reservation: Reservation): Promise<void> {
- const reservationFound = this.getReservationBy(
- ReservationFilterKey.RESERVATION_ID,
- reservation.reservationId,
- );
+ const reservationFound = this.getReservationBy('reservationId', reservation.reservationId);
if (!isUndefined(reservationFound)) {
await this.removeReservation(
reservationFound!,
if (this.hasEvses) {
for (const evseStatus of this.evses.values()) {
for (const connectorStatus of evseStatus.connectors.values()) {
- if (connectorStatus?.reservation?.[filterKey as keyof Reservation] === value) {
+ if (connectorStatus?.reservation?.[filterKey] === value) {
return connectorStatus.reservation;
}
}
}
} else {
for (const connectorStatus of this.connectors.values()) {
- if (connectorStatus?.reservation?.[filterKey as keyof Reservation] === value) {
+ if (connectorStatus?.reservation?.[filterKey] === value) {
return connectorStatus.reservation;
}
}
}
public validateIncomingRequestWithReservation(connectorId: number, idTag: string): boolean {
- return this.getReservationBy(ReservationFilterKey.CONNECTOR_ID, connectorId)?.idTag === idTag;
+ return this.getReservationBy('connectorId', connectorId)?.idTag === idTag;
}
public isConnectorReservable(
idTag?: string,
connectorId?: number,
): boolean {
- const reservationExists = !isUndefined(
- this.getReservationBy(ReservationFilterKey.RESERVATION_ID, reservationId),
- );
+ const reservationExists = !isUndefined(this.getReservationBy('reservationId', reservationId));
const userReservationExists =
- !isUndefined(idTag) && isUndefined(this.getReservationBy(ReservationFilterKey.ID_TAG, idTag!))
- ? false
- : true;
+ !isUndefined(idTag) && isUndefined(this.getReservationBy('idTag', idTag!)) ? false : true;
const notConnectorZero = isUndefined(connectorId) ? true : connectorId! > 0;
const freeConnectorsAvailable = this.getNumberOfReservableConnectors() > 0;
return (
OCPPVersion,
type RemoteStartTransactionRequest,
type RemoteStopTransactionRequest,
- ReservationFilterKey,
ReservationTerminationReason,
type ResetRequest,
type SetChargingProfileRequest,
};
if (reserved || reservedOnConnectorZero) {
const reservation = chargingStation.getReservationBy(
- ReservationFilterKey.CONNECTOR_ID,
+ 'connectorId',
reservedOnConnectorZero ? 0 : transactionConnectorId,
)!;
startTransactionPayload.reservationId = reservation.reservationId;
}
try {
const { reservationId } = commandPayload;
- const reservation = chargingStation.getReservationBy(
- ReservationFilterKey.RESERVATION_ID,
- reservationId,
- );
+ const reservation = chargingStation.getReservationBy('reservationId', reservationId);
if (isUndefined(reservation)) {
logger.error(
`${chargingStation.logPrefix()} Reservation with ID ${reservationId}
REPLACE_EXISTING = 'ReplaceExisting',
}
-export enum ReservationFilterKey {
- RESERVATION_ID = 'reservationId',
- ID_TAG = 'idTag',
- PARENT_ID_TAG = 'parentIdTag',
- CONNECTOR_ID = 'connectorId',
- EVSE_ID = 'evseId',
-}
+export type ReservationFilterKey = keyof OCPP16ReserveNowRequest;