Commit | Line | Data |
---|---|---|
33cea517 | 1 | import { |
32de5a57 | 2 | ProcedureName, |
33cea517 JB |
3 | ProtocolRequestHandler, |
4 | ProtocolVersion, | |
89b7a234 | 5 | RequestPayload, |
33cea517 | 6 | } from '../../../types/UIProtocol'; |
0d2cec76 | 7 | import { BroadcastChannelProcedureName } from '../../../types/WorkerBroadcastChannel'; |
6c1761d4 | 8 | import type { AbstractUIServer } from '../AbstractUIServer'; |
4198ad5c | 9 | import AbstractUIService from './AbstractUIService'; |
4198ad5c | 10 | |
f16356b9 | 11 | export default class UIService001 extends AbstractUIService { |
fe94fce0 | 12 | constructor(uiServer: AbstractUIServer) { |
33cea517 | 13 | super(uiServer, ProtocolVersion['0.0.1']); |
02a6943a | 14 | this.requestHandlers.set( |
89b7a234 JB |
15 | ProcedureName.START_CHARGING_STATION, |
16 | this.handleStartChargingStation.bind(this) as ProtocolRequestHandler | |
17 | ); | |
02a6943a | 18 | this.requestHandlers.set( |
89b7a234 JB |
19 | ProcedureName.STOP_CHARGING_STATION, |
20 | this.handleStopChargingStation.bind(this) as ProtocolRequestHandler | |
21 | ); | |
db2336d9 JB |
22 | this.requestHandlers.set( |
23 | ProcedureName.OPEN_CONNECTION, | |
24 | this.handleOpenConnection.bind(this) as ProtocolRequestHandler | |
25 | ); | |
26 | this.requestHandlers.set( | |
27 | ProcedureName.CLOSE_CONNECTION, | |
28 | this.handleCloseConnection.bind(this) as ProtocolRequestHandler | |
29 | ); | |
4f69be04 JB |
30 | this.requestHandlers.set( |
31 | ProcedureName.START_TRANSACTION, | |
32 | this.handleStartTransaction.bind(this) as ProtocolRequestHandler | |
33 | ); | |
34 | this.requestHandlers.set( | |
35 | ProcedureName.STOP_TRANSACTION, | |
36 | this.handleStopTransaction.bind(this) as ProtocolRequestHandler | |
37 | ); | |
38 | this.requestHandlers.set( | |
39 | ProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR, | |
40 | this.handleStartAutomaticTransactionGenerator.bind(this) as ProtocolRequestHandler | |
41 | ); | |
42 | this.requestHandlers.set( | |
43 | ProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR, | |
44 | this.handleStopAutomaticTransactionGenerator.bind(this) as ProtocolRequestHandler | |
45 | ); | |
1984f194 JB |
46 | this.requestHandlers.set( |
47 | ProcedureName.AUTHORIZE, | |
48 | this.handleAuthorize.bind(this) as ProtocolRequestHandler | |
49 | ); | |
a9ed42b2 JB |
50 | this.requestHandlers.set( |
51 | ProcedureName.STATUS_NOTIFICATION, | |
52 | this.handleStatusNotification.bind(this) as ProtocolRequestHandler | |
53 | ); | |
10db00b2 JB |
54 | this.requestHandlers.set( |
55 | ProcedureName.HEARTBEAT, | |
56 | this.handleHeartbeat.bind(this) as ProtocolRequestHandler | |
57 | ); | |
89b7a234 JB |
58 | } |
59 | ||
4f69be04 | 60 | private handleStartChargingStation(uuid: string, payload: RequestPayload): void { |
0d2cec76 | 61 | this.sendBroadcastChannelRequest( |
4e3ff94d | 62 | uuid, |
4f69be04 | 63 | BroadcastChannelProcedureName.START_CHARGING_STATION, |
0d2cec76 JB |
64 | payload |
65 | ); | |
89b7a234 JB |
66 | } |
67 | ||
4f69be04 | 68 | private handleStopChargingStation(uuid: string, payload: RequestPayload): void { |
0d2cec76 | 69 | this.sendBroadcastChannelRequest( |
4e3ff94d | 70 | uuid, |
4f69be04 | 71 | BroadcastChannelProcedureName.STOP_CHARGING_STATION, |
0d2cec76 JB |
72 | payload |
73 | ); | |
4198ad5c JB |
74 | } |
75 | ||
4f69be04 | 76 | private handleOpenConnection(uuid: string, payload: RequestPayload): void { |
0d2cec76 | 77 | this.sendBroadcastChannelRequest(uuid, BroadcastChannelProcedureName.OPEN_CONNECTION, payload); |
32de5a57 LM |
78 | } |
79 | ||
4f69be04 | 80 | private handleCloseConnection(uuid: string, payload: RequestPayload): void { |
0d2cec76 | 81 | this.sendBroadcastChannelRequest(uuid, BroadcastChannelProcedureName.CLOSE_CONNECTION, payload); |
32de5a57 | 82 | } |
db2336d9 | 83 | |
4f69be04 | 84 | private handleStartTransaction(uuid: string, payload: RequestPayload): void { |
0d2cec76 | 85 | this.sendBroadcastChannelRequest( |
db2336d9 | 86 | uuid, |
4f69be04 | 87 | BroadcastChannelProcedureName.START_TRANSACTION, |
0d2cec76 JB |
88 | payload |
89 | ); | |
db2336d9 JB |
90 | } |
91 | ||
4f69be04 | 92 | private handleStopTransaction(uuid: string, payload: RequestPayload): void { |
0d2cec76 | 93 | this.sendBroadcastChannelRequest(uuid, BroadcastChannelProcedureName.STOP_TRANSACTION, payload); |
4f69be04 JB |
94 | } |
95 | ||
96 | private handleStartAutomaticTransactionGenerator(uuid: string, payload: RequestPayload): void { | |
0d2cec76 | 97 | this.sendBroadcastChannelRequest( |
4f69be04 JB |
98 | uuid, |
99 | BroadcastChannelProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR, | |
0d2cec76 JB |
100 | payload |
101 | ); | |
4f69be04 JB |
102 | } |
103 | ||
104 | private handleStopAutomaticTransactionGenerator(uuid: string, payload: RequestPayload): void { | |
0d2cec76 | 105 | this.sendBroadcastChannelRequest( |
4f69be04 JB |
106 | uuid, |
107 | BroadcastChannelProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR, | |
0d2cec76 JB |
108 | payload |
109 | ); | |
db2336d9 | 110 | } |
a9ed42b2 | 111 | |
1984f194 JB |
112 | private handleAuthorize(uuid: string, payload: RequestPayload): void { |
113 | this.sendBroadcastChannelRequest(uuid, BroadcastChannelProcedureName.AUTHORIZE, payload); | |
114 | } | |
115 | ||
a9ed42b2 JB |
116 | private handleStatusNotification(uuid: string, payload: RequestPayload): void { |
117 | this.sendBroadcastChannelRequest( | |
118 | uuid, | |
119 | BroadcastChannelProcedureName.STATUS_NOTIFICATION, | |
120 | payload | |
121 | ); | |
122 | } | |
10db00b2 JB |
123 | |
124 | private handleHeartbeat(uuid: string, payload: RequestPayload): void { | |
125 | this.sendBroadcastChannelRequest(uuid, BroadcastChannelProcedureName.HEARTBEAT, payload); | |
126 | } | |
4198ad5c | 127 | } |