And more type convertion fixes.
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
"Configuration": { "configurationKey": [
{ "key": "NumberOfConnectors", "readonly": true, "value": 2},
{ "key": "param1", "readonly": false, "value": "test"},
- { "key": "meterValueInterval", "readonly": false, "value": 30},
+ { "key": "MeterValueSampleInterval", "readonly": false, "value": 30},
{ "key": "AuthorizeRemoteTxRequests", "readonly": false, "value": false}
]
},
"Configuration": { "configurationKey": [
{ "key": "NumberOfConnectors", "readonly": true, "value": 1},
{ "key": "param1", "readonly": false, "value": "test"},
- { "key": "meterValueInterval", "readonly": false, "value": 20},
+ { "key": "MeterValueSampleInterval", "readonly": false, "value": 20},
{ "key": "AuthorizeRemoteTxRequests", "readonly": false, "value": false}
]
},
"Configuration": { "configurationKey": [
{ "key": "NumberOfConnectors", "readonly": true, "value": 2},
{ "key": "param1", "readonly": false, "value": "test"},
- { "key": "meterValueInterval", "readonly": false, "value": 30},
+ { "key": "MeterValueSampleInterval", "readonly": false, "value": 30},
{ "key": "AuthorizeRemoteTxRequests", "readonly": false, "value": false}
]
},
"Configuration": { "configurationKey": [
{ "key": "NumberOfConnectors", "readonly": true, "value": 2},
{ "key": "param1", "readonly": false, "value": "test"},
- { "key": "meterValueInterval", "readonly": false, "value": 20},
+ { "key": "MeterValueSampleInterval", "readonly": false, "value": 20},
{ "key": "AuthorizeRemoteTxRequests", "readonly": false, "value": false}
]
},
"Configuration": { "configurationKey": [
{ "key": "NumberOfConnectors", "readonly": true, "value": 2},
{ "key": "param1", "readonly": false, "value": "test"},
- { "key": "meterValueInterval", "readonly": false, "value": 20},
+ { "key": "MeterValueSampleInterval", "readonly": false, "value": 20},
{ "key": "AuthorizeRemoteTxRequests", "readonly": false, "value": false}
]
},
"Configuration": { "configurationKey": [
{ "key": "NumberOfConnectors", "readonly": true, "value": 2},
{ "key": "param1", "readonly": false, "value": "test"},
- { "key": "meterValueInterval", "readonly": false, "value": 30},
+ { "key": "MeterValueSampleInterval", "readonly": false, "value": 30},
{ "key": "AuthorizeRemoteTxRequests", "readonly": false, "value": false}
]
},
"Configuration": { "configurationKey": [
{ "key": "NumberOfConnectors", "readonly": true, "value": 3},
{ "key": "param1", "readonly": false, "value": "test"},
- { "key": "meterValueInterval", "readonly": false, "value": 30},
+ { "key": "MeterValueSampleInterval", "readonly": false, "value": 30},
{ "key": "AuthorizeRemoteTxRequests", "readonly": false, "value": false}
]
},
"Configuration": { "configurationKey": [
{ "key": "NumberOfConnectors", "readonly": true, "value": 3},
{ "key": "param1", "readonly": false, "value": "test"},
- { "key": "meterValueInterval", "readonly": false, "value": 30},
+ { "key": "MeterValueSampleInterval", "readonly": false, "value": 30},
{ "key": "AuthorizeRemoteTxRequests", "readonly": false, "value": false}
]
},
"Configuration": { "configurationKey": [
{ "key": "NumberOfConnectors", "readonly": true, "value": 9},
{ "key": "param1", "readonly": false, "value": "test"},
- { "key": "meterValueInterval", "readonly": false, "value": 30},
+ { "key": "MeterValueSampleInterval", "readonly": false, "value": 30},
{ "key": "AuthorizeRemoteTxRequests", "readonly": false, "value": false}
]
},
_getAuthorizeRemoteTxRequests() {
const authorizeRemoteTxRequests = this._configuration.configurationKey.find((configElement) => configElement.key === 'AuthorizeRemoteTxRequests');
- return authorizeRemoteTxRequests ? authorizeRemoteTxRequests.value : false;
+ return authorizeRemoteTxRequests ? Utils.convertToBoolean(authorizeRemoteTxRequests.value) : false;
}
_buildChargingStation(index, stationTemplate) {
}
handleResponseStartTransaction(payload, requestPayload) {
+ // Reset connector transaction related attributes
this._connectors[requestPayload.connectorId].transactionStarted = false;
this._connectors[requestPayload.connectorId].idTag = requestPayload.idTag;
this._connectors[connector].lastSoC = 0;
logger.info(this._basicFormatLog() + ' Transaction ' + this._connectors[connector].transactionId + ' STARTED on ' + this._stationInfo.name + '#' + requestPayload.connectorId + ' with idTag ' + requestPayload.idTag);
this.sendStatusNotification(requestPayload.connectorId, 'Charging');
- const configuredMeterInterval = this._configuration.configurationKey.find((value) => value.key === 'meterValueInterval');
+ const configuredMeterValueSampleInterval = this._configuration.configurationKey.find((value) => value.key === 'MeterValueSampleInterval');
this.startMeterValues(requestPayload.connectorId,
- (configuredMeterInterval ? configuredMeterInterval.value * 1000 : 60000),
+ (configuredMeterValueSampleInterval ? configuredMeterValueSampleInterval.value * 1000 : 60000),
this);
}
}
async handleChangeConfiguration(commandPayload) {
const keyToChange = this._configuration.configurationKey.find((element) => element.key === commandPayload.key);
- if (keyToChange) {
- keyToChange.value = commandPayload.value;
+ if (keyToChange && !Utils.convertToBoolean(keyToChange.readonly)) {
+ const keyIndex = this._configuration.configurationKey.indexOf(keyToChange);
+ this._configuration.configurationKey[keyIndex].value = commandPayload.value;
return Constants.OCPP_RESPONSE_ACCEPTED;
}
return Constants.OCPP_RESPONSE_REJECTED;
// Persist previous value in connector
const connector = self._connectors[connectorID];
let consumption;
- consumption = Utils.getRandomInt(self._stationInfo.maxPower / 3600000 * interval, 3);
+ consumption = Utils.getRandomInt(self._stationInfo.maxPower / 3600000 * interval, 4);
if (connector && connector.lastConsumptionValue >= 0) {
connector.lastConsumptionValue += consumption;
} else {
return (Configuration.getConfig().hasOwnProperty('errorFile') ? Configuration.getConfig().errorFile : 'error.log');
}
- static getMeterValueInterval() {
+ static getMeterValueSampleInterval() {
// Read conf
- return (Configuration.getChargingStationConfiguration().hasOwnProperty('meterValueInterval') ? Configuration.getChargingStationConfiguration().meterValueInterval * 1000 : 60000);
+ return (Configuration.getChargingStationConfiguration().hasOwnProperty('MeterValueSampleInterval') ? Configuration.getChargingStationConfiguration().MeterValueSampleInterval * 1000 : 60000);
}
static getAutomaticTransactionConfiguration() {
return changedID;
}
+ static convertToBoolean(value) {
+ let result = false;
+ // Check boolean
+ if (value) {
+ // Check the type
+ if (typeof value === 'boolean') {
+ // Already a boolean
+ result = value;
+ } else {
+ // Convert
+ result = (value === 'true');
+ }
+ }
+ return result;
+ }
+
static getRandomInt(max, min) {
if (min) {
return Math.floor((Math.random() * (max - min)) + min);