+ public static getTemplateMaxNumberOfConnectors(stationTemplate: ChargingStationTemplate): number {
+ const templateConnectors = stationTemplate?.Connectors;
+ if (!templateConnectors) {
+ return -1;
+ }
+ return Object.keys(templateConnectors).length;
+ }
+
+ public static checkTemplateMaxConnectors(
+ templateMaxConnectors: number,
+ templateFile: string,
+ logPrefix: string
+ ): void {
+ if (templateMaxConnectors === 0) {
+ logger.warn(
+ `${logPrefix} Charging station information from template ${templateFile} with empty connectors configuration`
+ );
+ } else if (templateMaxConnectors < 0) {
+ logger.error(
+ `${logPrefix} Charging station information from template ${templateFile} with no connectors configuration defined`
+ );
+ }
+ }
+
+ public static getConfiguredNumberOfConnectors(
+ index: number,
+ stationTemplate: ChargingStationTemplate
+ ): number {
+ let configuredMaxConnectors: number;
+ if (!Utils.isEmptyArray(stationTemplate.numberOfConnectors)) {
+ const numberOfConnectors = stationTemplate.numberOfConnectors as number[];
+ // Distribute evenly the number of connectors
+ configuredMaxConnectors = numberOfConnectors[(index - 1) % numberOfConnectors.length];
+ } else if (!Utils.isUndefined(stationTemplate.numberOfConnectors)) {
+ configuredMaxConnectors = stationTemplate.numberOfConnectors as number;
+ } else {
+ configuredMaxConnectors = stationTemplate?.Connectors[0]
+ ? ChargingStationUtils.getTemplateMaxNumberOfConnectors(stationTemplate) - 1
+ : ChargingStationUtils.getTemplateMaxNumberOfConnectors(stationTemplate);
+ }
+ return configuredMaxConnectors;
+ }
+
+ public static checkConfiguredMaxConnectors(
+ configuredMaxConnectors: number,
+ templateFile: string,
+ logPrefix: string
+ ): void {
+ if (configuredMaxConnectors <= 0) {
+ logger.warn(
+ `${logPrefix} Charging station information from template ${templateFile} with ${configuredMaxConnectors} connectors`
+ );
+ }
+ }
+