feat: ensure charging station add op return its station info
[e-mobility-charging-stations-simulator.git] / src / types / ChargingStationWorker.ts
index 740d6e50a21a0e30f2138be7cbce8dd49fcf046c..c6fd0af2afdb84bb83cd354a4e00f8a3369d85c8 100644 (file)
@@ -1,5 +1,6 @@
 import type { WebSocket } from 'ws'
 
+import { type WorkerData, type WorkerMessage, WorkerMessageEvents } from '../worker/index.js'
 import type { ChargingStationAutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator.js'
 import { ChargingStationEvents } from './ChargingStationEvents.js'
 import type { ChargingStationInfo } from './ChargingStationInfo.js'
@@ -9,16 +10,21 @@ import type { EvseStatus } from './Evse.js'
 import type { JsonObject } from './JsonType.js'
 import type { BootNotificationResponse } from './ocpp/Responses.js'
 import type { Statistics } from './Statistics.js'
-import { type WorkerData, type WorkerMessage, WorkerMessageEvents } from '../worker/index.js'
 
-interface ChargingStationWorkerOptions extends JsonObject {
-  elementStartDelay?: number
+export interface ChargingStationOptions extends JsonObject {
+  supervisionUrls?: string | string[]
+  persistentConfiguration?: boolean
+  autoStart?: boolean
+  autoRegister?: boolean
+  enableStatistics?: boolean
+  ocppStrictCompliance?: boolean
+  stopTransactionsOnStopped?: boolean
 }
 
 export interface ChargingStationWorkerData extends WorkerData {
   index: number
   templateFile: string
-  chargingStationWorkerOptions?: ChargingStationWorkerOptions
+  options?: ChargingStationOptions
 }
 
 export type EvseStatusWorkerType = Omit<EvseStatus, 'connectors'> & {
@@ -31,6 +37,7 @@ export interface ChargingStationData extends WorkerData {
   connectors: ConnectorStatus[]
   evses: EvseStatusWorkerType[]
   ocppConfiguration: ChargingStationOcppConfiguration
+  supervisionUrl: string
   wsState?:
   | typeof WebSocket.CONNECTING
   | typeof WebSocket.OPEN
@@ -41,7 +48,7 @@ export interface ChargingStationData extends WorkerData {
 }
 
 enum ChargingStationMessageEvents {
-  performanceStatistics = 'performanceStatistics',
+  performanceStatistics = 'performanceStatistics'
 }
 
 export const ChargingStationWorkerMessageEvents = {
@@ -55,7 +62,18 @@ export type ChargingStationWorkerMessageEvents =
   | ChargingStationEvents
   | ChargingStationMessageEvents
 
-export type ChargingStationWorkerMessageData = ChargingStationData | Statistics
+export interface ChargingStationWorkerEventError extends WorkerData {
+  event: WorkerMessageEvents
+  name: string
+  message: string
+  stack?: string
+}
+
+export type ChargingStationWorkerMessageData =
+  | ChargingStationInfo
+  | ChargingStationData
+  | Statistics
+  | ChargingStationWorkerEventError
 
 export type ChargingStationWorkerMessage<T extends ChargingStationWorkerMessageData> = Omit<
 WorkerMessage<T>,