Commit | Line | Data |
---|---|---|
90befdb8 | 1 | export class OCPPServiceUtils { |
d5bd1c00 JB |
2 | protected constructor() { |
3 | // This is intentional | |
4 | } | |
5 | ||
90befdb8 JB |
6 | protected static getLimitFromSampledValueTemplateCustomValue( |
7 | value: string, | |
8 | limit: number, | |
9 | options: { limitationEnabled?: boolean; unitMultiplier?: number } = { | |
10 | limitationEnabled: true, | |
11 | unitMultiplier: 1, | |
12 | } | |
13 | ): number { | |
14 | options.limitationEnabled = options?.limitationEnabled ?? true; | |
15 | options.unitMultiplier = options?.unitMultiplier ?? 1; | |
f126aa15 | 16 | const numberValue = isNaN(parseInt(value)) ? Infinity : parseInt(value); |
90befdb8 | 17 | return options?.limitationEnabled |
f126aa15 JB |
18 | ? Math.min(numberValue * options.unitMultiplier, limit) |
19 | : numberValue * options.unitMultiplier; | |
90befdb8 JB |
20 | } |
21 | } |