X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStation.ts;h=feffa05da837ce929da0dce630a6a9f5601f2c87;hb=c56d42f1989acd8c336fb165d5e295245adb37fa;hp=ac704ea8097dcbf245d7d6f1c358a11275445dad;hpb=510f0fa5461cada6ca7c0e2aea525674fb00f079;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index ac704ea8..feffa05d 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1,6 +1,7 @@ import { BootNotificationResponse, RegistrationStatus } from '../types/ocpp/Responses'; import ChargingStationConfiguration, { ConfigurationKey } from '../types/ChargingStationConfiguration'; import ChargingStationTemplate, { CurrentOutType, PowerUnits, VoltageOut } from '../types/ChargingStationTemplate'; +import { ConnectorPhaseRotation, StandardParametersKey, SupportedFeatureProfiles } from '../types/ocpp/Configuration'; import Connectors, { Connector } from '../types/Connectors'; import { PerformanceObserver, performance } from 'perf_hooks'; import Requests, { AvailabilityType, BootNotificationRequest, IncomingRequest, IncomingRequestCommand } from '../types/ocpp/Requests'; @@ -23,7 +24,6 @@ import OCPPIncomingRequestService from './ocpp/OCPPIncomingRequestService'; import OCPPRequestService from './ocpp/OCPPRequestService'; import { OCPPVersion } from '../types/ocpp/OCPPVersion'; import PerformanceStatistics from '../utils/PerformanceStatistics'; -import { StandardParametersKey } from '../types/ocpp/Configuration'; import { StopTransactionReason } from '../types/ocpp/Transaction'; import Utils from '../utils/Utils'; import { WebSocketCloseEventStatusCode } from '../types/WebSocket'; @@ -161,6 +161,10 @@ export default class ChargingStation { return this.stationInfo.meteringPerTransaction ?? true; } + public getTransactionDataMeterValues(): boolean { + return this.stationInfo.transactionDataMeterValues ?? false; + } + public getEnergyActiveImportRegisterByTransactionId(transactionId: number): number | undefined { if (this.getMeteringPerTransaction()) { for (const connector in this.connectors) { @@ -349,6 +353,7 @@ export default class ChargingStation { delete this.getConnector(connectorId).transactionId; delete this.getConnector(connectorId).idTag; this.getConnector(connectorId).transactionEnergyActiveImportRegisterValue = 0; + delete this.getConnector(connectorId).transactionBeginMeterValue; this.stopMeterValues(connectorId); } @@ -405,9 +410,11 @@ export default class ChargingStation { } else { stationTemplateFromFile.power = stationTemplateFromFile.power as number; stationInfo.maxPower = stationTemplateFromFile.powerUnit === PowerUnits.KILO_WATT - ? (stationTemplateFromFile.power) * 1000 + ? stationTemplateFromFile.power * 1000 : stationTemplateFromFile.power; } + delete stationInfo.power; + delete stationInfo.powerUnit; stationInfo.chargingStationId = this.getChargingStationId(stationTemplateFromFile); stationInfo.resetTime = stationTemplateFromFile.resetTime ? stationTemplateFromFile.resetTime * 1000 : Constants.CHARGING_STATION_DEFAULT_RESET_TIME; return stationInfo; @@ -500,6 +507,26 @@ export default class ChargingStation { if (!this.getConfigurationKey(StandardParametersKey.MeterValuesSampledData)) { this.addConfigurationKey(StandardParametersKey.MeterValuesSampledData, MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER); } + if (!this.getConfigurationKey(StandardParametersKey.SupportedFeatureProfiles)) { + this.addConfigurationKey(StandardParametersKey.SupportedFeatureProfiles, SupportedFeatureProfiles.Core); + } + if (!this.getConfigurationKey(StandardParametersKey.ConnectorPhaseRotation)) { + const connectorPhaseRotation = []; + for (const connector in this.connectors) { + // AC/DC + if (Utils.convertToInt(connector) === 0 && this.getNumberOfPhases() === 0) { + connectorPhaseRotation.push(`${connector}.${ConnectorPhaseRotation.RST}`); + } else if (Utils.convertToInt(connector) > 0 && this.getNumberOfPhases() === 0) { + connectorPhaseRotation.push(`${connector}.${ConnectorPhaseRotation.NotApplicable}`); + // AC + } else if (Utils.convertToInt(connector) > 0 && this.getNumberOfPhases() === 1) { + connectorPhaseRotation.push(`${connector}.${ConnectorPhaseRotation.NotApplicable}`); + } else if (Utils.convertToInt(connector) > 0 && this.getNumberOfPhases() === 3) { + connectorPhaseRotation.push(`${connector}.${ConnectorPhaseRotation.RST}`); + } + } + this.addConfigurationKey(StandardParametersKey.ConnectorPhaseRotation, connectorPhaseRotation.toString()); + } this.stationInfo.powerDivider = this.getPowerDivider(); if (this.getEnableStatistics()) { this.performanceStatistics = new PerformanceStatistics(this.stationInfo.chargingStationId); @@ -561,7 +588,6 @@ export default class ChargingStation { try { // Parse the message [messageType, messageId, commandName, commandPayload, errorDetails] = JSON.parse(messageEvent.toString()) as IncomingRequest; - // Check the Type of message switch (messageType) { // Incoming Message @@ -883,7 +909,7 @@ export default class ChargingStation { const authorizationFile = this.getAuthorizationFile(); if (authorizationFile) { try { - fs.watch(authorizationFile).on('change', (e) => { + fs.watch(authorizationFile).on('change', () => { try { logger.debug(this.logPrefix() + ' Authorization file ' + authorizationFile + ' have changed, reload'); // Initialize authorizedTags @@ -902,8 +928,8 @@ export default class ChargingStation { private startStationTemplateFileMonitoring(): void { try { - // eslint-disable-next-line @typescript-eslint/no-misused-promises - fs.watch(this.stationTemplateFile).on('change', async (e): Promise => { + // eslint-disable-next-line @typescript-eslint/no-misused-promises + fs.watch(this.stationTemplateFile).on('change', async (): Promise => { try { logger.debug(this.logPrefix() + ' Template file ' + this.stationTemplateFile + ' have changed, reload'); // Initialize