}
public start(): void {
- if (this.started) {
- logger.error(`${this.logPrefix()} trying to start while already started`);
+ if (this.started === true) {
+ logger.warn(`${this.logPrefix()} trying to start while already started`);
return;
}
this.startConnectors();
}
public stop(): void {
- if (!this.started) {
- logger.error(`${this.logPrefix()} trying to stop while not started`);
+ if (this.started === false) {
+ logger.warn(`${this.logPrefix()} trying to stop while not started`);
return;
}
this.stopConnectors();
this.started = false;
}
+ public startConnector(connectorId: number): void {
+ if (this.chargingStation.connectors.has(connectorId) === false) {
+ logger.warn(`${this.logPrefix(connectorId)} trying to start on non existing connector`);
+ return;
+ }
+ if (this.connectorsStatus.get(connectorId)?.start === false) {
+ // Avoid hogging the event loop with a busy loop
+ setImmediate(() => {
+ this.internalStartConnector(connectorId).catch(() => {
+ /* This is intentional */
+ });
+ });
+ } else if (this.connectorsStatus.get(connectorId)?.start === true) {
+ logger.warn(`${this.logPrefix(connectorId)} already started on connector`);
+ }
+ }
+
+ public stopConnector(connectorId: number): void {
+ this.connectorsStatus.set(connectorId, {
+ ...this.connectorsStatus.get(connectorId),
+ start: false,
+ });
+ }
+
private startConnectors(): void {
if (
this.connectorsStatus?.size > 0 &&
this.connectorsStatus.get(connectorId).startDate.getTime()
)
);
- while (this.connectorsStatus.get(connectorId).start) {
+ while (this.connectorsStatus.get(connectorId).start === true) {
if (new Date() > this.connectorsStatus.get(connectorId).stopDate) {
this.stopConnector(connectorId);
break;
);
}
- private startConnector(connectorId: number): void {
- // Avoid hogging the event loop with a busy loop
- setImmediate(() => {
- this.internalStartConnector(connectorId).catch(() => {
- /* This is intentional */
- });
- });
- }
-
- private stopConnector(connectorId: number): void {
- this.connectorsStatus.set(connectorId, {
- ...this.connectorsStatus.get(connectorId),
- start: false,
- });
- }
-
private initializeConnectorStatus(connectorId: number): void {
this.connectorsStatus.get(connectorId).authorizeRequests =
this?.connectorsStatus.get(connectorId)?.authorizeRequests ?? 0;
private logPrefix(connectorId?: number): string {
return Utils.logPrefix(
` ${this.chargingStation.stationInfo.chargingStationId} | ATG${
- connectorId && ` on connector #${connectorId.toString()}`
+ connectorId !== undefined ? ` on connector #${connectorId.toString()}` : ''
}:`
);
}