storage of phase assignment + migration
MODIFY
src/migration/tasks/UpdateChargingStationTemplatesTask.ts
src/migration/tasks/UpdateChargingStationTemplatesTask.ts
@@ -5,6 +5,7 @@ import ChargingStationStorage from '../../storage/mongodb/ChargingStationStorage
import Constants from '../../utils/Constants';
import Logging from '../../utils/Logging';
import MigrationTask from '../MigrationTask';
+import { OCPPPhase } from '../../types/ocpp/OCPPServer';
import OCPPUtils from '../../server/ocpp/utils/OCPPUtils';
import { ServerAction } from '../../types/Server';
import Tenant from '../../types/Tenant';
@@ -51,6 +52,7 @@ export default class UpdateChargingStationTemplatesTask extends MigrationTask {
}
// Get the charging stations
const chargingStations = await ChargingStationStorage.getChargingStations(tenant.id, {
+ withSite: true,
issuer: true
}, Constants.DB_PARAMS_MAX_LIMIT);
// Update
@@ -66,6 +68,18 @@ export default class UpdateChargingStationTemplatesTask extends MigrationTask {
connector.amperageLimit = connector.amperage;
chargingStationUpdated = true;
}
+ if (!Utils.objectHasProperty(connector, 'phaseAssignmentToGrid')) {
+ if (chargingStation.siteArea?.numberOfPhases === 3) {
+ if (connector.numberOfConnectedPhase === 1) {
+ connector.phaseAssignmentToGrid = { cSPhaseL1: OCPPPhase.L1, cSPhaseL2: null, cSPhaseL3: null } ;
+ } else {
+ connector.phaseAssignmentToGrid = { cSPhaseL1: OCPPPhase.L1, cSPhaseL2: OCPPPhase.L2, cSPhaseL3: OCPPPhase.L3 } ;
+ }
+ } else {
+ connector.phaseAssignmentToGrid = null;
+ }
+ chargingStationUpdated = true;
+ }
}
// Save
if (chargingStationTemplateUpdated.technicalUpdated ||

MODIFY
src/server/rest/service/ChargingStationService.ts
src/server/rest/service/ChargingStationService.ts
@@ -148,6 +148,16 @@ export default class ChargingStationService {
connector.voltage = filteredConnector.voltage;
connector.currentType = filteredConnector.currentType;
connector.numberOfConnectedPhase = filteredConnector.numberOfConnectedPhase;
+ connector.phaseAssignmentToGrid = filteredConnector.phaseAssignmentToGrid;
+ }
+ } else if (siteArea?.numberOfPhases === 3 && filteredRequest.connectors) {
+ // Assign Phases
+ for (const filteredConnector of filteredRequest.connectors) {
+ // Set
+ const connector = Utils.getConnectorFromID(chargingStation, filteredConnector.connectorId);
+ if (filteredConnector.phaseAssignmentToGrid) {
+ connector.phaseAssignmentToGrid = filteredConnector.phaseAssignmentToGrid;
+ }
}
}
// Update timestamp

MODIFY
src/server/rest/service/security/ChargingStationSecurity.ts
src/server/rest/service/security/ChargingStationSecurity.ts
@@ -105,7 +105,8 @@ export default class ChargingStationSecurity {
currentType: connector.currentType,
voltage: connector.voltage,
amperage: connector.amperage,
- user: UserSecurity.filterMinimalUserResponse(connector.user, loggedUser)
+ user: UserSecurity.filterMinimalUserResponse(connector.user, loggedUser),
+ phaseAssignmentToGrid: connector.phaseAssignmentToGrid
};
});
if (chargingStation.chargePoints) {
@@ -388,7 +389,8 @@ export default class ChargingStationSecurity {
voltage: sanitize(connector.voltage),
amperage: sanitize(connector.amperage),
currentType: sanitize(connector.currentType),
- numberOfConnectedPhase: sanitize(connector.numberOfConnectedPhase)
+ numberOfConnectedPhase: sanitize(connector.numberOfConnectedPhase),
+ phaseAssignmentToGrid: sanitize(connector.phaseAssignmentToGrid)
};
}
return null;

MODIFY
src/storage/mongodb/ChargingStationStorage.ts
src/storage/mongodb/ChargingStationStorage.ts
@@ -930,6 +930,7 @@ export default class ChargingStationStorage {
numberOfConnectedPhase: connector.numberOfConnectedPhase,
currentType: connector.currentType,
chargePointID: connector.chargePointID,
+ phaseAssignmentToGrid: connector.phaseAssignmentToGrid,
};
}

MODIFY
src/types/ChargingStation.ts
src/types/ChargingStation.ts
-import { ChargePointStatus, OCPPFirmwareStatus, OCPPProtocol, OCPPVersion } from './ocpp/OCPPServer';
+import { ChargePointStatus, OCPPFirmwareStatus, OCPPPhase, OCPPProtocol, OCPPVersion } from './ocpp/OCPPServer';
import { ChargingRateUnitType } from './ChargingProfile';
import CreatedUpdatedProps from './CreatedUpdatedProps';
@@ -116,6 +116,7 @@ export interface Connector {
numberOfConnectedPhase?: number;
currentType?: CurrentType;
chargePointID?: number;
+ phaseAssignmentToGrid?: PhaseAssignmentToGrid;
}
export interface ConnectorMDB {
@@ -144,6 +145,13 @@ export interface ConnectorMDB {
numberOfConnectedPhase?: number;
currentType?: CurrentType;
chargePointID?: number;
+ phaseAssignmentToGrid?: PhaseAssignmentToGrid;
+}
+
+export interface PhaseAssignmentToGrid {
+ cSPhaseL1: OCPPPhase.L1 | OCPPPhase.L2 | OCPPPhase.L3;
+ cSPhaseL2: OCPPPhase.L1 | OCPPPhase.L2 | OCPPPhase.L3;
+ cSPhaseL3: OCPPPhase.L1 | OCPPPhase.L2 | OCPPPhase.L3;
}
export interface RemoteAuthorization {

MODIFY
src/types/requests/HttpChargingStationRequest.ts
src/types/requests/HttpChargingStationRequest.ts
-import { ConnectorType, CurrentType } from '../ChargingStation';
+import { ConnectorType, CurrentType, phaseAssignmentToGrid } from '../ChargingStation';
import HttpDatabaseRequest from './HttpDatabaseRequest';
@@ -54,6 +54,7 @@ export interface HttpChargingStationParamsUpdateRequest {
voltage: number;
currentType: CurrentType;
numberOfConnectedPhase: number;
+ phaseAssignmentToGrid: phaseAssignmentToGrid;
}[];
}

storage of phase assignment + migration