From 9b25a525133f0b7d8e57a566dc1e841c97318d16 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 20 Oct 2020 19:51:51 +0200 Subject: [PATCH] Allow to specify a hardcoded value for metervalues in template. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../evlink.station-template.json | 4 +-- .../schneider-imredd.station-template.json | 4 +-- .../schneider.station-template.json | 4 +-- ...ate.json => siemens.station-template.json} | 4 +-- src/charging-station/ChargingStation.js | 28 +++++++++++-------- 5 files changed, 24 insertions(+), 20 deletions(-) rename src/assets/station-templates/{siemens.mougins69.station-template.json => siemens.station-template.json} (95%) diff --git a/src/assets/station-templates/evlink.station-template.json b/src/assets/station-templates/evlink.station-template.json index 1efb99f6..3acbbfb4 100644 --- a/src/assets/station-templates/evlink.station-template.json +++ b/src/assets/station-templates/evlink.station-template.json @@ -1,8 +1,8 @@ { "authorizationFile": "./src/assets/authorization-tags.json", "baseName": "CS-EVLINK", - "chargePointModel": "EVLINKXX213", - "chargePointVendor": "SCHNEIDER", + "chargePointModel": "MONOBLOCK", + "chargePointVendor": "Schneider Electric", "chargePointSerialNumberPrefix": "EV.2S7P04", "firmwareVersion": "3.3.0.10", "power": 7360, diff --git a/src/assets/station-templates/schneider-imredd.station-template.json b/src/assets/station-templates/schneider-imredd.station-template.json index 1660e4a4..f383008e 100644 --- a/src/assets/station-templates/schneider-imredd.station-template.json +++ b/src/assets/station-templates/schneider-imredd.station-template.json @@ -1,8 +1,8 @@ { "authorizationFile": "./src/assets/authorization-tags.json", "baseName": "CS-SCHNEIDER", - "chargePointModel": "SCHNEIDERXX213", - "chargePointVendor": "SCHNEIDER", + "chargePointModel": "MONOBLOCK", + "chargePointVendor": "Schneider Electric", "power": 44160, "powerUnit": "W", "numberOfConnectors": 2, diff --git a/src/assets/station-templates/schneider.station-template.json b/src/assets/station-templates/schneider.station-template.json index 54a71498..225ce0e7 100644 --- a/src/assets/station-templates/schneider.station-template.json +++ b/src/assets/station-templates/schneider.station-template.json @@ -1,8 +1,8 @@ { "authorizationFile": "./src/assets/authorization-tags.json", "baseName": "CS-SCHNEIDER", - "chargePointModel": "SCHNEIDERXX213", - "chargePointVendor": "SCHNEIDER", + "chargePointModel": "MONOBLOCK", + "chargePointVendor": "Schneider Electric", "chargePointSerialNumberPrefix": "EV.2S22P44", "power": 44160, "powerUnit": "W", diff --git a/src/assets/station-templates/siemens.mougins69.station-template.json b/src/assets/station-templates/siemens.station-template.json similarity index 95% rename from src/assets/station-templates/siemens.mougins69.station-template.json rename to src/assets/station-templates/siemens.station-template.json index 206526ad..e362505e 100644 --- a/src/assets/station-templates/siemens.mougins69.station-template.json +++ b/src/assets/station-templates/siemens.station-template.json @@ -1,8 +1,8 @@ { "authorizationFile": "./src/assets/authorization-tags.json", - "baseName": "SAP-Mougins-69", + "baseName": "CS-SIEMENS", "fixedName": true, - "chargePointModel": "SiemensXX213", + "chargePointModel": "SIEMENSXX213", "chargePointVendor": "SIEMENS", "power": 44160, "powerUnit": "W", diff --git a/src/charging-station/ChargingStation.js b/src/charging-station/ChargingStation.js index cb0cf3a5..34cd53d5 100644 --- a/src/charging-station/ChargingStation.js +++ b/src/charging-station/ChargingStation.js @@ -548,25 +548,29 @@ class ChargingStation { const connector = self._connectors[connectorID]; // SoC measurand if (sampledValueLcl.sampledValue[index].measurand && sampledValueLcl.sampledValue[index].measurand === 'SoC') { - sampledValueLcl.sampledValue[index].value = Utils.getRandomInt(100); + sampledValueLcl.sampledValue[index].value = sampledValueLcl.sampledValue[index].value ? + sampledValueLcl.sampledValue[index].value : + sampledValueLcl.sampledValue[index].value = Utils.getRandomInt(100); if (sampledValueLcl.sampledValue[index].value > 100 || debug) { logger.error(`${self._basicFormatLog()} MeterValues measurand ${sampledValueLcl.sampledValue[index].measurand ? sampledValueLcl.sampledValue[index].measurand : 'Energy.Active.Import.Register'}: connectorID ${connectorID}, transaction ${connector.transactionId}, value: ${sampledValueLcl.sampledValue[index].value}`); } // Voltage measurand } else if (sampledValueLcl.sampledValue[index].measurand && sampledValueLcl.sampledValue[index].measurand === 'Voltage') { - sampledValueLcl.sampledValue[index].value = 230; + sampledValueLcl.sampledValue[index].value = sampledValueLcl.sampledValue[index].value ? sampledValueLcl.sampledValue[index].value : 230; // Energy.Active.Import.Register measurand (default) } else if (!sampledValueLcl.sampledValue[index].measurand || sampledValueLcl.sampledValue[index].measurand === 'Energy.Active.Import.Register') { - // Persist previous value in connector - const consumption = Utils.getRandomInt(self._stationInfo.maxPower / 3600000 * interval); - if (connector && connector.lastConsumptionValue >= 0) { - connector.lastConsumptionValue += consumption; - } else { - connector.lastConsumptionValue = 0; + if (!sampledValueLcl.sampledValue[index].value) { + const measurandValue = Utils.getRandomInt(self._stationInfo.maxPower / 3600000 * interval); + // Persist previous value in connector + if (connector && connector.lastEnergyActiveImportRegisterValue >= 0) { + connector.lastEnergyActiveImportRegisterValue += measurandValue; + } else { + connector.lastEnergyActiveImportRegisterValue = 0; + } + sampledValueLcl.sampledValue[index].value = connector.lastEnergyActiveImportRegisterValue; } + logger.info(`${self._basicFormatLog()} MeterValues measurand ${sampledValueLcl.sampledValue[index].measurand ? sampledValueLcl.sampledValue[index].measurand : 'Energy.Active.Import.Register'}: connectorID ${connectorID}, transaction ${connector.transactionId}, value ${sampledValueLcl.sampledValue[index].value}`); const maxConsumption = self._stationInfo.maxPower * 3600 / interval; - logger.info(`${self._basicFormatLog()} MeterValues measurand ${sampledValueLcl.sampledValue[index].measurand ? sampledValueLcl.sampledValue[index].measurand : 'Energy.Active.Import.Register'}: connectorID ${connectorID}, transaction ${connector.transactionId}, value ${connector.lastConsumptionValue}`); - sampledValueLcl.sampledValue[index].value = connector.lastConsumptionValue; if (sampledValueLcl.sampledValue[index].value > maxConsumption || debug) { logger.error(`${self._basicFormatLog()} MeterValues measurand ${sampledValueLcl.sampledValue[index].measurand ? sampledValueLcl.sampledValue[index].measurand : 'Energy.Active.Import.Register'}: connectorID ${connectorID}, transaction ${connector.transactionId}, value: ${sampledValueLcl.sampledValue[index].value}/${maxConsumption}`); } @@ -684,7 +688,7 @@ class ChargingStation { this._connectors[connectorID].transactionStarted = false; this._connectors[connectorID].transactionId = null; this._connectors[connectorID].idTag = null; - this._connectors[connectorID].lastConsumptionValue = -1; + this._connectors[connectorID].lastEnergyActiveImportRegisterValue = -1; } _resetTransactionOnConnector(connectorID) { @@ -715,7 +719,7 @@ class ChargingStation { this._connectors[transactionConnectorId].transactionStarted = true; this._connectors[transactionConnectorId].transactionId = payload.transactionId; this._connectors[transactionConnectorId].idTag = requestPayload.idTag; - this._connectors[transactionConnectorId].lastConsumptionValue = 0; + this._connectors[transactionConnectorId].lastEnergyActiveImportRegisterValue = 0; this.sendStatusNotification(requestPayload.connectorId, 'Charging'); logger.info(this._basicFormatLog() + ' Transaction ' + payload.transactionId + ' STARTED on ' + this._stationInfo.name + '#' + requestPayload.connectorId + ' for idTag ' + requestPayload.idTag); const configuredMeterValueSampleInterval = this._getConfigurationKey('MeterValueSampleInterval'); -- 2.34.1