Commit | Line | Data |
---|---|---|
66a7748d | 1 | import type { WebSocket } from 'ws' |
17e9e8ce | 2 | |
66a7748d JB |
3 | import type { ChargingStationAutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator.js' |
4 | import { ChargingStationEvents } from './ChargingStationEvents.js' | |
5 | import type { ChargingStationInfo } from './ChargingStationInfo.js' | |
6 | import type { ChargingStationOcppConfiguration } from './ChargingStationOcppConfiguration.js' | |
7 | import type { ConnectorStatus } from './ConnectorStatus.js' | |
8 | import type { EvseStatus } from './Evse.js' | |
9 | import type { JsonObject } from './JsonType.js' | |
10 | import type { BootNotificationResponse } from './ocpp/Responses.js' | |
11 | import type { Statistics } from './Statistics.js' | |
12 | import { type WorkerData, type WorkerMessage, WorkerMessageEvents } from '../worker/index.js' | |
d070d967 | 13 | |
71ac2bd7 JB |
14 | export interface ChargingStationOptions extends JsonObject { |
15 | autoStart?: boolean | |
d070d967 JB |
16 | } |
17 | ||
98dc07fa | 18 | export interface ChargingStationWorkerData extends WorkerData { |
66a7748d JB |
19 | index: number |
20 | templateFile: string | |
71ac2bd7 | 21 | options?: ChargingStationOptions |
98dc07fa JB |
22 | } |
23 | ||
09989bb8 | 24 | export type EvseStatusWorkerType = Omit<EvseStatus, 'connectors'> & { |
66a7748d JB |
25 | connectors?: ConnectorStatus[] |
26 | } | |
52952bf8 | 27 | |
32de5a57 | 28 | export interface ChargingStationData extends WorkerData { |
66a7748d JB |
29 | started: boolean |
30 | stationInfo: ChargingStationInfo | |
31 | connectors: ConnectorStatus[] | |
32 | evses: EvseStatusWorkerType[] | |
33 | ocppConfiguration: ChargingStationOcppConfiguration | |
1d41bc6b | 34 | supervisionUrl: string |
17e9e8ce | 35 | wsState?: |
66a7748d JB |
36 | | typeof WebSocket.CONNECTING |
37 | | typeof WebSocket.OPEN | |
38 | | typeof WebSocket.CLOSING | |
39 | | typeof WebSocket.CLOSED | |
40 | bootNotificationResponse?: BootNotificationResponse | |
41 | automaticTransactionGenerator?: ChargingStationAutomaticTransactionGeneratorConfiguration | |
32de5a57 LM |
42 | } |
43 | ||
44 | enum ChargingStationMessageEvents { | |
a223d9be | 45 | performanceStatistics = 'performanceStatistics' |
98dc07fa JB |
46 | } |
47 | ||
98dc07fa JB |
48 | export const ChargingStationWorkerMessageEvents = { |
49 | ...WorkerMessageEvents, | |
db54d2e0 | 50 | ...ChargingStationEvents, |
66a7748d JB |
51 | ...ChargingStationMessageEvents |
52 | } as const | |
53 | // eslint-disable-next-line @typescript-eslint/no-redeclare | |
db54d2e0 JB |
54 | export type ChargingStationWorkerMessageEvents = |
55 | | WorkerMessageEvents | |
56 | | ChargingStationEvents | |
66a7748d | 57 | | ChargingStationMessageEvents |
98dc07fa | 58 | |
244c1396 JB |
59 | export interface ChargingStationWorkerEventError extends WorkerData { |
60 | event: WorkerMessageEvents | |
61 | name: string | |
62 | message: string | |
63 | stack?: string | |
64 | } | |
65 | ||
66 | export type ChargingStationWorkerMessageData = | |
67 | | ChargingStationData | |
68 | | Statistics | |
69 | | ChargingStationWorkerEventError | |
53e5fd67 | 70 | |
c72f6634 | 71 | export type ChargingStationWorkerMessage<T extends ChargingStationWorkerMessageData> = Omit< |
66a7748d JB |
72 | WorkerMessage<T>, |
73 | 'event' | |
c72f6634 | 74 | > & { |
66a7748d JB |
75 | event: ChargingStationWorkerMessageEvents |
76 | } |