From: Jérôme Benoit Date: Wed, 9 Feb 2022 23:10:37 +0000 (+0100) Subject: Simplify some code logic X-Git-Tag: v1.1.47~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=6114e6f11b3fb12439d464e142fdf93866982b6c;p=e-mobility-charging-stations-simulator.git Simplify some code logic Signed-off-by: Jérôme Benoit --- 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 {