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