X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Ftypes%2FChargingStationWorker.ts;h=4d47a5e3698bb96a5bad1e9f3093af396993be32;hb=9388120364d5a2f3b9103f05802e1756d2dad04f;hp=cd2cb0058993ffb4ba6923a4b9f7b36c33f5814f;hpb=2896e06dc8d72adf7150b23c941079f622f6f37c;p=e-mobility-charging-stations-simulator.git diff --git a/src/types/ChargingStationWorker.ts b/src/types/ChargingStationWorker.ts index cd2cb005..4d47a5e3 100644 --- a/src/types/ChargingStationWorker.ts +++ b/src/types/ChargingStationWorker.ts @@ -1,56 +1,68 @@ -import type { WebSocket } from 'ws'; - -import type { - BootNotificationResponse, - ChargingStationAutomaticTransactionGeneratorConfiguration, - ChargingStationInfo, - ConnectorStatus, - JsonObject, - Statistics, -} from './internal'; -import { type WorkerData, type WorkerMessage, WorkerMessageEvents } from '../worker'; - -export interface ChargingStationWorkerOptions extends JsonObject { - elementStartDelay?: number; +import type { WebSocket } from 'ws' + +import type { WorkerData } from '../worker/index.js' +import type { ChargingStationAutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator.js' +import { ChargingStationEvents } from './ChargingStationEvents.js' +import type { ChargingStationInfo } from './ChargingStationInfo.js' +import type { ChargingStationOcppConfiguration } from './ChargingStationOcppConfiguration.js' +import type { ConnectorStatus } from './ConnectorStatus.js' +import type { EvseStatus } from './Evse.js' +import type { JsonObject } from './JsonType.js' +import type { BootNotificationResponse } from './ocpp/Responses.js' +import type { Statistics } from './Statistics.js' + +export interface ChargingStationOptions extends JsonObject { + supervisionUrls?: string | string[] + persistentConfiguration?: boolean + autoStart?: boolean + autoRegister?: boolean + enableStatistics?: boolean + ocppStrictCompliance?: boolean + stopTransactionsOnStopped?: boolean } export interface ChargingStationWorkerData extends WorkerData { - index: number; - templateFile: string; - chargingStationWorkerOptions?: ChargingStationWorkerOptions; + index: number + templateFile: string + options?: ChargingStationOptions +} + +export type EvseStatusWorkerType = Omit & { + connectors?: ConnectorStatus[] } export interface ChargingStationData extends WorkerData { - stationInfo: ChargingStationInfo; - started: boolean; + started: boolean + stationInfo: ChargingStationInfo + connectors: ConnectorStatus[] + evses: EvseStatusWorkerType[] + ocppConfiguration: ChargingStationOcppConfiguration + supervisionUrl: string wsState?: - | typeof WebSocket.CONNECTING - | typeof WebSocket.OPEN - | typeof WebSocket.CLOSING - | typeof WebSocket.CLOSED; - bootNotificationResponse?: BootNotificationResponse; - connectors: ConnectorStatus[]; - automaticTransactionGenerator?: ChargingStationAutomaticTransactionGeneratorConfiguration; + | 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', + performanceStatistics = 'performanceStatistics' } export const ChargingStationWorkerMessageEvents = { - ...WorkerMessageEvents, - ...ChargingStationMessageEvents, -} as const; -export type ChargingStationWorkerMessageEvents = WorkerMessageEvents | ChargingStationMessageEvents; - -export type ChargingStationWorkerMessageData = ChargingStationData | Statistics; - -export type ChargingStationWorkerMessage = Omit< - WorkerMessage, - 'id' -> & { - id: ChargingStationWorkerMessageEvents; -}; + ...ChargingStationEvents, + ...ChargingStationMessageEvents +} as const +// eslint-disable-next-line @typescript-eslint/no-redeclare +export type ChargingStationWorkerMessageEvents = + | ChargingStationEvents + | ChargingStationMessageEvents + +export type ChargingStationWorkerMessageData = ChargingStationData | Statistics + +export interface ChargingStationWorkerMessage { + event: ChargingStationWorkerMessageEvents + data: T +}