From: Jérôme Benoit Date: Sun, 8 May 2022 20:49:46 +0000 (+0200) Subject: Add missing src/charging-station/ocpp/OCPPServiceUtils.ts file X-Git-Tag: v1.1.59~2^2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=90befdb882c3c0d68878dad7985612c01ed19d8d;p=e-mobility-charging-stations-simulator.git Add missing src/charging-station/ocpp/OCPPServiceUtils.ts file Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts new file mode 100644 index 00000000..9d7cf620 --- /dev/null +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -0,0 +1,16 @@ +export class OCPPServiceUtils { + protected static getLimitFromSampledValueTemplateCustomValue( + value: string, + limit: number, + options: { limitationEnabled?: boolean; unitMultiplier?: number } = { + limitationEnabled: true, + unitMultiplier: 1, + } + ): number { + options.limitationEnabled = options?.limitationEnabled ?? true; + options.unitMultiplier = options?.unitMultiplier ?? 1; + return options?.limitationEnabled + ? Math.min(parseInt(value) * options.unitMultiplier, limit) + : parseInt(value) * options.unitMultiplier; + } +}