Commit | Line | Data |
---|---|---|
90befdb8 JB |
1 | export class OCPPServiceUtils { |
2 | protected static getLimitFromSampledValueTemplateCustomValue( | |
3 | value: string, | |
4 | limit: number, | |
5 | options: { limitationEnabled?: boolean; unitMultiplier?: number } = { | |
6 | limitationEnabled: true, | |
7 | unitMultiplier: 1, | |
8 | } | |
9 | ): number { | |
10 | options.limitationEnabled = options?.limitationEnabled ?? true; | |
11 | options.unitMultiplier = options?.unitMultiplier ?? 1; | |
12 | return options?.limitationEnabled | |
13 | ? Math.min(parseInt(value) * options.unitMultiplier, limit) | |
14 | : parseInt(value) * options.unitMultiplier; | |
15 | } | |
16 | } |