ATG: fix start transaction requests counting
[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 );
89b7a234
JB
46 }
47
4f69be04 48 private handleStartChargingStation(uuid: string, payload: RequestPayload): void {
0d2cec76 49 this.sendBroadcastChannelRequest(
4e3ff94d 50 uuid,
4f69be04 51 BroadcastChannelProcedureName.START_CHARGING_STATION,
0d2cec76
JB
52 payload
53 );
89b7a234
JB
54 }
55
4f69be04 56 private handleStopChargingStation(uuid: string, payload: RequestPayload): void {
0d2cec76 57 this.sendBroadcastChannelRequest(
4e3ff94d 58 uuid,
4f69be04 59 BroadcastChannelProcedureName.STOP_CHARGING_STATION,
0d2cec76
JB
60 payload
61 );
4198ad5c
JB
62 }
63
4f69be04 64 private handleOpenConnection(uuid: string, payload: RequestPayload): void {
0d2cec76 65 this.sendBroadcastChannelRequest(uuid, BroadcastChannelProcedureName.OPEN_CONNECTION, payload);
32de5a57
LM
66 }
67
4f69be04 68 private handleCloseConnection(uuid: string, payload: RequestPayload): void {
0d2cec76 69 this.sendBroadcastChannelRequest(uuid, BroadcastChannelProcedureName.CLOSE_CONNECTION, payload);
32de5a57 70 }
db2336d9 71
4f69be04 72 private handleStartTransaction(uuid: string, payload: RequestPayload): void {
0d2cec76 73 this.sendBroadcastChannelRequest(
db2336d9 74 uuid,
4f69be04 75 BroadcastChannelProcedureName.START_TRANSACTION,
0d2cec76
JB
76 payload
77 );
db2336d9
JB
78 }
79
4f69be04 80 private handleStopTransaction(uuid: string, payload: RequestPayload): void {
0d2cec76 81 this.sendBroadcastChannelRequest(uuid, BroadcastChannelProcedureName.STOP_TRANSACTION, payload);
4f69be04
JB
82 }
83
84 private handleStartAutomaticTransactionGenerator(uuid: string, payload: RequestPayload): void {
0d2cec76 85 this.sendBroadcastChannelRequest(
4f69be04
JB
86 uuid,
87 BroadcastChannelProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR,
0d2cec76
JB
88 payload
89 );
4f69be04
JB
90 }
91
92 private handleStopAutomaticTransactionGenerator(uuid: string, payload: RequestPayload): void {
0d2cec76 93 this.sendBroadcastChannelRequest(
4f69be04
JB
94 uuid,
95 BroadcastChannelProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR,
0d2cec76
JB
96 payload
97 );
db2336d9 98 }
4198ad5c 99}