-import { BootNotificationResponse, RegistrationStatus } from '../types/ocpp/RequestResponses';
+import { BootNotificationResponse, RegistrationStatus } from '../types/ocpp/Responses';
import ChargingStationConfiguration, { ConfigurationKey } from '../types/ChargingStationConfiguration';
import ChargingStationTemplate, { PowerOutType, VoltageOut } from '../types/ChargingStationTemplate';
import Connectors, { Connector } from '../types/Connectors';
public startHeartbeat(): void {
if (this.getHeartbeatInterval() && this.getHeartbeatInterval() > 0 && !this.heartbeatSetInterval) {
- this.heartbeatSetInterval = setInterval(async () => {
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
+ this.heartbeatSetInterval = setInterval(async (): Promise<void> => {
await this.ocppRequestService.sendHeartbeat();
}, this.getHeartbeatInterval());
logger.info(this.logPrefix() + ' Heartbeat started every ' + Utils.milliSecondsToHHMMSS(this.getHeartbeatInterval()));
return;
}
if (interval > 0) {
- this.getConnector(connectorId).transactionSetInterval = setInterval(async () => {
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
+ this.getConnector(connectorId).transactionSetInterval = setInterval(async (): Promise<void> => {
if (this.getEnableStatistics()) {
const sendMeterValues = performance.timerify(this.ocppRequestService.sendMeterValues);
this.performanceObserver.observe({
}
}
+ public addMessageToBuffer(message: string): void {
+ let dups = false;
+ // Handle dups in buffer
+ for (const bufferedMessage of this.messageQueue) {
+ // Same message
+ if (message === bufferedMessage) {
+ dups = true;
+ break;
+ }
+ }
+ if (!dups) {
+ // Buffer message
+ this.messageQueue.push(message);
+ }
+ }
+
private getChargingStationId(stationTemplate: ChargingStationTemplate): string {
// In case of multiple instances: add instance index to charging station id
let instanceIndex = process.env.CF_INSTANCE_INDEX ? process.env.CF_INSTANCE_INDEX : 0;
await Utils.sleep(this.bootNotificationResponse?.interval ? this.bootNotificationResponse.interval * 1000 : Constants.OCPP_DEFAULT_BOOT_NOTIFICATION_INTERVAL);
}
} while (!this.isRegistered() && (registrationRetryCount <= this.getRegistrationMaxRetries() || this.getRegistrationMaxRetries() === -1));
- }
- if (this.isRegistered()) {
+ } else if (this.isRegistered()) {
await this.startMessageSequence();
this.hasStopped && (this.hasStopped = false);
if (this.hasSocketRestarted && this.isWebSocketOpen()) {
}
private startStationTemplateFileMonitoring(): void {
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
fs.watch(this.stationTemplateFile).on('change', async (e): Promise<void> => {
try {
logger.debug(this.logPrefix() + ' Template file ' + this.stationTemplateFile + ' have changed, reload');