X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Ftypes%2FChargingStationWorker.ts;h=7578b217270a8e7f6342ef68c7bc90638d9efcd9;hb=bc5b1e94c9b908990fdb7590fa56ae65cfdc83a1;hp=3604a85d01e367d8257838c7eab2aedbbb590c4a;hpb=981ebfbeeb421a4b620aa61861f9ddb313a03f67;p=e-mobility-charging-stations-simulator.git diff --git a/src/types/ChargingStationWorker.ts b/src/types/ChargingStationWorker.ts index 3604a85d..7578b217 100644 --- a/src/types/ChargingStationWorker.ts +++ b/src/types/ChargingStationWorker.ts @@ -1,12 +1,17 @@ -import type { Status } 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 { +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; } @@ -17,31 +22,37 @@ export interface ChargingStationWorkerData extends WorkerData { } export interface ChargingStationData extends WorkerData { - stationInfo: ChargingStationInfo; started: boolean; - wsState?: number; - bootNotificationResponse: BootNotificationResponse; + stationInfo: ChargingStationInfo; connectors: ConnectorStatus[]; - automaticTransactionGeneratorStatuses?: Status[]; + ocppConfiguration: ChargingStationOcppConfiguration; + wsState?: + | typeof WebSocket.CONNECTING + | typeof WebSocket.OPEN + | typeof WebSocket.CLOSING + | typeof WebSocket.CLOSED; + bootNotificationResponse?: BootNotificationResponse; + automaticTransactionGenerator?: ChargingStationAutomaticTransactionGeneratorConfiguration; } enum ChargingStationMessageEvents { - STARTED = 'started', - STOPPED = 'stopped', - UPDATED = 'updated', - PERFORMANCE_STATISTICS = 'performanceStatistics', + started = 'started', + stopped = 'stopped', + updated = 'updated', + performanceStatistics = 'performanceStatistics', } -export type ChargingStationWorkerMessageEvents = WorkerMessageEvents | ChargingStationMessageEvents; - export const ChargingStationWorkerMessageEvents = { ...WorkerMessageEvents, ...ChargingStationMessageEvents, -}; +} as const; +export type ChargingStationWorkerMessageEvents = WorkerMessageEvents | ChargingStationMessageEvents; export type ChargingStationWorkerMessageData = ChargingStationData | Statistics; -export interface ChargingStationWorkerMessage - extends Omit, 'id'> { +export type ChargingStationWorkerMessage = Omit< + WorkerMessage, + 'id' +> & { id: ChargingStationWorkerMessageEvents; -} +};