feat(simulator): expose OCPP configuration in UI protocol
[e-mobility-charging-stations-simulator.git] / src / types / ChargingStationWorker.ts
1 import type { WebSocket } from 'ws';
2
3 import type {
4 BootNotificationResponse,
5 ChargingStationAutomaticTransactionGeneratorConfiguration,
6 ChargingStationInfo,
7 ChargingStationOcppConfiguration,
8 ConnectorStatus,
9 JsonObject,
10 Statistics,
11 } from './internal';
12 import { type WorkerData, type WorkerMessage, WorkerMessageEvents } from '../worker';
13
14 interface ChargingStationWorkerOptions extends JsonObject {
15 elementStartDelay?: number;
16 }
17
18 export interface ChargingStationWorkerData extends WorkerData {
19 index: number;
20 templateFile: string;
21 chargingStationWorkerOptions?: ChargingStationWorkerOptions;
22 }
23
24 export interface ChargingStationData extends WorkerData {
25 started: boolean;
26 stationInfo: ChargingStationInfo;
27 connectors: ConnectorStatus[];
28 ocppConfiguration: ChargingStationOcppConfiguration;
29 wsState?:
30 | typeof WebSocket.CONNECTING
31 | typeof WebSocket.OPEN
32 | typeof WebSocket.CLOSING
33 | typeof WebSocket.CLOSED;
34 bootNotificationResponse?: BootNotificationResponse;
35 automaticTransactionGenerator?: ChargingStationAutomaticTransactionGeneratorConfiguration;
36 }
37
38 enum ChargingStationMessageEvents {
39 STARTED = 'started',
40 STOPPED = 'stopped',
41 UPDATED = 'updated',
42 PERFORMANCE_STATISTICS = 'performanceStatistics',
43 }
44
45 export const ChargingStationWorkerMessageEvents = {
46 ...WorkerMessageEvents,
47 ...ChargingStationMessageEvents,
48 } as const;
49 export type ChargingStationWorkerMessageEvents = WorkerMessageEvents | ChargingStationMessageEvents;
50
51 export type ChargingStationWorkerMessageData = ChargingStationData | Statistics;
52
53 export type ChargingStationWorkerMessage<T extends ChargingStationWorkerMessageData> = Omit<
54 WorkerMessage<T>,
55 'id'
56 > & {
57 id: ChargingStationWorkerMessageEvents;
58 };