3 ProtocolRequestHandler
,
6 } from
'../../../types/UIProtocol';
7 import { BroadcastChannelProcedureName
} from
'../../../types/WorkerBroadcastChannel';
8 import type { AbstractUIServer
} from
'../AbstractUIServer';
9 import AbstractUIService from
'./AbstractUIService';
11 const ProcedureNameToBroadCastChannelProcedureNameMap
: Omit
<
12 Record
<ProcedureName
, BroadcastChannelProcedureName
>,
13 'startSimulator' | 'stopSimulator' | 'listChargingStations'
15 [ProcedureName
.START_CHARGING_STATION
]: BroadcastChannelProcedureName
.START_CHARGING_STATION
,
16 [ProcedureName
.STOP_CHARGING_STATION
]: BroadcastChannelProcedureName
.STOP_CHARGING_STATION
,
17 [ProcedureName
.CLOSE_CONNECTION
]: BroadcastChannelProcedureName
.CLOSE_CONNECTION
,
18 [ProcedureName
.OPEN_CONNECTION
]: BroadcastChannelProcedureName
.OPEN_CONNECTION
,
19 [ProcedureName
.START_AUTOMATIC_TRANSACTION_GENERATOR
]:
20 BroadcastChannelProcedureName
.START_AUTOMATIC_TRANSACTION_GENERATOR
,
21 [ProcedureName
.STOP_AUTOMATIC_TRANSACTION_GENERATOR
]:
22 BroadcastChannelProcedureName
.STOP_AUTOMATIC_TRANSACTION_GENERATOR
,
23 [ProcedureName
.START_TRANSACTION
]: BroadcastChannelProcedureName
.START_TRANSACTION
,
24 [ProcedureName
.STOP_TRANSACTION
]: BroadcastChannelProcedureName
.STOP_TRANSACTION
,
25 [ProcedureName
.AUTHORIZE
]: BroadcastChannelProcedureName
.AUTHORIZE
,
26 [ProcedureName
.STATUS_NOTIFICATION
]: BroadcastChannelProcedureName
.STATUS_NOTIFICATION
,
27 [ProcedureName
.HEARTBEAT
]: BroadcastChannelProcedureName
.HEARTBEAT
,
30 export default class UIService001
extends AbstractUIService
{
31 constructor(uiServer
: AbstractUIServer
) {
32 super(uiServer
, ProtocolVersion
['0.0.1']);
33 this.requestHandlers
.set(
34 ProcedureName
.START_CHARGING_STATION
,
35 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
37 this.requestHandlers
.set(
38 ProcedureName
.STOP_CHARGING_STATION
,
39 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
41 this.requestHandlers
.set(
42 ProcedureName
.OPEN_CONNECTION
,
43 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
45 this.requestHandlers
.set(
46 ProcedureName
.CLOSE_CONNECTION
,
47 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
49 this.requestHandlers
.set(
50 ProcedureName
.START_AUTOMATIC_TRANSACTION_GENERATOR
,
51 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
53 this.requestHandlers
.set(
54 ProcedureName
.STOP_AUTOMATIC_TRANSACTION_GENERATOR
,
55 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
57 this.requestHandlers
.set(
58 ProcedureName
.START_TRANSACTION
,
59 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
61 this.requestHandlers
.set(
62 ProcedureName
.STOP_TRANSACTION
,
63 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
65 this.requestHandlers
.set(
66 ProcedureName
.AUTHORIZE
,
67 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
69 this.requestHandlers
.set(
70 ProcedureName
.STATUS_NOTIFICATION
,
71 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
73 this.requestHandlers
.set(
74 ProcedureName
.HEARTBEAT
,
75 this.handleProtocolRequest
.bind(this) as ProtocolRequestHandler
79 private handleProtocolRequest(
81 procedureName
: ProcedureName
,
82 payload
: RequestPayload
84 this.sendBroadcastChannelRequest(
86 ProcedureNameToBroadCastChannelProcedureNameMap
[
88 ] as BroadcastChannelProcedureName
,