From: Jérôme Benoit Date: Fri, 28 Jul 2023 22:47:04 +0000 (+0200) Subject: refactor: remove unneeded redefinition of reservation type X-Git-Tag: v1.2.20~101 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=282582e5e5e1449b6eb3b414038c833a3ba7f264;p=e-mobility-charging-stations-simulator.git refactor: remove unneeded redefinition of reservation type Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index e802e0cb..f1dac8a3 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1013,7 +1013,7 @@ export class ChargingStation { ): [boolean, Reservation | undefined] { const foundReservation = this.getReservationBy( ReservationFilterKey.RESERVATION_ID, - reservation.id!, + reservation.reservationId!, ); return isUndefined(foundReservation) ? [false, undefined] : [true, foundReservation]; } diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 921c8f04..297b23b3 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -889,7 +889,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { ReservationFilterKey.CONNECTOR_ID, reservedOnConnectorZero ? 0 : transactionConnectorId, )!; - startTransactionPayload.reservationId = reservation.id; + startTransactionPayload.reservationId = reservation.reservationId; await chargingStation.removeReservation( reservation, ReservationTerminationReason.TRANSACTION_STARTED, diff --git a/src/types/index.ts b/src/types/index.ts index 436941aa..a5ab58ca 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -256,5 +256,8 @@ export { WebSocketCloseEventStatusCode, WebSocketCloseEventStatusString, } from './WebSocket'; -export { ReservationFilterKey, ReservationTerminationReason } from './ocpp/1.6/Reservation'; -export { type Reservation } from './ocpp/Reservation'; +export { + type Reservation, + ReservationFilterKey, + ReservationTerminationReason, +} from './ocpp/Reservation'; diff --git a/src/types/ocpp/1.6/Reservation.ts b/src/types/ocpp/1.6/Reservation.ts deleted file mode 100644 index 2197e171..00000000 --- a/src/types/ocpp/1.6/Reservation.ts +++ /dev/null @@ -1,23 +0,0 @@ -export interface OCPP16Reservation { - id: number; - connectorId: number; - expiryDate: Date; - idTag: string; - parentIdTag?: string; -} - -export enum ReservationTerminationReason { - EXPIRED = 'Expired', - TRANSACTION_STARTED = 'TransactionStarted', - CONNECTOR_STATE_CHANGED = 'ConnectorStateChanged', - RESERVATION_CANCELED = 'ReservationCanceled', - REPLACE_EXISTING = 'ReplaceExisting', -} - -export enum ReservationFilterKey { - RESERVATION_ID = 'id', - ID_TAG = 'idTag', - PARENT_ID_TAG = 'parentIdTag', - CONNECTOR_ID = 'connectorId', - EVSE_ID = 'evseId', -} diff --git a/src/types/ocpp/Reservation.ts b/src/types/ocpp/Reservation.ts index b185b874..0bcf101c 100644 --- a/src/types/ocpp/Reservation.ts +++ b/src/types/ocpp/Reservation.ts @@ -1,3 +1,19 @@ -import { type OCPP16Reservation } from './1.6/Reservation'; +import type { OCPP16ReserveNowRequest } from './1.6/Requests'; -export type Reservation = OCPP16Reservation; +export type Reservation = OCPP16ReserveNowRequest; + +export enum ReservationTerminationReason { + EXPIRED = 'Expired', + TRANSACTION_STARTED = 'TransactionStarted', + CONNECTOR_STATE_CHANGED = 'ConnectorStateChanged', + RESERVATION_CANCELED = 'ReservationCanceled', + REPLACE_EXISTING = 'ReplaceExisting', +} + +export enum ReservationFilterKey { + RESERVATION_ID = 'reservationId', + ID_TAG = 'idTag', + PARENT_ID_TAG = 'parentIdTag', + CONNECTOR_ID = 'connectorId', + EVSE_ID = 'evseId', +}