X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2FOCPPRequestService.ts;h=7077a28bb88c839590516e3af49a2b82964e8c5b;hb=9c5d9fa4cd1904b5e2d4c4a8277bed25865b61b6;hp=e00e2b99f9a2bbbddbdca10a6ae1427ffe982d2c;hpb=5e3cb7281de2b6fa8b61a453f964c2f213fefa80;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index e00e2b99..7077a28b 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -1,5 +1,3 @@ -import { parentPort } from 'worker_threads'; - import type { JSONSchemaType } from 'ajv'; import Ajv from 'ajv-draft-04'; import ajvFormats from 'ajv-formats'; @@ -23,7 +21,6 @@ import Constants from '../../utils/Constants'; import logger from '../../utils/Logger'; import Utils from '../../utils/Utils'; import type ChargingStation from '../ChargingStation'; -import { MessageChannelUtils } from '../MessageChannelUtils'; import type OCPPResponseService from './OCPPResponseService'; import { OCPPServiceUtils } from './OCPPServiceUtils'; @@ -127,7 +124,7 @@ export default abstract class OCPPRequestService { schema: JSONSchemaType, payload: T ): boolean { - if (!chargingStation.getPayloadSchemaValidation()) { + if (chargingStation.getPayloadSchemaValidation() === false) { return true; } const validate = this.ajv.compile(schema); @@ -178,11 +175,11 @@ export default abstract class OCPPRequestService { responseCallback, errorCallback ); - if (chargingStation.getEnableStatistics()) { + if (chargingStation.getEnableStatistics() === true) { chargingStation.performanceStatistics.addRequestStatistic(commandName, messageType); } // Check if wsConnection opened - if (chargingStation.isWebSocketConnectionOpened()) { + if (chargingStation.isWebSocketConnectionOpened() === true) { // Yes: Send Message const beginId = PerformanceStatistics.beginMeasure(commandName); // FIXME: Handle sending error @@ -193,7 +190,7 @@ export default abstract class OCPPRequestService { messageType )} payload: ${messageToSend}` ); - } else if (!params.skipBufferingOnError) { + } else if (params.skipBufferingOnError === false) { // Buffer it chargingStation.bufferMessage(messageToSend); const ocppError = new OCPPError( @@ -235,7 +232,7 @@ export default abstract class OCPPRequestService { payload: JsonType, requestPayload: JsonType ): Promise { - if (chargingStation.getEnableStatistics()) { + if (chargingStation.getEnableStatistics() === true) { chargingStation.performanceStatistics.addRequestStatistic( commandName, MessageType.CALL_RESULT_MESSAGE @@ -254,7 +251,6 @@ export default abstract class OCPPRequestService { reject(error); } finally { chargingStation.requests.delete(messageId); - // parentPort.postMessage(MessageChannelUtils.buildUpdatedMessage(chargingStation)); } } @@ -265,7 +261,7 @@ export default abstract class OCPPRequestService { * @param requestStatistic */ function errorCallback(error: OCPPError, requestStatistic = true): void { - if (requestStatistic && chargingStation.getEnableStatistics()) { + if (requestStatistic === true && chargingStation.getEnableStatistics() === true) { chargingStation.performanceStatistics.addRequestStatistic( commandName, MessageType.CALL_ERROR_MESSAGE @@ -278,7 +274,6 @@ export default abstract class OCPPRequestService { error ); chargingStation.requests.delete(messageId); - // parentPort.postMessage(MessageChannelUtils.buildUpdatedMessage(chargingStation)); reject(error); } }), @@ -366,7 +361,7 @@ export default abstract class OCPPRequestService { error: Error, params: HandleErrorParams = { throwError: true } ): void { - logger.error(`${chargingStation.logPrefix()} Request command ${commandName} error:`, error); + logger.error(`${chargingStation.logPrefix()} Request command '${commandName}' error:`, error); if (params?.throwError) { throw error; }