X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStation.ts;h=84aa81ca649336eda64779744c87600ac5d9a098;hb=81533a206ec56709897f27edf1298e7c86d74c31;hp=8d7907bad7c111968344a10502dd7df1224133a6;hpb=ad774cecafe0c4f31321ed6e7aff1b5c0c514097;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 8d7907ba..84aa81ca 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -825,21 +825,6 @@ export default class ChargingStation { 'supervisionUrl', 'supervisionUrls' ); - const firmwareVersionRegExp = stationTemplate.firmwareVersionPattern - ? new RegExp(stationTemplate.firmwareVersionPattern) - : Constants.SEMVER_REGEXP; - if ( - stationTemplate.firmwareVersion && - firmwareVersionRegExp.test(stationTemplate.firmwareVersion) === false - ) { - logger.warn( - `${this.logPrefix()} Firmware version '${ - stationTemplate.firmwareVersion - }' in template file ${ - this.templateFile - } does not match regular expression '${firmwareVersionRegExp.toString()}'` - ); - } const stationInfo: ChargingStationInfo = ChargingStationUtils.stationTemplateToStationInfo(stationTemplate); stationInfo.hashId = ChargingStationUtils.getHashId(this.index, stationTemplate); @@ -862,6 +847,18 @@ export default class ChargingStation { ? stationTemplate.power * 1000 : stationTemplate.power; } + stationInfo.firmwareVersionPattern = + stationTemplate.firmwareVersionPattern ?? Constants.SEMVER_PATTERN; + if ( + stationInfo.firmwareVersion && + new RegExp(stationInfo.firmwareVersionPattern).test(stationInfo.firmwareVersion) === false + ) { + logger.warn( + `${this.logPrefix()} Firmware version '${stationInfo.firmwareVersion}' in template file ${ + this.templateFile + } does not match firmware version pattern '${stationInfo.firmwareVersionPattern}'` + ); + } stationInfo.resetTime = stationTemplate.resetTime ? stationTemplate.resetTime * 1000 : Constants.CHARGING_STATION_DEFAULT_RESET_TIME; @@ -1000,6 +997,18 @@ export default class ChargingStation { status: RegistrationStatusEnumType.ACCEPTED, }; } + if ( + this.stationInfo.firmwareStatus === FirmwareStatus.Installing && + this.stationInfo.firmwareVersion && + this.stationInfo.firmwareVersionPattern + ) { + const match = this.stationInfo.firmwareVersion + .match(new RegExp(this.stationInfo.firmwareVersionPattern)) + .slice(1, this.stationInfo.firmwareVersion.split('.').length + 1); + const patchLevelIndex = match.length - 1; + match[patchLevelIndex] = (Utils.convertToInt(match[patchLevelIndex]) + 1).toString(); + this.stationInfo.firmwareVersion = match.join('.'); + } } private initializeOcppConfiguration(): void { @@ -1846,8 +1855,8 @@ export default class ChargingStation { status: FirmwareStatus.Installed, }); this.stationInfo.firmwareStatus = FirmwareStatus.Installed; - // TODO: bump firmware version } + // Start the ATG if (this.getAutomaticTransactionGeneratorConfigurationFromTemplate()?.enable === true) { this.startAutomaticTransactionGenerator();