X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Ftypes%2FChargingStationWorker.ts;h=c27ec6eb32e3eeec4c3cd8290c3cd414502288fc;hb=1b821a640d1f793e969eed6d76e9c20e7cebb626;hp=a48e07688f4df67b21eee449fa407c3ba85518de;hpb=ee0f106b09f38b1561d970ea4377eb199389298e;p=e-mobility-charging-stations-simulator.git diff --git a/src/types/ChargingStationWorker.ts b/src/types/ChargingStationWorker.ts index a48e0768..c27ec6eb 100644 --- a/src/types/ChargingStationWorker.ts +++ b/src/types/ChargingStationWorker.ts @@ -1,24 +1,54 @@ +import type { WebSocket } from 'ws'; + +import type { ChargingStationAutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator'; +import type { ChargingStationInfo } from './ChargingStationInfo'; +import type { ConnectorStatus } from './ConnectorStatus'; +import type { JsonObject } from './JsonType'; +import type { BootNotificationResponse } from './ocpp/Responses'; +import type { Statistics } from './Statistics'; import { WorkerData, WorkerMessage, WorkerMessageEvents } from './Worker'; +export interface ChargingStationWorkerOptions extends JsonObject { + elementStartDelay?: number; +} + export interface ChargingStationWorkerData extends WorkerData { index: number; templateFile: string; + chargingStationWorkerOptions?: ChargingStationWorkerOptions; +} + +export interface ChargingStationData extends WorkerData { + stationInfo: ChargingStationInfo; + started: boolean; + wsState?: + | typeof WebSocket.CONNECTING + | typeof WebSocket.OPEN + | typeof WebSocket.CLOSING + | typeof WebSocket.CLOSED; + bootNotificationResponse: BootNotificationResponse; + connectors: ConnectorStatus[]; + automaticTransactionGenerator?: ChargingStationAutomaticTransactionGeneratorConfiguration; } -enum InternalChargingStationWorkerMessageEvents { +enum ChargingStationMessageEvents { STARTED = 'started', STOPPED = 'stopped', - PERFORMANCE_STATISTICS = 'performanceStatistics' + UPDATED = 'updated', + PERFORMANCE_STATISTICS = 'performanceStatistics', } -export type ChargingStationWorkerMessageEvents = WorkerMessageEvents | InternalChargingStationWorkerMessageEvents; - 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; -} +};