import { ChargePointStatus } from '../types/ocpp/1.6/ChargePointStatus';
import ChargingStationInfo from '../types/ChargingStationInfo';
import Configuration from '../utils/Configuration';
-import Constants from '../utils/Constants.js';
+import Constants from '../utils/Constants';
import ElectricUtils from '../utils/ElectricUtils';
import MeasurandValues from '../types/MeasurandValues';
-import OCPPError from './OcppError.js';
+import OCPPError from './OcppError';
+import Requests from '../types/ocpp/1.6/Requests';
import Statistics from '../utils/Statistics';
import Utils from '../utils/Utils';
import WebSocket from 'ws';
private _autoReconnectRetryCount: number;
private _autoReconnectMaxRetries: number;
private _autoReconnectTimeout: number;
- private _requests: { [id: string]: [(payload?, requestPayload?) => void, (error?: OCPPError) => void, object] };
- private _messageQueue: any[];
+ private _requests: Requests;
+ private _messageQueue: string[];
private _automaticTransactionGeneration: AutomaticTransactionGenerator;
private _authorizedTags: string[];
private _heartbeatInterval: number;
constructor(index: number, stationTemplateFile: string) {
this._index = index;
this._stationTemplateFile = stationTemplateFile;
- this._connectors = {};
+ this._connectors = {} as Connectors;
this._initialize();
this._hasStopped = false;
this._autoReconnectMaxRetries = Configuration.getAutoReconnectMaxRetries(); // -1 for unlimited
this._autoReconnectTimeout = Configuration.getAutoReconnectTimeout() * 1000; // Ms, zero for disabling
- this._requests = {};
- this._messageQueue = [];
+ this._requests = {} as Requests;
+ this._messageQueue = [] as string[];
this._authorizedTags = this._loadAndGetAuthorizedTags();
}
if (this._hasSocketRestarted) {
this._startMessageSequence();
if (!Utils.isEmptyArray(this._messageQueue)) {
- this._messageQueue.forEach((message) => {
+ this._messageQueue.forEach((message, index) => {
if (this._wsConnection && this._wsConnection.readyState === WebSocket.OPEN) {
+ this._messageQueue.splice(index, 1);
this._wsConnection.send(message);
}
});
-import CommandStatisticsData from '../types/CommandStatisticsData';
+import CommandStatistics, { CommandStatisticsData } from '../types/CommandStatistics';
+
import Configuration from './Configuration';
import Constants from './Constants';
import { PerformanceEntry } from 'perf_hooks';
export default class Statistics {
private static instance: Statistics;
private _objName: string;
- private _commandsStatistics: {
- [command: string]: CommandStatisticsData
- };
+ private _commandsStatistics: CommandStatistics;
private constructor() {
- this._commandsStatistics = {};
+ this._commandsStatistics = {} as CommandStatistics;
}
set objName(objName: string) {