X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2FOCPPServiceUtils.ts;h=cf2aa07eb9d9c280295a74f10e84bdb5bf273b9a;hb=1431af786f4d2728bad4132d505758144798516b;hp=06c22367991bf5d6ac83d356b5aeeee7ec6218f2;hpb=6e939d9e416de33fa1c64fc7f4eb6be70954f69c;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index 06c22367..cf2aa07e 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -9,6 +9,7 @@ import { ChargePointErrorCode } from '../../types/ocpp/ChargePointErrorCode'; import { StandardParametersKey } from '../../types/ocpp/Configuration'; import type { ConnectorStatusEnum } from '../../types/ocpp/ConnectorStatusEnum'; import { ErrorType } from '../../types/ocpp/ErrorType'; +import { MessageType } from '../../types/ocpp/MessageType'; import { MeterValueMeasurand, type MeterValuePhase } from '../../types/ocpp/MeterValues'; import { OCPPVersion } from '../../types/ocpp/OCPPVersion'; import { @@ -44,6 +45,17 @@ export class OCPPServiceUtils { return ErrorType.FORMAT_VIOLATION; } + public static getMessageTypeString(messageType: MessageType): string { + switch (messageType) { + case MessageType.CALL_MESSAGE: + return 'request'; + case MessageType.CALL_RESULT_MESSAGE: + return 'response'; + case MessageType.CALL_ERROR_MESSAGE: + return 'error'; + } + } + public static isRequestCommandSupported( chargingStation: ChargingStation, command: RequestCommand @@ -130,7 +142,7 @@ export class OCPPServiceUtils { connectorId: number, status: ConnectorStatusEnum ): StatusNotificationRequest { - switch (chargingStation.stationInfo.ocppVersion) { + switch (chargingStation.stationInfo.ocppVersion ?? OCPPVersion.VERSION_16) { case OCPPVersion.VERSION_16: return { connectorId, @@ -145,6 +157,8 @@ export class OCPPServiceUtils { connectorId, evseId: connectorId, } as OCPP20StatusNotificationRequest; + default: + throw new BaseError('Cannot build status notification payload: OCPP version not supported'); } }