Simplify some code logic
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 9 Feb 2022 23:10:37 +0000 (00:10 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 9 Feb 2022 23:10:37 +0000 (00:10 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts
src/charging-station/ocpp/OCPPIncomingRequestService.ts
src/charging-station/ocpp/OCPPRequestService.ts
src/types/ConfigurationData.ts
src/utils/Configuration.ts

index 8d2efa755324f07e7a51064eb5651eb9107ae70b..e05ad162d24a1d28dc02df1bb67f2d42b7134826 100644 (file)
@@ -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<void> {
+    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
index e815fe298d4590f610f279443ca46998817552e2..e1651539699e8ffc0400f614c213ed5019cc9df6 100644 (file)
@@ -11,7 +11,7 @@ export default abstract class OCPPIncomingRequestService {
   }
 
   protected handleIncomingRequestError<T>(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;
     }
index ca1363929872f0c9209ca2d1e815fbbd91822845..da8870292d0d4d3751a11992e473dc05f06b2de5 100644 (file)
@@ -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;
   }
 
index fdb83b57486d3b9a1017e254ed874533ee406e25..54ce659cc81d369b632fc09b793c77776e36277e 100644 (file)
@@ -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',
index ab0a147300d2b29d8f13028d3a452d3ab8278f85..519f0465b1580f2bbb4f781777d0ff080849a0e2 100644 (file)
@@ -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 {