Implemented check on Phases
MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -356,7 +356,7 @@ export default class OCPPService {
// Save all
await ConsumptionStorage.saveConsumption(headers.tenantID, consumption);
}
- if (!transaction.phasesUsed && transaction.currentInstantAmps > 0 &&
+ if (!transaction.phasesUsed && Utils.checkIfPhasesProvidedInTransactionInProgress(transaction) &&
transaction.numberOfMeterValues >= 1) {
transaction.phasesUsed = Utils.getUsedPhasesInTransactionInProgress(chargingStation, transaction);
}

MODIFY
src/storage/mongodb/TransactionStorage.ts
src/storage/mongodb/TransactionStorage.ts
@@ -93,8 +93,14 @@ export default class TransactionStorage {
currentInstantAmpsL2: Utils.convertToInt(transactionToSave.currentInstantAmpsL2),
currentInstantAmpsL3: Utils.convertToInt(transactionToSave.currentInstantAmpsL3),
currentInstantAmpsDC: Utils.convertToInt(transactionToSave.currentInstantAmpsDC),
- phasesUsed: transactionToSave.phasesUsed,
};
+ if (transactionToSave.phasesUsed) {
+ transactionMDB.phasesUsed = {
+ csPhase1: Utils.convertToBoolean(transactionToSave.phasesUsed.csPhase1),
+ csPhase2: Utils.convertToBoolean(transactionToSave.phasesUsed.csPhase2),
+ csPhase3: Utils.convertToBoolean(transactionToSave.phasesUsed.csPhase3),
+ };
+ }
if (transactionToSave.stop) {
// Add stop
transactionMDB.stop = {

MODIFY
src/utils/Utils.ts
src/utils/Utils.ts
@@ -92,7 +92,7 @@ export default class Utils {
public static getUsedPhasesInTransactionInProgress(chargingStation: ChargingStation, transaction: Transaction): CSPhasesUsed {
const currentType = Utils.getChargingStationCurrentType(chargingStation, null, transaction.connectorId);
// AC Chargers
- if (currentType === CurrentType.AC && transaction.currentInstantAmps > 0) {
+ if (currentType === CurrentType.AC && Utils.checkIfPhasesProvidedInTransactionInProgress(transaction)) {
const cSPhasesUsed: CSPhasesUsed = {
csPhase1: false,
csPhase2: false,
@@ -109,15 +109,21 @@ export default class Utils {
cSPhasesUsed.csPhase3 = true;
}
return cSPhasesUsed;
- // DC Chargers
- } else if (currentType === CurrentType.DC) {
+ // Standard on three phases
+ }
return {
csPhase1: true,
csPhase2: true,
- csPhase3: true
- };
+ csPhase3: true };
}
- return null;
+
+ public static checkIfPhasesProvidedInTransactionInProgress(transaction: Transaction): boolean {
+ if (transaction.currentInstantAmps) {
+ if (transaction.currentInstantAmpsL1 > 0 || transaction.currentInstantAmpsL2 > 0 || transaction.currentInstantAmpsL3 > 0) {
+ return true;
+ }
+ }
+ return false;
}
public static getNumberOfUsedPhaseInTransactionInProgress(chargingStation: ChargingStation, transaction: Transaction): number {

Implemented check on Phases