private configurationFileHash!: string;
private connectorsConfigurationHash!: string;
private evsesConfigurationHash!: string;
+ private automaticTransactionGeneratorConfiguration?: AutomaticTransactionGeneratorConfiguration;
private ocppIncomingRequestService!: OCPPIncomingRequestService;
private readonly messageBuffer: Set<string>;
private configuredSupervisionUrl!: URL;
// Initialize
this.initialize();
this.idTagsCache.deleteIdTags(getIdTagsFile(this.stationInfo)!);
+ delete this.automaticTransactionGeneratorConfiguration;
// Restart the ATG
this.stopAutomaticTransactionGenerator();
if (this.getAutomaticTransactionGeneratorConfiguration()?.enable === true) {
}
public getAutomaticTransactionGeneratorConfiguration(): AutomaticTransactionGeneratorConfiguration {
- let automaticTransactionGeneratorConfiguration:
- | AutomaticTransactionGeneratorConfiguration
- | undefined;
- const automaticTransactionGeneratorConfigurationFromFile =
- this.getConfigurationFromFile()?.automaticTransactionGenerator;
- if (
- this.getAutomaticTransactionGeneratorPersistentConfiguration() &&
- automaticTransactionGeneratorConfigurationFromFile
- ) {
- automaticTransactionGeneratorConfiguration =
- automaticTransactionGeneratorConfigurationFromFile;
- } else {
- automaticTransactionGeneratorConfiguration =
- this.getTemplateFromFile()?.AutomaticTransactionGenerator;
+ if (isNullOrUndefined(this.automaticTransactionGeneratorConfiguration)) {
+ let automaticTransactionGeneratorConfiguration:
+ | AutomaticTransactionGeneratorConfiguration
+ | undefined;
+ const automaticTransactionGeneratorConfigurationFromFile =
+ this.getConfigurationFromFile()?.automaticTransactionGenerator;
+ if (
+ this.getAutomaticTransactionGeneratorPersistentConfiguration() &&
+ automaticTransactionGeneratorConfigurationFromFile
+ ) {
+ automaticTransactionGeneratorConfiguration =
+ automaticTransactionGeneratorConfigurationFromFile;
+ } else {
+ automaticTransactionGeneratorConfiguration =
+ this.getTemplateFromFile()?.AutomaticTransactionGenerator;
+ }
+ this.automaticTransactionGeneratorConfiguration = {
+ ...Constants.DEFAULT_ATG_CONFIGURATION,
+ ...automaticTransactionGeneratorConfiguration,
+ };
}
- return {
- ...Constants.DEFAULT_ATG_CONFIGURATION,
- ...automaticTransactionGeneratorConfiguration,
- };
+ return this.automaticTransactionGeneratorConfiguration!;
}
public getAutomaticTransactionGeneratorStatuses(): Status[] | undefined {
'config.json',
);
- private static configurationFileWatcher: FSWatcher | undefined;
- private static configurationData: ConfigurationData | null = null;
+ private static configurationFileWatcher?: FSWatcher;
+ private static configurationData?: ConfigurationData;
private static configurationSectionCache = new Map<
ConfigurationSection,
ConfigurationSectionType
}
}
- private static getConfigurationData(): ConfigurationData | null {
+ private static getConfigurationData(): ConfigurationData | undefined {
if (!Configuration.configurationData) {
try {
Configuration.configurationData = JSON.parse(
try {
return watch(Configuration.configurationFile, (event, filename): void => {
if (filename!.trim()!.length > 0 && event === 'change') {
- // Nullify to force configuration file reading
- Configuration.configurationData = null;
+ delete Configuration.configurationData;
Configuration.configurationSectionCache.clear();
if (!isUndefined(Configuration.configurationChangeCallback)) {
Configuration.configurationChangeCallback().catch((error) => {