-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
import { AsyncResource } from 'async_hooks';
}
public start(): void {
+ if (this.checkChargingStation() === false) {
+ return;
+ }
if (this.started === true) {
logger.warn(`${this.logPrefix()} is already started`);
return;
}
public startConnector(connectorId: number): void {
+ if (this.checkChargingStation(connectorId) === false) {
+ return;
+ }
if (this.connectorsStatus.has(connectorId) === false) {
logger.error(`${this.logPrefix(connectorId)} starting on non existing connector`);
throw new BaseError(`Connector ${connectorId} does not exist`);
this.internalStartConnector.bind(this) as (
this: AutomaticTransactionGenerator,
...args: any[]
- ) => void,
+ ) => Promise<void>,
this,
connectorId
- );
+ ).catch(() => {
+ /* This is intentional */
+ });
} else if (this.connectorsStatus.get(connectorId)?.start === true) {
logger.warn(`${this.logPrefix(connectorId)} is already started on connector`);
}
this.connectorsStatus.get(connectorId).rejectedStartTransactionRequests++;
}
}
+
+ private checkChargingStation(connectorId?: number): boolean {
+ if (this.chargingStation.started === false && this.chargingStation.starting === false) {
+ logger.warn(`${this.logPrefix(connectorId)} charging station is stopped, cannot proceed`);
+ return false;
+ }
+ return true;
+ }
}