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