X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Ftypes%2FChargingStationWorker.ts;h=ff3c5ef0fe56ed6b29d11745279dd334741a3b92;hb=0b1828224edf798044ef54672ddfc69598cd99a5;hp=d2881c0aa1f126fa955fc45f55c39d15fdffe8b3;hpb=ef4932d8aec470321413643e3c0647b0b29396de;p=e-mobility-charging-stations-simulator.git diff --git a/src/types/ChargingStationWorker.ts b/src/types/ChargingStationWorker.ts index d2881c0a..ff3c5ef0 100644 --- a/src/types/ChargingStationWorker.ts +++ b/src/types/ChargingStationWorker.ts @@ -1,56 +1,82 @@ -import type { WebSocket } from 'ws'; - -import type { - BootNotificationResponse, - ChargingStationAutomaticTransactionGeneratorConfiguration, - ChargingStationInfo, - ConnectorStatus, - JsonObject, - Statistics, -} from './internal'; -import { type WorkerData, type WorkerMessage, WorkerMessageEvents } from '../worker'; - -interface ChargingStationWorkerOptions extends JsonObject { - elementStartDelay?: number; +import type { WebSocket } from 'ws' + +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' +import { type WorkerData, type WorkerMessage, WorkerMessageEvents } from '../worker/index.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; + ...ChargingStationEvents, + ...ChargingStationMessageEvents +} as const +// eslint-disable-next-line @typescript-eslint/no-redeclare +export type ChargingStationWorkerMessageEvents = + | WorkerMessageEvents + | ChargingStationEvents + | ChargingStationMessageEvents -export type ChargingStationWorkerMessageData = ChargingStationData | Statistics; +export interface ChargingStationWorkerEventError extends WorkerData { + event: WorkerMessageEvents + name: string + message: string + stack?: string +} + +export type ChargingStationWorkerMessageData = + | ChargingStationData + | Statistics + | ChargingStationWorkerEventError export type ChargingStationWorkerMessage = Omit< - WorkerMessage, - 'id' +WorkerMessage, +'event' > & { - id: ChargingStationWorkerMessageEvents; -}; + event: ChargingStationWorkerMessageEvents +}