| 1 | import type { WebSocket } from 'ws' |
| 2 | |
| 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' |
| 13 | |
| 14 | export interface ChargingStationOptions extends JsonObject { |
| 15 | persistentConfiguration?: boolean |
| 16 | autoStart?: boolean |
| 17 | autoRegister?: boolean |
| 18 | enableStatistics?: boolean |
| 19 | ocppStrictCompliance?: boolean |
| 20 | stopTransactionsOnStopped?: boolean |
| 21 | } |
| 22 | |
| 23 | export interface ChargingStationWorkerData extends WorkerData { |
| 24 | index: number |
| 25 | templateFile: string |
| 26 | options?: ChargingStationOptions |
| 27 | } |
| 28 | |
| 29 | export type EvseStatusWorkerType = Omit<EvseStatus, 'connectors'> & { |
| 30 | connectors?: ConnectorStatus[] |
| 31 | } |
| 32 | |
| 33 | export interface ChargingStationData extends WorkerData { |
| 34 | started: boolean |
| 35 | stationInfo: ChargingStationInfo |
| 36 | connectors: ConnectorStatus[] |
| 37 | evses: EvseStatusWorkerType[] |
| 38 | ocppConfiguration: ChargingStationOcppConfiguration |
| 39 | supervisionUrl: string |
| 40 | wsState?: |
| 41 | | typeof WebSocket.CONNECTING |
| 42 | | typeof WebSocket.OPEN |
| 43 | | typeof WebSocket.CLOSING |
| 44 | | typeof WebSocket.CLOSED |
| 45 | bootNotificationResponse?: BootNotificationResponse |
| 46 | automaticTransactionGenerator?: ChargingStationAutomaticTransactionGeneratorConfiguration |
| 47 | } |
| 48 | |
| 49 | enum ChargingStationMessageEvents { |
| 50 | performanceStatistics = 'performanceStatistics' |
| 51 | } |
| 52 | |
| 53 | export const ChargingStationWorkerMessageEvents = { |
| 54 | ...WorkerMessageEvents, |
| 55 | ...ChargingStationEvents, |
| 56 | ...ChargingStationMessageEvents |
| 57 | } as const |
| 58 | // eslint-disable-next-line @typescript-eslint/no-redeclare |
| 59 | export type ChargingStationWorkerMessageEvents = |
| 60 | | WorkerMessageEvents |
| 61 | | ChargingStationEvents |
| 62 | | ChargingStationMessageEvents |
| 63 | |
| 64 | export interface ChargingStationWorkerEventError extends WorkerData { |
| 65 | event: WorkerMessageEvents |
| 66 | name: string |
| 67 | message: string |
| 68 | stack?: string |
| 69 | } |
| 70 | |
| 71 | export type ChargingStationWorkerMessageData = |
| 72 | | ChargingStationData |
| 73 | | Statistics |
| 74 | | ChargingStationWorkerEventError |
| 75 | |
| 76 | export type ChargingStationWorkerMessage<T extends ChargingStationWorkerMessageData> = Omit< |
| 77 | WorkerMessage<T>, |
| 78 | 'event' |
| 79 | > & { |
| 80 | event: ChargingStationWorkerMessageEvents |
| 81 | } |