X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStation.ts;h=b5ec5209ad8a56a2aa713a08de0a50da529b881e;hb=43d673d9a1659a8e954f14c9f554adf0c56f0635;hp=0c39613beefea49afdb1a3701457daba98fa12ee;hpb=77f00f84dff47dc35d2fca1afb3ca574dd3954b5;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 0c39613b..b5ec5209 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -29,6 +29,7 @@ import { WebSocketCloseEventStatusCode } from '../types/WebSocket'; import crypto from 'crypto'; import fs from 'fs'; import logger from '../utils/Logger'; +import path from 'path'; export default class ChargingStation { public stationTemplateFile: string; @@ -321,16 +322,16 @@ export default class ChargingStation { public addToMessageQueue(message: string): void { let dups = false; - // Handle dups in buffer + // Handle dups in message queue for (const bufferedMessage of this.messageQueue) { - // Same message + // Message already in the queue if (message === bufferedMessage) { dups = true; break; } } if (!dups) { - // Buffer message + // Queue message this.messageQueue.push(message); } } @@ -479,7 +480,8 @@ export default class ChargingStation { // Send BootNotification let registrationRetryCount = 0; do { - this.bootNotificationResponse = await this.ocppRequestService.sendBootNotification(this.bootNotificationRequest.chargePointModel, this.bootNotificationRequest.chargePointVendor, this.bootNotificationRequest.chargeBoxSerialNumber, this.bootNotificationRequest.firmwareVersion); + this.bootNotificationResponse = await this.ocppRequestService.sendBootNotification(this.bootNotificationRequest.chargePointModel, + this.bootNotificationRequest.chargePointVendor, this.bootNotificationRequest.chargeBoxSerialNumber, this.bootNotificationRequest.firmwareVersion); if (!this.isRegistered()) { registrationRetryCount++; await Utils.sleep(this.bootNotificationResponse?.interval ? this.bootNotificationResponse.interval * 1000 : Constants.OCPP_DEFAULT_BOOT_NOTIFICATION_INTERVAL); @@ -598,7 +600,7 @@ export default class ChargingStation { } private getAuthorizationFile(): string { - return this.stationInfo.authorizationFile && this.stationInfo.authorizationFile; + return this.stationInfo.authorizationFile && path.join(path.resolve(__dirname, '../'), 'assets', path.basename(this.stationInfo.authorizationFile)); } private getAuthorizedTags(): string[] {