X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Ftypes%2FChargingStationWorker.ts;h=7578b217270a8e7f6342ef68c7bc90638d9efcd9;hb=f911a4af34e676a49f542aec31cbef8075fb65ef;hp=f016d8ffba7f980cf4ddb77d6222a5c236005676;hpb=98dc07faaf264c0263d2c8de382efa9db59cd5b4;p=e-mobility-charging-stations-simulator.git diff --git a/src/types/ChargingStationWorker.ts b/src/types/ChargingStationWorker.ts index f016d8ff..7578b217 100644 --- a/src/types/ChargingStationWorker.ts +++ b/src/types/ChargingStationWorker.ts @@ -1,22 +1,58 @@ -import { WorkerData, WorkerMessage, WorkerMessageEvents } from './Worker'; +import type { WebSocket } from 'ws'; + +import type { + BootNotificationResponse, + ChargingStationAutomaticTransactionGeneratorConfiguration, + ChargingStationInfo, + ChargingStationOcppConfiguration, + ConnectorStatus, + JsonObject, + Statistics, +} from './internal'; +import { type WorkerData, type WorkerMessage, WorkerMessageEvents } from '../worker'; + +interface ChargingStationWorkerOptions extends JsonObject { + elementStartDelay?: number; +} export interface ChargingStationWorkerData extends WorkerData { index: number; templateFile: string; + chargingStationWorkerOptions?: ChargingStationWorkerOptions; } -enum InternalChargingStationWorkerMessageEvents { - PERFORMANCE_STATISTICS = 'performanceStatistics' +export interface ChargingStationData extends WorkerData { + started: boolean; + stationInfo: ChargingStationInfo; + connectors: ConnectorStatus[]; + ocppConfiguration: ChargingStationOcppConfiguration; + wsState?: + | typeof WebSocket.CONNECTING + | typeof WebSocket.OPEN + | typeof WebSocket.CLOSING + | typeof WebSocket.CLOSED; + bootNotificationResponse?: BootNotificationResponse; + automaticTransactionGenerator?: ChargingStationAutomaticTransactionGeneratorConfiguration; } -export type ChargingStationWorkerMessageEvents = WorkerMessageEvents | InternalChargingStationWorkerMessageEvents; +enum ChargingStationMessageEvents { + started = 'started', + stopped = 'stopped', + updated = 'updated', + performanceStatistics = 'performanceStatistics', +} export const ChargingStationWorkerMessageEvents = { ...WorkerMessageEvents, - ...InternalChargingStationWorkerMessageEvents -}; + ...ChargingStationMessageEvents, +} as const; +export type ChargingStationWorkerMessageEvents = WorkerMessageEvents | ChargingStationMessageEvents; +export type ChargingStationWorkerMessageData = ChargingStationData | Statistics; -export interface ChargingStationWorkerMessage extends Omit { +export type ChargingStationWorkerMessage = Omit< + WorkerMessage, + 'id' +> & { id: ChargingStationWorkerMessageEvents; -} +};