X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStation.ts;h=d7dcdceec9428543c5957738912b541a61d47ddd;hb=43ea87ca2228b1819069168fe00422ce1ec489d9;hp=98cd5e8348ca2722d057aa9dd112e94bd04237cb;hpb=8114d10e3893e96bb725ce2fca9744429ee4b75b;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 98cd5e83..d7dcdcee 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -3,7 +3,7 @@ import crypto from 'crypto'; import fs from 'fs'; import path from 'path'; -import { URL, fileURLToPath } from 'url'; +import { URL } from 'url'; import { parentPort } from 'worker_threads'; import WebSocket, { Data, RawData } from 'ws'; @@ -861,9 +861,7 @@ export default class ChargingStation { this.hashId = ChargingStationUtils.getHashId(this.index, this.getTemplateFromFile()); logger.info(`${this.logPrefix()} Charging station hashId '${this.hashId}'`); this.configurationFile = path.join( - path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../'), - 'assets', - 'configurations', + path.dirname(this.templateFile.replace('station-templates', 'configurations')), this.hashId + '.json' ); this.stationInfo = this.getStationInfo(); @@ -1400,7 +1398,7 @@ export default class ChargingStation { } logger.debug( `${this.logPrefix()} << Command '${ - requestCommandName ?? '' + requestCommandName ?? 'unknown' }' received response payload: ${JSON.stringify(request)}` ); responseCallback(commandPayload, requestPayload); @@ -1430,7 +1428,7 @@ export default class ChargingStation { } logger.debug( `${this.logPrefix()} << Command '${ - requestCommandName ?? '' + requestCommandName ?? 'unknown' }' received error payload: ${JSON.stringify(request)}` ); errorCallback(new OCPPError(errorType, errorMessage, requestCommandName, errorDetails)); @@ -1450,12 +1448,22 @@ export default class ChargingStation { } catch (error) { // Log logger.error( - '%s Incoming OCPP message %j matching cached request %j processing error %j', + "%s Incoming OCPP '%s' message '%j' matching cached request '%j' processing error: %j", this.logPrefix(), + commandName ?? requestCommandName ?? null, data.toString(), this.requests.get(messageId), error ); + if (!(error instanceof OCPPError)) { + logger.warn( + "%s Error thrown at incoming OCPP '%s' message '%j' handling is not an OCPPError: %j", + this.logPrefix(), + commandName ?? requestCommandName ?? null, + data.toString(), + error + ); + } // Send error messageType === MessageType.CALL_MESSAGE && (await this.ocppRequestService.sendError( @@ -1723,7 +1731,7 @@ export default class ChargingStation { { connectorId, transactionId, - meterValue: transactionEndMeterValue, + meterValue: [transactionEndMeterValue], } ); }