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; | |
f126aa15 | 12 | const numberValue = isNaN(parseInt(value)) ? Infinity : parseInt(value); |
90befdb8 | 13 | return options?.limitationEnabled |
f126aa15 JB |
14 | ? Math.min(numberValue * options.unitMultiplier, limit) |
15 | : numberValue * options.unitMultiplier; | |
90befdb8 JB |
16 | } |
17 | } |