X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStationUtils.ts;h=c216ed6bec8bae64bb3f2ae84bab9db91ba16d3b;hb=db7d7aa671a7fef2555f0528023d327353b944fd;hp=51887b1ba830ed66e2190093b439928f01da8474;hpb=8114d10e3893e96bb725ce2fca9744429ee4b75b;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStationUtils.ts b/src/charging-station/ChargingStationUtils.ts index 51887b1b..c216ed6b 100644 --- a/src/charging-station/ChargingStationUtils.ts +++ b/src/charging-station/ChargingStationUtils.ts @@ -16,7 +16,11 @@ import { ChargingProfileKindType, RecurrencyKindType } from '../types/ocpp/1.6/C import { ChargingProfile, ChargingSchedulePeriod } from '../types/ocpp/ChargingProfile'; import { StandardParametersKey } from '../types/ocpp/Configuration'; import { MeterValueMeasurand, MeterValuePhase } from '../types/ocpp/MeterValues'; -import { BootNotificationRequest } from '../types/ocpp/Requests'; +import { + BootNotificationRequest, + IncomingRequestCommand, + RequestCommand, +} from '../types/ocpp/Requests'; import { WebSocketCloseEventStatusString } from '../types/WebSocket'; import { WorkerProcessType } from '../types/Worker'; import Configuration from '../utils/Configuration'; @@ -530,6 +534,28 @@ export class ChargingStationUtils { ); } + public static isCommandSupported( + command: RequestCommand | IncomingRequestCommand, + stationInfo: ChargingStationInfo + ): boolean { + if ( + Object.values(IncomingRequestCommand).includes(command as IncomingRequestCommand) && + !stationInfo?.commandsSupport?.incomingCommands + ) { + return true; + } + if ( + Object.values(RequestCommand).includes(command as RequestCommand) && + !stationInfo?.commandsSupport?.outgoingCommands + ) { + return true; + } + return ( + ((stationInfo?.commandsSupport?.incomingCommands[command] as boolean) ?? false) || + ((stationInfo?.commandsSupport?.outgoingCommands[command] as boolean) ?? false) + ); + } + private static getRandomSerialNumberSuffix(params?: { randomBytesLength?: number; upperCase?: boolean;