private readonly sharedLRUCache: SharedLRUCache;
private webSocketPingSetInterval!: NodeJS.Timeout;
private readonly chargingStationWorkerBroadcastChannel: ChargingStationWorkerBroadcastChannel;
- private reservationExpiryDateSetInterval?: NodeJS.Timeout;
+ private reservationExpirationSetInterval?: NodeJS.Timeout;
constructor(index: number, templateFile: string) {
this.started = false;
this.performanceStatistics?.start();
}
if (this.hasFeatureProfile(SupportedFeatureProfiles.Reservation)) {
- this.startReservationExpiryDateSetInterval();
+ this.startReservationExpirationSetInterval();
}
this.openWSConnection();
// Monitor charging station template file
}
}
- public getReservationBy(key: string, value: number | string): Reservation {
+ public getReservationBy(filterKey: ReservationFilterKey, value: number | string): Reservation {
if (this.hasEvses) {
for (const evse of this.evses.values()) {
for (const connector of evse.connectors.values()) {
- if (connector?.reservation?.[key] === value) {
+ if (connector?.reservation?.[filterKey] === value) {
return connector.reservation;
}
}
}
} else {
for (const connector of this.connectors.values()) {
- if (connector?.reservation?.[key] === value) {
+ if (connector?.reservation?.[filterKey] === value) {
return connector.reservation;
}
}
return Utils.isUndefined(foundReservation) ? [false, null] : [true, foundReservation];
}
- public startReservationExpiryDateSetInterval(customInterval?: number): void {
+ public startReservationExpirationSetInterval(customInterval?: number): void {
const interval =
customInterval ?? Constants.DEFAULT_RESERVATION_EXPIRATION_OBSERVATION_INTERVAL;
logger.info(
`${this.logPrefix()} Reservation expiration date interval is set to ${interval}
- and starts on CS now`
+ and starts on charging station now`
);
// eslint-disable-next-line @typescript-eslint/no-misused-promises
- this.reservationExpiryDateSetInterval = setInterval(async (): Promise<void> => {
+ this.reservationExpirationSetInterval = setInterval(async (): Promise<void> => {
if (this.hasEvses) {
for (const evse of this.evses.values()) {
for (const connector of evse.connectors.values()) {
}
public restartReservationExpiryDateSetInterval(): void {
- this.stopReservationExpiryDateSetInterval();
- this.startReservationExpiryDateSetInterval();
+ this.stopReservationExpirationSetInterval();
+ this.startReservationExpirationSetInterval();
}
public validateIncomingRequestWithReservation(connectorId: number, idTag: string): boolean {
private countReservableConnectors(connectors: Map<number, ConnectorStatus>) {
let reservableConnectors = 0;
- for (const [id, connector] of connectors) {
- if (id === 0) {
+ for (const [connectorId, connector] of connectors) {
+ if (connectorId === 0) {
continue;
}
if (connector.status === ConnectorStatusEnum.Available) {
return this.stationInfo.supervisionUrlOcppConfiguration ?? false;
}
- private stopReservationExpiryDateSetInterval(): void {
- if (this.reservationExpiryDateSetInterval) {
- clearInterval(this.reservationExpiryDateSetInterval);
+ private stopReservationExpirationSetInterval(): void {
+ if (this.reservationExpirationSetInterval) {
+ clearInterval(this.reservationExpirationSetInterval);
}
}
type ClearChargingProfileRequest,
type ClearChargingProfileResponse,
type ConnectorStatus,
- ConnectorStatusEnum,
ErrorType,
type GenericResponse,
GenericStatus,
type UnlockConnectorResponse,
} from '../../../types';
import { Constants, Utils, logger } from '../../../utils';
-import { OCPPConstants } from '../OCPPConstants';
import { OCPPIncomingRequestService } from '../OCPPIncomingRequestService';
const moduleName = 'OCPP16IncomingRequestService';
connectorStatus.transactionRemoteStarted = true;
const startTransactionPayload: Partial<StartTransactionRequest> = {
connectorId: transactionConnectorId,
- idTag: idTag,
+ idTag,
};
if (reserved || reservedOnConnectorZero) {
const reservation = chargingStation.getReservationBy(
>(chargingStation, OCPP16RequestCommand.START_TRANSACTION, startTransactionPayload)
).idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED
) {
- logger.debug(remoteStartTransactionLogMsg);
return OCPP16Constants.OCPP_RESPONSE_ACCEPTED;
}
return this.notifyRemoteStartTransactionRejected(
})
).idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED
) {
- logger.debug(remoteStartTransactionLogMsg);
return OCPP16Constants.OCPP_RESPONSE_ACCEPTED;
}
return this.notifyRemoteStartTransactionRejected(
OCPP16IncomingRequestCommand.RESERVE_NOW
)
) {
- return OCPPConstants.OCPP_RESERVATION_RESPONSE_REJECTED;
+ return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED;
}
const { reservationId, idTag, connectorId } = commandPayload;
let response: OCPP16ReserveNowResponse;
try {
if (!chargingStation.isConnectorAvailable(connectorId) && connectorId > 0) {
- return OCPPConstants.OCPP_RESERVATION_RESPONSE_REJECTED;
+ return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED;
}
if (connectorId === 0 && !chargingStation.getReservationOnConnectorId0Enabled()) {
- return OCPPConstants.OCPP_RESERVATION_RESPONSE_REJECTED;
+ return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED;
}
if (!(await OCPP16ServiceUtils.isIdTagAuthorized(chargingStation, connectorId, idTag))) {
- return OCPPConstants.OCPP_RESERVATION_RESPONSE_REJECTED;
+ return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED;
}
switch (chargingStation.getConnectorStatus(connectorId).status) {
- case ConnectorStatusEnum.Faulted:
- response = OCPPConstants.OCPP_RESERVATION_RESPONSE_FAULTED;
+ case OCPP16ChargePointStatus.Faulted:
+ response = OCPP16Constants.OCPP_RESERVATION_RESPONSE_FAULTED;
break;
- case ConnectorStatusEnum.Occupied:
- response = OCPPConstants.OCPP_RESERVATION_RESPONSE_OCCUPIED;
+ case OCPP16ChargePointStatus.Preparing:
+ case OCPP16ChargePointStatus.Charging:
+ case OCPP16ChargePointStatus.SuspendedEV:
+ case OCPP16ChargePointStatus.SuspendedEVSE:
+ case OCPP16ChargePointStatus.Finishing:
+ response = OCPP16Constants.OCPP_RESERVATION_RESPONSE_OCCUPIED;
break;
- case ConnectorStatusEnum.Unavailable:
- response = OCPPConstants.OCPP_RESERVATION_RESPONSE_UNAVAILABLE;
+ case OCPP16ChargePointStatus.Unavailable:
+ response = OCPP16Constants.OCPP_RESERVATION_RESPONSE_UNAVAILABLE;
break;
- case ConnectorStatusEnum.Reserved:
+ case OCPP16ChargePointStatus.Reserved:
if (!chargingStation.isConnectorReservable(reservationId, idTag, connectorId)) {
- response = OCPPConstants.OCPP_RESERVATION_RESPONSE_OCCUPIED;
+ response = OCPP16Constants.OCPP_RESERVATION_RESPONSE_OCCUPIED;
break;
}
// eslint-disable-next-line no-fallthrough
default:
if (!chargingStation.isConnectorReservable(reservationId, idTag)) {
- response = OCPPConstants.OCPP_RESERVATION_RESPONSE_OCCUPIED;
+ response = OCPP16Constants.OCPP_RESERVATION_RESPONSE_OCCUPIED;
break;
}
await chargingStation.addReservation({
id: commandPayload.reservationId,
...commandPayload,
});
- response = OCPPConstants.OCPP_RESERVATION_RESPONSE_ACCEPTED;
+ response = OCPP16Constants.OCPP_RESERVATION_RESPONSE_ACCEPTED;
break;
}
return response;
} catch (error) {
- chargingStation.getConnectorStatus(connectorId).status = ConnectorStatusEnum.Available;
+ chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.Available;
return this.handleIncomingRequestError(
chargingStation,
OCPP16IncomingRequestCommand.RESERVE_NOW,
error as Error,
- { errorResponse: OCPPConstants.OCPP_RESERVATION_RESPONSE_FAULTED }
+ { errorResponse: OCPP16Constants.OCPP_RESERVATION_RESPONSE_FAULTED }
);
}
}
OCPP16IncomingRequestCommand.CANCEL_RESERVATION
)
) {
- return OCPPConstants.OCPP_CANCEL_RESERVATION_RESPONSE_REJECTED;
+ return OCPP16Constants.OCPP_CANCEL_RESERVATION_RESPONSE_REJECTED;
}
try {
const { reservationId } = commandPayload;
`${chargingStation.logPrefix()} Reservation with ID ${reservationId}
does not exist on charging station`
);
- return OCPPConstants.OCPP_CANCEL_RESERVATION_RESPONSE_REJECTED;
+ return OCPP16Constants.OCPP_CANCEL_RESERVATION_RESPONSE_REJECTED;
}
await chargingStation.removeReservation(reservation);
- return OCPPConstants.OCPP_CANCEL_RESERVATION_RESPONSE_ACCEPTED;
+ return OCPP16Constants.OCPP_CANCEL_RESERVATION_RESPONSE_ACCEPTED;
} catch (error) {
return this.handleIncomingRequestError(
chargingStation,
OCPP16IncomingRequestCommand.CANCEL_RESERVATION,
error as Error,
- { errorResponse: OCPPConstants.OCPP_CANCEL_RESERVATION_RESPONSE_REJECTED }
+ { errorResponse: OCPP16Constants.OCPP_CANCEL_RESERVATION_RESPONSE_REJECTED }
);
}
}