Handle Cahors DC charger
MODIFY
src/integration/charging-station-vendor/ChargingStationVendorIntegration.ts
src/integration/charging-station-vendor/ChargingStationVendorIntegration.ts
-import { ChargingProfile, ChargingSchedule } from '../../types/ChargingProfile';
-import ChargingStation, { ConnectorCurrentLimit, ConnectorCurrentLimitSource, StaticLimitAmps } from '../../types/ChargingStation';
+import { ChargingProfile, ChargingRateUnitType, ChargingSchedule } from '../../types/ChargingProfile';
+import ChargingStation, { ConnectorCurrentLimit, ConnectorCurrentLimitSource, PowerLimitUnits, StaticLimitAmps } from '../../types/ChargingStation';
import { OCPPChangeConfigurationCommandResult, OCPPChargingProfileStatus, OCPPClearChargingProfileCommandResult, OCPPClearChargingProfileStatus, OCPPConfigurationStatus, OCPPGetCompositeScheduleCommandResult, OCPPGetCompositeScheduleStatus, OCPPSetChargingProfileCommandResult } from '../../types/ocpp/OCPPClient';
import BackendError from '../../exception/BackendError';
@@ -88,7 +88,7 @@ export default abstract class ChargingStationVendorIntegration {
// Change the config
result = await chargingStationClient.changeConfiguration({
key: this.getOCPPParamNameForChargingLimitation(),
- value: occpLimitAmpValue + ''
+ value: occpLimitAmpValue.toString()
});
} catch (error) {
if (!error.status) {
@@ -104,8 +104,9 @@ export default abstract class ChargingStationVendorIntegration {
// Refresh Configuration
await OCPPUtils.requestAndSaveChargingStationOcppParameters(tenantID, chargingStation);
// Update the charger's connectors
+ const limitAmpsPerConnector = Utils.getLimitAmpsPerConnector(chargingStation, maxAmps);
for (const connector of chargingStation.connectors) {
- connector.amperageLimit = maxAmps / chargingStation.connectors.length;
+ connector.amperageLimit = limitAmpsPerConnector;
}
// Save it
await ChargingStationStorage.saveChargingStation(tenantID, chargingStation);
@@ -609,12 +610,71 @@ export default abstract class ChargingStationVendorIntegration {
return result;
}
- public abstract getOCPPParamNameForChargingLimitation(): string;
+ public getOCPPParamValueForChargingLimitation(chargingStation: ChargingStation, limitAmp: number): number {
+ // Check at charge point level
+ if (chargingStation.chargePoints) {
+ for (const chargePoint of chargingStation.chargePoints) {
+ if (chargePoint.excludeFromPowerLimitation) {
+ continue;
+ }
+ if (chargePoint.cannotChargeInParallel || chargePoint.sharePowerToAllConnectors) {
+ return limitAmp / Utils.getChargingStationNumberOfConnectedPhases(chargingStation);
+ }
+ }
+ }
+ return limitAmp / chargingStation.connectors.length / Utils.getChargingStationNumberOfConnectedPhases(chargingStation);
+ }
- public abstract getOCPPParamValueForChargingLimitation(chargingStation: ChargingStation, limitAmp: number);
+ public convertToVendorChargingProfile(chargingStation: ChargingStation, chargingProfile: ChargingProfile): ChargingProfile {
+ // Get vendor specific charging profile
+ const vendorSpecificChargingProfile = JSON.parse(JSON.stringify(chargingProfile));
+ // Check connector
+ if (chargingStation.connectors && vendorSpecificChargingProfile.profile && vendorSpecificChargingProfile.profile.chargingSchedule) {
+ // Convert to Watts?
+ if (chargingStation.powerLimitUnit === PowerLimitUnits.WATT) {
+ vendorSpecificChargingProfile.profile.chargingSchedule.chargingRateUnit = ChargingRateUnitType.WATT;
+ }
+ // Divide the power by the number of connectors and number of phases
+ for (const schedulePeriod of vendorSpecificChargingProfile.profile.chargingSchedule.chargingSchedulePeriod) {
+ // Check Unit
+ if (chargingStation.powerLimitUnit === PowerLimitUnits.AMPERE) {
+ // Limit Amps per phase
+ schedulePeriod.limit = Utils.getLimitAmpsPerConnector(chargingStation, schedulePeriod.limit) /
+ Utils.getChargingStationNumberOfConnectedPhases(chargingStation, vendorSpecificChargingProfile.connectorID);
+ } else {
+ // Limit Watts for all the phases (Cahors)
+ schedulePeriod.limit = Utils.convertAmpToWatt(
+ chargingStation, vendorSpecificChargingProfile.connectorID,
+ Utils.getLimitAmpsPerConnector(chargingStation, schedulePeriod.limit));
+ }
+ }
+ }
+ return vendorSpecificChargingProfile;
+ }
- public abstract convertToVendorChargingProfile(chargingStation: ChargingStation, chargingProfile: ChargingProfile): ChargingProfile;
+ public convertFromVendorChargingSchedule(chargingStation: ChargingStation, connectorID: number, chargingSchedule: ChargingSchedule): ChargingSchedule {
+ // Get vendor specific charging profile
+ if (!chargingSchedule) {
+ return chargingSchedule;
+ }
+ if (chargingSchedule.chargingSchedulePeriod) {
+ for (const chargingSchedulePeriod of chargingSchedule.chargingSchedulePeriod) {
+ // Convert to Amps?
+ if (chargingSchedule.chargingRateUnit === ChargingRateUnitType.WATT) {
+ chargingSchedulePeriod.limit = Utils.convertWattToAmp(chargingStation, connectorID, chargingSchedulePeriod.limit);
+ }
+ // Limit is per connector and per phase Convert to max Amp
+ chargingSchedulePeriod.limit = chargingSchedulePeriod.limit * (connectorID === 0 ?
+ chargingStation.connectors.length : 1) * Utils.getChargingStationNumberOfConnectedPhases(chargingStation, connectorID);
+ }
+ }
+ // Convert to Amps?
+ if (chargingSchedule.chargingRateUnit === ChargingRateUnitType.WATT) {
+ chargingSchedule.chargingRateUnit = ChargingRateUnitType.AMPERE;
+ }
+ return chargingSchedule;
+ }
- public abstract convertFromVendorChargingSchedule(chargingStation: ChargingStation, connectorID: number, vendorSpecificChargingSchedule: ChargingSchedule): ChargingSchedule;
+ public abstract getOCPPParamNameForChargingLimitation(): string;
}

MODIFY
src/integration/charging-station-vendor/delta/DeltaChargingStationVendorIntegration.ts
src/integration/charging-station-vendor/delta/DeltaChargingStationVendorIntegration.ts
-import { ChargingProfile, ChargingRateUnitType, ChargingSchedule } from '../../../types/ChargingProfile';
-import ChargingStation, { PowerLimitUnits } from '../../../types/ChargingStation';
-
+import ChargingStation from '../../../types/ChargingStation';
import ChargingStationVendorIntegration from '../ChargingStationVendorIntegration';
-import Utils from '../../../utils/Utils';
export default class DeltaChargingStationVendorIntegration extends ChargingStationVendorIntegration {
constructor(chargingStation: ChargingStation) {
@@ -12,53 +9,4 @@ export default class DeltaChargingStationVendorIntegration extends ChargingStati
public getOCPPParamNameForChargingLimitation(): string {
return 'Device/GridCurrent';
}
-
- public getOCPPParamValueForChargingLimitation(chargingStation: ChargingStation, limitAmp: number): number {
- return limitAmp / chargingStation.connectors.length / Utils.getChargingStationNumberOfConnectedPhases(chargingStation);
- }
-
- public convertToVendorChargingProfile(chargingStation: ChargingStation, chargingProfile: ChargingProfile): ChargingProfile {
- // Get vendor specific charging profile
- const vendorSpecificChargingProfile = JSON.parse(JSON.stringify(chargingProfile));
- // Check connector
- if (chargingStation.connectors && vendorSpecificChargingProfile.profile && vendorSpecificChargingProfile.profile.chargingSchedule) {
- // Convert to Watts?
- if (chargingStation.powerLimitUnit === PowerLimitUnits.WATT) {
- chargingProfile.profile.chargingSchedule.chargingRateUnit = ChargingRateUnitType.WATT;
- }
- // Divide the power by the number of connectors and number of phases
- for (const schedulePeriod of vendorSpecificChargingProfile.profile.chargingSchedule.chargingSchedulePeriod) {
- schedulePeriod.limit = schedulePeriod.limit / (vendorSpecificChargingProfile.connectorID === 0 ?
- chargingStation.connectors.length : 1) / Utils.getChargingStationNumberOfConnectedPhases(chargingStation, chargingProfile.connectorID);
- // Check Unit
- if (chargingStation.powerLimitUnit === PowerLimitUnits.WATT) {
- schedulePeriod.limit = Utils.convertAmpToWatt(chargingStation, chargingProfile.connectorID, schedulePeriod.limit);
- }
- }
- }
- return vendorSpecificChargingProfile;
- }
-
- public convertFromVendorChargingSchedule(chargingStation: ChargingStation, connectorID: number, chargingSchedule: ChargingSchedule): ChargingSchedule {
- // Get vendor specific charging profile
- if (!chargingSchedule) {
- return chargingSchedule;
- }
- if (chargingSchedule.chargingSchedulePeriod) {
- for (const chargingSchedulePeriod of chargingSchedule.chargingSchedulePeriod) {
- // Convert to Amps?
- if (chargingSchedule.chargingRateUnit === ChargingRateUnitType.WATT) {
- chargingSchedulePeriod.limit = Utils.convertWattToAmp(chargingStation, connectorID, chargingSchedulePeriod.limit);
- }
- // Limit is per connector and per phase Convert to max Amp
- chargingSchedulePeriod.limit = chargingSchedulePeriod.limit * (connectorID === 0 ?
- chargingStation.connectors.length : 1) * Utils.getChargingStationNumberOfConnectedPhases(chargingStation, connectorID);
- }
- }
- // Convert to Amps?
- if (chargingSchedule.chargingRateUnit === ChargingRateUnitType.WATT) {
- chargingSchedule.chargingRateUnit = ChargingRateUnitType.AMPERE;
- }
- return chargingSchedule;
- }
}

MODIFY
src/integration/charging-station-vendor/schneider/SchneiderChargingStationVendorIntegration.ts
src/integration/charging-station-vendor/schneider/SchneiderChargingStationVendorIntegration.ts
-import { ChargingProfile, ChargingRateUnitType, ChargingSchedule } from '../../../types/ChargingProfile';
-import ChargingStation, { PowerLimitUnits } from '../../../types/ChargingStation';
-
+import ChargingStation from '../../../types/ChargingStation';
import ChargingStationVendorIntegration from '../ChargingStationVendorIntegration';
-import Utils from '../../../utils/Utils';
export default class SchneiderChargingStationVendorIntegration extends ChargingStationVendorIntegration {
constructor(chargingStation: ChargingStation) {
@@ -12,53 +9,4 @@ export default class SchneiderChargingStationVendorIntegration extends ChargingS
public getOCPPParamNameForChargingLimitation(): string {
return 'maxintensitysocket';
}
-
- public getOCPPParamValueForChargingLimitation(chargingStation: ChargingStation, limitAmp: number): number {
- return limitAmp / chargingStation.connectors.length / Utils.getChargingStationNumberOfConnectedPhases(chargingStation);
- }
-
- public convertToVendorChargingProfile(chargingStation: ChargingStation, chargingProfile: ChargingProfile): ChargingProfile {
- // Get vendor specific charging profile
- const vendorSpecificChargingProfile = JSON.parse(JSON.stringify(chargingProfile));
- // Check connector
- if (chargingStation.connectors && vendorSpecificChargingProfile.profile && vendorSpecificChargingProfile.profile.chargingSchedule) {
- // Convert to Watts?
- if (chargingStation.powerLimitUnit === PowerLimitUnits.WATT) {
- chargingProfile.profile.chargingSchedule.chargingRateUnit = ChargingRateUnitType.WATT;
- }
- // Divide the power by the number of connectors and number of phases
- for (const schedulePeriod of vendorSpecificChargingProfile.profile.chargingSchedule.chargingSchedulePeriod) {
- schedulePeriod.limit = schedulePeriod.limit / (vendorSpecificChargingProfile.connectorID === 0 ?
- chargingStation.connectors.length : 1) / Utils.getChargingStationNumberOfConnectedPhases(chargingStation, chargingProfile.connectorID);
- // Check Unit
- if (chargingStation.powerLimitUnit === PowerLimitUnits.WATT) {
- schedulePeriod.limit = Utils.convertAmpToWatt(chargingStation, chargingProfile.connectorID, schedulePeriod.limit);
- }
- }
- }
- return vendorSpecificChargingProfile;
- }
-
- public convertFromVendorChargingSchedule(chargingStation: ChargingStation, connectorID: number, chargingSchedule: ChargingSchedule): ChargingSchedule {
- // Get vendor specific charging profile
- if (!chargingSchedule) {
- return chargingSchedule;
- }
- if (chargingSchedule.chargingSchedulePeriod) {
- for (const chargingSchedulePeriod of chargingSchedule.chargingSchedulePeriod) {
- // Convert to Amps?
- if (chargingSchedule.chargingRateUnit === ChargingRateUnitType.WATT) {
- chargingSchedulePeriod.limit = Utils.convertWattToAmp(chargingStation, connectorID, chargingSchedulePeriod.limit);
- }
- // Limit is per connector and per phase Convert to max Amp
- chargingSchedulePeriod.limit = chargingSchedulePeriod.limit * (connectorID === 0 ?
- chargingStation.connectors.length : 1) * Utils.getChargingStationNumberOfConnectedPhases(chargingStation, connectorID);
- }
- }
- // Convert to Amps?
- if (chargingSchedule.chargingRateUnit === ChargingRateUnitType.WATT) {
- chargingSchedule.chargingRateUnit = ChargingRateUnitType.AMPERE;
- }
- return chargingSchedule;
- }
}

MODIFY
src/integration/charging-station-vendor/webasto/WebastoChargingStationVendorIntegration.ts
src/integration/charging-station-vendor/webasto/WebastoChargingStationVendorIntegration.ts
-import { ChargingProfile, ChargingRateUnitType, ChargingSchedule } from '../../../types/ChargingProfile';
-import ChargingStation, { PowerLimitUnits } from '../../../types/ChargingStation';
-
+import ChargingStation from '../../../types/ChargingStation';
import ChargingStationVendorIntegration from '../ChargingStationVendorIntegration';
-import Utils from '../../../utils/Utils';
export default class WebastoChargingStationVendorIntegration extends ChargingStationVendorIntegration {
constructor(chargingStation: ChargingStation) {
@@ -12,53 +9,4 @@ export default class WebastoChargingStationVendorIntegration extends ChargingSta
public getOCPPParamNameForChargingLimitation(): string {
return 'OperatorCurrentLimit';
}
-
- public getOCPPParamValueForChargingLimitation(chargingStation: ChargingStation, limitAmp: number): number {
- return limitAmp / chargingStation.connectors.length / Utils.getChargingStationNumberOfConnectedPhases(chargingStation);
- }
-
- public convertToVendorChargingProfile(chargingStation: ChargingStation, chargingProfile: ChargingProfile): ChargingProfile {
- // Get vendor specific charging profile
- const vendorSpecificChargingProfile = JSON.parse(JSON.stringify(chargingProfile));
- // Check connector
- if (chargingStation.connectors && vendorSpecificChargingProfile.profile && vendorSpecificChargingProfile.profile.chargingSchedule) {
- // Convert to Watts?
- if (chargingStation.powerLimitUnit === PowerLimitUnits.WATT) {
- chargingProfile.profile.chargingSchedule.chargingRateUnit = ChargingRateUnitType.WATT;
- }
- // Divide the power by the number of connectors and number of phases
- for (const schedulePeriod of vendorSpecificChargingProfile.profile.chargingSchedule.chargingSchedulePeriod) {
- schedulePeriod.limit = schedulePeriod.limit / (vendorSpecificChargingProfile.connectorID === 0 ?
- chargingStation.connectors.length : 1) / Utils.getChargingStationNumberOfConnectedPhases(chargingStation, chargingProfile.connectorID);
- // Check Unit
- if (chargingStation.powerLimitUnit === PowerLimitUnits.WATT) {
- schedulePeriod.limit = Utils.convertAmpToWatt(chargingStation, chargingProfile.connectorID, schedulePeriod.limit);
- }
- }
- }
- return vendorSpecificChargingProfile;
- }
-
- public convertFromVendorChargingSchedule(chargingStation: ChargingStation, connectorID: number, chargingSchedule: ChargingSchedule): ChargingSchedule {
- // Get vendor specific charging profile
- if (!chargingSchedule) {
- return chargingSchedule;
- }
- if (chargingSchedule.chargingSchedulePeriod) {
- for (const chargingSchedulePeriod of chargingSchedule.chargingSchedulePeriod) {
- // Convert to Amps?
- if (chargingSchedule.chargingRateUnit === ChargingRateUnitType.WATT) {
- chargingSchedulePeriod.limit = Utils.convertWattToAmp(chargingStation, connectorID, chargingSchedulePeriod.limit);
- }
- // Limit is per connector and per phase Convert to max Amp
- chargingSchedulePeriod.limit = chargingSchedulePeriod.limit * (connectorID === 0 ?
- chargingStation.connectors.length : 1) * Utils.getChargingStationNumberOfConnectedPhases(chargingStation, connectorID);
- }
- }
- // Convert to Amps?
- if (chargingSchedule.chargingRateUnit === ChargingRateUnitType.WATT) {
- chargingSchedule.chargingRateUnit = ChargingRateUnitType.AMPERE;
- }
- return chargingSchedule;
- }
}

MODIFY
src/utils/Utils.ts
src/utils/Utils.ts
@@ -512,15 +512,13 @@ export default class Utils {
}
}
// Check at connector level
- if (totalAmps === 0) {
- if (chargingStation.connectors) {
+ if (totalAmps === 0 && chargingStation.connectors) {
for (const connector of chargingStation.connectors) {
totalAmps += connector.amperage;
}
}
}
- }
- if (totalAmps === 0 && chargingStation.maximumPower > 0) {
+ if (totalAmps === 0 && chargingStation.maximumPower) {
totalAmps = Utils.convertWattToAmp(chargingStation, 0, chargingStation.maximumPower);
}
return totalAmps;
@@ -529,13 +527,13 @@ export default class Utils {
public static getChargingStationPower(chargingStation: ChargingStation, connectorId = 0): number {
if (chargingStation) {
// Check at charging station level
- if (connectorId === 0 && chargingStation.maximumPower > 0) {
+ if (connectorId === 0 && chargingStation.maximumPower) {
return chargingStation.maximumPower;
}
// Check at charge point level
if (chargingStation.chargePoints) {
for (const chargePoint of chargingStation.chargePoints) {
- if (chargePoint.connectorIDs.includes(connectorId) && chargePoint.power > 0 &&
+ if (chargePoint.connectorIDs.includes(connectorId) && chargePoint.power &&
(chargePoint.cannotChargeInParallel || chargePoint.sharePowerToAllConnectors)) {
return chargePoint.power;
}
@@ -543,7 +541,7 @@ export default class Utils {
}
// Check at connector level
if (chargingStation.connectors && chargingStation.connectors[connectorId - 1] &&
- chargingStation.connectors[connectorId - 1].power > 0) {
+ chargingStation.connectors[connectorId - 1].power) {
return chargingStation.connectors[connectorId - 1].power;
}
}
@@ -580,18 +578,21 @@ export default class Utils {
return 1;
}
- public static getChargingStationAmperage(chargingStation: ChargingStation, connectorId = 0): number {
+ public static getChargingStationVoltage(chargingStation: ChargingStation, connectorId = 0): number {
if (chargingStation) {
+ // Check at charging station level
+ if (chargingStation.voltage) {
+ return chargingStation.voltage;
+ }
// Check at charge point level
if (chargingStation.chargePoints) {
for (const chargePoint of chargingStation.chargePoints) {
// Take the first
- if (connectorId === 0 && chargePoint.amperage) {
- return chargePoint.amperage;
+ if (connectorId === 0 && chargePoint.voltage) {
+ return chargePoint.voltage;
}
- if (chargePoint.connectorIDs.includes(connectorId) && chargePoint.amperage &&
- (chargePoint.cannotChargeInParallel || chargePoint.sharePowerToAllConnectors)) {
- return chargePoint.amperage;
+ if (chargePoint.connectorIDs.includes(connectorId) && chargePoint.voltage) {
+ return chargePoint.voltage;
}
}
}
@@ -599,33 +600,29 @@ export default class Utils {
if (chargingStation.connectors) {
for (const connector of chargingStation.connectors) {
// Take the first
- if (connectorId === 0 && connector.amperage) {
- return connector.amperage;
+ if (connectorId === 0 && connector.voltage) {
+ return connector.voltage;
}
- if (connector.connectorId === connectorId && connector.amperage) {
- return connector.amperage;
+ if (connector.connectorId === connectorId && connector.voltage) {
+ return connector.voltage;
}
}
}
}
- return null;
+ return 0;
}
- public static getChargingStationVoltage(chargingStation: ChargingStation, connectorId = 0): number {
+ public static getChargingStationCurrentType(chargingStation: ChargingStation, connectorId = 0): CurrentType {
if (chargingStation) {
- // Check at charging station level
- if (chargingStation.voltage > 0) {
- return chargingStation.voltage;
- }
// Check at charge point level
if (chargingStation.chargePoints) {
for (const chargePoint of chargingStation.chargePoints) {
// Take the first
- if (connectorId === 0 && chargePoint.voltage > 0) {
- return chargePoint.voltage;
+ if (connectorId === 0 && chargePoint.currentType) {
+ return chargePoint.currentType;
}
- if (chargePoint.connectorIDs.includes(connectorId) && chargePoint.voltage > 0) {
- return chargePoint.voltage;
+ if (chargePoint.connectorIDs.includes(connectorId) && chargePoint.currentType) {
+ return chargePoint.currentType;
}
}
}
@@ -633,29 +630,30 @@ export default class Utils {
if (chargingStation.connectors) {
for (const connector of chargingStation.connectors) {
// Take the first
- if (connectorId === 0 && connector.voltage > 0) {
- return connector.voltage;
+ if (connectorId === 0 && connector.currentType) {
+ return connector.currentType;
}
- if (connector.connectorId === connectorId && connector.voltage > 0) {
- return connector.voltage;
+ if (connector.connectorId === connectorId && connector.currentType) {
+ return connector.currentType;
}
}
}
}
- return 0;
+ return null;
}
- public static getChargingStationCurrentType(chargingStation: ChargingStation, connectorId = 0): CurrentType {
+ public static getChargingStationAmperage(chargingStation: ChargingStation, connectorId = 0): number {
if (chargingStation) {
// Check at charge point level
if (chargingStation.chargePoints) {
for (const chargePoint of chargingStation.chargePoints) {
// Take the first
- if (connectorId === 0 && chargePoint.currentType) {
- return chargePoint.currentType;
+ if (connectorId === 0 && chargePoint.amperage) {
+ return chargePoint.amperage;
}
- if (chargePoint.connectorIDs.includes(connectorId) && chargePoint.currentType) {
- return chargePoint.currentType;
+ if (chargePoint.connectorIDs.includes(connectorId) && chargePoint.amperage &&
+ (chargePoint.cannotChargeInParallel || chargePoint.sharePowerToAllConnectors)) {
+ return chargePoint.amperage;
}
}
}
@@ -663,11 +661,11 @@ export default class Utils {
if (chargingStation.connectors) {
for (const connector of chargingStation.connectors) {
// Take the first
- if (connectorId === 0 && connector.currentType) {
- return connector.currentType;
+ if (connectorId === 0 && connector.amperage) {
+ return connector.amperage;
}
- if (connector.connectorId === connectorId && connector.currentType) {
- return connector.currentType;
+ if (connector.connectorId === connectorId && connector.amperage) {
+ return connector.amperage;
}
}
}
@@ -675,6 +673,50 @@ export default class Utils {
return null;
}
+ public static getChargingStationLimitAmperage(chargingStation: ChargingStation, connectorId = 0): number {
+ let amperageLimit = 0;
+ if (chargingStation) {
+ if (connectorId > 0) {
+ return chargingStation.connectors[connectorId - 1].amperageLimit;
+ }
+ // Check at charge point level
+ if (chargingStation.chargePoints) {
+ for (const chargePoint of chargingStation.chargePoints) {
+ if (chargePoint.excludeFromPowerLimitation) {
+ continue;
+ }
+ if (chargePoint.cannotChargeInParallel || chargePoint.sharePowerToAllConnectors) {
+ return chargingStation.connectors[chargePoint.connectorIDs[0] - 1].amperageLimit;
+ }
+ for (const connectorID of chargePoint.connectorIDs) {
+ amperageLimit += chargingStation.connectors[connectorID - 1].amperageLimit;
+ }
+ }
+ // Check at connector level
+ } else if (chargingStation.connectors) {
+ for (const connector of chargingStation.connectors) {
+ amperageLimit += connector.amperageLimit;
+ }
+ }
+ }
+ return amperageLimit;
+ }
+
+ public static getLimitAmpsPerConnector(chargingStation: ChargingStation, limitAmp: number): number {
+ // Check at charge point level
+ if (chargingStation.chargePoints) {
+ for (const chargePoint of chargingStation.chargePoints) {
+ if (chargePoint.excludeFromPowerLimitation) {
+ continue;
+ }
+ if (chargePoint.cannotChargeInParallel || chargePoint.sharePowerToAllConnectors) {
+ return limitAmp;
+ }
+ }
+ }
+ return limitAmp / chargingStation.connectors.length;
+ }
+
public static isEmptyArray(array): boolean {
if (Array.isArray(array) && array.length > 0) {
return false;
@@ -1062,16 +1104,6 @@ export default class Utils {
user: req.user.id
});
}
- // pragma if (new Date(filteredRequest.profile.chargingSchedule.startSchedule).getTime() < new Date().getTime()) {
- // throw new AppError({
- // source: Constants.CENTRAL_SERVER,
- // action: ServerAction.CHARGING_PROFILE_UPDATE,
- // errorCode: HTTPError.GENERAL_ERROR,
- // message: 'Charging Profile\'s start date must not be in the past',
- // module: MODULE_NAME, method: 'checkIfChargingProfileIsValid',
- // user: req.user.id
- // });
- // }
// Check End of Schedule <= 24h
const endScheduleDate = new Date(new Date(filteredRequest.profile.chargingSchedule.startSchedule).getTime() +
filteredRequest.profile.chargingSchedule.duration * 1000);
@@ -1085,13 +1117,11 @@ export default class Utils {
user: req.user.id
});
}
- // Check Min Limitation of each Schedule
- let maxAmpLimit = 0;
- for (const connector of chargingStation.connectors) {
- if (connector) {
- maxAmpLimit += connector.amperage;
- }
- }
+ // Check Max Limitation of each Schedule
+ const maxAmpLimit = Utils.getChargingStationLimitAmperage(chargingStation);
+ console.log('====================================');
+ console.log(maxAmpLimit);
+ console.log('====================================');
for (const chargingSchedulePeriod of filteredRequest.profile.chargingSchedule.chargingSchedulePeriod) {
// Check Min
if (chargingSchedulePeriod.limit < StaticLimitAmps.MIN_LIMIT) {

Handle Cahors DC charger