- } as OCPP16BootNotificationRequest;
- case OCPPVersion.VERSION_20:
- case OCPPVersion.VERSION_201:
- return {
- reason: bootReason,
- chargingStation: {
- model: stationInfo.chargePointModel,
- vendorName: stationInfo.chargePointVendor,
- ...(!isUndefined(stationInfo.firmwareVersion) && {
- firmwareVersion: stationInfo.firmwareVersion,
- }),
- ...(!isUndefined(stationInfo.chargeBoxSerialNumber) && {
- serialNumber: stationInfo.chargeBoxSerialNumber,
- }),
- ...((!isUndefined(stationInfo.iccid) || !isUndefined(stationInfo.imsi)) && {
- modem: {
- ...(!isUndefined(stationInfo.iccid) && { iccid: stationInfo.iccid }),
- ...(!isUndefined(stationInfo.imsi) && { imsi: stationInfo.imsi }),
- },
- }),
- },
- } as OCPP20BootNotificationRequest;
- }
- }
-
- public static warnTemplateKeysDeprecation(
- stationTemplate: ChargingStationTemplate,
- logPrefix: string,
- templateFile: string
- ) {
- const templateKeys: { key: string; deprecatedKey: string }[] = [
- { key: 'supervisionUrls', deprecatedKey: 'supervisionUrl' },
- { key: 'idTagsFile', deprecatedKey: 'authorizationFile' },
- ];
- for (const templateKey of templateKeys) {
- ChargingStationUtils.warnDeprecatedTemplateKey(
- stationTemplate,
- templateKey.deprecatedKey,
- logPrefix,
- templateFile,
- `Use '${templateKey.key}' instead`
- );
- ChargingStationUtils.convertDeprecatedTemplateKey(
- stationTemplate,
- templateKey.deprecatedKey,
- templateKey.key
- );
- }
- }
-
- public static stationTemplateToStationInfo(
- stationTemplate: ChargingStationTemplate
- ): ChargingStationInfo {
- stationTemplate = cloneObject<ChargingStationTemplate>(stationTemplate);
- delete stationTemplate.power;
- delete stationTemplate.powerUnit;
- delete stationTemplate?.Connectors;
- delete stationTemplate?.Evses;
- delete stationTemplate.Configuration;
- delete stationTemplate.AutomaticTransactionGenerator;
- delete stationTemplate.chargeBoxSerialNumberPrefix;
- delete stationTemplate.chargePointSerialNumberPrefix;
- delete stationTemplate.meterSerialNumberPrefix;
- return stationTemplate as unknown as ChargingStationInfo;
- }
-
- public static createSerialNumber(
- stationTemplate: ChargingStationTemplate,
- stationInfo: ChargingStationInfo,
- params: {
- randomSerialNumberUpperCase?: boolean;
- randomSerialNumber?: boolean;
- } = {
- randomSerialNumberUpperCase: true,
- randomSerialNumber: true,
- }
- ): void {
- params = { ...{ randomSerialNumberUpperCase: true, randomSerialNumber: true }, ...params };
- const serialNumberSuffix = params?.randomSerialNumber
- ? ChargingStationUtils.getRandomSerialNumberSuffix({
- upperCase: params.randomSerialNumberUpperCase,
- })
- : '';
- isNotEmptyString(stationTemplate?.chargePointSerialNumberPrefix) &&
- (stationInfo.chargePointSerialNumber = `${stationTemplate.chargePointSerialNumberPrefix}${serialNumberSuffix}`);
- isNotEmptyString(stationTemplate?.chargeBoxSerialNumberPrefix) &&
- (stationInfo.chargeBoxSerialNumber = `${stationTemplate.chargeBoxSerialNumberPrefix}${serialNumberSuffix}`);
- isNotEmptyString(stationTemplate?.meterSerialNumberPrefix) &&
- (stationInfo.meterSerialNumber = `${stationTemplate.meterSerialNumberPrefix}${serialNumberSuffix}`);
- }
-
- public static propagateSerialNumber(
- stationTemplate: ChargingStationTemplate,
- stationInfoSrc: ChargingStationInfo,
- stationInfoDst: ChargingStationInfo
- ) {
- if (!stationInfoSrc || !stationTemplate) {
- throw new BaseError(
- 'Missing charging station template or existing configuration to propagate serial number'
- );
- }
- stationTemplate?.chargePointSerialNumberPrefix && stationInfoSrc?.chargePointSerialNumber
- ? (stationInfoDst.chargePointSerialNumber = stationInfoSrc.chargePointSerialNumber)
- : stationInfoDst?.chargePointSerialNumber && delete stationInfoDst.chargePointSerialNumber;
- stationTemplate?.chargeBoxSerialNumberPrefix && stationInfoSrc?.chargeBoxSerialNumber
- ? (stationInfoDst.chargeBoxSerialNumber = stationInfoSrc.chargeBoxSerialNumber)
- : stationInfoDst?.chargeBoxSerialNumber && delete stationInfoDst.chargeBoxSerialNumber;
- stationTemplate?.meterSerialNumberPrefix && stationInfoSrc?.meterSerialNumber
- ? (stationInfoDst.meterSerialNumber = stationInfoSrc.meterSerialNumber)
- : stationInfoDst?.meterSerialNumber && delete stationInfoDst.meterSerialNumber;
+ },
+ } as OCPP20BootNotificationRequest;
+ }
+};
+
+export const warnTemplateKeysDeprecation = (
+ stationTemplate: ChargingStationTemplate,
+ logPrefix: string,
+ templateFile: string
+) => {
+ const templateKeys: { key: string; deprecatedKey: string }[] = [
+ { key: 'supervisionUrls', deprecatedKey: 'supervisionUrl' },
+ { key: 'idTagsFile', deprecatedKey: 'authorizationFile' },
+ ];
+ for (const templateKey of templateKeys) {
+ warnDeprecatedTemplateKey(
+ stationTemplate,
+ templateKey.deprecatedKey,
+ logPrefix,
+ templateFile,
+ `Use '${templateKey.key}' instead`
+ );
+ convertDeprecatedTemplateKey(stationTemplate, templateKey.deprecatedKey, templateKey.key);
+ }
+};
+
+export const stationTemplateToStationInfo = (
+ stationTemplate: ChargingStationTemplate
+): ChargingStationInfo => {
+ stationTemplate = cloneObject<ChargingStationTemplate>(stationTemplate);
+ delete stationTemplate.power;
+ delete stationTemplate.powerUnit;
+ delete stationTemplate?.Connectors;
+ delete stationTemplate?.Evses;
+ delete stationTemplate.Configuration;
+ delete stationTemplate.AutomaticTransactionGenerator;
+ delete stationTemplate.chargeBoxSerialNumberPrefix;
+ delete stationTemplate.chargePointSerialNumberPrefix;
+ delete stationTemplate.meterSerialNumberPrefix;
+ return stationTemplate as unknown as ChargingStationInfo;
+};
+
+export const createSerialNumber = (
+ stationTemplate: ChargingStationTemplate,
+ stationInfo: ChargingStationInfo,
+ params: {
+ randomSerialNumberUpperCase?: boolean;
+ randomSerialNumber?: boolean;
+ } = {
+ randomSerialNumberUpperCase: true,
+ randomSerialNumber: true,
+ }
+): void => {
+ params = { ...{ randomSerialNumberUpperCase: true, randomSerialNumber: true }, ...params };
+ const serialNumberSuffix = params?.randomSerialNumber
+ ? getRandomSerialNumberSuffix({
+ upperCase: params.randomSerialNumberUpperCase,
+ })
+ : '';
+ isNotEmptyString(stationTemplate?.chargePointSerialNumberPrefix) &&
+ (stationInfo.chargePointSerialNumber = `${stationTemplate.chargePointSerialNumberPrefix}${serialNumberSuffix}`);
+ isNotEmptyString(stationTemplate?.chargeBoxSerialNumberPrefix) &&
+ (stationInfo.chargeBoxSerialNumber = `${stationTemplate.chargeBoxSerialNumberPrefix}${serialNumberSuffix}`);
+ isNotEmptyString(stationTemplate?.meterSerialNumberPrefix) &&
+ (stationInfo.meterSerialNumber = `${stationTemplate.meterSerialNumberPrefix}${serialNumberSuffix}`);
+};
+
+export const propagateSerialNumber = (
+ stationTemplate: ChargingStationTemplate,
+ stationInfoSrc: ChargingStationInfo,
+ stationInfoDst: ChargingStationInfo
+) => {
+ if (!stationInfoSrc || !stationTemplate) {
+ throw new BaseError(
+ 'Missing charging station template or existing configuration to propagate serial number'
+ );