type ChargingStationOcppConfiguration,
type ChargingStationTemplate,
ConnectorPhaseRotation,
- ConnectorStatus,
+ type ConnectorStatus,
ConnectorStatusEnum,
CurrentType,
type ErrorCallback,
RegistrationStatusEnumType,
RequestCommand,
type Response,
- type ResponseCallback,
StandardParametersKey,
type StatusNotificationRequest,
type StatusNotificationResponse,
return localAuthListEnabled ? Utils.convertToBoolean(localAuthListEnabled.value) : false;
}
+ public getHeartbeatInterval(): number {
+ const HeartbeatInterval = ChargingStationConfigurationUtils.getConfigurationKey(
+ this,
+ StandardParametersKey.HeartbeatInterval
+ );
+ if (HeartbeatInterval) {
+ return Utils.convertToInt(HeartbeatInterval.value) * 1000;
+ }
+ const HeartBeatInterval = ChargingStationConfigurationUtils.getConfigurationKey(
+ this,
+ StandardParametersKey.HeartBeatInterval
+ );
+ if (HeartBeatInterval) {
+ return Utils.convertToInt(HeartBeatInterval.value) * 1000;
+ }
+ this.stationInfo?.autoRegister === false &&
+ logger.warn(
+ `${this.logPrefix()} Heartbeat interval configuration key not set, using default value: ${
+ Constants.DEFAULT_HEARTBEAT_INTERVAL
+ }`
+ );
+ return Constants.DEFAULT_HEARTBEAT_INTERVAL;
+ }
+
public setSupervisionUrl(url: string): void {
if (
this.getSupervisionUrlOcppConfiguration() &&
}
public startHeartbeat(): void {
- if (
- this.getHeartbeatInterval() &&
- this.getHeartbeatInterval() > 0 &&
- !this.heartbeatSetInterval
- ) {
+ if (this.getHeartbeatInterval() > 0 && !this.heartbeatSetInterval) {
this.heartbeatSetInterval = setInterval(() => {
this.ocppRequestService
.requestHandler<HeartbeatRequest, HeartbeatResponse>(this, RequestCommand.HEARTBEAT)
);
} else {
logger.error(
- `${this.logPrefix()} Heartbeat interval set to ${
- this.getHeartbeatInterval()
- ? Utils.formatDurationMilliSeconds(this.getHeartbeatInterval())
- : this.getHeartbeatInterval()
- }, not starting the heartbeat`
+ `${this.logPrefix()} Heartbeat interval set to ${this.getHeartbeatInterval()}, not starting the heartbeat`
);
}
}
}
public openWSConnection(
- options: WsOptions = this.stationInfo?.wsOptions ?? Constants.EMPTY_OBJECT,
+ options: WsOptions = this.stationInfo?.wsOptions ?? {},
params: { closeOpened?: boolean; terminateOpened?: boolean } = {
closeOpened: false,
terminateOpened: false,
},
reset: true,
},
- stationTemplate?.firmwareUpgrade ?? Constants.EMPTY_OBJECT
+ stationTemplate?.firmwareUpgrade ?? {}
);
stationInfo.resetTime = !Utils.isNullOrUndefined(stationTemplate?.resetTime)
? stationTemplate.resetTime * 1000
fs.mkdirSync(path.dirname(this.configurationFile), { recursive: true });
}
const configurationData: ChargingStationConfiguration =
- Utils.cloneObject(this.getConfigurationFromFile()) ?? Constants.EMPTY_OBJECT;
+ Utils.cloneObject(this.getConfigurationFromFile()) ?? {};
this.ocppConfiguration?.configurationKey &&
(configurationData.configurationKey = this.ocppConfiguration.configurationKey);
this.stationInfo && (configurationData.stationInfo = this.stationInfo);
);
} else {
logger.error(
- `${this.logPrefix()} WebSocket ping interval set to ${
- webSocketPingInterval
- ? Utils.formatDurationSeconds(webSocketPingInterval)
- : webSocketPingInterval
- }, not starting the WebSocket ping`
+ `${this.logPrefix()} WebSocket ping interval set to ${webSocketPingInterval}, not starting the WebSocket ping`
);
}
}
private stopWebSocketPing(): void {
if (this.webSocketPingSetInterval) {
clearInterval(this.webSocketPingSetInterval);
+ delete this.webSocketPingSetInterval;
}
}
return new URL(supervisionUrls as string);
}
- private getHeartbeatInterval(): number {
- const HeartbeatInterval = ChargingStationConfigurationUtils.getConfigurationKey(
- this,
- StandardParametersKey.HeartbeatInterval
- );
- if (HeartbeatInterval) {
- return Utils.convertToInt(HeartbeatInterval.value) * 1000;
- }
- const HeartBeatInterval = ChargingStationConfigurationUtils.getConfigurationKey(
- this,
- StandardParametersKey.HeartBeatInterval
- );
- if (HeartBeatInterval) {
- return Utils.convertToInt(HeartBeatInterval.value) * 1000;
- }
- this.stationInfo?.autoRegister === false &&
- logger.warn(
- `${this.logPrefix()} Heartbeat interval configuration key not set, using default value: ${
- Constants.DEFAULT_HEARTBEAT_INTERVAL
- }`
- );
- return Constants.DEFAULT_HEARTBEAT_INTERVAL;
- }
-
private stopHeartbeat(): void {
if (this.heartbeatSetInterval) {
clearInterval(this.heartbeatSetInterval);
+ delete this.heartbeatSetInterval;
}
}
);
this.openWSConnection(
{
- ...(this.stationInfo?.wsOptions ?? Constants.EMPTY_OBJECT),
+ ...(this.stationInfo?.wsOptions ?? {}),
handshakeTimeout: reconnectTimeout,
},
{ closeOpened: true }