X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Ftypes%2FChargingStationWorker.ts;h=d53152dc00dd4c2cf56f0d23064d35548468d9cc;hb=1185579a331f3484e8ed7882203d2e58466635dd;hp=155a353a0d61efb84bf894de867a86fb8c233a03;hpb=d070d967782492d71c5716d2560177531f826f53;p=e-mobility-charging-stations-simulator.git diff --git a/src/types/ChargingStationWorker.ts b/src/types/ChargingStationWorker.ts index 155a353a..d53152dc 100644 --- a/src/types/ChargingStationWorker.ts +++ b/src/types/ChargingStationWorker.ts @@ -1,8 +1,17 @@ -import { WorkerData, WorkerMessage, WorkerMessageEvents } from './Worker'; - -import { JsonType } from './JsonType'; - -export interface ChargingStationWorkerOptions extends JsonType { +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; } @@ -12,20 +21,38 @@ export interface ChargingStationWorkerData extends WorkerData { chargingStationWorkerOptions?: ChargingStationWorkerOptions; } -enum InternalChargingStationWorkerMessageEvents { +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; +} + +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, 'id'> { +export type ChargingStationWorkerMessage = Omit< + WorkerMessage, + 'id' +> & { id: ChargingStationWorkerMessageEvents; -} +};