X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStation.ts;h=5bc0ec9ad24d8ae76f486f388eb86d03a2cad0b8;hb=6a4032b5d8f3cbaa18d3beddcdfe9d335c1cba90;hp=622eef71becf56cc164977c27065a98522d3d4bc;hpb=50fb0298a0efa3da95fe9a67ba87e20295b30f6e;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 622eef71..5bc0ec9a 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -113,7 +113,6 @@ import { type StopTransactionResponse, SupervisionUrlDistribution, SupportedFeatureProfiles, - VendorParametersKey, Voltage, type WSError, WebSocketCloseEventStatusCode, @@ -1141,29 +1140,7 @@ export class ChargingStation extends EventEmitter { } private getStationInfo(): ChargingStationInfo { - const defaultStationInfo: Partial = { - enableStatistics: false, - remoteAuthorization: true, - currentOutType: CurrentType.AC, - mainVoltageMeterValues: true, - phaseLineToLineVoltageMeterValues: false, - customValueLimitationMeterValues: true, - ocppStrictCompliance: true, - outOfOrderEndMeterValues: false, - beginEndMeterValues: false, - meteringPerTransaction: true, - transactionDataMeterValues: false, - supervisionUrlOcppConfiguration: false, - supervisionUrlOcppKey: VendorParametersKey.ConnectionUrl, - ocppVersion: OCPPVersion.VERSION_16, - ocppPersistentConfiguration: true, - stationInfoPersistentConfiguration: true, - automaticTransactionGeneratorPersistentConfiguration: true, - autoReconnectMaxRetries: -1, - registrationMaxRetries: -1, - reconnectExponentialDelay: false, - stopTransactionsOnStopped: true, - }; + const defaultStationInfo = Constants.DEFAULT_STATION_INFO; const stationInfoFromTemplate: ChargingStationInfo = this.getStationInfoFromTemplate(); const stationInfoFromFile: ChargingStationInfo | undefined = this.getStationInfoFromFile( stationInfoFromTemplate?.stationInfoPersistentConfiguration, @@ -1222,15 +1199,17 @@ export class ChargingStation extends EventEmitter { const patternGroup: number | undefined = this.stationInfo.firmwareUpgrade?.versionUpgrade?.patternGroup ?? this.stationInfo.firmwareVersion?.split('.').length; - const match = this.stationInfo - .firmwareVersion!.match(new RegExp(this.stationInfo.firmwareVersionPattern!))! - .slice(1, patternGroup! + 1); - const patchLevelIndex = match.length - 1; - match[patchLevelIndex] = ( - convertToInt(match[patchLevelIndex]) + - this.stationInfo.firmwareUpgrade!.versionUpgrade!.step! - ).toString(); - this.stationInfo.firmwareVersion = match?.join('.'); + const match = new RegExp(this.stationInfo.firmwareVersionPattern!) + .exec(this.stationInfo.firmwareVersion!) + ?.slice(1, patternGroup! + 1); + if (!isNullOrUndefined(match)) { + const patchLevelIndex = match!.length - 1; + match![patchLevelIndex] = ( + convertToInt(match![patchLevelIndex]) + + this.stationInfo.firmwareUpgrade!.versionUpgrade!.step! + ).toString(); + this.stationInfo.firmwareVersion = match!.join('.'); + } } this.saveStationInfo(); this.configuredSupervisionUrl = this.getConfiguredSupervisionUrl();