Commit | Line | Data |
---|---|---|
33cea517 | 1 | import { |
32de5a57 | 2 | ProcedureName, |
33cea517 JB |
3 | ProtocolRequestHandler, |
4 | ProtocolVersion, | |
89b7a234 | 5 | RequestPayload, |
33cea517 | 6 | } from '../../../types/UIProtocol'; |
4e3ff94d JB |
7 | import { |
8 | BroadcastChannelProcedureName, | |
9 | BroadcastChannelRequestPayload, | |
10 | } from '../../../types/WorkerBroadcastChannel'; | |
fe94fce0 | 11 | import { AbstractUIServer } from '../AbstractUIServer'; |
4198ad5c | 12 | import AbstractUIService from './AbstractUIService'; |
4198ad5c | 13 | |
f16356b9 | 14 | export default class UIService001 extends AbstractUIService { |
fe94fce0 | 15 | constructor(uiServer: AbstractUIServer) { |
33cea517 | 16 | super(uiServer, ProtocolVersion['0.0.1']); |
02a6943a | 17 | this.requestHandlers.set( |
32de5a57 | 18 | ProcedureName.START_TRANSACTION, |
e7aeea18 JB |
19 | this.handleStartTransaction.bind(this) as ProtocolRequestHandler |
20 | ); | |
02a6943a | 21 | this.requestHandlers.set( |
32de5a57 | 22 | ProcedureName.STOP_TRANSACTION, |
e7aeea18 JB |
23 | this.handleStopTransaction.bind(this) as ProtocolRequestHandler |
24 | ); | |
02a6943a | 25 | this.requestHandlers.set( |
89b7a234 JB |
26 | ProcedureName.START_CHARGING_STATION, |
27 | this.handleStartChargingStation.bind(this) as ProtocolRequestHandler | |
28 | ); | |
02a6943a | 29 | this.requestHandlers.set( |
89b7a234 JB |
30 | ProcedureName.STOP_CHARGING_STATION, |
31 | this.handleStopChargingStation.bind(this) as ProtocolRequestHandler | |
32 | ); | |
db2336d9 JB |
33 | this.requestHandlers.set( |
34 | ProcedureName.OPEN_CONNECTION, | |
35 | this.handleOpenConnection.bind(this) as ProtocolRequestHandler | |
36 | ); | |
37 | this.requestHandlers.set( | |
38 | ProcedureName.CLOSE_CONNECTION, | |
39 | this.handleCloseConnection.bind(this) as ProtocolRequestHandler | |
40 | ); | |
89b7a234 JB |
41 | } |
42 | ||
6c8f5d90 | 43 | private handleStartTransaction(uuid: string, payload: RequestPayload): void { |
6812b4e1 | 44 | this.uiServiceWorkerBroadcastChannel.sendRequest([ |
4e3ff94d | 45 | uuid, |
89b7a234 | 46 | BroadcastChannelProcedureName.START_TRANSACTION, |
4e3ff94d | 47 | payload as BroadcastChannelRequestPayload, |
89b7a234 | 48 | ]); |
89b7a234 JB |
49 | } |
50 | ||
6c8f5d90 | 51 | private handleStopTransaction(uuid: string, payload: RequestPayload): void { |
6812b4e1 | 52 | this.uiServiceWorkerBroadcastChannel.sendRequest([ |
4e3ff94d | 53 | uuid, |
89b7a234 | 54 | BroadcastChannelProcedureName.STOP_TRANSACTION, |
4e3ff94d | 55 | payload as BroadcastChannelRequestPayload, |
89b7a234 | 56 | ]); |
4198ad5c JB |
57 | } |
58 | ||
6c8f5d90 | 59 | private handleStartChargingStation(uuid: string, payload: RequestPayload): void { |
6812b4e1 | 60 | this.uiServiceWorkerBroadcastChannel.sendRequest([ |
4e3ff94d | 61 | uuid, |
89b7a234 | 62 | BroadcastChannelProcedureName.START_CHARGING_STATION, |
4e3ff94d | 63 | payload as BroadcastChannelRequestPayload, |
89b7a234 | 64 | ]); |
32de5a57 LM |
65 | } |
66 | ||
6c8f5d90 | 67 | private handleStopChargingStation(uuid: string, payload: RequestPayload): void { |
6812b4e1 | 68 | this.uiServiceWorkerBroadcastChannel.sendRequest([ |
4e3ff94d | 69 | uuid, |
89b7a234 | 70 | BroadcastChannelProcedureName.STOP_CHARGING_STATION, |
4e3ff94d | 71 | payload as BroadcastChannelRequestPayload, |
89b7a234 | 72 | ]); |
32de5a57 | 73 | } |
db2336d9 JB |
74 | |
75 | private handleOpenConnection(uuid: string, payload: RequestPayload): void { | |
76 | this.uiServiceWorkerBroadcastChannel.sendRequest([ | |
77 | uuid, | |
78 | BroadcastChannelProcedureName.OPEN_CONNECTION, | |
79 | payload as BroadcastChannelRequestPayload, | |
80 | ]); | |
81 | } | |
82 | ||
83 | private handleCloseConnection(uuid: string, payload: RequestPayload): void { | |
84 | this.uiServiceWorkerBroadcastChannel.sendRequest([ | |
85 | uuid, | |
86 | BroadcastChannelProcedureName.CLOSE_CONNECTION, | |
87 | payload as BroadcastChannelRequestPayload, | |
88 | ]); | |
89 | } | |
4198ad5c | 90 | } |