Added default property to template method
MODIFY
src/server/ocpp/utils/OCPPUtils.ts
src/server/ocpp/utils/OCPPUtils.ts
@@ -9,6 +9,7 @@ import BackendError from '../../../exception/BackendError';
import { BillingDataTransactionStop } from '../../../types/Billing';
import BillingFactory from '../../../integration/billing/BillingFactory';
import ChargingStationClientFactory from '../../../client/ocpp/ChargingStationClientFactory';
+import ChargingStationFactory from '../../../factories/ChargingStationFactory';
import ChargingStationStorage from '../../../storage/mongodb/ChargingStationStorage';
import ChargingStationVendorFactory from '../../../integration/charging-station-vendor/ChargingStationVendorFactory';
import Constants from '../../../utils/Constants';
@@ -25,6 +26,7 @@ import PricingFactory from '../../../integration/pricing/PricingFactory';
import { PricingSettingsType } from '../../../types/Setting';
import { ServerAction } from '../../../types/Server';
import SiteArea from '../../../types/SiteArea';
+import SiteAreaStorage from '../../../storage/mongodb/SiteAreaStorage';
import Tenant from '../../../types/Tenant';
import TenantComponents from '../../../types/TenantComponents';
import TenantStorage from '../../../storage/mongodb/TenantStorage';
@@ -1183,6 +1185,20 @@ export default class OCPPUtils {
} else {
delete connector.numberOfConnectedPhase;
}
+ if (chargingStation.siteAreaID && !connector.phaseAssignmentToGrid) {
+ const siteArea = await SiteAreaStorage.getSiteArea(tenantID, chargingStation.siteAreaID);
+ if (siteArea.numberOfPhases === 3) {
+ const numberOfPhases = Utils.getNumberOfConnectedPhases(chargingStation);
+ switch (numberOfPhases) {
+ case 3:
+ connector.phaseAssignmentToGrid = { csPhaseL1: OCPPPhase.L1, csPhaseL2: OCPPPhase.L2, csPhaseL3: OCPPPhase.L3 } ;
+ break;
+ case 1:
+ connector.phaseAssignmentToGrid = { csPhaseL1: OCPPPhase.L1, csPhaseL2: null, csPhaseL3: null } ;
+ break;
+ }
+ }
+ }
return true;
}
}

MODIFY
test/api/context/TenantContext.ts
test/api/context/TenantContext.ts
@@ -283,12 +283,21 @@ export default class TenantContext {
`Connector ID 1 of charging station ${createdChargingStation.id} must have 96 A`);
expect(createdChargingStation.connectors[0].type).to.eql('T2',
`Connector ID 1 of charging station ${createdChargingStation.id} must have Type 2 connector`);
+ if (siteArea) {
+ console.log(siteArea);
+ expect(createdChargingStation.connectors[0].phaseAssignmentToGrid).to.eql({},
+ `Connector ID 1 of charging station ${createdChargingStation.id} must have default phase assignment`);
+ }
expect(createdChargingStation.connectors[1].power).to.eql(22080,
`Connector ID 2 of charging station ${createdChargingStation.id} must have 22080 W`);
expect(createdChargingStation.connectors[1].amperage).to.eql(96,
`Connector ID 2 of charging station ${createdChargingStation.id} must have 96 A`);
expect(createdChargingStation.connectors[1].type).to.eql('T2',
`Connector ID 2 of charging station ${createdChargingStation.id} must have Type 2 connector`);
+ if (siteArea) {
+ expect(createdChargingStation.connectors[1].phaseAssignmentToGrid).to.eql({},
+ `Connector ID 1 of charging station ${createdChargingStation.id} must have default phase assignment`);
+ }
// Charge Points
expect(createdChargingStation.chargePoints.length).to.eql(1,
`Number of charge point of charging station ${createdChargingStation.id} must be 1`);

Added default property to template method