X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FAutomaticTransactionGenerator.ts;h=0389526fd6a9400a90404903a360d8d607448fd6;hb=ec94a3cf52930554aa2ffbdf67c06f23095cabb6;hp=477a8d9c824f2922cb178631d5156ee840a96878;hpb=56c298254011750a08c6be90d94c098c31f6bdc3;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index 477a8d9c..0389526f 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -31,11 +31,15 @@ export class AutomaticTransactionGenerator extends AsyncResource { public readonly connectorsStatus: Map; public started: boolean; + private starting: boolean; + private stopping: boolean; private readonly chargingStation: ChargingStation; private constructor(chargingStation: ChargingStation) { super(moduleName); this.started = false; + this.starting = false; + this.stopping = false; this.chargingStation = chargingStation; this.connectorsStatus = new Map(); this.initializeConnectorsStatus(); @@ -63,8 +67,14 @@ export class AutomaticTransactionGenerator extends AsyncResource { logger.warn(`${this.logPrefix()} is already started`); return; } + if (this.starting === true) { + logger.warn(`${this.logPrefix()} is already starting`); + return; + } + this.starting = true; this.startConnectors(); this.started = true; + this.starting = false; } public stop(): void { @@ -72,8 +82,14 @@ export class AutomaticTransactionGenerator extends AsyncResource { logger.warn(`${this.logPrefix()} is already stopped`); return; } + if (this.stopping === true) { + logger.warn(`${this.logPrefix()} is already stopping`); + return; + } + this.stopping = true; this.stopConnectors(); this.started = false; + this.stopping = false; } public startConnector(connectorId: number): void {