fix: add sanity check at evses initialization
[e-mobility-charging-stations-simulator.git] / src / types / ChargingStationWorker.ts
CommitLineData
17e9e8ce
JB
1import type { WebSocket } from 'ws';
2
2896e06d
JB
3import type {
4 BootNotificationResponse,
5 ChargingStationAutomaticTransactionGeneratorConfiguration,
6 ChargingStationInfo,
8d8599f0 7 ChargingStationOcppConfiguration,
2896e06d
JB
8 ConnectorStatus,
9 JsonObject,
10 Statistics,
11} from './internal';
268a74bb 12import { type WorkerData, type WorkerMessage, WorkerMessageEvents } from '../worker';
d070d967 13
ef4932d8 14interface ChargingStationWorkerOptions extends JsonObject {
d070d967
JB
15 elementStartDelay?: number;
16}
17
98dc07fa
JB
18export interface ChargingStationWorkerData extends WorkerData {
19 index: number;
20 templateFile: string;
d070d967 21 chargingStationWorkerOptions?: ChargingStationWorkerOptions;
98dc07fa
JB
22}
23
32de5a57 24export interface ChargingStationData extends WorkerData {
452a82ca 25 started: boolean;
8d8599f0
JB
26 stationInfo: ChargingStationInfo;
27 connectors: ConnectorStatus[];
28 ocppConfiguration: ChargingStationOcppConfiguration;
17e9e8ce
JB
29 wsState?:
30 | typeof WebSocket.CONNECTING
31 | typeof WebSocket.OPEN
32 | typeof WebSocket.CLOSING
33 | typeof WebSocket.CLOSED;
1895299d 34 bootNotificationResponse?: BootNotificationResponse;
c72f6634 35 automaticTransactionGenerator?: ChargingStationAutomaticTransactionGeneratorConfiguration;
32de5a57
LM
36}
37
38enum ChargingStationMessageEvents {
721646e9
JB
39 started = 'started',
40 stopped = 'stopped',
41 updated = 'updated',
42 performanceStatistics = 'performanceStatistics',
98dc07fa
JB
43}
44
98dc07fa
JB
45export const ChargingStationWorkerMessageEvents = {
46 ...WorkerMessageEvents,
32de5a57 47 ...ChargingStationMessageEvents,
edd13439
JB
48} as const;
49export type ChargingStationWorkerMessageEvents = WorkerMessageEvents | ChargingStationMessageEvents;
98dc07fa 50
53e5fd67
JB
51export type ChargingStationWorkerMessageData = ChargingStationData | Statistics;
52
c72f6634
JB
53export type ChargingStationWorkerMessage<T extends ChargingStationWorkerMessageData> = Omit<
54 WorkerMessage<T>,
55 'id'
56> & {
98dc07fa 57 id: ChargingStationWorkerMessageEvents;
17e9e8ce 58};