From cd63f57ee11cdc6ffb32a8672c536fb9ae4f8509 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 3 Apr 2026 22:06:40 +0200 Subject: [PATCH] refactor: add unit suffixes to time-related constants and fix heartbeat unit mismatch - Rename 19 constants to include _MS or _SECONDS suffix (Constants, OCPPConstants, WorkerConstants) - Remove redundant // Ms and // Seconds comments from definitions - Fix pre-existing bug: resetLimits set HeartbeatInterval to 60000 seconds instead of 60 - Remove 97 redundant heartbeatInterval overrides in tests (mock default already correct) --- .../AutomaticTransactionGenerator.ts | 6 +- src/charging-station/Bootstrap.ts | 4 +- src/charging-station/ChargingStation.ts | 30 +++++----- .../ChargingStationWorkerBroadcastChannel.ts | 2 +- .../ocpp/1.6/OCPP16ResponseService.ts | 2 +- .../ocpp/2.0/OCPP20ServiceUtils.ts | 2 +- .../ocpp/2.0/OCPP20VariableManager.ts | 2 +- .../ocpp/2.0/OCPP20VariableRegistry.ts | 12 ++-- src/charging-station/ocpp/OCPPConstants.ts | 2 +- .../ocpp/OCPPRequestService.ts | 4 +- src/utils/Configuration.ts | 10 ++-- src/utils/Constants.ts | 34 +++++------ src/utils/Utils.ts | 2 +- src/worker/WorkerConstants.ts | 8 +-- src/worker/index.ts | 4 +- ...rgingStationWorkerBroadcastChannel.test.ts | 54 ++++++----------- ...omingRequestService-TriggerMessage.test.ts | 3 +- .../OCPP16Integration-Transactions.test.ts | 3 +- .../OCPP16RequestService-CallChain.test.ts | 3 +- ...PP16ResponseService-SimpleHandlers.test.ts | 3 +- .../ocpp/1.6/OCPP16TestUtils.ts | 18 +++--- .../2.0/OCPP20CertSigningRetryManager.test.ts | 3 +- ...ngRequestService-CertificateSigned.test.ts | 6 +- ...0IncomingRequestService-ClearCache.test.ts | 3 +- ...RequestService-CustomerInformation.test.ts | 3 +- ...ncomingRequestService-DataTransfer.test.ts | 3 +- ...ngRequestService-DeleteCertificate.test.ts | 6 +- ...comingRequestService-GetBaseReport.test.ts | 7 +-- ...Service-GetInstalledCertificateIds.test.ts | 6 +- ...CPP20IncomingRequestService-GetLog.test.ts | 3 +- ...equestService-GetTransactionStatus.test.ts | 3 +- ...ncomingRequestService-GetVariables.test.ts | 10 ++-- ...gRequestService-InstallCertificate.test.ts | 3 +- ...0IncomingRequestService-MasterPass.test.ts | 3 +- ...estService-RequestStartTransaction.test.ts | 9 +-- ...uestService-RequestStopTransaction.test.ts | 3 +- ...ngRequestService-SetNetworkProfile.test.ts | 3 +- ...ncomingRequestService-SetVariables.test.ts | 21 ++++--- ...omingRequestService-TriggerMessage.test.ts | 6 +- ...mingRequestService-UnlockConnector.test.ts | 6 +- ...omingRequestService-UpdateFirmware.test.ts | 15 ++--- .../2.0/OCPP20Integration-Certificate.test.ts | 3 +- .../ocpp/2.0/OCPP20Integration.test.ts | 3 +- .../OCPP20RequestService-CallChain.test.ts | 3 +- .../OCPP20RequestService-DataTransfer.test.ts | 3 +- ...Service-FirmwareStatusNotification.test.ts | 3 +- .../2.0/OCPP20RequestService-ISO15118.test.ts | 9 +-- ...questService-LogStatusNotification.test.ts | 3 +- .../OCPP20RequestService-MeterValues.test.ts | 3 +- .../OCPP20RequestService-NotifyReport.test.ts | 3 +- ...tService-SecurityEventNotification.test.ts | 3 +- ...PP20RequestService-SignCertificate.test.ts | 6 +- ...20ResponseService-BootNotification.test.ts | 3 +- ...PP20ResponseService-SimpleHandlers.test.ts | 3 +- ...20ResponseService-TransactionEvent.test.ts | 6 +- .../OCPP20ServiceUtils-ReconnectDelay.test.ts | 2 - ...P20ServiceUtils-StatusNotification.test.ts | 3 +- ...CPP20ServiceUtils-TransactionEvent.test.ts | 29 ++++------ .../ocpp/2.0/OCPP20TestUtils.ts | 12 ++-- .../ocpp/2.0/OCPP20VariableManager.test.ts | 58 +++++++++++-------- .../ocpp/OCPPServiceUtils-meterValues.test.ts | 12 ++-- tests/utils/Utils.test.ts | 12 ++-- 62 files changed, 215 insertions(+), 297 deletions(-) diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index 12a0d5ea..6a73c97e 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -497,7 +497,7 @@ export class AutomaticTransactionGenerator { ) logged = true } - await sleep(Constants.DEFAULT_ATG_WAIT_TIME) + await sleep(Constants.DEFAULT_ATG_WAIT_TIME_MS) } } @@ -512,7 +512,7 @@ export class AutomaticTransactionGenerator { ) logged = true } - await sleep(Constants.DEFAULT_ATG_WAIT_TIME) + await sleep(Constants.DEFAULT_ATG_WAIT_TIME_MS) } } @@ -527,7 +527,7 @@ export class AutomaticTransactionGenerator { ) logged = true } - await sleep(Constants.DEFAULT_ATG_WAIT_TIME) + await sleep(Constants.DEFAULT_ATG_WAIT_TIME_MS) } } } diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index d82574c6..c9408cf0 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -586,13 +586,13 @@ export class Bootstrap extends EventEmitter implements IBootstrap { return await new Promise((resolve, reject: (reason?: unknown) => void) => { const waitTimeout = setTimeout(() => { const timeoutMessage = `Timeout ${formatDurationMilliSeconds( - Constants.STOP_CHARGING_STATIONS_TIMEOUT + Constants.STOP_CHARGING_STATIONS_TIMEOUT_MS )} reached at stopping charging stations` logger.warn( `${this.logPrefix()} ${moduleName}.waitChargingStationsStopped: ${timeoutMessage}` ) reject(new BaseError(timeoutMessage)) - }, Constants.STOP_CHARGING_STATIONS_TIMEOUT) + }, Constants.STOP_CHARGING_STATIONS_TIMEOUT_MS) waitChargingStationEvents( this, ChargingStationWorkerMessageEvents.stopped, diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index d98164b2..3f64f267 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -447,10 +447,10 @@ export class ChargingStation extends EventEmitter { if (getConfigurationKey(this, StandardParametersKey.ConnectionTimeOut) != null) { return convertToInt( getConfigurationKey(this, StandardParametersKey.ConnectionTimeOut)?.value ?? - Constants.DEFAULT_EV_CONNECTION_TIMEOUT + Constants.DEFAULT_EV_CONNECTION_TIMEOUT_SECONDS ) } - return Constants.DEFAULT_EV_CONNECTION_TIMEOUT + return Constants.DEFAULT_EV_CONNECTION_TIMEOUT_SECONDS } /** @@ -604,9 +604,9 @@ export class ChargingStation extends EventEmitter { } this.stationInfo?.autoRegister === false && logger.warn( - `${this.logPrefix()} Heartbeat interval configuration key not set, using default value: ${Constants.DEFAULT_HEARTBEAT_INTERVAL.toString()}` + `${this.logPrefix()} Heartbeat interval configuration key not set, using default value: ${Constants.DEFAULT_HEARTBEAT_INTERVAL_MS.toString()}` ) - return Constants.DEFAULT_HEARTBEAT_INTERVAL + return Constants.DEFAULT_HEARTBEAT_INTERVAL_MS } public getLocalAuthListEnabled (): boolean { @@ -694,7 +694,7 @@ export class ChargingStation extends EventEmitter { public getWebSocketPingInterval (): number { return getConfigurationKey(this, StandardParametersKey.WebSocketPingInterval) != null ? convertToInt(getConfigurationKey(this, StandardParametersKey.WebSocketPingInterval)?.value) - : Constants.DEFAULT_WS_PING_INTERVAL + : Constants.DEFAULT_WS_PING_INTERVAL_SECONDS } public hasConnector (connectorId: number): boolean { @@ -852,7 +852,7 @@ export class ChargingStation extends EventEmitter { params?: { closeOpened?: boolean; terminateOpened?: boolean } ): void { options = { - handshakeTimeout: secondsToMilliseconds(Constants.DEFAULT_WS_HANDSHAKE_TIMEOUT), + handshakeTimeout: secondsToMilliseconds(Constants.DEFAULT_WS_HANDSHAKE_TIMEOUT_SECONDS), ...this.stationInfo?.wsOptions, ...options, } @@ -1150,8 +1150,8 @@ export class ChargingStation extends EventEmitter { try { await promiseWithTimeout( this.stopMessageSequence(reason, stopTransactions), - Constants.STOP_MESSAGE_SEQUENCE_TIMEOUT, - `Timeout ${formatDurationMilliSeconds(Constants.STOP_MESSAGE_SEQUENCE_TIMEOUT)} reached at stopping message sequence` + Constants.STOP_MESSAGE_SEQUENCE_TIMEOUT_MS, + `Timeout ${formatDurationMilliSeconds(Constants.STOP_MESSAGE_SEQUENCE_TIMEOUT_MS)} reached at stopping message sequence` ) } catch (error: unknown) { logger.error(`${this.logPrefix()} Error while stopping message sequence:`, error) @@ -1484,7 +1484,7 @@ export class ChargingStation extends EventEmitter { jitterPercent: 0.2, retryNumber: this.wsConnectionRetryCount, }) - : secondsToMilliseconds(Constants.DEFAULT_WS_RECONNECT_DELAY) + : secondsToMilliseconds(Constants.DEFAULT_WS_RECONNECT_DELAY_SECONDS) } private getStationInfo (options?: ChargingStationOptions): ChargingStationInfo { @@ -2099,7 +2099,7 @@ export class ChargingStation extends EventEmitter { addConfigurationKey( this, StandardParametersKey.ConnectionTimeOut, - Constants.DEFAULT_EV_CONNECTION_TIMEOUT.toString() + Constants.DEFAULT_EV_CONNECTION_TIMEOUT_SECONDS.toString() ) } this.saveOcppConfiguration() @@ -2331,8 +2331,8 @@ export class ChargingStation extends EventEmitter { baseDelayMs: this.bootNotificationResponse?.interval != null ? secondsToMilliseconds(this.bootNotificationResponse.interval) - : Constants.DEFAULT_BOOT_NOTIFICATION_INTERVAL, - jitterMs: Constants.DEFAULT_WS_RECONNECT_TIMEOUT_OFFSET, + : Constants.DEFAULT_BOOT_NOTIFICATION_INTERVAL_MS, + jitterMs: Constants.DEFAULT_WS_RECONNECT_TIMEOUT_OFFSET_MS, retryNumber: registrationRetryCount, }) ) @@ -2375,8 +2375,8 @@ export class ChargingStation extends EventEmitter { ++this.wsConnectionRetryCount const reconnectDelay = this.getReconnectDelay() const reconnectTimeout = - reconnectDelay - Constants.DEFAULT_WS_RECONNECT_TIMEOUT_OFFSET > 0 - ? reconnectDelay - Constants.DEFAULT_WS_RECONNECT_TIMEOUT_OFFSET + reconnectDelay - Constants.DEFAULT_WS_RECONNECT_TIMEOUT_OFFSET_MS > 0 + ? reconnectDelay - Constants.DEFAULT_WS_RECONNECT_TIMEOUT_OFFSET_MS : 0 logger.error( `${this.logPrefix()} WebSocket connection retry in ${formatDurationMilliSeconds(reconnectDelay)}, timeout ${formatDurationMilliSeconds(reconnectTimeout)}` @@ -2594,7 +2594,7 @@ export class ChargingStation extends EventEmitter { if (!this.isWebSocketConnectionOpened() || isEmpty(this.messageQueue)) { this.clearIntervalFlushMessageBuffer() } - }, Constants.DEFAULT_MESSAGE_BUFFER_FLUSH_INTERVAL) + }, Constants.DEFAULT_MESSAGE_BUFFER_FLUSH_INTERVAL_MS) } private async startMessageSequence (ATGStopAbsoluteDuration?: boolean): Promise { diff --git a/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts b/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts index 902cbedb..a2adb481 100644 --- a/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts +++ b/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts @@ -419,7 +419,7 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne ) return key != null ? secondsToMilliseconds(convertToInt(key.value)) - : Constants.DEFAULT_METER_VALUES_INTERVAL + : Constants.DEFAULT_METER_VALUES_INTERVAL_MS })() return await this.chargingStation.ocppRequestService.requestHandler< MeterValuesRequest, diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index b60ce5e9..d4333032 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -451,7 +451,7 @@ export class OCPP16ResponseService extends OCPPResponseService { connectorId, configuredMeterValueSampleInterval != null ? secondsToMilliseconds(convertToInt(configuredMeterValueSampleInterval.value)) - : Constants.DEFAULT_METER_VALUES_INTERVAL + : Constants.DEFAULT_METER_VALUES_INTERVAL_MS ) } else { logger.warn( diff --git a/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts b/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts index 0b949562..7dc41c2b 100644 --- a/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts +++ b/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts @@ -430,7 +430,7 @@ export class OCPP20ServiceUtils { chargingStation, OCPP20ComponentName.SampledDataCtrlr, OCPP20RequiredVariableName.TxUpdatedInterval, - Constants.DEFAULT_TX_UPDATED_INTERVAL + Constants.DEFAULT_TX_UPDATED_INTERVAL_SECONDS ) } diff --git a/src/charging-station/ocpp/2.0/OCPP20VariableManager.ts b/src/charging-station/ocpp/2.0/OCPP20VariableManager.ts index 6a20a04f..e8093ed8 100644 --- a/src/charging-station/ocpp/2.0/OCPP20VariableManager.ts +++ b/src/charging-station/ocpp/2.0/OCPP20VariableManager.ts @@ -678,7 +678,7 @@ export class OCPP20VariableManager { variableMetadata.variable === (OCPP20RequiredVariableName.TxUpdatedInterval as string) && !value ) { - value = Constants.DEFAULT_TX_UPDATED_INTERVAL.toString() + value = Constants.DEFAULT_TX_UPDATED_INTERVAL_SECONDS.toString() } value = applyPostProcess(chargingStation, variableMetadata, value) diff --git a/src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts b/src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts index c2687bd4..efafaab8 100644 --- a/src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts +++ b/src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts @@ -603,7 +603,7 @@ export const VARIABLE_REGISTRY: Record = { allowZero: true, component: OCPP20ComponentName.ChargingStation, dataType: DataEnumType.integer, - defaultValue: Constants.DEFAULT_WS_PING_INTERVAL.toString(), + defaultValue: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS.toString(), description: 'Interval in seconds between WebSocket ping (keep-alive) frames. 0 disables pings.', max: 3600, @@ -1465,7 +1465,7 @@ export const VARIABLE_REGISTRY: Record = { )]: { component: OCPP20ComponentName.OCPPCommCtrlr, dataType: DataEnumType.integer, - defaultValue: millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL).toString(), + defaultValue: millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL_MS).toString(), description: 'Interval between Heartbeat messages.', max: 86400, maxLength: 10, @@ -1523,7 +1523,7 @@ export const VARIABLE_REGISTRY: Record = { allowZero: true, component: OCPP20ComponentName.OCPPCommCtrlr, dataType: DataEnumType.integer, - defaultValue: Constants.DEFAULT_WS_PING_INTERVAL.toString(), + defaultValue: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS.toString(), description: '0 disables client side websocket Ping/Pong. Positive values are interpreted as number of seconds between pings. Negative values are not allowed.', min: 0, @@ -1594,7 +1594,7 @@ export const VARIABLE_REGISTRY: Record = { )]: { component: OCPP20ComponentName.OCPPCommCtrlr, dataType: DataEnumType.integer, - defaultValue: Constants.DEFAULT_MESSAGE_TIMEOUT.toString(), + defaultValue: Constants.DEFAULT_MESSAGE_TIMEOUT_SECONDS.toString(), description: 'Timeout (in seconds) waiting for responses to general OCPP messages.', instance: 'Default', max: 3600, @@ -1904,7 +1904,7 @@ export const VARIABLE_REGISTRY: Record = { )]: { component: OCPP20ComponentName.SampledDataCtrlr, dataType: DataEnumType.integer, - defaultValue: Constants.DEFAULT_TX_UPDATED_INTERVAL.toString(), + defaultValue: Constants.DEFAULT_TX_UPDATED_INTERVAL_SECONDS.toString(), description: 'Interval between sampling of metering data for Updated TransactionEvent messages.', max: 3600, @@ -2351,7 +2351,7 @@ export const VARIABLE_REGISTRY: Record = { [buildRegistryKey(OCPP20ComponentName.TxCtrlr, OCPP20RequiredVariableName.EVConnectionTimeOut)]: { component: OCPP20ComponentName.TxCtrlr, dataType: DataEnumType.integer, - defaultValue: Constants.DEFAULT_EV_CONNECTION_TIMEOUT.toString(), + defaultValue: Constants.DEFAULT_EV_CONNECTION_TIMEOUT_SECONDS.toString(), description: 'Timeout for EV to establish connection.', max: 3600, maxLength: 10, diff --git a/src/charging-station/ocpp/OCPPConstants.ts b/src/charging-station/ocpp/OCPPConstants.ts index 0583649b..a79edf6c 100644 --- a/src/charging-station/ocpp/OCPPConstants.ts +++ b/src/charging-station/ocpp/OCPPConstants.ts @@ -159,7 +159,7 @@ export class OCPPConstants { status: TriggerMessageStatus.REJECTED, }) - static readonly OCPP_WEBSOCKET_TIMEOUT = 60000 // Ms + static readonly OCPP_WEBSOCKET_TIMEOUT_MS = 60000 static readonly UNKNOWN_OCPP_COMMAND = 'unknown OCPP command' as | IncomingRequestCommand diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 1278e14e..771d8dd1 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -393,7 +393,7 @@ export abstract class OCPPRequestService { new OCPPError( ErrorType.GENERIC_ERROR, `Timeout ${formatDurationMilliSeconds( - OCPPConstants.OCPP_WEBSOCKET_TIMEOUT + OCPPConstants.OCPP_WEBSOCKET_TIMEOUT_MS )} reached for ${ params.skipBufferingOnError === false ? '' : 'non ' }buffered message id '${messageId}' with content '${messageToSend}'`, @@ -401,7 +401,7 @@ export abstract class OCPPRequestService { messagePayload instanceof OCPPError ? messagePayload.details : undefined ) ) - }, OCPPConstants.OCPP_WEBSOCKET_TIMEOUT) + }, OCPPConstants.OCPP_WEBSOCKET_TIMEOUT_MS) chargingStation.wsConnection?.send(messageToSend, (error?: Error) => { PerformanceStatistics.endMeasure(commandName, beginId) clearTimeout(sendTimeout) diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index 39e95297..deb6d3fd 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -20,10 +20,10 @@ import { } from '../types/index.js' import { checkWorkerProcessType, - DEFAULT_ELEMENT_ADD_DELAY, + DEFAULT_ELEMENT_ADD_DELAY_MS, DEFAULT_POOL_MAX_SIZE, DEFAULT_POOL_MIN_SIZE, - DEFAULT_WORKER_START_DELAY, + DEFAULT_WORKER_START_DELAY_MS, WorkerProcessType, } from '../worker/index.js' import { checkDeprecatedConfigurationKeys } from './ConfigurationMigration.js' @@ -72,16 +72,16 @@ const defaultLogConfiguration: LogConfiguration = { format: 'simple', level: 'info', rotate: true, - statisticsInterval: Constants.DEFAULT_LOG_STATISTICS_INTERVAL, + statisticsInterval: Constants.DEFAULT_LOG_STATISTICS_INTERVAL_SECONDS, } const defaultWorkerConfiguration: WorkerConfiguration = { - elementAddDelay: DEFAULT_ELEMENT_ADD_DELAY, + elementAddDelay: DEFAULT_ELEMENT_ADD_DELAY_MS, elementsPerWorker: 'auto', poolMaxSize: DEFAULT_POOL_MAX_SIZE, poolMinSize: DEFAULT_POOL_MIN_SIZE, processType: WorkerProcessType.workerSet, - startDelay: DEFAULT_WORKER_START_DELAY, + startDelay: DEFAULT_WORKER_START_DELAY_MS, } // eslint-disable-next-line @typescript-eslint/no-extraneous-class diff --git a/src/utils/Constants.ts b/src/utils/Constants.ts index 1dbde98f..5953ec63 100644 --- a/src/utils/Constants.ts +++ b/src/utils/Constants.ts @@ -20,7 +20,7 @@ export class Constants { stopAfterHours: 0.25, }) - static readonly DEFAULT_ATG_WAIT_TIME = 1000 // Ms + static readonly DEFAULT_ATG_WAIT_TIME_MS = 1000 static readonly DEFAULT_AUTH_CACHE_CLEANUP_INTERVAL_SECONDS = 300 @@ -32,25 +32,25 @@ export class Constants { static readonly DEFAULT_AUTH_CACHE_TTL_SECONDS = 3600 - static readonly DEFAULT_BOOT_NOTIFICATION_INTERVAL = 60000 // Ms + static readonly DEFAULT_BOOT_NOTIFICATION_INTERVAL_MS = 60000 static readonly DEFAULT_CIRCULAR_BUFFER_CAPACITY = 386 - static readonly DEFAULT_EV_CONNECTION_TIMEOUT = 180 // Seconds + static readonly DEFAULT_EV_CONNECTION_TIMEOUT_SECONDS = 180 static readonly DEFAULT_FLUCTUATION_PERCENT = 5 static readonly DEFAULT_HASH_ALGORITHM = 'sha384' - static readonly DEFAULT_HEARTBEAT_INTERVAL = 60000 // Ms + static readonly DEFAULT_HEARTBEAT_INTERVAL_MS = 60000 - static readonly DEFAULT_LOG_STATISTICS_INTERVAL = 60 // Seconds + static readonly DEFAULT_LOG_STATISTICS_INTERVAL_SECONDS = 60 - static readonly DEFAULT_MESSAGE_BUFFER_FLUSH_INTERVAL = 60000 // Ms + static readonly DEFAULT_MESSAGE_BUFFER_FLUSH_INTERVAL_MS = 60000 - static readonly DEFAULT_MESSAGE_TIMEOUT = 30 // Seconds + static readonly DEFAULT_MESSAGE_TIMEOUT_SECONDS = 30 - static readonly DEFAULT_METER_VALUES_INTERVAL = 60000 // Ms + static readonly DEFAULT_METER_VALUES_INTERVAL_MS = 60000 static readonly DEFAULT_PERFORMANCE_DIRECTORY = 'performance' @@ -83,7 +83,7 @@ export class Constants { reconnectExponentialDelay: false, registrationMaxRetries: -1, remoteAuthorization: true, - resetTime: 30000, // Ms + resetTime: 30000, stationInfoPersistentConfiguration: true, stopTransactionsOnStopped: true, supervisionUrlOcppConfiguration: false, @@ -92,15 +92,15 @@ export class Constants { useConnectorId0: true, }) - static readonly DEFAULT_TX_UPDATED_INTERVAL = 30 // Seconds + static readonly DEFAULT_TX_UPDATED_INTERVAL_SECONDS = 30 static readonly DEFAULT_UI_SERVER_HOST = 'localhost' static readonly DEFAULT_UI_SERVER_PORT = 8080 - static readonly DEFAULT_WS_HANDSHAKE_TIMEOUT = 30 // Seconds - static readonly DEFAULT_WS_PING_INTERVAL = 30 // Seconds - static readonly DEFAULT_WS_RECONNECT_DELAY = 30 // Seconds - static readonly DEFAULT_WS_RECONNECT_TIMEOUT_OFFSET = 1000 // Ms + static readonly DEFAULT_WS_HANDSHAKE_TIMEOUT_SECONDS = 30 + static readonly DEFAULT_WS_PING_INTERVAL_SECONDS = 30 + static readonly DEFAULT_WS_RECONNECT_DELAY_SECONDS = 30 + static readonly DEFAULT_WS_RECONNECT_TIMEOUT_OFFSET_MS = 1000 static readonly EMPTY_FROZEN_OBJECT = Object.freeze({}) @@ -112,11 +112,11 @@ export class Constants { // Node.js setInterval/setTimeout maximum safe delay value (2^31-1 ms ≈ 24.8 days) // Values exceeding this limit cause Node.js to reset the delay to 1ms - static readonly MAX_SETINTERVAL_DELAY = 2147483647 // Ms + static readonly MAX_SETINTERVAL_DELAY_MS = 2147483647 static readonly PERFORMANCE_RECORDS_TABLE = 'performance_records' - static readonly STOP_CHARGING_STATIONS_TIMEOUT = 60000 // Ms + static readonly STOP_CHARGING_STATIONS_TIMEOUT_MS = 60000 - static readonly STOP_MESSAGE_SEQUENCE_TIMEOUT = 30000 // Ms + static readonly STOP_MESSAGE_SEQUENCE_TIMEOUT_MS = 30000 } diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index b7dbeef9..88d58011 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -425,7 +425,7 @@ export const computeExponentialBackOffDelay = (options: { * @see https://nodejs.org/api/timers.html#settimeoutcallback-delay-args */ export const clampToSafeTimerValue = (delayMs: number): number => { - return Math.min(Math.max(0, delayMs), Constants.MAX_SETINTERVAL_DELAY) + return Math.min(Math.max(0, delayMs), Constants.MAX_SETINTERVAL_DELAY_MS) } /** diff --git a/src/worker/WorkerConstants.ts b/src/worker/WorkerConstants.ts index 5f4084f5..b7460257 100644 --- a/src/worker/WorkerConstants.ts +++ b/src/worker/WorkerConstants.ts @@ -10,8 +10,8 @@ export const EMPTY_FUNCTION = Object.freeze(() => { export const workerSetVersion = '1.0.1' -export const DEFAULT_ELEMENT_ADD_DELAY = 0 -export const DEFAULT_WORKER_START_DELAY = 500 +export const DEFAULT_ELEMENT_ADD_DELAY_MS = 0 +export const DEFAULT_WORKER_START_DELAY_MS = 500 export const DEFAULT_POOL_MIN_SIZE = Math.max(1, Math.floor(availableParallelism() / 2)) export const DEFAULT_POOL_MAX_SIZE = Math.max( DEFAULT_POOL_MIN_SIZE, @@ -28,10 +28,10 @@ export const DEFAULT_POOL_OPTIONS: Readonly = Object.freeze({ }) export const DEFAULT_WORKER_OPTIONS: Readonly = Object.freeze({ - elementAddDelay: DEFAULT_ELEMENT_ADD_DELAY, + elementAddDelay: DEFAULT_ELEMENT_ADD_DELAY_MS, elementsPerWorker: DEFAULT_ELEMENTS_PER_WORKER, poolMaxSize: DEFAULT_POOL_MAX_SIZE, poolMinSize: DEFAULT_POOL_MIN_SIZE, poolOptions: DEFAULT_POOL_OPTIONS, - workerStartDelay: DEFAULT_WORKER_START_DELAY, + workerStartDelay: DEFAULT_WORKER_START_DELAY_MS, }) diff --git a/src/worker/index.ts b/src/worker/index.ts index 00308170..16740ed9 100644 --- a/src/worker/index.ts +++ b/src/worker/index.ts @@ -1,10 +1,10 @@ export type { WorkerAbstract } from './WorkerAbstract.js' export { - DEFAULT_ELEMENT_ADD_DELAY, + DEFAULT_ELEMENT_ADD_DELAY_MS, DEFAULT_ELEMENTS_PER_WORKER, DEFAULT_POOL_MAX_SIZE, DEFAULT_POOL_MIN_SIZE, - DEFAULT_WORKER_START_DELAY, + DEFAULT_WORKER_START_DELAY_MS, } from './WorkerConstants.js' export { WorkerFactory } from './WorkerFactory.js' export { diff --git a/tests/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.test.ts b/tests/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.test.ts index b92fcc84..71da1cb8 100644 --- a/tests/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.test.ts +++ b/tests/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.test.ts @@ -181,9 +181,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return SUCCESS for SIGN_CERTIFICATE with Accepted status', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) @@ -200,9 +199,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return FAILURE for SIGN_CERTIFICATE with Rejected status', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) @@ -221,9 +219,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return SUCCESS for GET_15118_EV_CERTIFICATE with Accepted status', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) @@ -240,9 +237,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return FAILURE for GET_15118_EV_CERTIFICATE with Failed status', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) @@ -261,9 +257,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return SUCCESS for GET_CERTIFICATE_STATUS with Accepted status', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) @@ -280,9 +275,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return FAILURE for GET_CERTIFICATE_STATUS with Failed status', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) @@ -301,9 +295,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return SUCCESS for LOG_STATUS_NOTIFICATION with empty response', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) @@ -320,9 +313,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return FAILURE for LOG_STATUS_NOTIFICATION with non-empty response', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) @@ -339,9 +331,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return SUCCESS for NOTIFY_CUSTOMER_INFORMATION with empty response', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) @@ -358,9 +349,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return FAILURE for NOTIFY_CUSTOMER_INFORMATION with non-empty response', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) @@ -377,9 +367,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return SUCCESS for NOTIFY_REPORT with empty response', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) @@ -396,9 +385,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return FAILURE for NOTIFY_REPORT with non-empty response', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) @@ -415,9 +403,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return SUCCESS for SECURITY_EVENT_NOTIFICATION with empty response', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) @@ -434,9 +421,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return FAILURE for SECURITY_EVENT_NOTIFICATION with non-empty response', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) @@ -455,9 +441,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return SUCCESS for TRANSACTION_EVENT with empty response', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) @@ -475,9 +460,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return SUCCESS for TRANSACTION_EVENT with no idTokenInfo', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) @@ -495,9 +479,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return SUCCESS for TRANSACTION_EVENT with Accepted idTokenInfo', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) @@ -514,9 +497,8 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { await it('should return FAILURE for TRANSACTION_EVENT with Blocked idTokenInfo', () => { const { station } = createMockChargingStation({ connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) instance = new ChargingStationWorkerBroadcastChannel(station) diff --git a/tests/charging-station/ocpp/1.6/OCPP16IncomingRequestService-TriggerMessage.test.ts b/tests/charging-station/ocpp/1.6/OCPP16IncomingRequestService-TriggerMessage.test.ts index d2ec110c..861c8fab 100644 --- a/tests/charging-station/ocpp/1.6/OCPP16IncomingRequestService-TriggerMessage.test.ts +++ b/tests/charging-station/ocpp/1.6/OCPP16IncomingRequestService-TriggerMessage.test.ts @@ -276,14 +276,13 @@ await describe('OCPP16IncomingRequestService — TriggerMessage', async () => { const { station: rejectStation } = createMockChargingStation({ baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 2, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: rejectingMock, }, stationInfo: { ocppVersion: OCPPVersion.VERSION_16, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) const request: OCPP16TriggerMessageRequest = { diff --git a/tests/charging-station/ocpp/1.6/OCPP16Integration-Transactions.test.ts b/tests/charging-station/ocpp/1.6/OCPP16Integration-Transactions.test.ts index 1e5fc229..93903de9 100644 --- a/tests/charging-station/ocpp/1.6/OCPP16Integration-Transactions.test.ts +++ b/tests/charging-station/ocpp/1.6/OCPP16Integration-Transactions.test.ts @@ -55,7 +55,6 @@ function createIntegrationContext (): { const { station } = createMockChargingStation({ baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 2, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: () => Promise.resolve({}), }, @@ -63,7 +62,7 @@ function createIntegrationContext (): { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_16, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) // IncomingRequest service (handles RemoteStart/Stop from CSMS) diff --git a/tests/charging-station/ocpp/1.6/OCPP16RequestService-CallChain.test.ts b/tests/charging-station/ocpp/1.6/OCPP16RequestService-CallChain.test.ts index f89a49e1..defd32ee 100644 --- a/tests/charging-station/ocpp/1.6/OCPP16RequestService-CallChain.test.ts +++ b/tests/charging-station/ocpp/1.6/OCPP16RequestService-CallChain.test.ts @@ -44,7 +44,6 @@ await describe('OCPP 1.6 Request Call Chain — requestHandler → buildRequestP const { station: mockStation } = createMockChargingStation({ baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 2, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: async () => Promise.resolve({} as JsonType), }, @@ -52,7 +51,7 @@ await describe('OCPP 1.6 Request Call Chain — requestHandler → buildRequestP ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_16, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = mockStation }) diff --git a/tests/charging-station/ocpp/1.6/OCPP16ResponseService-SimpleHandlers.test.ts b/tests/charging-station/ocpp/1.6/OCPP16ResponseService-SimpleHandlers.test.ts index 487ef583..fa540be7 100644 --- a/tests/charging-station/ocpp/1.6/OCPP16ResponseService-SimpleHandlers.test.ts +++ b/tests/charging-station/ocpp/1.6/OCPP16ResponseService-SimpleHandlers.test.ts @@ -38,12 +38,11 @@ function createSimpleHandlerStation (): MockChargingStation { const { station } = createMockChargingStation({ baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_16, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) return station as MockChargingStation } diff --git a/tests/charging-station/ocpp/1.6/OCPP16TestUtils.ts b/tests/charging-station/ocpp/1.6/OCPP16TestUtils.ts index 2d1043e5..490be5c4 100644 --- a/tests/charging-station/ocpp/1.6/OCPP16TestUtils.ts +++ b/tests/charging-station/ocpp/1.6/OCPP16TestUtils.ts @@ -4,6 +4,7 @@ * and configuration key helpers for OCPP 1.6 unit and integration tests. */ +import { millisecondsToSeconds } from 'date-fns' import { mock } from 'node:test' import type { ChargingStation } from '../../../../src/charging-station/index.js' @@ -139,13 +140,12 @@ export function createOCPP16IncomingRequestTestContext ( const { station } = createMockChargingStation({ baseName, connectorsCount, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_16, ...stationInfo, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) return { incomingRequestService, station, testableService } @@ -164,7 +164,6 @@ export function createOCPP16ListenerStation (baseName: string): { const { station } = createMockChargingStation({ baseName, connectorsCount: 2, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: requestHandlerMock, }, @@ -172,7 +171,7 @@ export function createOCPP16ListenerStation (baseName: string): { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_16, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) return { requestHandlerMock, station } } @@ -194,13 +193,12 @@ export function createOCPP16RequestTestContext ( const { station } = createMockChargingStation({ baseName, connectorsCount: 2, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_16, ...stationInfo, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) return { requestService, station, testableRequestService } @@ -225,13 +223,12 @@ export function createOCPP16ResponseTestContext ( const { station } = createMockChargingStation({ baseName, connectorsCount: 2, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_16, ...stationInfo, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) return { responseService, station } @@ -255,14 +252,13 @@ export function createStandardStation ( const { station } = createMockChargingStation({ baseName, connectorsCount, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_16, resetTime: 5000, ...stationInfo, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) return station as MockChargingStation @@ -327,7 +323,7 @@ export function resetLimits (chargingStation: ChargingStation) { upsertConfigurationKey( chargingStation, OCPP16StandardParametersKey.HeartbeatInterval, - Constants.DEFAULT_HEARTBEAT_INTERVAL.toString() + millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL_MS).toString() ) } diff --git a/tests/charging-station/ocpp/2.0/OCPP20CertSigningRetryManager.test.ts b/tests/charging-station/ocpp/2.0/OCPP20CertSigningRetryManager.test.ts index b06ce775..fe12d5a1 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20CertSigningRetryManager.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20CertSigningRetryManager.test.ts @@ -44,14 +44,13 @@ await describe('OCPP20CertSigningRetryManager', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: requestHandlerMock, }, stationInfo: { ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = newStation diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CertificateSigned.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CertificateSigned.test.ts index c80a3a44..f22f3e2b 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CertificateSigned.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CertificateSigned.test.ts @@ -49,12 +49,11 @@ await describe('I04 - CertificateSigned', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = mockStation stationWithCertManager = createStationWithCertificateManager( @@ -182,12 +181,11 @@ await describe('I04 - CertificateSigned', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) // certificateManager is not set on this station (not present by default) diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts index 3b612a31..33693619 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts @@ -31,12 +31,11 @@ await describe('C11 - Clear Authorization Data in Authorization Cache', async () baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = mockStation incomingRequestService = new OCPP20IncomingRequestService() diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CustomerInformation.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CustomerInformation.test.ts index a6063f8f..ea8d0eb9 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CustomerInformation.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CustomerInformation.test.ts @@ -33,12 +33,11 @@ await describe('N32 - CustomerInformation', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = mockStation testableService = createTestableIncomingRequestService(new OCPP20IncomingRequestService()) diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DataTransfer.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DataTransfer.test.ts index dc801aeb..bd6d895d 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DataTransfer.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DataTransfer.test.ts @@ -25,12 +25,11 @@ await describe('P01 - DataTransfer', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = mockStation testableService = createTestableIncomingRequestService(new OCPP20IncomingRequestService()) diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DeleteCertificate.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DeleteCertificate.test.ts index 9ca69b2f..131818a8 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DeleteCertificate.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DeleteCertificate.test.ts @@ -56,12 +56,11 @@ await describe('I04 - DeleteCertificate', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = mockStation @@ -177,12 +176,11 @@ await describe('I04 - DeleteCertificate', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) const stationNoCertManager = diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts index 2bfdc5b0..954bf0e2 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts @@ -54,18 +54,17 @@ await describe('B07 - Get Base Report', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppConfiguration: { configurationKey: [ { key: StandardParametersKey.HeartbeatInterval, readonly: false, - value: millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL).toString(), + value: millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL_MS).toString(), }, { key: StandardParametersKey.MeterValueSampleInterval, readonly: false, - value: millisecondsToSeconds(Constants.DEFAULT_METER_VALUES_INTERVAL).toString(), + value: millisecondsToSeconds(Constants.DEFAULT_METER_VALUES_INTERVAL_MS).toString(), }, ], }, @@ -77,7 +76,7 @@ await describe('B07 - Get Base Report', async () => { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = mockStation diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetInstalledCertificateIds.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetInstalledCertificateIds.test.ts index 51e38d7f..f9f32bfc 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetInstalledCertificateIds.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetInstalledCertificateIds.test.ts @@ -40,12 +40,11 @@ await describe('I04 - GetInstalledCertificateIds', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = mockStation @@ -239,12 +238,11 @@ await describe('I04 - GetInstalledCertificateIds', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) // Explicitly set to null/undefined diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetLog.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetLog.test.ts index b6ba9715..0a896fbe 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetLog.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetLog.test.ts @@ -39,12 +39,11 @@ await describe('K01 - GetLog', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = mockStation testableService = createTestableIncomingRequestService(new OCPP20IncomingRequestService()) diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetTransactionStatus.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetTransactionStatus.test.ts index 7f9ed904..9e0ea95d 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetTransactionStatus.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetTransactionStatus.test.ts @@ -28,12 +28,11 @@ await describe('D14 - GetTransactionStatus', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = mockStation testableService = createTestableIncomingRequestService(new OCPP20IncomingRequestService()) diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetVariables.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetVariables.test.ts index 6789d323..52cdfdfe 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetVariables.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetVariables.test.ts @@ -45,12 +45,11 @@ await describe('B06 - Get Variables', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = newStation incomingRequestService = new OCPP20IncomingRequestService() @@ -91,7 +90,7 @@ await describe('B06 - Get Variables', async () => { assert.strictEqual(firstResult.attributeType, AttributeEnumType.Actual) assert.strictEqual( firstResult.attributeValue, - millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL).toString() + millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL_MS).toString() ) assert.strictEqual(firstResult.component.name, OCPP20ComponentName.OCPPCommCtrlr) assert.strictEqual(firstResult.variable.name, OCPP20OptionalVariableName.HeartbeatInterval) @@ -101,7 +100,10 @@ await describe('B06 - Get Variables', async () => { const secondResult = response.getVariableResult[1] assert.strictEqual(secondResult.attributeStatus, GetVariableStatusEnumType.Accepted) assert.strictEqual(secondResult.attributeType, AttributeEnumType.Actual) - assert.strictEqual(secondResult.attributeValue, Constants.DEFAULT_WS_PING_INTERVAL.toString()) + assert.strictEqual( + secondResult.attributeValue, + Constants.DEFAULT_WS_PING_INTERVAL_SECONDS.toString() + ) assert.strictEqual(secondResult.component.name, OCPP20ComponentName.ChargingStation) assert.strictEqual(secondResult.variable.name, OCPP20OptionalVariableName.WebSocketPingInterval) assert.strictEqual(secondResult.attributeStatusInfo, undefined) diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-InstallCertificate.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-InstallCertificate.test.ts index 1bef26db..4793d4e8 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-InstallCertificate.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-InstallCertificate.test.ts @@ -47,12 +47,11 @@ await describe('I03 - InstallCertificate', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) mockStation = initialStation diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-MasterPass.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-MasterPass.test.ts index bd30481b..c9ee625c 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-MasterPass.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-MasterPass.test.ts @@ -42,7 +42,6 @@ await describe('C12.FR.09 - MasterPassGroupId Check', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: async () => Promise.resolve({}), }, @@ -50,7 +49,7 @@ await describe('C12.FR.09 - MasterPassGroupId Check', async () => { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) mockStation = station const incomingRequestService = new OCPP20IncomingRequestService() diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStartTransaction.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStartTransaction.test.ts index ea4e6d94..4eea501f 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStartTransaction.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStartTransaction.test.ts @@ -63,7 +63,6 @@ await describe('F01 & F02 - Remote Start Transaction', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: async () => Promise.resolve({}), }, @@ -71,7 +70,7 @@ await describe('F01 & F02 - Remote Start Transaction', async () => { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) mockStation = station incomingRequestService = new OCPP20IncomingRequestService() @@ -194,7 +193,6 @@ await describe('F01 & F02 - Remote Start Transaction', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: async () => Promise.resolve({}), }, @@ -202,7 +200,7 @@ await describe('F01 & F02 - Remote Start Transaction', async () => { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) const stationId = spyChargingStation.stationInfo?.chargingStationId ?? 'unknown' @@ -682,7 +680,6 @@ await describe('F01 & F02 - Remote Start Transaction', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME + '-FAIL-START', connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: async (_chargingStation: unknown, commandName: unknown) => { if (commandName === OCPP20RequestCommand.TRANSACTION_EVENT) { @@ -696,7 +693,7 @@ await describe('F01 & F02 - Remote Start Transaction', async () => { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) const failStationId = failStation.stationInfo?.chargingStationId ?? 'unknown' diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStopTransaction.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStopTransaction.test.ts index d2029e2d..45ec0027 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStopTransaction.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStopTransaction.test.ts @@ -303,7 +303,6 @@ await describe('F03 - Remote Stop Transaction', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME + '-FAIL', connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: async (_chargingStation: unknown, commandName: unknown) => { if (commandName === OCPP20RequestCommand.TRANSACTION_EVENT) { @@ -317,7 +316,7 @@ await describe('F03 - Remote Stop Transaction', async () => { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) const failStationId = failStation.stationInfo?.chargingStationId ?? 'unknown' diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-SetNetworkProfile.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-SetNetworkProfile.test.ts index 7191b61f..525bc75b 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-SetNetworkProfile.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-SetNetworkProfile.test.ts @@ -33,12 +33,11 @@ await describe('B43 - SetNetworkProfile', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = mockStation testableService = createTestableIncomingRequestService(new OCPP20IncomingRequestService()) diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-SetVariables.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-SetVariables.test.ts index 71261d59..487bf2f9 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-SetVariables.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-SetVariables.test.ts @@ -51,12 +51,11 @@ await describe('B05 - Set Variables', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) mockStation = station incomingRequestService = new OCPP20IncomingRequestService() @@ -75,14 +74,14 @@ await describe('B05 - Set Variables', async () => { setVariableData: [ { attributeType: AttributeEnumType.Actual, - attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL + 1).toString(), + attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL_SECONDS + 1).toString(), component: { name: OCPP20ComponentName.ChargingStation }, variable: { name: OCPP20OptionalVariableName.WebSocketPingInterval }, }, { attributeType: AttributeEnumType.Actual, attributeValue: ( - millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL) + 1 + millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL_MS) + 1 ).toString(), component: { name: OCPP20ComponentName.OCPPCommCtrlr }, variable: { name: OCPP20OptionalVariableName.HeartbeatInterval }, @@ -214,7 +213,7 @@ await describe('B05 - Set Variables', async () => { setVariableData: [ // Accepted { - attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL + 3).toString(), + attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL_SECONDS + 3).toString(), component: { name: OCPP20ComponentName.ChargingStation }, variable: { name: OCPP20OptionalVariableName.WebSocketPingInterval }, }, @@ -234,7 +233,7 @@ await describe('B05 - Set Variables', async () => { // Unsupported attribute type (WebSocketPingInterval) { attributeType: AttributeEnumType.Target, - attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL + 10).toString(), + attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL_SECONDS + 10).toString(), component: { name: OCPP20ComponentName.ChargingStation }, variable: { name: OCPP20OptionalVariableName.WebSocketPingInterval }, }, @@ -274,7 +273,7 @@ await describe('B05 - Set Variables', async () => { setVariableData: [ { attributeType: AttributeEnumType.Target, - attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL + 6).toString(), + attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL_SECONDS + 6).toString(), component: { name: OCPP20ComponentName.ChargingStation }, variable: { name: OCPP20OptionalVariableName.WebSocketPingInterval }, }, @@ -310,8 +309,8 @@ await describe('B05 - Set Variables', async () => { // FR: B07.FR.10 await it('should persist HeartbeatInterval and WebSocketPingInterval after setting', () => { - const hbNew = (millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL) + 20).toString() - const wsNew = (Constants.DEFAULT_WS_PING_INTERVAL + 20).toString() + const hbNew = (millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL_MS) + 20).toString() + const wsNew = (Constants.DEFAULT_WS_PING_INTERVAL_SECONDS + 20).toString() const setRequest: OCPP20SetVariablesRequest = { setVariableData: [ { @@ -400,13 +399,13 @@ await describe('B05 - Set Variables', async () => { const request: OCPP20SetVariablesRequest = { setVariableData: [ { - attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL + 2).toString(), + attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL_SECONDS + 2).toString(), component: { name: OCPP20ComponentName.ChargingStation }, variable: { name: OCPP20OptionalVariableName.WebSocketPingInterval }, }, { attributeValue: ( - millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL) + 2 + millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL_MS) + 2 ).toString(), component: { name: OCPP20ComponentName.OCPPCommCtrlr }, variable: { name: OCPP20OptionalVariableName.HeartbeatInterval }, diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-TriggerMessage.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-TriggerMessage.test.ts index a0730e3a..7867bd8c 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-TriggerMessage.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-TriggerMessage.test.ts @@ -44,14 +44,13 @@ function createTriggerMessageStation (): { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: requestHandlerMock, }, stationInfo: { ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) const mockStation = station as MockChargingStation return { mockStation, requestHandlerMock } @@ -564,14 +563,13 @@ await describe('F06 - TriggerMessage', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: rejectingMock, }, stationInfo: { ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) const request: OCPP20TriggerMessageRequest = { diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-UnlockConnector.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-UnlockConnector.test.ts index f31dc83a..09d14464 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-UnlockConnector.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-UnlockConnector.test.ts @@ -41,14 +41,13 @@ function createUnlockConnectorStation (): { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: requestHandlerMock, }, stationInfo: { ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) return { mockStation: station as MockChargingStation, requestHandlerMock } } @@ -164,14 +163,13 @@ await describe('F05 - UnlockConnector', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 2, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: requestHandlerMock, }, stationInfo: { ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) const multiConnectorStation = station as MockChargingStation diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-UpdateFirmware.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-UpdateFirmware.test.ts index 239dedce..4b120bb5 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-UpdateFirmware.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-UpdateFirmware.test.ts @@ -44,12 +44,11 @@ await describe('L01/L02 - UpdateFirmware', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = mockStation testableService = createTestableIncomingRequestService(new OCPP20IncomingRequestService()) @@ -83,7 +82,6 @@ await describe('L01/L02 - UpdateFirmware', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: mock.fn(async () => Promise.resolve({})), }, @@ -91,7 +89,7 @@ await describe('L01/L02 - UpdateFirmware', async () => { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) createStationWithCertificateManager(stationWithCert, certManager) @@ -118,12 +116,11 @@ await describe('L01/L02 - UpdateFirmware', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) createStationWithCertificateManager(stationWithCert, certManager) @@ -165,12 +162,11 @@ await describe('L01/L02 - UpdateFirmware', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 2, evseConfiguration: { evsesCount: 2 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) // Set an active transaction on EVSE 1's connector @@ -202,12 +198,11 @@ await describe('L01/L02 - UpdateFirmware', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 2, evseConfiguration: { evsesCount: 2 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) const request: OCPP20UpdateFirmwareRequest = { diff --git a/tests/charging-station/ocpp/2.0/OCPP20Integration-Certificate.test.ts b/tests/charging-station/ocpp/2.0/OCPP20Integration-Certificate.test.ts index 97d9d318..d4301e74 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20Integration-Certificate.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20Integration-Certificate.test.ts @@ -34,7 +34,6 @@ function createIntegrationStation (): ChargingStation { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: async () => Promise.resolve({}), }, @@ -42,7 +41,7 @@ function createIntegrationStation (): ChargingStation { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) return station } diff --git a/tests/charging-station/ocpp/2.0/OCPP20Integration.test.ts b/tests/charging-station/ocpp/2.0/OCPP20Integration.test.ts index 69d3b4e8..892ea862 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20Integration.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20Integration.test.ts @@ -37,7 +37,6 @@ function createIntegrationStation (): ChargingStation { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: async () => Promise.resolve({}), }, @@ -45,7 +44,7 @@ function createIntegrationStation (): ChargingStation { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) return station } diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-CallChain.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-CallChain.test.ts index 3f536b00..ee4c618c 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-CallChain.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-CallChain.test.ts @@ -43,12 +43,11 @@ await describe('OCPP 2.0 Request Call Chain — requestHandler → buildRequestP baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = mockStation }) diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-DataTransfer.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-DataTransfer.test.ts index a20ea121..7f0b2481 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-DataTransfer.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-DataTransfer.test.ts @@ -34,12 +34,11 @@ await describe('P02 - DataTransfer', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = newStation diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-FirmwareStatusNotification.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-FirmwareStatusNotification.test.ts index 4239018f..dada4577 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-FirmwareStatusNotification.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-FirmwareStatusNotification.test.ts @@ -35,12 +35,11 @@ await describe('J01 - FirmwareStatusNotification', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = newStation diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-ISO15118.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-ISO15118.test.ts index 6945a316..ef3498f7 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-ISO15118.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-ISO15118.test.ts @@ -41,12 +41,11 @@ await describe('OCPP20 ISO15118 Request Service', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = newStation }) @@ -208,12 +207,11 @@ await describe('OCPP20 ISO15118 Request Service', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = result.station }) @@ -334,12 +332,11 @@ await describe('OCPP20 ISO15118 Request Service', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = result.station }) diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-LogStatusNotification.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-LogStatusNotification.test.ts index 3c8a0534..cc4612e0 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-LogStatusNotification.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-LogStatusNotification.test.ts @@ -35,12 +35,11 @@ await describe('M04 - LogStatusNotification', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = newStation diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-MeterValues.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-MeterValues.test.ts index 7b99540d..9b1ad5e6 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-MeterValues.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-MeterValues.test.ts @@ -34,12 +34,11 @@ await describe('G01 - MeterValues', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = newStation diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts index 32b0d1b3..f9c4dd95 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts @@ -45,7 +45,6 @@ await describe('B07/B08 - NotifyReport', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { chargePointModel: TEST_CHARGE_POINT_MODEL, chargePointSerialNumber: TEST_CHARGE_POINT_SERIAL_NUMBER, @@ -54,7 +53,7 @@ await describe('B07/B08 - NotifyReport', async () => { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = createdStation }) diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-SecurityEventNotification.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-SecurityEventNotification.test.ts index 7988c353..e9c4b1d5 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-SecurityEventNotification.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-SecurityEventNotification.test.ts @@ -33,12 +33,11 @@ await describe('A04 - SecurityEventNotification', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = newStation diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-SignCertificate.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-SignCertificate.test.ts index 5139b6b9..4ad278be 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-SignCertificate.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-SignCertificate.test.ts @@ -34,12 +34,11 @@ await describe('I02 - SignCertificate Request', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = createdStation station.ocppConfiguration = { @@ -348,12 +347,11 @@ await describe('I02 - SignCertificate Request', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) stationWithoutCertManager.ocppConfiguration = { diff --git a/tests/charging-station/ocpp/2.0/OCPP20ResponseService-BootNotification.test.ts b/tests/charging-station/ocpp/2.0/OCPP20ResponseService-BootNotification.test.ts index a49a71d8..b8d36afe 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20ResponseService-BootNotification.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20ResponseService-BootNotification.test.ts @@ -43,13 +43,12 @@ function createBootNotificationStation (): MockChargingStation { const { station } = createMockChargingStation({ baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { // Bypass AJV schema validation — tests focus on handler logic ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) return station as MockChargingStation } diff --git a/tests/charging-station/ocpp/2.0/OCPP20ResponseService-SimpleHandlers.test.ts b/tests/charging-station/ocpp/2.0/OCPP20ResponseService-SimpleHandlers.test.ts index c2b80f60..a370e835 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20ResponseService-SimpleHandlers.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20ResponseService-SimpleHandlers.test.ts @@ -30,12 +30,11 @@ function createSimpleHandlerStation (): MockChargingStation { const { station } = createMockChargingStation({ baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) return station as MockChargingStation } diff --git a/tests/charging-station/ocpp/2.0/OCPP20ResponseService-TransactionEvent.test.ts b/tests/charging-station/ocpp/2.0/OCPP20ResponseService-TransactionEvent.test.ts index 1dd2826e..c992b065 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20ResponseService-TransactionEvent.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20ResponseService-TransactionEvent.test.ts @@ -83,12 +83,11 @@ await describe('D01 - TransactionEvent Response', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = mockStation // Set connector transactionId to the UUID string used in request payloads @@ -282,12 +281,11 @@ await describe('D01 - TransactionEvent Response', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 2, evseConfiguration: { evsesCount: 2 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) setupConnectorWithTransaction(multiStation, 1, { transactionId: 10 }) const connector1 = multiStation.getConnectorStatus(1) diff --git a/tests/charging-station/ocpp/2.0/OCPP20ServiceUtils-ReconnectDelay.test.ts b/tests/charging-station/ocpp/2.0/OCPP20ServiceUtils-ReconnectDelay.test.ts index d8c428b1..0f795840 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20ServiceUtils-ReconnectDelay.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20ServiceUtils-ReconnectDelay.test.ts @@ -17,7 +17,6 @@ import { OCPP20OptionalVariableName, OCPPVersion, } from '../../../../src/types/index.js' -import { Constants } from '../../../../src/utils/index.js' import { standardCleanup } from '../../../helpers/TestLifecycleHelpers.js' import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js' import { createMockChargingStation } from '../../ChargingStationTestUtils.js' @@ -74,7 +73,6 @@ await describe('OCPP20ServiceUtils.computeReconnectDelay', async () => { const { station: mockStation } = createMockChargingStation({ baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { chargingStationId: TEST_CHARGING_STATION_BASE_NAME, ocppVersion: OCPPVersion.VERSION_201, diff --git a/tests/charging-station/ocpp/2.0/OCPP20ServiceUtils-StatusNotification.test.ts b/tests/charging-station/ocpp/2.0/OCPP20ServiceUtils-StatusNotification.test.ts index 4dd47608..1543f643 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20ServiceUtils-StatusNotification.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20ServiceUtils-StatusNotification.test.ts @@ -29,12 +29,11 @@ await describe('OCPP20ServiceUtils', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 2, evseConfiguration: { evsesCount: 2 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: true, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) mockStation = station }) diff --git a/tests/charging-station/ocpp/2.0/OCPP20ServiceUtils-TransactionEvent.test.ts b/tests/charging-station/ocpp/2.0/OCPP20ServiceUtils-TransactionEvent.test.ts index 9e69ba96..d8c93355 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20ServiceUtils-TransactionEvent.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20ServiceUtils-TransactionEvent.test.ts @@ -99,7 +99,6 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: async () => Promise.resolve({} as EmptyObject), }, @@ -107,7 +106,7 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { ocppStrictCompliance: true, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) mockStation = station resetLimits(mockStation) @@ -333,7 +332,6 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: () => { throw new Error('Network error') @@ -343,7 +341,7 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { ocppStrictCompliance: true, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) const connectorId = 1 @@ -507,7 +505,6 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: () => { throw new Error('Context test error') @@ -517,7 +514,7 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { ocppStrictCompliance: true, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) const connectorId = 1 @@ -588,7 +585,6 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: async () => Promise.resolve({} as EmptyObject), }, @@ -596,7 +592,7 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { ocppStrictCompliance: true, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) mockStation = station resetLimits(mockStation) @@ -1935,7 +1931,6 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: errorOnSecondMock, }, @@ -1943,7 +1938,7 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { ocppStrictCompliance: true, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) errorStation.isWebSocketConnectionOpened = () => false @@ -2278,7 +2273,6 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: () => { throw new Error('Network timeout') @@ -2288,7 +2282,7 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { ocppStrictCompliance: true, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) // Mock WebSocket as open @@ -2330,7 +2324,7 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { await it('should return default interval when TxUpdatedInterval is not configured', () => { const interval = OCPP20ServiceUtils.getTxUpdatedInterval(station) - assert.strictEqual(interval, Constants.DEFAULT_TX_UPDATED_INTERVAL * 1000) + assert.strictEqual(interval, Constants.DEFAULT_TX_UPDATED_INTERVAL_SECONDS * 1000) }) await it('should return configured interval in milliseconds', () => { @@ -2360,7 +2354,7 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { const interval = OCPP20ServiceUtils.getTxUpdatedInterval(station) - assert.strictEqual(interval, Constants.DEFAULT_TX_UPDATED_INTERVAL * 1000) + assert.strictEqual(interval, Constants.DEFAULT_TX_UPDATED_INTERVAL_SECONDS * 1000) }) await it('should return default for zero value', () => { @@ -2375,7 +2369,7 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { const interval = OCPP20ServiceUtils.getTxUpdatedInterval(station) - assert.strictEqual(interval, Constants.DEFAULT_TX_UPDATED_INTERVAL * 1000) + assert.strictEqual(interval, Constants.DEFAULT_TX_UPDATED_INTERVAL_SECONDS * 1000) }) await it('should return default for negative value', () => { @@ -2390,7 +2384,7 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { const interval = OCPP20ServiceUtils.getTxUpdatedInterval(station) - assert.strictEqual(interval, Constants.DEFAULT_TX_UPDATED_INTERVAL * 1000) + assert.strictEqual(interval, Constants.DEFAULT_TX_UPDATED_INTERVAL_SECONDS * 1000) }) }) @@ -2704,7 +2698,6 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: async () => Promise.resolve({} as EmptyObject), }, @@ -2712,7 +2705,7 @@ await describe('OCPP20 TransactionEvent ServiceUtils', async () => { ocppStrictCompliance: true, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = s resetLimits(station) diff --git a/tests/charging-station/ocpp/2.0/OCPP20TestUtils.ts b/tests/charging-station/ocpp/2.0/OCPP20TestUtils.ts index 1752fc4a..e9950d8e 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20TestUtils.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20TestUtils.ts @@ -136,7 +136,6 @@ export function createMockStationWithRequestTracking (): MockStationWithTracking baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: requestHandlerMock, }, @@ -144,7 +143,7 @@ export function createMockStationWithRequestTracking (): MockStationWithTracking ocppStrictCompliance: true, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station.isWebSocketConnectionOpened = () => isOnline @@ -182,13 +181,12 @@ export function createOCPP20RequestTestContext ( baseName, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, ...stationInfo, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) return { requestService, station, testableRequestService } @@ -486,13 +484,12 @@ export const ResetTestFixtures = { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, resetTime: 5000, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) const mockStation = station as MockChargingStation mockStation.getNumberOfRunningTransactions = () => runningTransactions @@ -699,7 +696,6 @@ export function createOCPP20ListenerStation (baseName: string): { baseName, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppRequestService: { requestHandler: requestHandlerMock, }, @@ -707,7 +703,7 @@ export function createOCPP20ListenerStation (baseName: string): { ocppStrictCompliance: false, ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) return { requestHandlerMock, station } } diff --git a/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts b/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts index bced6777..ead290f8 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts @@ -76,7 +76,6 @@ await describe('B05 - OCPP20VariableManager', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, ocppConfiguration: { configurationKey: [ { @@ -85,7 +84,7 @@ await describe('B05 - OCPP20VariableManager', async () => { StandardParametersKey.HeartbeatInterval ), readonly: false, - value: millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL).toString(), + value: millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL_MS).toString(), }, { key: buildConfigKey( @@ -93,14 +92,14 @@ await describe('B05 - OCPP20VariableManager', async () => { StandardParametersKey.WebSocketPingInterval ), readonly: false, - value: Constants.DEFAULT_WS_PING_INTERVAL.toString(), + value: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS.toString(), }, ], }, stationInfo: { ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = newStation }) @@ -149,7 +148,7 @@ await describe('B05 - OCPP20VariableManager', async () => { assert.strictEqual(result[0].attributeType, AttributeEnumType.Actual) assert.strictEqual( result[0].attributeValue, - millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL).toString() + millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL_MS).toString() ) assert.strictEqual(result[0].component.name, OCPP20ComponentName.OCPPCommCtrlr) assert.strictEqual(result[0].variable.name, OCPP20OptionalVariableName.HeartbeatInterval) @@ -159,7 +158,7 @@ await describe('B05 - OCPP20VariableManager', async () => { assert.strictEqual(result[1].attributeType, AttributeEnumType.Actual) assert.strictEqual( result[1].attributeValue, - Constants.DEFAULT_EV_CONNECTION_TIMEOUT.toString() + Constants.DEFAULT_EV_CONNECTION_TIMEOUT_SECONDS.toString() ) assert.strictEqual(result[1].component.name, OCPP20ComponentName.TxCtrlr) assert.strictEqual(result[1].variable.name, OCPP20RequiredVariableName.EVConnectionTimeOut) @@ -359,7 +358,7 @@ await describe('B05 - OCPP20VariableManager', async () => { assert.strictEqual(result[0].attributeType, AttributeEnumType.Actual) assert.strictEqual( result[0].attributeValue, - millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL).toString() + millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL_MS).toString() ) assert.strictEqual(result[0].component.name, OCPP20ComponentName.OCPPCommCtrlr) assert.strictEqual(result[0].variable.name, OCPP20OptionalVariableName.HeartbeatInterval) @@ -367,14 +366,20 @@ await describe('B05 - OCPP20VariableManager', async () => { // Second variable: WebSocketPingInterval assert.strictEqual(result[1].attributeStatus, GetVariableStatusEnumType.Accepted) assert.strictEqual(result[1].attributeType, AttributeEnumType.Actual) - assert.strictEqual(result[1].attributeValue, Constants.DEFAULT_WS_PING_INTERVAL.toString()) + assert.strictEqual( + result[1].attributeValue, + Constants.DEFAULT_WS_PING_INTERVAL_SECONDS.toString() + ) assert.strictEqual(result[1].component.name, OCPP20ComponentName.ChargingStation) assert.strictEqual(result[1].variable.name, OCPP20OptionalVariableName.WebSocketPingInterval) assert.strictEqual(result[1].attributeStatusInfo, undefined) // Third variable: MessageTimeout assert.strictEqual(result[2].attributeStatus, GetVariableStatusEnumType.Accepted) assert.strictEqual(result[2].attributeType, AttributeEnumType.Actual) - assert.strictEqual(result[2].attributeValue, Constants.DEFAULT_MESSAGE_TIMEOUT.toString()) + assert.strictEqual( + result[2].attributeValue, + Constants.DEFAULT_MESSAGE_TIMEOUT_SECONDS.toString() + ) assert.strictEqual(result[2].component.name, OCPP20ComponentName.OCPPCommCtrlr) assert.strictEqual(result[2].component.instance, 'Default') assert.strictEqual(result[2].variable.name, OCPP20RequiredVariableName.MessageTimeout) @@ -486,14 +491,14 @@ await describe('B05 - OCPP20VariableManager', async () => { await it('should accept setting writable variables (Actual default)', () => { const request: OCPP20SetVariableDataType[] = [ { - attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL + 1).toString(), + attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL_SECONDS + 1).toString(), component: { name: OCPP20ComponentName.ChargingStation }, variable: { name: OCPP20OptionalVariableName.WebSocketPingInterval }, }, { attributeType: AttributeEnumType.Actual, attributeValue: ( - millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL) + 1 + millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL_MS) + 1 ).toString(), component: { name: OCPP20ComponentName.OCPPCommCtrlr }, variable: { name: OCPP20OptionalVariableName.HeartbeatInterval }, @@ -598,7 +603,7 @@ await describe('B05 - OCPP20VariableManager', async () => { await it('should handle multiple mixed SetVariables in one call', () => { const request: OCPP20SetVariableDataType[] = [ { - attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL + 2).toString(), + attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL_SECONDS + 2).toString(), component: { name: OCPP20ComponentName.ChargingStation }, variable: { name: OCPP20OptionalVariableName.WebSocketPingInterval }, }, @@ -796,7 +801,7 @@ await describe('B05 - OCPP20VariableManager', async () => { const request: OCPP20SetVariableDataType[] = [ { attributeType: AttributeEnumType.Target, - attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL + 5).toString(), + attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL_SECONDS + 5).toString(), component: { name: OCPP20ComponentName.ChargingStation }, variable: { name: OCPP20OptionalVariableName.WebSocketPingInterval }, }, @@ -817,7 +822,7 @@ await describe('B05 - OCPP20VariableManager', async () => { const req: OCPP20SetVariableDataType[] = [ { attributeValue: ( - millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL) + 10 + millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL_MS) + 10 ).toString(), component: { name: OCPP20ComponentName.OCPPCommCtrlr }, variable: { name: OCPP20OptionalVariableName.HeartbeatInterval }, @@ -900,7 +905,7 @@ await describe('B05 - OCPP20VariableManager', async () => { ])[0] const posRes = manager.setVariables(station, [ { - attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL + 10).toString(), + attributeValue: (Constants.DEFAULT_WS_PING_INTERVAL_SECONDS + 10).toString(), component: { name: OCPP20ComponentName.ChargingStation }, variable: { name: OCPP20OptionalVariableName.WebSocketPingInterval }, }, @@ -959,7 +964,7 @@ await describe('B05 - OCPP20VariableManager', async () => { await it('should validate EVConnectionTimeOut positive integer >0 and reject invalid', () => { const okRes = manager.setVariables(station, [ { - attributeValue: (Constants.DEFAULT_EV_CONNECTION_TIMEOUT + 5).toString(), + attributeValue: (Constants.DEFAULT_EV_CONNECTION_TIMEOUT_SECONDS + 5).toString(), component: { name: OCPP20ComponentName.TxCtrlr }, variable: { name: OCPP20RequiredVariableName.EVConnectionTimeOut }, }, @@ -1030,7 +1035,7 @@ await describe('B05 - OCPP20VariableManager', async () => { await it('should validate MessageTimeout positive integer >0 and reject invalid', () => { const okRes = manager.setVariables(station, [ { - attributeValue: (Constants.DEFAULT_MESSAGE_TIMEOUT + 5).toString(), + attributeValue: (Constants.DEFAULT_MESSAGE_TIMEOUT_SECONDS + 5).toString(), component: { instance: 'Default', name: OCPP20ComponentName.OCPPCommCtrlr }, variable: { name: OCPP20RequiredVariableName.MessageTimeout }, }, @@ -1169,7 +1174,10 @@ await describe('B05 - OCPP20VariableManager', async () => { ])[0] assert.strictEqual(res.attributeStatus, GetVariableStatusEnumType.Accepted) assert.strictEqual(res.attributeStatusInfo, undefined) - assert.strictEqual(res.attributeValue, Constants.DEFAULT_EV_CONNECTION_TIMEOUT.toString()) + assert.strictEqual( + res.attributeValue, + Constants.DEFAULT_EV_CONNECTION_TIMEOUT_SECONDS.toString() + ) const after = getConfigurationKey( station, buildConfigKey(OCPP20ComponentName.TxCtrlr, OCPP20RequiredVariableName.EVConnectionTimeOut) @@ -1753,11 +1761,10 @@ await describe('B05 - OCPP20VariableManager', async () => { baseName: 'MMStation', connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) await it('should return NotSupportedAttributeType for MinSet HeartbeatInterval', () => { @@ -2220,23 +2227,21 @@ await describe('B05 - OCPP20VariableManager', async () => { baseName: 'StationA', connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { hashId: 'station-a-hash', ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) const { station: stationB } = createMockChargingStation({ baseName: 'StationB', connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { hashId: 'station-b-hash', ocppVersion: OCPPVersion.VERSION_201, }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) try { @@ -2269,7 +2274,10 @@ await describe('B05 - OCPP20VariableManager', async () => { }, ])[0] assert.strictEqual(resultB.attributeStatus, GetVariableStatusEnumType.Accepted) - assert.strictEqual(resultB.attributeValue, Constants.DEFAULT_EV_CONNECTION_TIMEOUT.toString()) + assert.strictEqual( + resultB.attributeValue, + Constants.DEFAULT_EV_CONNECTION_TIMEOUT_SECONDS.toString() + ) } finally { VARIABLE_REGISTRY[registryKey].defaultValue = originalDefault manager.invalidateMappingsCache() diff --git a/tests/charging-station/ocpp/OCPPServiceUtils-meterValues.test.ts b/tests/charging-station/ocpp/OCPPServiceUtils-meterValues.test.ts index 031f2e2f..0255a302 100644 --- a/tests/charging-station/ocpp/OCPPServiceUtils-meterValues.test.ts +++ b/tests/charging-station/ocpp/OCPPServiceUtils-meterValues.test.ts @@ -76,9 +76,8 @@ await describe('buildMeterValue', async () => { const { station: s } = createMockChargingStation({ baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_16 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = s const connectorStatus = station.getConnectorStatus(1) @@ -112,9 +111,8 @@ await describe('buildMeterValue', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: OCPPVersion.VERSION_201 }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, }) station = s const connectorStatus = station.getConnectorStatus(1) @@ -192,16 +190,14 @@ await describe('buildMeterValue', async () => { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, evseConfiguration: { evsesCount: 1 }, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: version }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, } : { baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 1, - heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL, stationInfo: { ocppVersion: version }, - websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL, + websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS, } const { station: s } = createMockChargingStation(opts) const connectorStatus = s.getConnectorStatus(1) diff --git a/tests/utils/Utils.test.ts b/tests/utils/Utils.test.ts index 84d3c423..3e84e211 100644 --- a/tests/utils/Utils.test.ts +++ b/tests/utils/Utils.test.ts @@ -537,20 +537,20 @@ await describe('Utils', async () => { ) }) - await it('should clamp values to safe timer range (0 to MAX_SETINTERVAL_DELAY)', () => { + await it('should clamp values to safe timer range (0 to MAX_SETINTERVAL_DELAY_MS)', () => { assert.strictEqual(clampToSafeTimerValue(0), 0) assert.strictEqual(clampToSafeTimerValue(1000), 1000) assert.strictEqual( - clampToSafeTimerValue(Constants.MAX_SETINTERVAL_DELAY), - Constants.MAX_SETINTERVAL_DELAY + clampToSafeTimerValue(Constants.MAX_SETINTERVAL_DELAY_MS), + Constants.MAX_SETINTERVAL_DELAY_MS ) assert.strictEqual( - clampToSafeTimerValue(Constants.MAX_SETINTERVAL_DELAY + 1), - Constants.MAX_SETINTERVAL_DELAY + clampToSafeTimerValue(Constants.MAX_SETINTERVAL_DELAY_MS + 1), + Constants.MAX_SETINTERVAL_DELAY_MS ) assert.strictEqual( clampToSafeTimerValue(Number.MAX_SAFE_INTEGER), - Constants.MAX_SETINTERVAL_DELAY + Constants.MAX_SETINTERVAL_DELAY_MS ) assert.strictEqual(clampToSafeTimerValue(-1), 0) assert.strictEqual(clampToSafeTimerValue(-1000), 0) -- 2.43.0