refactor(simulator): remove uneeded check
[e-mobility-charging-stations-simulator.git] / src / types / ChargingStationWorker.ts
... / ...
CommitLineData
1import type { WebSocket } from 'ws';
2
3import type {
4 BootNotificationResponse,
5 ChargingStationAutomaticTransactionGeneratorConfiguration,
6 ChargingStationInfo,
7 ChargingStationOcppConfiguration,
8 ConnectorStatus,
9 JsonObject,
10 Statistics,
11} from './internal';
12import { type WorkerData, type WorkerMessage, WorkerMessageEvents } from '../worker';
13
14interface ChargingStationWorkerOptions extends JsonObject {
15 elementStartDelay?: number;
16}
17
18export interface ChargingStationWorkerData extends WorkerData {
19 index: number;
20 templateFile: string;
21 chargingStationWorkerOptions?: ChargingStationWorkerOptions;
22}
23
24export 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
38enum ChargingStationMessageEvents {
39 started = 'started',
40 stopped = 'stopped',
41 updated = 'updated',
42 performanceStatistics = 'performanceStatistics',
43}
44
45export const ChargingStationWorkerMessageEvents = {
46 ...WorkerMessageEvents,
47 ...ChargingStationMessageEvents,
48} as const;
49export type ChargingStationWorkerMessageEvents = WorkerMessageEvents | ChargingStationMessageEvents;
50
51export type ChargingStationWorkerMessageData = ChargingStationData | Statistics;
52
53export type ChargingStationWorkerMessage<T extends ChargingStationWorkerMessageData> = Omit<
54 WorkerMessage<T>,
55 'id'
56> & {
57 id: ChargingStationWorkerMessageEvents;
58};