X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FHelpers.ts;h=22ed5041e0515cc6b0769b3acb85df2d54525287;hb=d990f4bc8ad5366a200fd3d89be76c084fd71cea;hp=bf118e9fbb4f9a13111d57c1cc332a3cedd2225c;hpb=36b73d95deccfb6538929c48e0f989fb1c696e8a;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/Helpers.ts b/src/charging-station/Helpers.ts index bf118e9f..22ed5041 100644 --- a/src/charging-station/Helpers.ts +++ b/src/charging-station/Helpers.ts @@ -146,16 +146,16 @@ export const getHashId = (index: number, stationTemplate: ChargingStationTemplat const chargingStationInfo = { chargePointModel: stationTemplate.chargePointModel, chargePointVendor: stationTemplate.chargePointVendor, - ...(stationTemplate.chargeBoxSerialNumberPrefix !== undefined && { + ...(stationTemplate.chargeBoxSerialNumberPrefix != null && { chargeBoxSerialNumber: stationTemplate.chargeBoxSerialNumberPrefix }), - ...(stationTemplate.chargePointSerialNumberPrefix !== undefined && { + ...(stationTemplate.chargePointSerialNumberPrefix != null && { chargePointSerialNumber: stationTemplate.chargePointSerialNumberPrefix }), - ...(stationTemplate.meterSerialNumberPrefix !== undefined && { + ...(stationTemplate.meterSerialNumberPrefix != null && { meterSerialNumber: stationTemplate.meterSerialNumberPrefix }), - ...(stationTemplate.meterType !== undefined && { + ...(stationTemplate.meterType != null && { meterType: stationTemplate.meterType }) } @@ -338,11 +338,18 @@ export const setChargingStationOptions = ( stationInfo: ChargingStationInfo, options?: ChargingStationOptions ): ChargingStationInfo => { + if (options?.supervisionUrls != null) { + stationInfo.supervisionUrls = options.supervisionUrls + } if (options?.persistentConfiguration != null) { + stationInfo.stationInfoPersistentConfiguration = options.persistentConfiguration stationInfo.ocppPersistentConfiguration = options.persistentConfiguration stationInfo.automaticTransactionGeneratorPersistentConfiguration = options.persistentConfiguration } + if (options?.autoStart != null) { + stationInfo.autoStart = options.autoStart + } if (options?.autoRegister != null) { stationInfo.autoRegister = options.autoRegister } @@ -417,21 +424,21 @@ export const createBootNotificationRequest = ( return { chargePointModel: stationInfo.chargePointModel, chargePointVendor: stationInfo.chargePointVendor, - ...(stationInfo.chargeBoxSerialNumber !== undefined && { + ...(stationInfo.chargeBoxSerialNumber != null && { chargeBoxSerialNumber: stationInfo.chargeBoxSerialNumber }), - ...(stationInfo.chargePointSerialNumber !== undefined && { + ...(stationInfo.chargePointSerialNumber != null && { chargePointSerialNumber: stationInfo.chargePointSerialNumber }), - ...(stationInfo.firmwareVersion !== undefined && { + ...(stationInfo.firmwareVersion != null && { firmwareVersion: stationInfo.firmwareVersion }), - ...(stationInfo.iccid !== undefined && { iccid: stationInfo.iccid }), - ...(stationInfo.imsi !== undefined && { imsi: stationInfo.imsi }), - ...(stationInfo.meterSerialNumber !== undefined && { + ...(stationInfo.iccid != null && { iccid: stationInfo.iccid }), + ...(stationInfo.imsi != null && { imsi: stationInfo.imsi }), + ...(stationInfo.meterSerialNumber != null && { meterSerialNumber: stationInfo.meterSerialNumber }), - ...(stationInfo.meterType !== undefined && { + ...(stationInfo.meterType != null && { meterType: stationInfo.meterType }) } satisfies OCPP16BootNotificationRequest @@ -442,16 +449,16 @@ export const createBootNotificationRequest = ( chargingStation: { model: stationInfo.chargePointModel, vendorName: stationInfo.chargePointVendor, - ...(stationInfo.firmwareVersion !== undefined && { + ...(stationInfo.firmwareVersion != null && { firmwareVersion: stationInfo.firmwareVersion }), - ...(stationInfo.chargeBoxSerialNumber !== undefined && { + ...(stationInfo.chargeBoxSerialNumber != null && { serialNumber: stationInfo.chargeBoxSerialNumber }), - ...((stationInfo.iccid !== undefined || stationInfo.imsi !== undefined) && { + ...((stationInfo.iccid != null || stationInfo.imsi != null) && { modem: { - ...(stationInfo.iccid !== undefined && { iccid: stationInfo.iccid }), - ...(stationInfo.imsi !== undefined && { imsi: stationInfo.imsi }) + ...(stationInfo.iccid != null && { iccid: stationInfo.iccid }), + ...(stationInfo.imsi != null && { imsi: stationInfo.imsi }) } }) } @@ -476,7 +483,7 @@ export const warnTemplateKeysDeprecation = ( templateKey.deprecatedKey, logPrefix, templateFile, - templateKey.key !== undefined ? `Use '${templateKey.key}' instead` : undefined + templateKey.key != null ? `Use '${templateKey.key}' instead` : undefined ) convertDeprecatedTemplateKey(stationTemplate, templateKey.deprecatedKey, templateKey.key) } @@ -492,6 +499,7 @@ export const stationTemplateToStationInfo = ( delete stationTemplate.Evses delete stationTemplate.Configuration delete stationTemplate.AutomaticTransactionGenerator + delete stationTemplate.numberOfConnectors delete stationTemplate.chargeBoxSerialNumberPrefix delete stationTemplate.chargePointSerialNumberPrefix delete stationTemplate.meterSerialNumberPrefix @@ -769,7 +777,7 @@ const warnDeprecatedTemplateKey = ( templateFile: string, logMsgToAppend = '' ): void => { - if (template[key as keyof ChargingStationTemplate] !== undefined) { + if (template[key as keyof ChargingStationTemplate] != null) { const logMsg = `Deprecated template key '${key}' usage in file '${templateFile}'${ isNotEmptyString(logMsgToAppend) ? `. ${logMsgToAppend}` : '' }` @@ -783,8 +791,8 @@ const convertDeprecatedTemplateKey = ( deprecatedKey: string, key?: string ): void => { - if (template[deprecatedKey as keyof ChargingStationTemplate] !== undefined) { - if (key !== undefined) { + if (template[deprecatedKey as keyof ChargingStationTemplate] != null) { + if (key != null) { (template as unknown as Record)[key] = template[deprecatedKey as keyof ChargingStationTemplate] }