| 1 | import type { WebSocket } from 'ws'; |
| 2 | |
| 3 | import type { ChargingStationAutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator'; |
| 4 | import { ChargingStationEvents } from './ChargingStationEvents'; |
| 5 | import type { ChargingStationInfo } from './ChargingStationInfo'; |
| 6 | import type { ChargingStationOcppConfiguration } from './ChargingStationOcppConfiguration'; |
| 7 | import type { ConnectorStatus } from './ConnectorStatus'; |
| 8 | import type { EvseStatus } from './Evse'; |
| 9 | import type { JsonObject } from './JsonType'; |
| 10 | import type { BootNotificationResponse } from './ocpp/Responses'; |
| 11 | import type { Statistics } from './Statistics'; |
| 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 type EvseStatusWorkerType = Omit<EvseStatus, 'connectors'> & { |
| 25 | connectors?: ConnectorStatus[]; |
| 26 | }; |
| 27 | |
| 28 | export interface ChargingStationData extends WorkerData { |
| 29 | started: boolean; |
| 30 | stationInfo: ChargingStationInfo; |
| 31 | connectors: ConnectorStatus[]; |
| 32 | evses: EvseStatusWorkerType[]; |
| 33 | ocppConfiguration: ChargingStationOcppConfiguration; |
| 34 | wsState?: |
| 35 | | typeof WebSocket.CONNECTING |
| 36 | | typeof WebSocket.OPEN |
| 37 | | typeof WebSocket.CLOSING |
| 38 | | typeof WebSocket.CLOSED; |
| 39 | bootNotificationResponse?: BootNotificationResponse; |
| 40 | automaticTransactionGenerator?: ChargingStationAutomaticTransactionGeneratorConfiguration; |
| 41 | } |
| 42 | |
| 43 | enum ChargingStationMessageEvents { |
| 44 | performanceStatistics = 'performanceStatistics', |
| 45 | } |
| 46 | |
| 47 | export const ChargingStationWorkerMessageEvents = { |
| 48 | ...WorkerMessageEvents, |
| 49 | ...ChargingStationEvents, |
| 50 | ...ChargingStationMessageEvents, |
| 51 | } as const; |
| 52 | export type ChargingStationWorkerMessageEvents = |
| 53 | | WorkerMessageEvents |
| 54 | | ChargingStationEvents |
| 55 | | ChargingStationMessageEvents; |
| 56 | |
| 57 | export type ChargingStationWorkerMessageData = ChargingStationData | Statistics; |
| 58 | |
| 59 | export type ChargingStationWorkerMessage<T extends ChargingStationWorkerMessageData> = Omit< |
| 60 | WorkerMessage<T>, |
| 61 | 'event' |
| 62 | > & { |
| 63 | event: ChargingStationWorkerMessageEvents; |
| 64 | }; |