Backport of a front end fix
MODIFY
src/utils/Utils.ts
src/utils/Utils.ts
-import { AnalyticsSettingsType, AssetSettingsType, BillingSettingsType, PricingSettingsType, RefundSettingsType, RoamingSettingsType, SettingDBContent, SmartChargingContentType } from '../types/Setting';
-import { ChargePointStatus, OCPPProtocol, OCPPVersion } from '../types/ocpp/OCPPServer';
-import ChargingStation, { ChargePoint, Connector, ConnectorCurrentLimitSource, CurrentType, StaticLimitAmps } from '../types/ChargingStation';
-import User, { UserRole, UserStatus } from '../types/User';
+import crypto from 'crypto';
+import fs from 'fs';
+import path from 'path';
+import url from 'url';
+
+import bcrypt from 'bcryptjs';
+import { Request } from 'express';
+import _ from 'lodash';
+import moment from 'moment';
+import { ObjectID } from 'mongodb';
+import passwordGenerator from 'password-generator';
+import localIP from 'quick-local-ip';
+import tzlookup from 'tz-lookup';
+import { v4 as uuid } from 'uuid';
+import validator from 'validator';
-import { ActionsResponse } from '../types/GlobalType';
-import AppError from '../exception/AppError';
-import Asset from '../types/Asset';
import Authorizations from '../authorization/Authorizations';
+import AppError from '../exception/AppError';
import BackendError from '../exception/BackendError';
+import TenantStorage from '../storage/mongodb/TenantStorage';
+import UserStorage from '../storage/mongodb/UserStorage';
+import Asset from '../types/Asset';
import { Car } from '../types/Car';
import { ChargingProfile } from '../types/ChargingProfile';
+import ChargingStation, { ChargePoint, Connector, ConnectorCurrentLimitSource, CurrentType, StaticLimitAmps } from '../types/ChargingStation';
import Company from '../types/Company';
-import Configuration from './Configuration';
import ConnectorStats from '../types/ConnectorStats';
-import Constants from './Constants';
-import Cypher from './Cypher';
+import { ActionsResponse } from '../types/GlobalType';
import { HTTPError } from '../types/HTTPError';
-import { InactivityStatus } from '../types/Transaction';
-import Logging from './Logging';
import OCPIEndpoint from '../types/ocpi/OCPIEndpoint';
-import { ObjectID } from 'mongodb';
-import { Request } from 'express';
+import { ChargePointStatus, OCPPProtocol, OCPPVersion } from '../types/ocpp/OCPPServer';
import { ServerAction } from '../types/Server';
+import { AnalyticsSettingsType, AssetSettingsType, BillingSettingsType, PricingSettingsType, RefundSettingsType, RoamingSettingsType, SettingDBContent, SmartChargingContentType } from '../types/Setting';
import Site from '../types/Site';
import SiteArea from '../types/SiteArea';
import Tag from '../types/Tag';
import Tenant from '../types/Tenant';
import TenantComponents from '../types/TenantComponents';
-import TenantStorage from '../storage/mongodb/TenantStorage';
-import UserStorage from '../storage/mongodb/UserStorage';
+import { InactivityStatus } from '../types/Transaction';
+import User, { UserRole, UserStatus } from '../types/User';
import UserToken from '../types/UserToken';
-import _ from 'lodash';
-import bcrypt from 'bcryptjs';
-import crypto from 'crypto';
-import fs from 'fs';
-import localIP from 'quick-local-ip';
-import moment from 'moment';
-import passwordGenerator from 'password-generator';
-import path from 'path';
-import tzlookup from 'tz-lookup';
-import url from 'url';
-import { v4 as uuid } from 'uuid';
-import validator from 'validator';
+import Configuration from './Configuration';
+import Constants from './Constants';
+import Cypher from './Cypher';
+import Logging from './Logging';
const _centralSystemFrontEndConfig = Configuration.getCentralSystemFrontEndConfig();
const _tenants = [];
@@ -559,6 +560,7 @@ export default class Utils {
return totalAmps;
}
+ // Tslint:disable-next-line: cyclomatic-complexity
public static getChargingStationPower(chargingStation: ChargingStation, chargePoint: ChargePoint, connectorId = 0): number {
let totalPower = 0;
if (chargingStation) {
@@ -570,8 +572,8 @@ export default class Utils {
if (connectorId === 0 && chargePointOfCS.power) {
totalPower += chargePointOfCS.power;
// Connector
- } else if (chargePointOfCS.connectorIDs.includes(connectorId) && chargePointOfCS.power &&
- (chargePointOfCS.cannotChargeInParallel || chargePointOfCS.sharePowerToAllConnectors)) {
+ } else if (chargePointOfCS.connectorIDs.includes(connectorId) && chargePointOfCS.power) {
+ if (chargePointOfCS.cannotChargeInParallel || chargePointOfCS.sharePowerToAllConnectors) {
// Check Connector ID
const connector = Utils.getConnectorFromID(chargingStation, connectorId);
if (connector.power) {
@@ -579,6 +581,9 @@ export default class Utils {
}
return chargePointOfCS.power;
}
+ // Power is shared evenly on connectors
+ return chargePointOfCS.power / chargePointOfCS.connectorIDs.length;
+ }
}
}
}
@@ -721,6 +726,7 @@ export default class Utils {
return null;
}
+ // Tslint:disable-next-line: cyclomatic-complexity
public static getChargingStationAmperage(chargingStation: ChargingStation, chargePoint?: ChargePoint, connectorId = 0): number {
let totalAmps = 0;
if (chargingStation) {
@@ -731,16 +737,19 @@ export default class Utils {
// Charging Station
if (connectorId === 0 && chargePointOfCS.amperage) {
totalAmps += chargePointOfCS.amperage;
- // Connector
- } else if (chargePointOfCS.connectorIDs.includes(connectorId) && chargePointOfCS.amperage &&
- (chargePointOfCS.cannotChargeInParallel || chargePointOfCS.sharePowerToAllConnectors)) {
- // Check Connector ID
+ } else if (chargePointOfCS.connectorIDs.includes(connectorId) && chargePointOfCS.amperage) {
+ if (chargePointOfCS.cannotChargeInParallel || chargePointOfCS.sharePowerToAllConnectors) {
+ // Same power for all connectors
+ // Check Connector ID first
const connector = Utils.getConnectorFromID(chargingStation, connectorId);
if (connector.amperage) {
return connector.amperage;
}
return chargePointOfCS.amperage;
}
+ // Power is split evenly per connector
+ return chargePointOfCS.amperage / chargePointOfCS.connectorIDs.length;
+ }
}
}
}

Backport of a front end fix