Store phases used in transaction
MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -358,6 +358,10 @@ export default class OCPPService {
// Save all
await ConsumptionStorage.saveConsumption(headers.tenantID, consumption);
}
+ if (!transaction.phasesUsed && transaction.currentInstantAmps > 0
+ && transaction.numberOfMeterValues >= 1) {
+ transaction.phasesUsed = Utils.getUsedPhasesInTransactionInProgress(chargingStation, transaction);
+ }
// Handle OCPI
await OCPPUtils.processOCPITransaction(headers.tenantID, transaction, chargingStation, TransactionAction.UPDATE);
// Save Transaction
@@ -366,8 +370,8 @@ export default class OCPPService {
await this.updateChargingStationWithTransaction(headers.tenantID, chargingStation, transaction);
// Save Charging Station
await ChargingStationStorage.saveChargingStation(headers.tenantID, chargingStation);
- // First Meter Value and no Car -> Trigger Smart Charging to adjust the single phase Car
- if (transaction.numberOfMeterValues === 1 && !transaction.carID &&
+ // First Meter Value -> Trigger Smart Charging to adjust the single phase Car
+ if (transaction.numberOfMeterValues === 1 && transaction.phasesUsed &&
!Utils.isTransactionInProgressOnThreePhases(chargingStation, transaction)) {
// Yes: Trigger Smart Charging
await this.triggerSmartCharging(headers.tenantID, chargingStation);

MODIFY
src/storage/mongodb/TransactionStorage.ts
src/storage/mongodb/TransactionStorage.ts
@@ -93,6 +93,7 @@ export default class TransactionStorage {
currentInstantAmpsL2: Utils.convertToInt(transactionToSave.currentInstantAmpsL2),
currentInstantAmpsL3: Utils.convertToInt(transactionToSave.currentInstantAmpsL3),
currentInstantAmpsDC: Utils.convertToInt(transactionToSave.currentInstantAmpsDC),
+ phasesUsed: transactionToSave.phasesUsed,
};
if (transactionToSave.stop) {
// Add stop

MODIFY
src/types/Transaction.ts
src/types/Transaction.ts
@@ -30,6 +30,7 @@ export enum TransactionAction {
export default interface Transaction extends AbstractCurrentConsumption {
id?: number;
carID?: string;
+ phasesUsed?: CSPhasesUsed;
siteID?: string;
siteAreaID?: string;
issuer: boolean;
@@ -77,6 +78,12 @@ export default interface Transaction extends AbstractCurrentConsumption {
};
}
+export interface CSPhasesUsed {
+ CSPhase1: boolean;
+ CSPhase2: boolean;
+ CSPhase3: boolean;
+}
+
export interface TransactionStop {
timestamp: Date;
meterStop: number;

MODIFY
src/utils/Utils.ts
src/utils/Utils.ts
@@ -2,7 +2,7 @@ import { AnalyticsSettingsType, AssetSettingsType, BillingSettingsType, PricingS
import { Car, CarCatalog, CarType } from '../types/Car';
import { ChargePointStatus, OCPPProtocol, OCPPVersion } from '../types/ocpp/OCPPServer';
import ChargingStation, { ChargePoint, Connector, ConnectorCurrentLimitSource, CurrentType, SiteAreaLimitSource } from '../types/ChargingStation';
-import Transaction, { InactivityStatus } from '../types/Transaction';
+import Transaction, { CSPhasesUsed, InactivityStatus } from '../types/Transaction';
import User, { UserRole, UserStatus } from '../types/User';
import { ActionsResponse } from '../types/GlobalType';
@@ -89,17 +89,43 @@ export default class Utils {
return threePhases;
}
+ public static getUsedPhasesInTransactionInProgress(chargingStation: ChargingStation, transaction: Transaction): CSPhasesUsed {
+ const currentType = Utils.getChargingStationCurrentType(chargingStation, null, transaction.connectorId);
+ if (currentType === CurrentType.AC && transaction.currentInstantAmps > 0) {
+ const cSPhasesUsed = {
+ CSPhase1: false,
+ CSPhase2: false,
+ CSPhase3: false } as CSPhasesUsed;
+ if (transaction.currentInstantAmpsL1 > 0) {
+ cSPhasesUsed.CSPhase1 = true;
+ }
+ if (transaction.currentInstantAmpsL2 > 0) {
+ cSPhasesUsed.CSPhase2 = true;
+ }
+ if (transaction.currentInstantAmpsL3 > 0) {
+ cSPhasesUsed.CSPhase3 = true;
+ }
+ return cSPhasesUsed;
+ } else if (currentType === CurrentType.DC) {
+ return {
+ CSPhase1: true,
+ CSPhase2: true,
+ CSPhase3: true };
+ }
+ return null;
+ }
+
public static getNumberOfUsedPhaseInTransactionInProgress(chargingStation: ChargingStation, transaction: Transaction): number {
const currentType = Utils.getChargingStationCurrentType(chargingStation, null, transaction.connectorId);
let nbrOfPhases = 0;
- if (currentType === CurrentType.AC) {
- if (transaction.currentInstantAmpsL1 > 0) {
+ if (currentType === CurrentType.AC && transaction.phasesUsed) {
+ if (transaction.phasesUsed.CSPhase1) {
nbrOfPhases++;
}
- if (transaction.currentInstantAmpsL2 > 0) {
+ if (transaction.phasesUsed.CSPhase2) {
nbrOfPhases++;
}
- if (transaction.currentInstantAmpsL3 > 0) {
+ if (transaction.phasesUsed.CSPhase3) {
nbrOfPhases++;
}
}

Store phases used in transaction