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