From 6114e6f11b3fb12439d464e142fdf93866982b6c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 10 Feb 2022 00:10:37 +0100 Subject: [PATCH] Simplify some code logic MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStation.ts | 8 ++++---- src/charging-station/ocpp/OCPPIncomingRequestService.ts | 2 +- src/charging-station/ocpp/OCPPRequestService.ts | 2 +- src/types/ConfigurationData.ts | 1 - src/utils/Configuration.ts | 1 - 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 8d2efa75..e05ad162 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -665,10 +665,6 @@ export default class ChargingStation { } } while (!this.isInAcceptedState() && (registrationRetryCount <= this.getRegistrationMaxRetries() || this.getRegistrationMaxRetries() === -1)); } - if (this.isInAcceptedState() && this.stationInfo.autoRegister) { - await this.ocppRequestService.sendBootNotification(this.bootNotificationRequest.chargePointModel, - this.bootNotificationRequest.chargePointVendor, this.bootNotificationRequest.chargeBoxSerialNumber, this.bootNotificationRequest.firmwareVersion); - } if (this.isInAcceptedState()) { await this.startMessageSequence(); this.stopped && (this.stopped = false); @@ -878,6 +874,10 @@ export default class ChargingStation { } private async startMessageSequence(): Promise { + if (this.stationInfo.autoRegister) { + await this.ocppRequestService.sendBootNotification(this.bootNotificationRequest.chargePointModel, + this.bootNotificationRequest.chargePointVendor, this.bootNotificationRequest.chargeBoxSerialNumber, this.bootNotificationRequest.firmwareVersion); + } // Start WebSocket ping this.startWebSocketPing(); // Start heartbeat diff --git a/src/charging-station/ocpp/OCPPIncomingRequestService.ts b/src/charging-station/ocpp/OCPPIncomingRequestService.ts index e815fe29..e1651539 100644 --- a/src/charging-station/ocpp/OCPPIncomingRequestService.ts +++ b/src/charging-station/ocpp/OCPPIncomingRequestService.ts @@ -11,7 +11,7 @@ export default abstract class OCPPIncomingRequestService { } protected handleIncomingRequestError(commandName: IncomingRequestCommand, error: Error, errorOcppResponse?: T): T { - logger.error(this.chargingStation.logPrefix() + ' Incoming request command ' + commandName + ' error: %j', error); + logger.error(this.chargingStation.logPrefix() + ' Incoming request command %s error: %j', commandName, error); if (errorOcppResponse) { return errorOcppResponse; } diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index ca136392..da887029 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -111,7 +111,7 @@ export default abstract class OCPPRequestService { } protected handleRequestError(commandName: RequestCommand, error: Error): void { - logger.error(this.chargingStation.logPrefix() + ' Request command ' + commandName + ' error: %j', error); + logger.error(this.chargingStation.logPrefix() + ' Request command %s error: %j', commandName, error); throw error; } diff --git a/src/types/ConfigurationData.ts b/src/types/ConfigurationData.ts index fdb83b57..54ce659c 100644 --- a/src/types/ConfigurationData.ts +++ b/src/types/ConfigurationData.ts @@ -2,7 +2,6 @@ import { ServerOptions } from 'ws'; import { StorageType } from './Storage'; import type { WorkerChoiceStrategy } from 'poolifier'; import { WorkerProcessType } from './Worker'; -import { level } from 'winston'; export enum SupervisionUrlDistribution { ROUND_ROBIN = 'round-robin', diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index ab0a1473..519f0465 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -7,7 +7,6 @@ import type { WorkerChoiceStrategy } from 'poolifier'; import { WorkerProcessType } from '../types/Worker'; import chalk from 'chalk'; import fs from 'fs'; -import { level } from 'winston'; import path from 'path'; export default class Configuration { -- 2.34.1