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() &&
);
} 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`
);
}
}
);
} 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`
);
}
}
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);
{ visible: false },
{ overwrite: true, save: true }
);
- chargingStation.heartbeatSetInterval
- ? chargingStation.restartHeartbeat()
- : chargingStation.startHeartbeat();
+ OCPP16ServiceUtils.startHeartbeatInterval(chargingStation, payload.interval);
}
if (Object.values(RegistrationStatusEnumType).includes(payload.status)) {
const logMsg = `${chargingStation.logPrefix()} Charging station in '${
RegistrationStatusEnumType,
type ResponseHandler,
} from '../../../types';
-import { Constants, logger } from '../../../utils';
+import { logger } from '../../../utils';
import { OCPP20ServiceUtils, OCPPResponseService } from '../internal';
const moduleName = 'OCPP20ResponseService';
{},
{ overwrite: true, save: true }
);
- chargingStation.heartbeatSetInterval
- ? chargingStation.restartHeartbeat()
- : chargingStation.startHeartbeat();
+ OCPP20ServiceUtils.startHeartbeatInterval(chargingStation, payload.interval);
}
if (Object.values(RegistrationStatusEnumType).includes(payload.status)) {
const logMsg = `${chargingStation.logPrefix()} Charging station in '${
}
}
+ public static startHeartbeatInterval(chargingStation: ChargingStation, interval: number): void {
+ if (!chargingStation.heartbeatSetInterval) {
+ chargingStation.startHeartbeat();
+ } else if (chargingStation.getHeartbeatInterval() !== interval) {
+ chargingStation.restartHeartbeat();
+ }
+ }
+
protected static parseJsonSchemaFile<T extends JsonType>(
filePath: string,
ocppVersion: OCPPVersion,
}
public stop(): void {
- if (this.displayInterval) {
- clearInterval(this.displayInterval);
- delete this.displayInterval;
- }
+ this.stopLogStatisticsInterval();
performance.clearMarks();
performance.clearMeasures();
this.performanceObserver?.disconnect();
}
private startLogStatisticsInterval(): void {
- if (Configuration.getLogStatisticsInterval() > 0 && !this.displayInterval) {
+ const logStatisticsInterval = Configuration.getLogStatisticsInterval();
+ if (logStatisticsInterval > 0 && !this.displayInterval) {
this.displayInterval = setInterval(() => {
this.logStatistics();
- }, Configuration.getLogStatisticsInterval() * 1000);
+ }, logStatisticsInterval * 1000);
logger.info(
- `${this.logPrefix()} logged every ${Utils.formatDurationSeconds(
- Configuration.getLogStatisticsInterval()
- )}`
+ `${this.logPrefix()} logged every ${Utils.formatDurationSeconds(logStatisticsInterval)}`
);
} else if (this.displayInterval) {
logger.info(
`${this.logPrefix()} already logged every ${Utils.formatDurationSeconds(
- Configuration.getLogStatisticsInterval()
+ logStatisticsInterval
)}`
);
} else {
logger.info(
- `${this.logPrefix()} log interval is set to ${Configuration.getLogStatisticsInterval()?.toString()}. Not logging statistics`
+ `${this.logPrefix()} log interval is set to ${logStatisticsInterval?.toString()}. Not logging statistics`
);
}
}
+ private stopLogStatisticsInterval(): void {
+ if (this.displayInterval) {
+ clearInterval(this.displayInterval);
+ delete this.displayInterval;
+ }
+ }
+
private median(dataSet: number[]): number {
if (Array.isArray(dataSet) === true && dataSet.length === 1) {
return dataSet[0];