if (!Constants.SUPPORTED_MEASURANDS.includes(sampledValueTemplates[index]?.measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER)) {
logger.warn(`${this.logPrefix()} Unsupported MeterValues measurand ${measurand} ${phase ? `on phase ${phase} ` : ''}in template on connectorId ${connectorId}`);
} else if (phase && sampledValueTemplates[index]?.phase === phase && sampledValueTemplates[index]?.measurand === measurand
- && this.getConfigurationKey(StandardParametersKey.MeterValuesSampledData).value.includes(measurand)) {
+ && this.getConfigurationKey(StandardParametersKey.MeterValuesSampledData).value.includes(measurand)) {
return sampledValueTemplates[index];
} else if (!phase && !sampledValueTemplates[index].phase && sampledValueTemplates[index]?.measurand === measurand
&& this.getConfigurationKey(StandardParametersKey.MeterValuesSampledData).value.includes(measurand)) {
}
if (this.automaticTransactionGeneration.timeToStop) {
// The ATG might sleep
- void this.automaticTransactionGeneration.start();
+ this.automaticTransactionGeneration.start().catch(() => { });
}
}
}
const authorizationFile = this.getAuthorizationFile();
if (authorizationFile) {
try {
- fs.watch(authorizationFile).on('change', () => {
- try {
- logger.debug(this.logPrefix() + ' Authorization file ' + authorizationFile + ' have changed, reload');
- // Initialize authorizedTags
- this.authorizedTags = this.getAuthorizedTags();
- console.log('here');
- } catch (error) {
- logger.error(this.logPrefix() + ' Authorization file monitoring error: %j', error);
+ fs.watch(authorizationFile, (event, filename) => {
+ if (filename && event === 'change') {
+ try {
+ logger.debug(this.logPrefix() + ' Authorization file ' + authorizationFile + ' have changed, reload');
+ // Initialize authorizedTags
+ this.authorizedTags = this.getAuthorizedTags();
+ } catch (error) {
+ logger.error(this.logPrefix() + ' Authorization file monitoring error: %j', error);
+ }
}
});
} catch (error) {
private startStationTemplateFileMonitoring(): void {
try {
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
- fs.watch(this.stationTemplateFile).on('change', async (): Promise<void> => {
- try {
- logger.debug(this.logPrefix() + ' Template file ' + this.stationTemplateFile + ' have changed, reload');
- // Initialize
- this.initialize();
- // Restart the ATG
- if (!this.stationInfo.AutomaticTransactionGenerator.enable &&
- this.automaticTransactionGeneration) {
- await this.automaticTransactionGeneration.stop();
- }
- this.startAutomaticTransactionGenerator();
- if (this.getEnableStatistics()) {
- this.performanceStatistics.restart();
- } else {
- this.performanceStatistics.stop();
+ fs.watch(this.stationTemplateFile, async (event, filename): Promise<void> => {
+ if (filename && event === 'change') {
+ try {
+ logger.debug(this.logPrefix() + ' Template file ' + this.stationTemplateFile + ' have changed, reload');
+ // Initialize
+ this.initialize();
+ // Restart the ATG
+ if (!this.stationInfo.AutomaticTransactionGenerator.enable &&
+ this.automaticTransactionGeneration) {
+ await this.automaticTransactionGeneration.stop();
+ }
+ this.startAutomaticTransactionGenerator();
+ if (this.getEnableStatistics()) {
+ this.performanceStatistics.restart();
+ } else {
+ this.performanceStatistics.stop();
+ }
+ // FIXME?: restart heartbeat and WebSocket ping when their interval values have changed
+ } catch (error) {
+ logger.error(this.logPrefix() + ' Charging station template file monitoring error: %j', error);
}
- // FIXME?: restart heartbeat and WebSocket ping when their interval values have changed
- } catch (error) {
- logger.error(this.logPrefix() + ' Charging station template file monitoring error: %j', error);
}
});
} catch (error) {
private static getConfigurationFileWatcher(): fs.FSWatcher {
try {
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
- return fs.watch(Configuration.configurationFilePath).on('change', async (): Promise<void> => {
- // Nullify to force configuration file reading
- Configuration.configuration = null;
- if (!Configuration.isUndefined(Configuration.configurationChangeCallback)) {
- await Configuration.configurationChangeCallback();
+ return fs.watch(Configuration.configurationFilePath, async (event, filename): Promise<void> => {
+ if (filename && event === 'change') {
+ // Nullify to force configuration file reading
+ Configuration.configuration = null;
+ if (!Configuration.isUndefined(Configuration.configurationChangeCallback)) {
+ await Configuration.configurationChangeCallback();
+ }
}
});
} catch (error) {