public static isCommandSupported(
command: RequestCommand | IncomingRequestCommand,
- stationInfo: ChargingStationInfo
+ chargingStation: ChargingStation
): boolean {
+ const isIncomingRequestCommand = Object.values(IncomingRequestCommand).includes(
+ command as IncomingRequestCommand
+ );
+ const isRequestCommand = Object.values(RequestCommand).includes(command as RequestCommand);
if (
- Object.values(IncomingRequestCommand).includes(command as IncomingRequestCommand) &&
- !stationInfo?.commandsSupport?.incomingCommands
+ isIncomingRequestCommand &&
+ !chargingStation.stationInfo?.commandsSupport?.incomingCommands
) {
return true;
- }
- if (
- Object.values(RequestCommand).includes(command as RequestCommand) &&
- !stationInfo?.commandsSupport?.outgoingCommands
+ } else if (
+ isIncomingRequestCommand &&
+ chargingStation.stationInfo?.commandsSupport?.incomingCommands
+ ) {
+ return (
+ (chargingStation.stationInfo?.commandsSupport?.incomingCommands[command] as boolean) ??
+ false
+ );
+ } else if (
+ isRequestCommand &&
+ !chargingStation.stationInfo?.commandsSupport?.outgoingCommands
) {
return true;
+ } else if (isRequestCommand && chargingStation.stationInfo?.commandsSupport?.outgoingCommands) {
+ return (
+ (chargingStation.stationInfo?.commandsSupport?.outgoingCommands[command] as boolean) ??
+ false
+ );
}
- return (
- ((stationInfo?.commandsSupport?.incomingCommands[command] as boolean) ?? false) ||
- ((stationInfo?.commandsSupport?.outgoingCommands[command] as boolean) ?? false)
- );
+ logger.error(`${chargingStation.logPrefix()} Unknown OCPP command '${command}'`);
+ return false;
}
private static getRandomSerialNumberSuffix(params?: {