repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactor: stop !== shutdown semantic
[e-mobility-charging-stations-simulator.git]
/
src
/
charging-station
/
Bootstrap.ts
diff --git
a/src/charging-station/Bootstrap.ts
b/src/charging-station/Bootstrap.ts
index db884ed874285adae8c532ff6b3fccb175ec5fbb..677843d27c1c479ac4c9e34f98bcd98f38a55a44 100644
(file)
--- a/
src/charging-station/Bootstrap.ts
+++ b/
src/charging-station/Bootstrap.ts
@@
-129,7
+129,7
@@
export class Bootstrap extends EventEmitter {
public async stop(): Promise<void> {
if (isMainThread && this.started === true) {
public async stop(): Promise<void> {
if (isMainThread && this.started === true) {
- await this.uiServer?.send
BroadcastChannelRequest
(
+ await this.uiServer?.send
RequestOnBroadcastChannel
(
this.uiServer.buildProtocolRequest(
Utils.generateUUID(),
ProcedureName.STOP_CHARGING_STATION,
this.uiServer.buildProtocolRequest(
Utils.generateUUID(),
ProcedureName.STOP_CHARGING_STATION,
@@
-299,18
+299,23
@@
export class Bootstrap extends EventEmitter {
process.exit(0);
})
.catch((error) => {
process.exit(0);
})
.catch((error) => {
- console.error(chalk.red('Error while s
topping charging stations simulator:
'), error);
+ console.error(chalk.red('Error while s
hutdowning charging stations simulator:
'), error);
process.exit(1);
});
};
process.exit(1);
});
};
- private waitForChargingStationsStopped = async (): Promise<void> => {
+ private waitForChargingStationsStopped = async (
+ stoppedEventsToWait = this.numberOfStartedChargingStations
+ ): Promise<number> => {
return new Promise((resolve) => {
let stoppedEvents = 0;
return new Promise((resolve) => {
let stoppedEvents = 0;
+ if (stoppedEventsToWait === 0) {
+ resolve(stoppedEvents);
+ }
this.on(ChargingStationWorkerMessageEvents.stopped, () => {
++stoppedEvents;
this.on(ChargingStationWorkerMessageEvents.stopped, () => {
++stoppedEvents;
- if (stoppedEvents ===
this.numberOfChargingStations
) {
- resolve();
+ if (stoppedEvents ===
stoppedEventsToWait
) {
+ resolve(
stoppedEvents
);
}
});
});
}
});
});