From 7decf1b6ce8390d7f379c7d935134724b3baff4e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 6 May 2021 20:21:18 +0200 Subject: [PATCH] README.md: add more documentation for cs template MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- README.md | 12 +++++++++++ .../abb-atg.station-template.json | 2 +- .../abb.station-template.json | 2 +- .../virtual-simple-atg.station-template.json | 2 +- .../virtual-simple.station-template.json | 2 +- .../virtual.station-template.json | 2 +- src/charging-station/ChargingStation.ts | 20 +++++++++---------- .../ocpp/1.6/OCPP16RequestService.ts | 18 ++++++++--------- src/types/ChargingStationTemplate.ts | 4 ++-- 9 files changed, 38 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 0813c836..e63f32f6 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,18 @@ firmwareVersion | | '' | string | charging stations firmware version power | | | integer\|integer[] | charging stations maximum power value(s) powerSharedByConnectors | true/false | false | boolean | charging stations power shared by its connectors powerUnit | W/kW | W | string | charging stations power unit +currentOutType | AC/DC | AC | string | charging stations current out type +numberOfPhases | 1/3 | AC:3/DC:0 | integer | charging stations number of phase(s) +numberOfConnectors | | | integer\|integer[] | charging stations number of connector(s) +useConnectorId0 | true/false | true | boolean | use connector id 0 definition from the template +randomConnectors | true/false | false | boolean | randomize the connector id +resetTime | | 60 | integer | seconds to wait before the charging stations come back at reset +connectionTimeout | | 30 | integer | connection timeout to the OCPP-J server +autoReconnectMaxRetries | | -1 (unlimited) | integer | connection retries to the OCPP-J server +reconnectExponentialDelay | true/false | false | boolean | connection delay retry to the OCPP-J server +registrationMaxRetries | | -1 (unlimited) | boolean | charging stations boot notification retries +enableStatistics | true/false | true | boolean | enable charging stations statistics +voltageOut | | AC:230/DC:400 | number | charging stations voltage out ## License diff --git a/src/assets/station-templates/abb-atg.station-template.json b/src/assets/station-templates/abb-atg.station-template.json index 316f8b3e..b11a543f 100644 --- a/src/assets/station-templates/abb-atg.station-template.json +++ b/src/assets/station-templates/abb-atg.station-template.json @@ -8,7 +8,7 @@ "power": 50000, "powerSharedByConnectors": true, "powerUnit": "W", - "powerOutType": "DC", + "currentOutType": "DC", "useConnectorId0": true, "randomConnectors": false, "resetTime": 60, diff --git a/src/assets/station-templates/abb.station-template.json b/src/assets/station-templates/abb.station-template.json index 3f743f96..0ba61ec6 100644 --- a/src/assets/station-templates/abb.station-template.json +++ b/src/assets/station-templates/abb.station-template.json @@ -7,7 +7,7 @@ "power": 50000, "powerSharedByConnectors": true, "powerUnit": "W", - "powerOutType": "DC", + "currentOutType": "DC", "numberOfConnectors": 2, "useConnectorId0": true, "randomConnectors": false, diff --git a/src/assets/station-templates/virtual-simple-atg.station-template.json b/src/assets/station-templates/virtual-simple-atg.station-template.json index 0da43ac6..a695e2bd 100644 --- a/src/assets/station-templates/virtual-simple-atg.station-template.json +++ b/src/assets/station-templates/virtual-simple-atg.station-template.json @@ -6,7 +6,7 @@ "power": 75000, "powerUnit": "W", "powerSharedByConnectors": true, - "powerOutType": "DC", + "currentOutType": "DC", "numberOfConnectors": 3, "randomConnectors": false, "Configuration": { diff --git a/src/assets/station-templates/virtual-simple.station-template.json b/src/assets/station-templates/virtual-simple.station-template.json index f251d2c4..4af1ab1d 100644 --- a/src/assets/station-templates/virtual-simple.station-template.json +++ b/src/assets/station-templates/virtual-simple.station-template.json @@ -6,7 +6,7 @@ "power": 50000, "powerUnit": "W", "powerSharedByConnectors": true, - "powerOutType": "DC", + "currentOutType": "DC", "numberOfConnectors": 3, "randomConnectors": false, "Configuration": { diff --git a/src/assets/station-templates/virtual.station-template.json b/src/assets/station-templates/virtual.station-template.json index 8cb63eb6..0a713610 100644 --- a/src/assets/station-templates/virtual.station-template.json +++ b/src/assets/station-templates/virtual.station-template.json @@ -6,7 +6,7 @@ "power": 50000, "powerUnit": "W", "powerSharedByConnectors": true, - "powerOutType": "DC", + "currentOutType": "DC", "numberOfConnectors": 9, "randomConnectors": false, "Configuration": { diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index a5e31588..d1745f75 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1,6 +1,6 @@ import { BootNotificationResponse, RegistrationStatus } from '../types/ocpp/Responses'; import ChargingStationConfiguration, { ConfigurationKey } from '../types/ChargingStationConfiguration'; -import ChargingStationTemplate, { PowerOutType, VoltageOut } from '../types/ChargingStationTemplate'; +import ChargingStationTemplate, { CurrentOutType, VoltageOut } from '../types/ChargingStationTemplate'; import Connectors, { Connector } from '../types/Connectors'; import { PerformanceObserver, performance } from 'perf_hooks'; import Requests, { AvailabilityType, BootNotificationRequest, IncomingRequest, IncomingRequestCommand } from '../types/ocpp/Requests'; @@ -91,10 +91,10 @@ export default class ChargingStation { } public getNumberOfPhases(): number { - switch (this.getPowerOutType()) { - case PowerOutType.AC: + switch (this.getCurrentOutType()) { + case CurrentOutType.AC: return !Utils.isUndefined(this.stationInfo.numberOfPhases) ? this.stationInfo.numberOfPhases : 3; - case PowerOutType.DC: + case CurrentOutType.DC: return 0; } } @@ -119,18 +119,18 @@ export default class ChargingStation { return this.connectors[id]; } - public getPowerOutType(): PowerOutType { - return !Utils.isUndefined(this.stationInfo.powerOutType) ? this.stationInfo.powerOutType : PowerOutType.AC; + public getCurrentOutType(): CurrentOutType { + return !Utils.isUndefined(this.stationInfo.currentOutType) ? this.stationInfo.currentOutType : CurrentOutType.AC; } public getVoltageOut(): number { - const errMsg = `${this.logPrefix()} Unknown ${this.getPowerOutType()} powerOutType in template file ${this.stationTemplateFile}, cannot define default voltage out`; + const errMsg = `${this.logPrefix()} Unknown ${this.getCurrentOutType()} currentOutType in template file ${this.stationTemplateFile}, cannot define default voltage out`; let defaultVoltageOut: number; - switch (this.getPowerOutType()) { - case PowerOutType.AC: + switch (this.getCurrentOutType()) { + case CurrentOutType.AC: defaultVoltageOut = VoltageOut.VOLTAGE_230; break; - case PowerOutType.DC: + case CurrentOutType.DC: defaultVoltageOut = VoltageOut.VOLTAGE_400; break; default: diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index 96502b3c..fe9d27f0 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -4,6 +4,7 @@ import { MeterValue, MeterValueLocation, MeterValuePhase, MeterValueUnit, MeterV import { ACElectricUtils } from '../../../utils/ElectricUtils'; import Constants from '../../../utils/Constants'; +import { CurrentOutType } from '../../../types/ChargingStationTemplate'; import MeasurandValues from '../../../types/MeasurandValues'; import { MessageType } from '../../../types/ocpp/MessageType'; import { OCPP16BootNotificationResponse } from '../../../types/ocpp/1.6/Responses'; @@ -12,7 +13,6 @@ import { OCPP16ChargePointStatus } from '../../../types/ocpp/1.6/ChargePointStat import { OCPP16StandardParametersKey } from '../../../types/ocpp/1.6/Configuration'; import OCPPError from '../../OcppError'; import OCPPRequestService from '../OCPPRequestService'; -import { PowerOutType } from '../../../types/ChargingStationTemplate'; import Utils from '../../../utils/Utils'; import logger from '../../../utils/Logger'; @@ -161,12 +161,12 @@ export default class OCPP16RequestService extends OCPPRequestService { logger.error(errMsg); throw Error(errMsg); } - const errMsg = `${self.chargingStation.logPrefix()} MeterValues measurand ${meterValuesTemplate[index].measurand ? meterValuesTemplate[index].measurand : OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER}: Unknown ${self.chargingStation.getPowerOutType()} powerOutType in template file ${self.chargingStation.stationTemplateFile}, cannot calculate ${meterValuesTemplate[index].measurand ? meterValuesTemplate[index].measurand : OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER} measurand value`; + const errMsg = `${self.chargingStation.logPrefix()} MeterValues measurand ${meterValuesTemplate[index].measurand ? meterValuesTemplate[index].measurand : OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER}: Unknown ${self.chargingStation.getCurrentOutType()} currentOutType in template file ${self.chargingStation.stationTemplateFile}, cannot calculate ${meterValuesTemplate[index].measurand ? meterValuesTemplate[index].measurand : OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER} measurand value`; const powerMeasurandValues = {} as MeasurandValues; const maxPower = Math.round(self.chargingStation.stationInfo.maxPower / self.chargingStation.stationInfo.powerDivider); const maxPowerPerPhase = Math.round((self.chargingStation.stationInfo.maxPower / self.chargingStation.stationInfo.powerDivider) / self.chargingStation.getNumberOfPhases()); - switch (self.chargingStation.getPowerOutType()) { - case PowerOutType.AC: + switch (self.chargingStation.getCurrentOutType()) { + case CurrentOutType.AC: if (Utils.isUndefined(meterValuesTemplate[index].value)) { powerMeasurandValues.L1 = Utils.getRandomFloatRounded(maxPowerPerPhase); powerMeasurandValues.L2 = 0; @@ -178,7 +178,7 @@ export default class OCPP16RequestService extends OCPPRequestService { powerMeasurandValues.allPhases = Utils.roundTo(powerMeasurandValues.L1 + powerMeasurandValues.L2 + powerMeasurandValues.L3, 2); } break; - case PowerOutType.DC: + case CurrentOutType.DC: if (Utils.isUndefined(meterValuesTemplate[index].value)) { powerMeasurandValues.allPhases = Utils.getRandomFloatRounded(maxPower); } @@ -221,11 +221,11 @@ export default class OCPP16RequestService extends OCPPRequestService { logger.error(errMsg); throw Error(errMsg); } - const errMsg = `${self.chargingStation.logPrefix()} MeterValues measurand ${meterValuesTemplate[index].measurand ? meterValuesTemplate[index].measurand : OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER}: Unknown ${self.chargingStation.getPowerOutType()} powerOutType in template file ${self.chargingStation.stationTemplateFile}, cannot calculate ${meterValuesTemplate[index].measurand ? meterValuesTemplate[index].measurand : OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER} measurand value`; + const errMsg = `${self.chargingStation.logPrefix()} MeterValues measurand ${meterValuesTemplate[index].measurand ? meterValuesTemplate[index].measurand : OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER}: Unknown ${self.chargingStation.getCurrentOutType()} currentOutType in template file ${self.chargingStation.stationTemplateFile}, cannot calculate ${meterValuesTemplate[index].measurand ? meterValuesTemplate[index].measurand : OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER} measurand value`; const currentMeasurandValues: MeasurandValues = {} as MeasurandValues; let maxAmperage: number; - switch (self.chargingStation.getPowerOutType()) { - case PowerOutType.AC: + switch (self.chargingStation.getCurrentOutType()) { + case CurrentOutType.AC: maxAmperage = ACElectricUtils.amperagePerPhaseFromPower(self.chargingStation.getNumberOfPhases(), self.chargingStation.stationInfo.maxPower / self.chargingStation.stationInfo.powerDivider, self.chargingStation.getVoltageOut()); if (Utils.isUndefined(meterValuesTemplate[index].value)) { currentMeasurandValues.L1 = Utils.getRandomFloatRounded(maxAmperage); @@ -238,7 +238,7 @@ export default class OCPP16RequestService extends OCPPRequestService { currentMeasurandValues.allPhases = Utils.roundTo((currentMeasurandValues.L1 + currentMeasurandValues.L2 + currentMeasurandValues.L3) / self.chargingStation.getNumberOfPhases(), 2); } break; - case PowerOutType.DC: + case CurrentOutType.DC: maxAmperage = ACElectricUtils.amperageTotalFromPower(self.chargingStation.stationInfo.maxPower / self.chargingStation.stationInfo.powerDivider, self.chargingStation.getVoltageOut()); if (Utils.isUndefined(meterValuesTemplate[index].value)) { currentMeasurandValues.allPhases = Utils.getRandomFloatRounded(maxAmperage); diff --git a/src/types/ChargingStationTemplate.ts b/src/types/ChargingStationTemplate.ts index a11f6aa0..44aea77f 100644 --- a/src/types/ChargingStationTemplate.ts +++ b/src/types/ChargingStationTemplate.ts @@ -3,7 +3,7 @@ import Connectors from './Connectors'; import { OCPPProtocol } from './ocpp/OCPPProtocol'; import { OCPPVersion } from './ocpp/OCPPVersion'; -export enum PowerOutType { +export enum CurrentOutType { AC = 'AC', DC = 'DC', } @@ -46,7 +46,7 @@ export default interface ChargingStationTemplate { power: number | number[]; powerSharedByConnectors?: boolean; powerUnit: PowerUnits; - powerOutType?: PowerOutType; + currentOutType?: CurrentOutType; numberOfPhases?: number; numberOfConnectors?: number | number[]; useConnectorId0?: boolean; -- 2.34.1