From: Jérôme Benoit Date: Sun, 18 Oct 2020 13:58:00 +0000 (+0200) Subject: Improve changeConfiguration. X-Git-Tag: v1.0.1-0~284 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=7d887a1b6453278a1afa38a882d4c38042ddee25;hp=61c2e33de75d3fb3b789ec4a50aad9e3e789894a;p=e-mobility-charging-stations-simulator.git Improve changeConfiguration. Signed-off-by: Jérôme Benoit --- diff --git a/src/assets/station-templates/abb.station-template.json b/src/assets/station-templates/abb.station-template.json index 922ec8f1..6faab078 100644 --- a/src/assets/station-templates/abb.station-template.json +++ b/src/assets/station-templates/abb.station-template.json @@ -35,7 +35,8 @@ "key": "VendorKey", "readonly": false, "value": "VendorValue", - "visible": false + "visible": false, + "reboot": true } ] }, diff --git a/src/charging-station/ChargingStation.js b/src/charging-station/ChargingStation.js index abfd9263..a99e4887 100644 --- a/src/charging-station/ChargingStation.js +++ b/src/charging-station/ChargingStation.js @@ -649,12 +649,18 @@ class ChargingStation { async handleChangeConfiguration(commandPayload) { const keyToChange = this._getConfigurationKey(commandPayload.key); - if (keyToChange && !Utils.convertToBoolean(keyToChange.readonly)) { + if (!keyToChange) { + return {status: Constants.OCPP_ERROR_NOT_SUPPORTED}; + } else if (keyToChange && Utils.convertToBoolean(keyToChange.readonly)) { + return Constants.OCPP_RESPONSE_REJECTED; + } else if (keyToChange && !Utils.convertToBoolean(keyToChange.readonly)) { const keyIndex = this._configuration.configurationKey.indexOf(keyToChange); this._configuration.configurationKey[keyIndex].value = commandPayload.value; + if (Utils.convertToBoolean(keyToChange.reboot)) { + return Constants.OCPP_RESPONSE_REBOOT_REQUIRED; + } return Constants.OCPP_RESPONSE_ACCEPTED; } - return Constants.OCPP_RESPONSE_REJECTED; } async handleRemoteStartTransaction(commandPayload) { diff --git a/src/utils/Constants.js b/src/utils/Constants.js index b5b55cc3..8873280f 100644 --- a/src/utils/Constants.js +++ b/src/utils/Constants.js @@ -103,6 +103,7 @@ class Constants { static OCPP_RESPONSE_ACCEPTED = {status: 'Accepted'}; static OCPP_RESPONSE_REJECTED = {status: 'Rejected'}; + static OCPP_RESPONSE_REBOOT_REQUIRED = {status: 'RebootRequired'}; static OCPP_SOCKET_TIMEOUT = 60000; // 60 sec static OCPP_JSON_CALL_MESSAGE = 2; // Client-to-Server static OCPP_JSON_CALL_RESULT_MESSAGE = 3; // Server-to-Client