From 291cb255bec471875566d94ea674b7f476a2b7a1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 13 Jun 2021 22:39:33 +0200 Subject: [PATCH] Add support for ConnectionTimeOut standard parameter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- README.md | 2 +- src/charging-station/ChargingStation.ts | 5 ++++- src/utils/Constants.ts | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0a24123d..5246171d 100644 --- a/README.md +++ b/README.md @@ -218,7 +218,7 @@ All kind of OCPP parameters are supported in a charging station template. The li - :white_check_mark: AuthorizeRemoteTxRequests (type: boolean) (units: -) - :x: ClockAlignedDataInterval (type: integer) (units: seconds) -- :x: ConnectionTimeOut (type: integer) (units: seconds) +- :white_check_mark: ConnectionTimeOut (type: integer) (units: seconds) - :x: GetConfigurationMaxKeys (type: integer) (units: -) - :white_check_mark: HeartbeatInterval (type: integer) (units: seconds) - :x: LocalAuthorizeOffline (type: boolean) (units: -) diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 10806bd2..e0845e75 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -707,13 +707,16 @@ export default class ChargingStation { // 0 for disabling private getConnectionTimeout(): number | undefined { + if (this.getConfigurationKey(StandardParametersKey.ConnectionTimeOut)) { + return parseInt(this.getConfigurationKey(StandardParametersKey.ConnectionTimeOut).value) ?? Constants.DEFAULT_CONNECTION_TIMEOUT; + } if (!Utils.isUndefined(this.stationInfo.connectionTimeout)) { return this.stationInfo.connectionTimeout; } if (!Utils.isUndefined(Configuration.getConnectionTimeout())) { return Configuration.getConnectionTimeout(); } - return 30; + return Constants.DEFAULT_CONNECTION_TIMEOUT; } // -1 for unlimited, 0 for disabling diff --git a/src/utils/Constants.ts b/src/utils/Constants.ts index 706ef41c..a7e274a7 100644 --- a/src/utils/Constants.ts +++ b/src/utils/Constants.ts @@ -36,4 +36,6 @@ export default class Constants { static readonly DEFAULT_WORKER_POOL_MIN_SIZE = 4; static readonly DEFAULT_WORKER_POOL_MAX_SIZE = 16; static readonly DEFAULT_CHARGING_STATIONS_PER_WORKER = 1; + + static readonly DEFAULT_CONNECTION_TIMEOUT = 30; } -- 2.34.1