- 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)
)
logged = true
}
- await sleep(Constants.DEFAULT_ATG_WAIT_TIME)
+ await sleep(Constants.DEFAULT_ATG_WAIT_TIME_MS)
}
}
)
logged = true
}
- await sleep(Constants.DEFAULT_ATG_WAIT_TIME)
+ await sleep(Constants.DEFAULT_ATG_WAIT_TIME_MS)
}
}
)
logged = true
}
- await sleep(Constants.DEFAULT_ATG_WAIT_TIME)
+ await sleep(Constants.DEFAULT_ATG_WAIT_TIME_MS)
}
}
}
return await new Promise<string>((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,
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
}
/**
}
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 {
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 {
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,
}
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)
jitterPercent: 0.2,
retryNumber: this.wsConnectionRetryCount,
})
- : secondsToMilliseconds(Constants.DEFAULT_WS_RECONNECT_DELAY)
+ : secondsToMilliseconds(Constants.DEFAULT_WS_RECONNECT_DELAY_SECONDS)
}
private getStationInfo (options?: ChargingStationOptions): ChargingStationInfo {
addConfigurationKey(
this,
StandardParametersKey.ConnectionTimeOut,
- Constants.DEFAULT_EV_CONNECTION_TIMEOUT.toString()
+ Constants.DEFAULT_EV_CONNECTION_TIMEOUT_SECONDS.toString()
)
}
this.saveOcppConfiguration()
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,
})
)
++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)}`
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<void> {
)
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,
connectorId,
configuredMeterValueSampleInterval != null
? secondsToMilliseconds(convertToInt(configuredMeterValueSampleInterval.value))
- : Constants.DEFAULT_METER_VALUES_INTERVAL
+ : Constants.DEFAULT_METER_VALUES_INTERVAL_MS
)
} else {
logger.warn(
chargingStation,
OCPP20ComponentName.SampledDataCtrlr,
OCPP20RequiredVariableName.TxUpdatedInterval,
- Constants.DEFAULT_TX_UPDATED_INTERVAL
+ Constants.DEFAULT_TX_UPDATED_INTERVAL_SECONDS
)
}
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)
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,
)]: {
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,
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,
)]: {
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,
)]: {
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,
[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,
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
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}'`,
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)
} 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'
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
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
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'
reconnectExponentialDelay: false,
registrationMaxRetries: -1,
remoteAuthorization: true,
- resetTime: 30000, // Ms
+ resetTime: 30000,
stationInfoPersistentConfiguration: true,
stopTransactionsOnStopped: true,
supervisionUrlOcppConfiguration: false,
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({})
// 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
}
* @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)
}
/**
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,
})
export const DEFAULT_WORKER_OPTIONS: Readonly<WorkerOptions> = 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,
})
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 {
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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 = {
const { station } = createMockChargingStation({
baseName: TEST_CHARGING_STATION_BASE_NAME,
connectorsCount: 2,
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: () => Promise.resolve({}),
},
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)
const { station: mockStation } = createMockChargingStation({
baseName: TEST_CHARGING_STATION_BASE_NAME,
connectorsCount: 2,
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: async () => Promise.resolve({} as JsonType),
},
ocppStrictCompliance: false,
ocppVersion: OCPPVersion.VERSION_16,
},
- websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL,
+ websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS,
})
station = mockStation
})
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
}
* 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'
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 }
const { station } = createMockChargingStation({
baseName,
connectorsCount: 2,
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: requestHandlerMock,
},
ocppStrictCompliance: false,
ocppVersion: OCPPVersion.VERSION_16,
},
- websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL,
+ websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS,
})
return { requestHandlerMock, station }
}
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 }
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 }
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
upsertConfigurationKey(
chargingStation,
OCPP16StandardParametersKey.HeartbeatInterval,
- Constants.DEFAULT_HEARTBEAT_INTERVAL.toString()
+ millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL_MS).toString()
)
}
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
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(
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)
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()
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())
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())
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
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 =
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(),
},
],
},
ocppStrictCompliance: false,
ocppVersion: OCPPVersion.VERSION_201,
},
- websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL,
+ websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS,
})
station = mockStation
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
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
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())
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())
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()
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)
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)
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
baseName: TEST_CHARGING_STATION_BASE_NAME,
connectorsCount: 3,
evseConfiguration: { evsesCount: 3 },
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: async () => Promise.resolve({}),
},
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()
baseName: TEST_CHARGING_STATION_BASE_NAME,
connectorsCount: 3,
evseConfiguration: { evsesCount: 3 },
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: async () => Promise.resolve({}),
},
ocppStrictCompliance: false,
ocppVersion: OCPPVersion.VERSION_201,
},
- websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL,
+ websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS,
})
mockStation = station
incomingRequestService = new OCPP20IncomingRequestService()
baseName: TEST_CHARGING_STATION_BASE_NAME,
connectorsCount: 3,
evseConfiguration: { evsesCount: 3 },
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: async () => Promise.resolve({}),
},
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'
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) {
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'
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) {
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'
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())
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()
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 },
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 },
},
// 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 },
},
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 },
},
// 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: [
{
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 },
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 }
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 = {
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 }
}
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
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())
baseName: TEST_CHARGING_STATION_BASE_NAME,
connectorsCount: 1,
evseConfiguration: { evsesCount: 1 },
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: mock.fn(async () => Promise.resolve({})),
},
ocppStrictCompliance: false,
ocppVersion: OCPPVersion.VERSION_201,
},
- websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL,
+ websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS,
})
createStationWithCertificateManager(stationWithCert, certManager)
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)
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
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 = {
baseName: TEST_CHARGING_STATION_BASE_NAME,
connectorsCount: 3,
evseConfiguration: { evsesCount: 3 },
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: async () => Promise.resolve({}),
},
ocppStrictCompliance: false,
ocppVersion: OCPPVersion.VERSION_201,
},
- websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL,
+ websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS,
})
return station
}
baseName: TEST_CHARGING_STATION_BASE_NAME,
connectorsCount: 3,
evseConfiguration: { evsesCount: 3 },
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: async () => Promise.resolve({}),
},
ocppStrictCompliance: false,
ocppVersion: OCPPVersion.VERSION_201,
},
- websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL,
+ websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS,
})
return station
}
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
})
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
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
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
})
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
})
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
})
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
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
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,
ocppStrictCompliance: false,
ocppVersion: OCPPVersion.VERSION_201,
},
- websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL,
+ websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS,
})
station = createdStation
})
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
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 = {
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 = {
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
}
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
}
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
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)
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'
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,
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
})
baseName: TEST_CHARGING_STATION_BASE_NAME,
connectorsCount: 3,
evseConfiguration: { evsesCount: 3 },
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: async () => Promise.resolve({} as EmptyObject),
},
ocppStrictCompliance: true,
ocppVersion: OCPPVersion.VERSION_201,
},
- websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL,
+ websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS,
})
mockStation = station
resetLimits(mockStation)
baseName: TEST_CHARGING_STATION_BASE_NAME,
connectorsCount: 1,
evseConfiguration: { evsesCount: 1 },
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: () => {
throw new Error('Network error')
ocppStrictCompliance: true,
ocppVersion: OCPPVersion.VERSION_201,
},
- websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL,
+ websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS,
})
const connectorId = 1
baseName: TEST_CHARGING_STATION_BASE_NAME,
connectorsCount: 1,
evseConfiguration: { evsesCount: 1 },
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: () => {
throw new Error('Context test error')
ocppStrictCompliance: true,
ocppVersion: OCPPVersion.VERSION_201,
},
- websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL,
+ websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS,
})
const connectorId = 1
baseName: TEST_CHARGING_STATION_BASE_NAME,
connectorsCount: 3,
evseConfiguration: { evsesCount: 3 },
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: async () => Promise.resolve({} as EmptyObject),
},
ocppStrictCompliance: true,
ocppVersion: OCPPVersion.VERSION_201,
},
- websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL,
+ websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS,
})
mockStation = station
resetLimits(mockStation)
baseName: TEST_CHARGING_STATION_BASE_NAME,
connectorsCount: 1,
evseConfiguration: { evsesCount: 1 },
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: errorOnSecondMock,
},
ocppStrictCompliance: true,
ocppVersion: OCPPVersion.VERSION_201,
},
- websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL,
+ websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS,
})
errorStation.isWebSocketConnectionOpened = () => false
baseName: TEST_CHARGING_STATION_BASE_NAME,
connectorsCount: 1,
evseConfiguration: { evsesCount: 1 },
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: () => {
throw new Error('Network timeout')
ocppStrictCompliance: true,
ocppVersion: OCPPVersion.VERSION_201,
},
- websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL,
+ websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS,
})
// Mock WebSocket as open
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', () => {
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', () => {
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', () => {
const interval = OCPP20ServiceUtils.getTxUpdatedInterval(station)
- assert.strictEqual(interval, Constants.DEFAULT_TX_UPDATED_INTERVAL * 1000)
+ assert.strictEqual(interval, Constants.DEFAULT_TX_UPDATED_INTERVAL_SECONDS * 1000)
})
})
baseName: TEST_CHARGING_STATION_BASE_NAME,
connectorsCount: 3,
evseConfiguration: { evsesCount: 3 },
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: async () => Promise.resolve({} as EmptyObject),
},
ocppStrictCompliance: true,
ocppVersion: OCPPVersion.VERSION_201,
},
- websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL,
+ websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS,
})
station = s
resetLimits(station)
baseName: TEST_CHARGING_STATION_BASE_NAME,
connectorsCount: 3,
evseConfiguration: { evsesCount: 3 },
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: requestHandlerMock,
},
ocppStrictCompliance: true,
ocppVersion: OCPPVersion.VERSION_201,
},
- websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL,
+ websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS,
})
station.isWebSocketConnectionOpened = () => isOnline
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 }
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
baseName,
connectorsCount: 3,
evseConfiguration: { evsesCount: 3 },
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppRequestService: {
requestHandler: requestHandlerMock,
},
ocppStrictCompliance: false,
ocppVersion: OCPPVersion.VERSION_201,
},
- websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL,
+ websocketPingInterval: Constants.DEFAULT_WS_PING_INTERVAL_SECONDS,
})
return { requestHandlerMock, station }
}
baseName: TEST_CHARGING_STATION_BASE_NAME,
connectorsCount: 3,
evseConfiguration: { evsesCount: 3 },
- heartbeatInterval: Constants.DEFAULT_HEARTBEAT_INTERVAL,
ocppConfiguration: {
configurationKey: [
{
StandardParametersKey.HeartbeatInterval
),
readonly: false,
- value: millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL).toString(),
+ value: millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL_MS).toString(),
},
{
key: buildConfigKey(
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
})
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)
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)
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)
// 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)
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 },
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 },
},
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 },
},
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 },
])[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 },
},
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 },
},
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 },
},
])[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)
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', () => {
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 {
},
])[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()
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)
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)
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)
)
})
- 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)