X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStationUtils.ts;h=540ec4ffa36bfef0dccbdb45afc2a8ca1e6a0769;hb=d270cc878c61c42098557a0e03cc1620f74112de;hp=fd0dd7651f02a1e65fc5cbf00bed5e25634ce0ef;hpb=0e4fa348298d36900560f7466f21f44090d2fe1b;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStationUtils.ts b/src/charging-station/ChargingStationUtils.ts index fd0dd765..540ec4ff 100644 --- a/src/charging-station/ChargingStationUtils.ts +++ b/src/charging-station/ChargingStationUtils.ts @@ -13,7 +13,10 @@ import { Voltage, } from '../types/ChargingStationTemplate'; import { ChargingProfileKindType, RecurrencyKindType } from '../types/ocpp/1.6/ChargingProfile'; +import type { OCPP16BootNotificationRequest } from '../types/ocpp/1.6/Requests'; +import { BootReasonEnumType, OCPP20BootNotificationRequest } from '../types/ocpp/2.0/Requests'; import type { ChargingProfile, ChargingSchedulePeriod } from '../types/ocpp/ChargingProfile'; +import { OCPPVersion } from '../types/ocpp/OCPPVersion'; import type { BootNotificationRequest } from '../types/ocpp/Requests'; import { WorkerProcessType } from '../types/Worker'; import Configuration from '../utils/Configuration'; @@ -132,27 +135,50 @@ export class ChargingStationUtils { public static createBootNotificationRequest( stationInfo: ChargingStationInfo ): BootNotificationRequest { - return { - chargePointModel: stationInfo.chargePointModel, - chargePointVendor: stationInfo.chargePointVendor, - ...(!Utils.isUndefined(stationInfo.chargeBoxSerialNumber) && { - chargeBoxSerialNumber: stationInfo.chargeBoxSerialNumber, - }), - ...(!Utils.isUndefined(stationInfo.chargePointSerialNumber) && { - chargePointSerialNumber: stationInfo.chargePointSerialNumber, - }), - ...(!Utils.isUndefined(stationInfo.firmwareVersion) && { - firmwareVersion: stationInfo.firmwareVersion, - }), - ...(!Utils.isUndefined(stationInfo.iccid) && { iccid: stationInfo.iccid }), - ...(!Utils.isUndefined(stationInfo.imsi) && { imsi: stationInfo.imsi }), - ...(!Utils.isUndefined(stationInfo.meterSerialNumber) && { - meterSerialNumber: stationInfo.meterSerialNumber, - }), - ...(!Utils.isUndefined(stationInfo.meterType) && { - meterType: stationInfo.meterType, - }), - }; + const ocppVersion = stationInfo.ocppVersion ?? OCPPVersion.VERSION_16; + switch (ocppVersion) { + case OCPPVersion.VERSION_16: + return { + chargePointModel: stationInfo.chargePointModel, + chargePointVendor: stationInfo.chargePointVendor, + ...(!Utils.isUndefined(stationInfo.chargeBoxSerialNumber) && { + chargeBoxSerialNumber: stationInfo.chargeBoxSerialNumber, + }), + ...(!Utils.isUndefined(stationInfo.chargePointSerialNumber) && { + chargePointSerialNumber: stationInfo.chargePointSerialNumber, + }), + ...(!Utils.isUndefined(stationInfo.firmwareVersion) && { + firmwareVersion: stationInfo.firmwareVersion, + }), + ...(!Utils.isUndefined(stationInfo.iccid) && { iccid: stationInfo.iccid }), + ...(!Utils.isUndefined(stationInfo.imsi) && { imsi: stationInfo.imsi }), + ...(!Utils.isUndefined(stationInfo.meterSerialNumber) && { + meterSerialNumber: stationInfo.meterSerialNumber, + }), + ...(!Utils.isUndefined(stationInfo.meterType) && { + meterType: stationInfo.meterType, + }), + } as OCPP16BootNotificationRequest; + case OCPPVersion.VERSION_20: + case OCPPVersion.VERSION_201: + return { + reason: BootReasonEnumType.PowerUp, + chargingStation: { + model: stationInfo.chargePointModel, + vendorName: stationInfo.chargePointVendor, + ...(!Utils.isUndefined(stationInfo.firmwareVersion) && { + firmwareVersion: stationInfo.firmwareVersion, + }), + ...(!Utils.isUndefined(stationInfo.chargeBoxSerialNumber) && { + serialNumber: stationInfo.chargeBoxSerialNumber, + }), + modem: { + ...(!Utils.isUndefined(stationInfo.iccid) && { iccid: stationInfo.iccid }), + ...(!Utils.isUndefined(stationInfo.imsi) && { imsi: stationInfo.imsi }), + }, + }, + } as OCPP20BootNotificationRequest; + } } public static workerPoolInUse(): boolean {