}
}
);
- FileUtils.watchJsonFile<ChargingStationConfiguration>(
- this.logPrefix(),
- FileType.ChargingStationConfiguration,
- this.configurationFile,
- this.configuration
- );
+ // FIXME: triggered by saveConfiguration()
+ // if (this.getOcppPersistentConfiguration()) {
+ // FileUtils.watchJsonFile<ChargingStationConfiguration>(
+ // this.logPrefix(),
+ // FileType.ChargingStationConfiguration,
+ // this.configurationFile,
+ // this.configuration
+ // );
+ // }
// Handle WebSocket message
this.wsConnection.on(
'message',
}
}
- private getSupervisionUrlOcppKey(): string {
- return this.stationInfo.supervisionUrlOcppKey ?? VendorDefaultParametersKey.ConnectionUrl;
- }
-
private getSupervisionUrlOcppConfiguration(): boolean {
return this.stationInfo.supervisionUrlOcppConfiguration ?? false;
}
+ private getSupervisionUrlOcppKey(): string {
+ return this.stationInfo.supervisionUrlOcppKey ?? VendorDefaultParametersKey.ConnectionUrl;
+ }
+
private getChargingStationId(stationTemplate: ChargingStationTemplate): string {
// In case of multiple instances: add instance index to charging station id
const instanceIndex = process.env.CF_INSTANCE_INDEX ?? 0;
return this.stationInfo.ocppVersion ? this.stationInfo.ocppVersion : OCPPVersion.VERSION_16;
}
+ private getOcppPersistentConfiguration(): boolean {
+ return this.stationInfo.ocppPersistentConfiguration ?? true;
+ }
+
private handleUnsupportedVersion(version: OCPPVersion) {
const errMsg = `${this.logPrefix()} Unsupported protocol version '${version}' configured in template file ${
this.stationTemplateFile
this.stationInfo = this.buildStationInfo();
this.configurationFile = path.join(
path.resolve(__dirname, '../'),
- 'assets',
- 'configurations',
+ 'assets/configurations',
this.stationInfo.chargingStationId + '.json'
);
this.configuration = this.getConfiguration();
private getConfigurationFromFile(): ChargingStationConfiguration | null {
let configuration: ChargingStationConfiguration = null;
- if (this.configurationFile && fs.existsSync(this.configurationFile)) {
+ if (
+ this.getOcppPersistentConfiguration() &&
+ this.configurationFile &&
+ fs.existsSync(this.configurationFile)
+ ) {
try {
configuration = JSON.parse(
fs.readFileSync(this.configurationFile, 'utf8')
}
private saveConfiguration(): void {
- if (this.configurationFile) {
- try {
- if (!fs.existsSync(path.dirname(this.configurationFile))) {
- fs.mkdirSync(path.dirname(this.configurationFile), { recursive: true });
+ if (this.getOcppPersistentConfiguration()) {
+ if (this.configurationFile) {
+ try {
+ if (!fs.existsSync(path.dirname(this.configurationFile))) {
+ fs.mkdirSync(path.dirname(this.configurationFile), { recursive: true });
+ }
+ const fileDescriptor = fs.openSync(this.configurationFile, 'w');
+ fs.writeFileSync(fileDescriptor, JSON.stringify(this.configuration, null, 2));
+ fs.closeSync(fileDescriptor);
+ } catch (error) {
+ FileUtils.handleFileException(
+ this.logPrefix(),
+ FileType.ChargingStationConfiguration,
+ this.configurationFile,
+ error as NodeJS.ErrnoException
+ );
}
- const fileDescriptor = fs.openSync(this.configurationFile, 'w');
- fs.writeFileSync(fileDescriptor, JSON.stringify(this.configuration, null, 2));
- fs.closeSync(fileDescriptor);
- } catch (error) {
- FileUtils.handleFileException(
- this.logPrefix(),
- FileType.ChargingStationConfiguration,
- this.configurationFile,
- error as NodeJS.ErrnoException
+ } else {
+ logger.error(
+ `${this.logPrefix()} Trying to save charging station configuration to undefined file`
);
}
- } else {
- logger.error(
- `${this.logPrefix()} Trying to save charging station configuration to undefined file`
- );
}
}
this.chargingStation.getConnectorStatus(authorizeConnectorId).idTagAuthorized = false;
delete this.chargingStation.getConnectorStatus(authorizeConnectorId).authorizeIdTag;
logger.debug(
- `${this.chargingStation.logPrefix()} IdTag ${requestPayload.idTag} refused with status ${
+ `${this.chargingStation.logPrefix()} IdTag ${requestPayload.idTag} refused with status '${
payload.idTagInfo.status
- } on connector ${authorizeConnectorId}`
+ }' on connector ${authorizeConnectorId}`
);
}
}
this.chargingStation.logPrefix() +
' Starting transaction id ' +
payload.transactionId.toString() +
- ' REJECTED with status ' +
+ " REJECTED with status '" +
payload?.idTagInfo?.status +
- ', idTag ' +
+ "', idTag " +
requestPayload.idTag
);
await this.resetConnectorOnStartTransactionError(connectorId);
this.chargingStation.logPrefix() +
' Stopping transaction id ' +
requestPayload.transactionId.toString() +
- ' REJECTED with status ' +
- payload.idTagInfo?.status
+ " REJECTED with status '" +
+ payload.idTagInfo?.status +
+ "'"
);
}
}