import { PerformanceStatistics } from '../performance';
import {
AuthorizationStatus,
- ConnectorStatusEnum,
RequestCommand,
type StartTransactionRequest,
type StartTransactionResponse,
);
return false;
}
- if (
- this.chargingStation.getConnectorStatus(connectorId)?.status ===
- ConnectorStatusEnum.Unavailable
- ) {
- logger.info(
- `${this.logPrefix(
- connectorId,
- )} entered in transaction loop while the connector ${connectorId} status is unavailable`,
- );
- return false;
- }
return true;
}
(connectorMaximumAvailablePower * interval) / (3600 * 1000),
2,
);
- const energyValueRounded = energySampledValueTemplate.value
+ const energyValueRounded = isNotEmptyString(energySampledValueTemplate.value)
? // Cumulate the fluctuated value around the static one
getRandomFloatFluctuatedRounded(
OCPP16ServiceUtils.getLimitFromSampledValueTemplateCustomValue(
protected static getLimitFromSampledValueTemplateCustomValue(
value: string,
limit: number,
- options?: { limitationEnabled?: boolean; unitMultiplier?: number },
+ options?: { limitationEnabled?: boolean; unitMultiplier?: number; defaultValue?: number },
): number {
options = {
...{
limitationEnabled: true,
unitMultiplier: 1,
+ defaultValue: 0,
},
...options,
};
- const parsedInt = parseInt(value);
- const numberValue = isNaN(parsedInt) ? Infinity : parsedInt;
- return options?.limitationEnabled
- ? min(numberValue * options.unitMultiplier!, limit)
- : numberValue * options.unitMultiplier!;
+ const parsedValue = parseInt(value);
+ if (options?.limitationEnabled) {
+ const numberValue = !isNaN(parsedValue) ? parsedValue : Infinity;
+ return min(numberValue * options.unitMultiplier!, limit);
+ }
+ return (!isNaN(parsedValue) ? parsedValue : options.defaultValue!) * options.unitMultiplier!;
}
private static isIdTagLocalAuthorized(chargingStation: ChargingStation, idTag: string): boolean {