From: Jérôme Benoit Date: Mon, 13 Nov 2023 08:20:31 +0000 (+0100) Subject: fix: do not test for connector status in ATG X-Git-Tag: v1.2.24~4 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=77684af8bb6c39f9c1e2eb8e0f9ac8c0f1dd7855;p=e-mobility-charging-stations-simulator.git fix: do not test for connector status in ATG Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index 3d1e8b1c..efc3769a 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -12,7 +12,6 @@ import { BaseError } from '../exception'; import { PerformanceStatistics } from '../performance'; import { AuthorizationStatus, - ConnectorStatusEnum, RequestCommand, type StartTransactionRequest, type StartTransactionResponse, @@ -305,17 +304,6 @@ export class AutomaticTransactionGenerator extends AsyncResource { ); return false; } - if ( - this.chargingStation.getConnectorStatus(connectorId)?.status === - ConnectorStatusEnum.Unavailable - ) { - logger.info( - `${this.logPrefix( - connectorId, - )} entered in transaction loop while the connector ${connectorId} status is unavailable`, - ); - return false; - } return true; } diff --git a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts index 0086877c..63339cf2 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts @@ -740,7 +740,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { (connectorMaximumAvailablePower * interval) / (3600 * 1000), 2, ); - const energyValueRounded = energySampledValueTemplate.value + const energyValueRounded = isNotEmptyString(energySampledValueTemplate.value) ? // Cumulate the fluctuated value around the static one getRandomFloatFluctuatedRounded( OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue( diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index 7da384d3..3a1423c4 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -419,20 +419,22 @@ export class OCPPServiceUtils { protected static getLimitFromSampledValueTemplateCustomValue( value: string, limit: number, - options?: { limitationEnabled?: boolean; unitMultiplier?: number }, + options?: { limitationEnabled?: boolean; unitMultiplier?: number; defaultValue?: number }, ): number { options = { ...{ limitationEnabled: true, unitMultiplier: 1, + defaultValue: 0, }, ...options, }; - const parsedInt = parseInt(value); - const numberValue = isNaN(parsedInt) ? Infinity : parsedInt; - return options?.limitationEnabled - ? min(numberValue * options.unitMultiplier!, limit) - : numberValue * options.unitMultiplier!; + const parsedValue = parseInt(value); + if (options?.limitationEnabled) { + const numberValue = !isNaN(parsedValue) ? parsedValue : Infinity; + return min(numberValue * options.unitMultiplier!, limit); + } + return (!isNaN(parsedValue) ? parsedValue : options.defaultValue!) * options.unitMultiplier!; } private static isIdTagLocalAuthorized(chargingStation: ChargingStation, idTag: string): boolean {