- const stationInfoFromFile: ChargingStationInfo = this.getStationInfoFromFile();
- if (stationInfoFromFile?.hash === stationInfoFromTemplate.hash) {
- return stationInfoFromFile;
- }
- this.createSerialNumber(stationInfoFromTemplate, stationInfoFromFile);
- return stationInfoFromTemplate;
- }
-
- private saveStationInfo(): void {
- this.saveConfiguration(Section.stationInfo);
- }
-
- private getOcppVersion(): OCPPVersion {
- return this.stationInfo.ocppVersion ? this.stationInfo.ocppVersion : OCPPVersion.VERSION_16;
- }
-
- private getOcppPersistentConfiguration(): boolean {
- return this.stationInfo.ocppPersistentConfiguration ?? true;
- }
-
- private handleUnsupportedVersion(version: OCPPVersion) {
- const errMsg = `${this.logPrefix()} Unsupported protocol version '${version}' configured in template file ${
- this.templateFile
- }`;
- logger.error(errMsg);
- throw new Error(errMsg);
- }
-
- private 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,
- }),
- };
- }
-
- private getHashId(stationInfo: ChargingStationInfo): string {
- const hashBootNotificationRequest = {
- chargePointModel: stationInfo.chargePointModel,
- chargePointVendor: stationInfo.chargePointVendor,
- ...(!Utils.isUndefined(stationInfo.chargeBoxSerialNumberPrefix) && {
- chargeBoxSerialNumber: stationInfo.chargeBoxSerialNumberPrefix,
- }),
- ...(!Utils.isUndefined(stationInfo.chargePointSerialNumberPrefix) && {
- chargePointSerialNumber: stationInfo.chargePointSerialNumberPrefix,
- }),
- ...(!Utils.isUndefined(stationInfo.firmwareVersion) && {
- firmwareVersion: stationInfo.firmwareVersion,
- }),
- ...(!Utils.isUndefined(stationInfo.iccid) && { iccid: stationInfo.iccid }),
- ...(!Utils.isUndefined(stationInfo.imsi) && { imsi: stationInfo.imsi }),
- ...(!Utils.isUndefined(stationInfo.meterSerialNumberPrefix) && {
- meterSerialNumber: stationInfo.meterSerialNumberPrefix,
- }),
- ...(!Utils.isUndefined(stationInfo.meterType) && {
- meterType: stationInfo.meterType,
- }),
- };
- return crypto
- .createHash(Constants.DEFAULT_HASH_ALGORITHM)
- .update(JSON.stringify(hashBootNotificationRequest) + stationInfo.chargingStationId)
- .digest('hex');
- }
-
- private initialize(): void {
- this.stationInfo = this.getStationInfo();
- logger.info(`${this.logPrefix()} Charging station hashId '${this.hashId}'`);
- this.bootNotificationRequest = this.createBootNotificationRequest(this.stationInfo);
- this.ocppConfiguration = this.getOcppConfiguration();
- delete this.stationInfo.Configuration;
- this.wsConfiguredConnectionUrl = new URL(
- this.getConfiguredSupervisionUrl().href + '/' + this.stationInfo.chargingStationId