UI Services: add status notification command
[e-mobility-charging-stations-simulator.git] / src / charging-station / ui-server / ui-services / UIService001.ts
CommitLineData
33cea517 1import {
32de5a57 2 ProcedureName,
33cea517
JB
3 ProtocolRequestHandler,
4 ProtocolVersion,
89b7a234 5 RequestPayload,
33cea517 6} from '../../../types/UIProtocol';
0d2cec76 7import { BroadcastChannelProcedureName } from '../../../types/WorkerBroadcastChannel';
6c1761d4 8import type { AbstractUIServer } from '../AbstractUIServer';
4198ad5c 9import AbstractUIService from './AbstractUIService';
4198ad5c 10
f16356b9 11export 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 );
a9ed42b2
JB
46 this.requestHandlers.set(
47 ProcedureName.STATUS_NOTIFICATION,
48 this.handleStatusNotification.bind(this) as ProtocolRequestHandler
49 );
89b7a234
JB
50 }
51
4f69be04 52 private handleStartChargingStation(uuid: string, payload: RequestPayload): void {
0d2cec76 53 this.sendBroadcastChannelRequest(
4e3ff94d 54 uuid,
4f69be04 55 BroadcastChannelProcedureName.START_CHARGING_STATION,
0d2cec76
JB
56 payload
57 );
89b7a234
JB
58 }
59
4f69be04 60 private handleStopChargingStation(uuid: string, payload: RequestPayload): void {
0d2cec76 61 this.sendBroadcastChannelRequest(
4e3ff94d 62 uuid,
4f69be04 63 BroadcastChannelProcedureName.STOP_CHARGING_STATION,
0d2cec76
JB
64 payload
65 );
4198ad5c
JB
66 }
67
4f69be04 68 private handleOpenConnection(uuid: string, payload: RequestPayload): void {
0d2cec76 69 this.sendBroadcastChannelRequest(uuid, BroadcastChannelProcedureName.OPEN_CONNECTION, payload);
32de5a57
LM
70 }
71
4f69be04 72 private handleCloseConnection(uuid: string, payload: RequestPayload): void {
0d2cec76 73 this.sendBroadcastChannelRequest(uuid, BroadcastChannelProcedureName.CLOSE_CONNECTION, payload);
32de5a57 74 }
db2336d9 75
4f69be04 76 private handleStartTransaction(uuid: string, payload: RequestPayload): void {
0d2cec76 77 this.sendBroadcastChannelRequest(
db2336d9 78 uuid,
4f69be04 79 BroadcastChannelProcedureName.START_TRANSACTION,
0d2cec76
JB
80 payload
81 );
db2336d9
JB
82 }
83
4f69be04 84 private handleStopTransaction(uuid: string, payload: RequestPayload): void {
0d2cec76 85 this.sendBroadcastChannelRequest(uuid, BroadcastChannelProcedureName.STOP_TRANSACTION, payload);
4f69be04
JB
86 }
87
88 private handleStartAutomaticTransactionGenerator(uuid: string, payload: RequestPayload): void {
0d2cec76 89 this.sendBroadcastChannelRequest(
4f69be04
JB
90 uuid,
91 BroadcastChannelProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR,
0d2cec76
JB
92 payload
93 );
4f69be04
JB
94 }
95
96 private handleStopAutomaticTransactionGenerator(uuid: string, payload: RequestPayload): void {
0d2cec76 97 this.sendBroadcastChannelRequest(
4f69be04
JB
98 uuid,
99 BroadcastChannelProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR,
0d2cec76
JB
100 payload
101 );
db2336d9 102 }
a9ed42b2
JB
103
104 private handleStatusNotification(uuid: string, payload: RequestPayload): void {
105 this.sendBroadcastChannelRequest(
106 uuid,
107 BroadcastChannelProcedureName.STATUS_NOTIFICATION,
108 payload
109 );
110 }
4198ad5c 111}