X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Ftypes%2FChargingStationWorker.ts;h=ac13f441a921d50eced020fd4defe5c122f77993;hb=12240a2ea6b5c924befefa8846732249ad357730;hp=945d3d207d00865674b9fc7346f3d81a27d57a5b;hpb=8114d10e3893e96bb725ce2fca9744429ee4b75b;p=e-mobility-charging-stations-simulator.git diff --git a/src/types/ChargingStationWorker.ts b/src/types/ChargingStationWorker.ts index 945d3d20..ac13f441 100644 --- a/src/types/ChargingStationWorker.ts +++ b/src/types/ChargingStationWorker.ts @@ -1,4 +1,11 @@ -import { JsonObject } from './JsonType'; +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 { @@ -11,22 +18,38 @@ export interface ChargingStationWorkerData extends WorkerData { chargingStationWorkerOptions?: ChargingStationWorkerOptions; } -enum InternalChargingStationWorkerMessageEvents { +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 ChargingStationMessageEvents { STARTED = 'started', STOPPED = 'stopped', + UPDATED = 'updated', PERFORMANCE_STATISTICS = 'performanceStatistics', } -export type ChargingStationWorkerMessageEvents = - | WorkerMessageEvents - | InternalChargingStationWorkerMessageEvents; +export type ChargingStationWorkerMessageEvents = WorkerMessageEvents | ChargingStationMessageEvents; export const ChargingStationWorkerMessageEvents = { ...WorkerMessageEvents, - ...InternalChargingStationWorkerMessageEvents, + ...ChargingStationMessageEvents, }; -export interface ChargingStationWorkerMessage - extends Omit, 'id'> { +export type ChargingStationWorkerMessageData = ChargingStationData | Statistics; + +export type ChargingStationWorkerMessage = Omit< + WorkerMessage, + 'id' +> & { id: ChargingStationWorkerMessageEvents; -} +};