Warn if UI server is configured to listen on something else than the
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / OCPPServiceUtils.ts
1 export class OCPPServiceUtils {
2 protected constructor() {
3 // This is intentional
4 }
5
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;
16 const numberValue = isNaN(parseInt(value)) ? Infinity : parseInt(value);
17 return options?.limitationEnabled
18 ? Math.min(numberValue * options.unitMultiplier, limit)
19 : numberValue * options.unitMultiplier;
20 }
21 }