From: Jérôme Benoit Date: Thu, 25 Aug 2022 15:41:37 +0000 (+0200) Subject: UI protocol: Allow to send some relevant commands to several charging… (#152) X-Git-Tag: v1.1.66~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=4eca248cf2d300b51dc45412766a821184a00dcb;p=e-mobility-charging-stations-simulator.git UI protocol: Allow to send some relevant commands to several charging… (#152) --- diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..69ef742b --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +/src/ui/web/dist diff --git a/README.md b/README.md index f5964162..563b2e31 100644 --- a/README.md +++ b/README.md @@ -450,9 +450,9 @@ Response: Request: `ProcedureName`: 'startTransaction' `PDU`: { -`hashId`: the unique identifier of a charging station -`connectorId`: the id of the connector -`idTag`: the RFID tag +`hashId`: charging station unique identifier string (deprecated) | `hashIds`: charging station unique identifier strings array, +`connectorId`: connector id integer, +`idTag`: RFID tag string } Response: @@ -465,8 +465,8 @@ Response: Request: `ProcedureName`: 'stopTransaction' `PDU`: { -`hashId`: the unique identifier of a charging station -`transactionId`: the id of the transaction +`hashId`: charging station unique identifier string (deprecated) | `hashIds`: charging station unique identifier strings array, +`transactionId`: transaction id integer } Response: @@ -479,7 +479,7 @@ Response: Request: `ProcedureName`: 'startChargingStation' `PDU`: { -`hashId`: the unique identifier of a charging station +`hashId`: charging station unique identifier string (deprecated) | `hashIds`: charging station unique identifier strings array } Response: @@ -492,7 +492,7 @@ Response: Request: `ProcedureName`: 'stopChargingStation' `PDU`: { -`hashId`: the unique identifier of a charging station +`hashId`: charging station unique identifier string (deprecated) | `hashIds`: charging station unique identifier strings array } Response: @@ -505,7 +505,7 @@ Response: Request: `ProcedureName`: 'openConnection' `PDU`: { -`hashId`: the unique identifier of a charging station +`hashId`: charging station unique identifier string (deprecated) | `hashIds`: charging station unique identifier strings array } Response: @@ -518,7 +518,7 @@ Response: Request: `ProcedureName`: 'closeConnection' `PDU`: { -`hashId`: the unique identifier of a charging station +`hashId`: charging station unique identifier string (deprecated) | `hashIds`: charging station unique identifier strings array } Response: diff --git a/src/charging-station/ChargingStationWorkerBroadcastChannel.ts b/src/charging-station/ChargingStationWorkerBroadcastChannel.ts index 9e88b418..9de2cfb2 100644 --- a/src/charging-station/ChargingStationWorkerBroadcastChannel.ts +++ b/src/charging-station/ChargingStationWorkerBroadcastChannel.ts @@ -44,9 +44,23 @@ export default class ChargingStationWorkerBroadcastChannel extends WorkerBroadca const [uuid, command, requestPayload] = messageEvent.data as BroadcastChannelRequest; - if (requestPayload?.hashId !== this.chargingStation.hashId) { + if ( + requestPayload?.hashId === undefined && + (requestPayload?.hashIds as string[])?.includes(this.chargingStation.hashId) === false + ) { return; } + if ( + requestPayload?.hashIds === undefined && + requestPayload?.hashId !== this.chargingStation.hashId + ) { + return; + } + if (requestPayload?.hashId !== undefined) { + logger.warn( + `${this.chargingStation.logPrefix()} ${moduleName}.requestHandler: 'hashId' field usage in PDU is deprecated, use 'hashIds' instead` + ); + } let responsePayload: BroadcastChannelResponsePayload; let commandResponse: CommandResponse; diff --git a/src/types/UIProtocol.ts b/src/types/UIProtocol.ts index 63bb7ca1..1939fdd5 100644 --- a/src/types/UIProtocol.ts +++ b/src/types/UIProtocol.ts @@ -35,6 +35,7 @@ export enum ProcedureName { export interface RequestPayload extends JsonObject { hashId?: string; + hashIds?: string[]; } export enum ResponseStatus { diff --git a/src/types/WorkerBroadcastChannel.ts b/src/types/WorkerBroadcastChannel.ts index 0015b717..0d6da48d 100644 --- a/src/types/WorkerBroadcastChannel.ts +++ b/src/types/WorkerBroadcastChannel.ts @@ -16,13 +16,24 @@ export enum BroadcastChannelProcedureName { CLOSE_CONNECTION = 'closeConnection', } -export interface BroadcastChannelRequestPayload extends Omit { - hashId: string; +interface BaseBroadcastChannelRequestPayload extends Omit { connectorId?: number; transactionId?: number; idTag?: string; } +interface HashIdBroadcastChannelRequestPayload extends BaseBroadcastChannelRequestPayload { + hashId: string; +} + +interface HashIdsBroadcastChannelRequestPayload extends BaseBroadcastChannelRequestPayload { + hashIds: string[]; +} + +export type BroadcastChannelRequestPayload = + | HashIdBroadcastChannelRequestPayload + | HashIdsBroadcastChannelRequestPayload; + export type BroadcastChannelResponsePayload = ResponsePayload; export type MessageEvent = { data: BroadcastChannelRequest | BroadcastChannelResponse }; diff --git a/src/ui/web/src/type/UIProtocol.ts b/src/ui/web/src/type/UIProtocol.ts index b8d40f31..23537c3e 100644 --- a/src/ui/web/src/type/UIProtocol.ts +++ b/src/ui/web/src/type/UIProtocol.ts @@ -33,6 +33,7 @@ export enum ProcedureName { } export interface RequestPayload extends JsonObject { hashId?: string; + hashIds?: string[]; } export enum ResponseStatus {