From: Jérôme Benoit Date: Sat, 17 Oct 2020 22:46:53 +0000 (+0200) Subject: Make getConfiguration response smarter. X-Git-Tag: v1.0.1-0~294 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=facd8ebde74a5d3d16ed65f88d942abcbe79a1e0;p=e-mobility-charging-stations-simulator.git Make getConfiguration response smarter. 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 f256c37e..1fef0e8a 100644 --- a/src/assets/station-templates/abb.station-template.json +++ b/src/assets/station-templates/abb.station-template.json @@ -35,6 +35,12 @@ "key": "AuthorizeRemoteTxRequests", "readonly": false, "value": false + }, + { + "key": "VendorKey", + "readonly": false, + "value": "VendorValue", + "visible": false } ] }, diff --git a/src/charging-station/ChargingStation.js b/src/charging-station/ChargingStation.js index 38e9f582..91232e5f 100644 --- a/src/charging-station/ChargingStation.js +++ b/src/charging-station/ChargingStation.js @@ -531,22 +531,22 @@ class ChargingStation { handleResponseStopTransaction(payload, requestPayload) { if (payload.idTagInfo && payload.idTagInfo.status) { - logger.debug(this._basicFormatLog() + ' Stop transaction ' + requestPayload.transactionId + ' response status: ' + payload.idTagInfo.status ); + logger.debug(this._basicFormatLog() + ' Stop transaction ' + requestPayload.transactionId + ' response status: ' + payload.idTagInfo.status); } else { logger.debug(this._basicFormatLog() + ' Stop transaction ' + requestPayload.transactionId + ' response status: Unknown'); } } - handleResponseStatusNotification(payload) { - logger.debug(this._basicFormatLog() + ' Status notification response received: %j', payload); + handleResponseStatusNotification(payload, requestPayload) { + logger.debug(this._basicFormatLog() + ' Status notification response received: %j to status notification request: %j', payload, requestPayload); } - handleResponseMeterValues(payload) { - logger.debug(this._basicFormatLog() + ' MeterValues response received: %j', payload); + handleResponseMeterValues(payload, requestPayload) { + logger.debug(this._basicFormatLog() + ' MeterValues response received: %j to MeterValues request: %j', payload, requestPayload); } - handleResponseHeartbeat(payload) { - logger.debug(this._basicFormatLog() + ' Heartbeat response received: %j', payload); + handleResponseHeartbeat(payload, requestPayload) { + logger.debug(this._basicFormatLog() + ' Heartbeat response received: %j to Heartbeat request: %j', payload, requestPayload); } async handleRequest(messageId, commandName, commandPayload) { @@ -560,7 +560,7 @@ class ChargingStation { } catch (error) { // Log logger.error(this._basicFormatLog() + ' Handle request error: ' + error); - // Send back response to inform back end + // Send back response to inform backend await this.sendError(messageId, error); } } else { @@ -573,7 +573,27 @@ class ChargingStation { } async handleGetConfiguration(commandPayload) { - return this._configuration; + const configurationKey = []; + const unknownKey = []; + for (const configuration of this._configuration.configurationKey) { + if (Utils.isUndefined(configuration.visible)) { + configuration.visible = true; + } else { + configuration.visible = Utils.convertToBoolean(configuration.visible); + } + if (!configuration.visible) { + continue; + } + configurationKey.push({ + key: configuration.key, + readonly: configuration.readonly, + value: configuration.value, + }); + } + return { + configurationKey, + unknownKey, + }; } async handleChangeConfiguration(commandPayload) { diff --git a/src/utils/Utils.js b/src/utils/Utils.js index 5f467fea..446f5241 100644 --- a/src/utils/Utils.js +++ b/src/utils/Utils.js @@ -135,6 +135,13 @@ class Utils { static cloneJSonDocument(jsonDocument) { return JSON.parse(JSON.stringify(jsonDocument)); } + + static isUndefined(value) { + if (typeof value === 'undefined') { + return true; + } + return false; + } } module.exports = Utils;