X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcharging-station%2Fui-server%2Fui-services%2FAbstractUIService.ts;h=71b057abe4a2f7369c1376d97ffcc55046eb0e89;hb=7671fa0be211e944f027ebd83f3a0ad64c2ef2d6;hp=62249549c268b11b383dd151f91d23429a70fb4b;hpb=53ac516c575adaacd199a68d39b5ace22876ee83;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ui-server/ui-services/AbstractUIService.ts b/src/charging-station/ui-server/ui-services/AbstractUIService.ts index 62249549..71b057ab 100644 --- a/src/charging-station/ui-server/ui-services/AbstractUIService.ts +++ b/src/charging-station/ui-server/ui-services/AbstractUIService.ts @@ -1,7 +1,7 @@ -import BaseError from '../../../exception/BaseError'; -import type OCPPError from '../../../exception/OCPPError'; -import { Bootstrap } from '../../../internal'; +import { BaseError, type OCPPError } from '../../../exception'; import { + BroadcastChannelProcedureName, + type BroadcastChannelRequestPayload, ProcedureName, type ProtocolRequest, type ProtocolRequestHandler, @@ -9,19 +9,15 @@ import { type RequestPayload, type ResponsePayload, ResponseStatus, -} from '../../../types/UIProtocol'; -import { - BroadcastChannelProcedureName, - type BroadcastChannelRequestPayload, -} from '../../../types/WorkerBroadcastChannel'; -import logger from '../../../utils/Logger'; -import Utils from '../../../utils/Utils'; -import UIServiceWorkerBroadcastChannel from '../../UIServiceWorkerBroadcastChannel'; +} from '../../../types'; +import { Utils, logger } from '../../../utils'; +import { Bootstrap } from '../../Bootstrap'; +import { UIServiceWorkerBroadcastChannel } from '../../broadcast-channel/UIServiceWorkerBroadcastChannel'; import type { AbstractUIServer } from '../AbstractUIServer'; const moduleName = 'AbstractUIService'; -export default abstract class AbstractUIService { +export abstract class AbstractUIService { protected static readonly ProcedureNameToBroadCastChannelProcedureNameMap: Omit< Record, | ProcedureName.START_SIMULATOR @@ -36,6 +32,7 @@ export default abstract class AbstractUIService { BroadcastChannelProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR, [ProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR]: BroadcastChannelProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR, + [ProcedureName.SET_SUPERVISION_URL]: BroadcastChannelProcedureName.SET_SUPERVISION_URL, [ProcedureName.START_TRANSACTION]: BroadcastChannelProcedureName.START_TRANSACTION, [ProcedureName.STOP_TRANSACTION]: BroadcastChannelProcedureName.STOP_TRANSACTION, [ProcedureName.AUTHORIZE]: BroadcastChannelProcedureName.AUTHORIZE, @@ -103,7 +100,7 @@ export default abstract class AbstractUIService { }; } finally { // Send response for payload not forwarded to broadcast channel - if (responsePayload !== undefined) { + if (!Utils.isNullOrUndefined(responsePayload)) { this.sendResponse(messageId, responsePayload); } } @@ -156,6 +153,7 @@ export default abstract class AbstractUIService { ): void { if (Utils.isNotEmptyArray(payload.hashIds)) { payload.hashIds = payload.hashIds + .filter((hashId) => !Utils.isNullOrUndefined(hashId)) .map((hashId) => { if (this.uiServer.chargingStations.has(hashId) === true) { return hashId; @@ -166,8 +164,7 @@ export default abstract class AbstractUIService { 'sendBroadcastChannelRequest' )} Charging station with hashId '${hashId}' not found` ); - }) - .filter((hashId) => hashId !== undefined); + }); } const expectedNumberOfResponses = Utils.isNotEmptyArray(payload.hashIds) ? payload.hashIds.length