- const configuredMaxConnectors =
- ChargingStationUtils.getConfiguredNumberOfConnectors(stationTemplate);
- ChargingStationUtils.checkConfiguredMaxConnectors(
- configuredMaxConnectors,
- this.templateFile,
- this.logPrefix()
- );
- // Build evses or connectors if needed (FIXME: should be factored out)
- if (stationInfo?.Connectors && !stationInfo?.Evses) {
- const templateMaxConnectors = ChargingStationUtils.getMaxNumberOfConnectors(
- stationTemplate.Connectors
- );
- ChargingStationUtils.checkTemplateMaxConnectors(
- templateMaxConnectors,
- this.templateFile,
- this.logPrefix()
- );
- if (
- configuredMaxConnectors >
- (stationTemplate?.Connectors[0] ? templateMaxConnectors - 1 : templateMaxConnectors) &&
- !stationTemplate?.randomConnectors
- ) {
- logger.warn(
- `${this.logPrefix()} Number of connectors exceeds the number of connector configurations in template ${
- this.templateFile
- }, forcing random connector configurations affectation`
- );
- stationInfo.randomConnectors = true;
- }
- this.initializeConnectors(stationInfo, configuredMaxConnectors);
- } else if (stationInfo?.Evses && !stationInfo?.Connectors) {
- this.initializeEvses(stationInfo);
- } else if (stationInfo?.Evses && stationInfo?.Connectors) {
- const errorMsg = `Connectors and evses defined at the same time in template file ${this.templateFile}`;
- logger.error(`${this.logPrefix()} ${errorMsg}`);
- throw new BaseError(errorMsg);
- } else {
- const errorMsg = `No connectors or evses defined in template file ${this.templateFile}`;
- logger.error(`${this.logPrefix()} ${errorMsg}`);
- throw new BaseError(errorMsg);
- }