upperCase: params.randomSerialNumberUpperCase,
})
: '';
- stationInfo.chargePointSerialNumber =
- Utils.isNotEmptyString(stationTemplate?.chargePointSerialNumberPrefix) &&
- `${stationTemplate.chargePointSerialNumberPrefix}${serialNumberSuffix}`;
- stationInfo.chargeBoxSerialNumber =
- Utils.isNotEmptyString(stationTemplate?.chargeBoxSerialNumberPrefix) &&
- `${stationTemplate.chargeBoxSerialNumberPrefix}${serialNumberSuffix}`;
- stationInfo.meterSerialNumber =
- Utils.isNotEmptyString(stationTemplate?.meterSerialNumberPrefix) &&
- `${stationTemplate.meterSerialNumberPrefix}${serialNumberSuffix}`;
+ stationInfo.chargePointSerialNumber = Utils.isNotEmptyString(
+ stationTemplate?.chargePointSerialNumberPrefix
+ )
+ ? `${stationTemplate.chargePointSerialNumberPrefix}${serialNumberSuffix}`
+ : undefined;
+ stationInfo.chargeBoxSerialNumber = Utils.isNotEmptyString(
+ stationTemplate?.chargeBoxSerialNumberPrefix
+ )
+ ? `${stationTemplate.chargeBoxSerialNumberPrefix}${serialNumberSuffix}`
+ : undefined;
+ stationInfo.meterSerialNumber = Utils.isNotEmptyString(stationTemplate?.meterSerialNumberPrefix)
+ ? `${stationTemplate.meterSerialNumberPrefix}${serialNumberSuffix}`
+ : undefined;
}
public static propagateSerialNumber(
): GetConfigurationResponse {
const configurationKey: OCPPConfigurationKey[] = [];
const unknownKey: string[] = [];
- if (Utils.isEmptyArray(commandPayload.key) === true) {
+ if (Utils.isUndefined(commandPayload.key) === true) {
for (const configuration of chargingStation.ocppConfiguration.configurationKey) {
if (Utils.isUndefined(configuration.visible) === true) {
configuration.visible = true;
value: configuration.value,
});
}
- } else {
+ } else if (Utils.isNotEmptyArray(commandPayload.key) === true) {
for (const key of commandPayload.key) {
const keyFound = ChargingStationConfigurationUtils.getConfigurationKey(
chargingStation,
import { MessageType } from '../types/ocpp/MessageType';
import type { IncomingRequestCommand, RequestCommand } from '../types/ocpp/Requests';
import type { Statistics, TimeSeries } from '../types/Statistics';
-import { CircularArray, DEFAULT_CIRCULAR_ARRAY_SIZE } from '../utils/CircularArray';
+import { CircularArray } from '../utils/CircularArray';
import Configuration from '../utils/Configuration';
+import Constants from '../utils/Constants';
import logger from '../utils/Logger';
import Utils from '../utils/Utils';
this.statistics.statisticsData.get(entryName).avgTimeMeasurement =
this.statistics.statisticsData.get(entryName).totalTimeMeasurement /
this.statistics.statisticsData.get(entryName).countTimeMeasurement;
- Array.isArray(this.statistics.statisticsData.get(entryName)?.timeMeasurementSeries) === true
+ this.statistics.statisticsData.get(entryName)?.timeMeasurementSeries instanceof CircularArray
? this.statistics.statisticsData
.get(entryName)
?.timeMeasurementSeries?.push({ timestamp: entry.startTime, value: entry.duration })
: (this.statistics.statisticsData.get(entryName).timeMeasurementSeries =
- new CircularArray<TimeSeries>(DEFAULT_CIRCULAR_ARRAY_SIZE, {
+ new CircularArray<TimeSeries>(Constants.DEFAULT_CIRCULAR_BUFFER_CAPACITY, {
timestamp: entry.startTime,
value: entry.duration,
}));
}
export interface GetConfigurationRequest extends JsonObject {
- key?: string | OCPP16StandardParametersKey[];
+ key?: (string | OCPP16StandardParametersKey)[];
}
export enum ResetType {
// Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
-export const DEFAULT_CIRCULAR_ARRAY_SIZE = Number.MAX_SAFE_INTEGER;
+const DEFAULT_CIRCULAR_ARRAY_SIZE = 1024;
/**
* Array with a maximum length shifting items when full.
static readonly SEMVER_PATTERN =
'^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$';
- static readonly DEFAULT_CIRCULAR_BUFFER_CAPACITY = Number.MAX_SAFE_INTEGER;
+ static readonly DEFAULT_CIRCULAR_BUFFER_CAPACITY = 1024;
static readonly DEFAULT_HASH_ALGORITHM = 'sha384';
it('Verify circular array default size at instance creation', () => {
const circularArray = new CircularArray();
- expect(circularArray.size).toBe(Number.MAX_SAFE_INTEGER);
+ expect(circularArray.size).toBe(1024);
});
it('Verify that circular array size can be set at instance creation', () => {