break;
default:
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
- throw new Error(`Unknown reservation termination reason '${reason}'`);
+ throw new BaseError(`Unknown reservation termination reason '${reason}'`);
}
}
import type { JSONSchemaType } from 'ajv';
import { Client, type FTPResponse } from 'basic-ftp';
-import { secondsToMilliseconds } from 'date-fns';
+import { isWithinInterval, secondsToMilliseconds } from 'date-fns';
import { create } from 'tar';
import { OCPP16Constants } from './OCPP16Constants';
.chargingProfiles!) {
// FIXME: build the composite schedule including the local power limit, the stack level, the charging rate unit, etc.
if (
- chargingProfile.chargingSchedule.startSchedule! >= startDate &&
- chargingProfile.chargingSchedule.startSchedule! <= endDate
+ isWithinInterval(chargingProfile.chargingSchedule.startSchedule!, {
+ start: startDate,
+ end: endDate,
+ })
) {
compositeSchedule = chargingProfile.chargingSchedule;
break;
}
}
logger.warn(
- `${chargingStation.logPrefix()} Trying to remote stop a non existing transaction with id:
+ `${chargingStation.logPrefix()} Trying to remote stop a non existing transaction with id
${transactionId.toString()}`,
);
return OCPP16Constants.OCPP_RESPONSE_REJECTED;
if (accessResponse.code === 220) {
ftpClient.trackProgress((info) => {
logger.info(
- `${chargingStation.logPrefix()} ${
+ `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetDiagnostics: ${
info.bytes / 1024
} bytes transferred from diagnostics archive ${info.name}`,
);
)!;
if (reservation.idTag !== requestPayload.idTag) {
logger.warn(
- `${chargingStation.logPrefix()} Transaction reserved ${
+ `${chargingStation.logPrefix()} Reserved transaction ${
payload.transactionId
} started with a different idTag ${requestPayload.idTag} than the reservation one ${
reservation.idTag
}
if (hasReservationExpired(reservation)) {
logger.warn(
- `${chargingStation.logPrefix()} Transaction reserved ${
+ `${chargingStation.logPrefix()} Reserved transaction ${
payload.transactionId
} started with expired reservation ${
requestPayload.reservationId
);
} else {
logger.warn(
- `${chargingStation.logPrefix()} Starting transaction with id ${payload.transactionId.toString()} REJECTED with status '${payload
- .idTagInfo?.status}', idTag '${requestPayload.idTag}'`,
+ `${chargingStation.logPrefix()} Starting transaction with id ${payload.transactionId.toString()} REJECTED on ${
+ chargingStation.stationInfo.chargingStationId
+ }#${transactionConnectorId.toString()} with status '${payload.idTagInfo?.status}', idTag '${
+ requestPayload.idTag
+ }'${
+ OCPP16ServiceUtils.hasReservation(
+ chargingStation,
+ transactionConnectorId,
+ requestPayload.idTag,
+ )
+ ? `, reservationId '${requestPayload.reservationId}'`
+ : ''
+ }`,
);
await this.resetConnectorOnStartTransactionError(chargingStation, transactionConnectorId);
}
(chargingStation.getConnectorStatus(connectorId)?.status ===
OCPP16ChargePointStatus.Reserved &&
connectorReservation &&
+ !hasReservationExpired(connectorReservation) &&
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
- (hasReservationExpired(connectorReservation) || connectorReservation?.idTag !== idTag)) ||
+ connectorReservation?.idTag === idTag) ||
(chargingStation.getConnectorStatus(0)?.status === OCPP16ChargePointStatus.Reserved &&
chargingStationReservation &&
- (hasReservationExpired(chargingStationReservation) ||
- chargingStationReservation?.idTag !== idTag))
+ !hasReservationExpired(chargingStationReservation) &&
+ chargingStationReservation?.idTag === idTag)
) {
- return false;
+ return true;
}
- return true;
+ return false;
};
public static parseJsonSchemaFile<T extends JsonType>(