| 1 | import type { WebSocket } from 'ws' |
| 2 | |
| 3 | import type { WorkerData } from '../worker/index.js' |
| 4 | import type { ChargingStationAutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator.js' |
| 5 | import { ChargingStationEvents } from './ChargingStationEvents.js' |
| 6 | import type { ChargingStationInfo } from './ChargingStationInfo.js' |
| 7 | import type { ChargingStationOcppConfiguration } from './ChargingStationOcppConfiguration.js' |
| 8 | import type { ConnectorStatus } from './ConnectorStatus.js' |
| 9 | import type { EvseStatus } from './Evse.js' |
| 10 | import type { JsonObject } from './JsonType.js' |
| 11 | import type { BootNotificationResponse } from './ocpp/Responses.js' |
| 12 | import type { Statistics } from './Statistics.js' |
| 13 | |
| 14 | export interface ChargingStationOptions extends JsonObject { |
| 15 | supervisionUrls?: string | string[] |
| 16 | persistentConfiguration?: boolean |
| 17 | autoStart?: boolean |
| 18 | autoRegister?: boolean |
| 19 | enableStatistics?: boolean |
| 20 | ocppStrictCompliance?: boolean |
| 21 | stopTransactionsOnStopped?: boolean |
| 22 | } |
| 23 | |
| 24 | export interface ChargingStationWorkerData extends WorkerData { |
| 25 | index: number |
| 26 | templateFile: string |
| 27 | options?: ChargingStationOptions |
| 28 | } |
| 29 | |
| 30 | export type EvseStatusWorkerType = Omit<EvseStatus, 'connectors'> & { |
| 31 | connectors?: ConnectorStatus[] |
| 32 | } |
| 33 | |
| 34 | export interface ChargingStationData extends WorkerData { |
| 35 | started: boolean |
| 36 | stationInfo: ChargingStationInfo |
| 37 | connectors: ConnectorStatus[] |
| 38 | evses: EvseStatusWorkerType[] |
| 39 | ocppConfiguration: ChargingStationOcppConfiguration |
| 40 | supervisionUrl: string |
| 41 | wsState?: |
| 42 | | typeof WebSocket.CONNECTING |
| 43 | | typeof WebSocket.OPEN |
| 44 | | typeof WebSocket.CLOSING |
| 45 | | typeof WebSocket.CLOSED |
| 46 | bootNotificationResponse?: BootNotificationResponse |
| 47 | automaticTransactionGenerator?: ChargingStationAutomaticTransactionGeneratorConfiguration |
| 48 | } |
| 49 | |
| 50 | enum ChargingStationMessageEvents { |
| 51 | performanceStatistics = 'performanceStatistics' |
| 52 | } |
| 53 | |
| 54 | export const ChargingStationWorkerMessageEvents = { |
| 55 | ...ChargingStationEvents, |
| 56 | ...ChargingStationMessageEvents |
| 57 | } as const |
| 58 | // eslint-disable-next-line @typescript-eslint/no-redeclare |
| 59 | export type ChargingStationWorkerMessageEvents = |
| 60 | | ChargingStationEvents |
| 61 | | ChargingStationMessageEvents |
| 62 | |
| 63 | export type ChargingStationWorkerMessageData = ChargingStationData | Statistics |
| 64 | |
| 65 | export interface ChargingStationWorkerMessage<T extends ChargingStationWorkerMessageData> { |
| 66 | event: ChargingStationWorkerMessageEvents |
| 67 | data: T |
| 68 | } |