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