+ }
+
+ public static resetConnectorStatus(connectorStatus: ConnectorStatus): void {
+ connectorStatus.idTagLocalAuthorized = false;
+ connectorStatus.idTagAuthorized = false;
+ connectorStatus.transactionRemoteStarted = false;
+ connectorStatus.transactionStarted = false;
+ delete connectorStatus?.localAuthorizeIdTag;
+ delete connectorStatus?.authorizeIdTag;
+ delete connectorStatus?.transactionId;
+ delete connectorStatus?.transactionIdTag;
+ connectorStatus.transactionEnergyActiveImportRegisterValue = 0;
+ delete connectorStatus?.transactionBeginMeterValue;
+ }
+
+ public static createBootNotificationRequest(
+ stationInfo: ChargingStationInfo,
+ bootReason: BootReasonEnumType = BootReasonEnumType.PowerUp
+ ): BootNotificationRequest {
+ 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: bootReason,
+ chargingStation: {
+ model: stationInfo.chargePointModel,
+ vendorName: stationInfo.chargePointVendor,
+ ...(!Utils.isUndefined(stationInfo.firmwareVersion) && {
+ firmwareVersion: stationInfo.firmwareVersion,
+ }),
+ ...(!Utils.isUndefined(stationInfo.chargeBoxSerialNumber) && {
+ serialNumber: stationInfo.chargeBoxSerialNumber,
+ }),
+ ...((!Utils.isUndefined(stationInfo.iccid) || !Utils.isUndefined(stationInfo.imsi)) && {
+ modem: {
+ ...(!Utils.isUndefined(stationInfo.iccid) && { iccid: stationInfo.iccid }),
+ ...(!Utils.isUndefined(stationInfo.imsi) && { imsi: stationInfo.imsi }),
+ },
+ }),
+ },
+ } as OCPP20BootNotificationRequest;
+ }
+ }
+
+ public static workerPoolInUse(): boolean {
+ return [WorkerProcessType.dynamicPool, WorkerProcessType.staticPool].includes(
+ Configuration.getWorker().processType
+ );
+ }
+
+ public static workerDynamicPoolInUse(): boolean {
+ return Configuration.getWorker().processType === WorkerProcessType.dynamicPool;
+ }
+
+ public static warnTemplateKeysDeprecation(
+ templateFile: string,
+ stationTemplate: ChargingStationTemplate,
+ logPrefix: 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,
+ templateFile,
+ logPrefix,
+ `Use '${templateKey.key}' instead`
+ );
+ ChargingStationUtils.convertDeprecatedTemplateKey(
+ stationTemplate,
+ templateKey.deprecatedKey,
+ templateKey.key
+ );
+ }
+ }
+
+ public static stationTemplateToStationInfo(
+ stationTemplate: ChargingStationTemplate
+ ): ChargingStationInfo {
+ stationTemplate = Utils.cloneObject(stationTemplate);
+ delete stationTemplate.power;
+ delete stationTemplate.powerUnit;
+ delete stationTemplate.Configuration;
+ delete stationTemplate.AutomaticTransactionGenerator;
+ delete stationTemplate.chargeBoxSerialNumberPrefix;
+ delete stationTemplate.chargePointSerialNumberPrefix;
+ delete stationTemplate.meterSerialNumberPrefix;
+ return stationTemplate as unknown as ChargingStationInfo;
+ }
+
+ public static createStationInfoHash(stationInfo: ChargingStationInfo): void {
+ delete stationInfo.infoHash;
+ stationInfo.infoHash = crypto
+ .createHash(Constants.DEFAULT_HASH_ALGORITHM)
+ .update(JSON.stringify(stationInfo))
+ .digest('hex');