3 ProtocolRequestHandler
,
6 } from
'../../../types/UIProtocol';
7 import { BroadcastChannelProcedureName
} from
'../../../types/WorkerBroadcastChannel';
8 import type { AbstractUIServer
} from
'../AbstractUIServer';
9 import AbstractUIService from
'./AbstractUIService';
11 export default class UIService001
extends AbstractUIService
{
12 private static readonly ProcedureNameToBroadCastChannelProcedureNameMap
: Omit
<
13 Record
<ProcedureName
, BroadcastChannelProcedureName
>,
14 'startSimulator' | 'stopSimulator' | 'listChargingStations'
16 [ProcedureName
.START_CHARGING_STATION
]: BroadcastChannelProcedureName
.START_CHARGING_STATION
,
17 [ProcedureName
.STOP_CHARGING_STATION
]: BroadcastChannelProcedureName
.STOP_CHARGING_STATION
,
18 [ProcedureName
.CLOSE_CONNECTION
]: BroadcastChannelProcedureName
.CLOSE_CONNECTION
,
19 [ProcedureName
.OPEN_CONNECTION
]: BroadcastChannelProcedureName
.OPEN_CONNECTION
,
20 [ProcedureName
.START_AUTOMATIC_TRANSACTION_GENERATOR
]:
21 BroadcastChannelProcedureName
.START_AUTOMATIC_TRANSACTION_GENERATOR
,
22 [ProcedureName
.STOP_AUTOMATIC_TRANSACTION_GENERATOR
]:
23 BroadcastChannelProcedureName
.STOP_AUTOMATIC_TRANSACTION_GENERATOR
,
24 [ProcedureName
.START_TRANSACTION
]: BroadcastChannelProcedureName
.START_TRANSACTION
,
25 [ProcedureName
.STOP_TRANSACTION
]: BroadcastChannelProcedureName
.STOP_TRANSACTION
,
26 [ProcedureName
.AUTHORIZE
]: BroadcastChannelProcedureName
.AUTHORIZE
,
27 [ProcedureName
.STATUS_NOTIFICATION
]: BroadcastChannelProcedureName
.STATUS_NOTIFICATION
,
28 [ProcedureName
.HEARTBEAT
]: BroadcastChannelProcedureName
.HEARTBEAT
,
29 [ProcedureName
.METER_VALUES
]: BroadcastChannelProcedureName
.METER_VALUES
,
32 constructor(uiServer
: AbstractUIServer
) {
33 super(uiServer
, ProtocolVersion
['0.0.1']);
34 this.requestHandlers
.set(
35 ProcedureName
.START_CHARGING_STATION
,
36 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
38 this.requestHandlers
.set(
39 ProcedureName
.STOP_CHARGING_STATION
,
40 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
42 this.requestHandlers
.set(
43 ProcedureName
.OPEN_CONNECTION
,
44 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
46 this.requestHandlers
.set(
47 ProcedureName
.CLOSE_CONNECTION
,
48 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
50 this.requestHandlers
.set(
51 ProcedureName
.START_AUTOMATIC_TRANSACTION_GENERATOR
,
52 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
54 this.requestHandlers
.set(
55 ProcedureName
.STOP_AUTOMATIC_TRANSACTION_GENERATOR
,
56 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
58 this.requestHandlers
.set(
59 ProcedureName
.START_TRANSACTION
,
60 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
62 this.requestHandlers
.set(
63 ProcedureName
.STOP_TRANSACTION
,
64 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
66 this.requestHandlers
.set(
67 ProcedureName
.AUTHORIZE
,
68 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
70 this.requestHandlers
.set(
71 ProcedureName
.STATUS_NOTIFICATION
,
72 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
74 this.requestHandlers
.set(
75 ProcedureName
.HEARTBEAT
,
76 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
78 this.requestHandlers
.set(
79 ProcedureName
.METER_VALUES
,
80 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
84 private handleProtocolRequest(
86 procedureName
: ProcedureName
,
87 payload
: RequestPayload
89 this.sendBroadcastChannelRequest(
91 UIService001
.ProcedureNameToBroadCastChannelProcedureNameMap
[
93 ] as BroadcastChannelProcedureName
,