X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Ftypes%2FChargingStationWorker.ts;h=ff3c5ef0fe56ed6b29d11745279dd334741a3b92;hb=57c0ba059e47d46ad545d9783920b53ee56c7184;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..ff3c5ef0 100644 --- a/src/types/ChargingStationWorker.ts +++ b/src/types/ChargingStationWorker.ts @@ -1,31 +1,82 @@ -import { WorkerData, WorkerMessage, WorkerMessageEvents } from './Worker'; +import type { WebSocket } from 'ws' -import { JsonType } from './JsonType'; +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 ChargingStationWorkerOptions extends JsonType { - elementStartDelay?: number; +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 } -enum InternalChargingStationWorkerMessageEvents { - STARTED = 'started', - STOPPED = 'stopped', - PERFORMANCE_STATISTICS = 'performanceStatistics' +export type EvseStatusWorkerType = Omit & { + connectors?: ConnectorStatus[] } -export type ChargingStationWorkerMessageEvents = WorkerMessageEvents | InternalChargingStationWorkerMessageEvents; +export interface ChargingStationData extends WorkerData { + 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 + automaticTransactionGenerator?: ChargingStationAutomaticTransactionGeneratorConfiguration +} + +enum ChargingStationMessageEvents { + performanceStatistics = 'performanceStatistics' +} export const ChargingStationWorkerMessageEvents = { ...WorkerMessageEvents, - ...InternalChargingStationWorkerMessageEvents -}; + ...ChargingStationEvents, + ...ChargingStationMessageEvents +} as const +// eslint-disable-next-line @typescript-eslint/no-redeclare +export type ChargingStationWorkerMessageEvents = + | WorkerMessageEvents + | ChargingStationEvents + | ChargingStationMessageEvents + +export interface ChargingStationWorkerEventError extends WorkerData { + event: WorkerMessageEvents + name: string + message: string + stack?: string +} +export type ChargingStationWorkerMessageData = + | ChargingStationData + | Statistics + | ChargingStationWorkerEventError -export interface ChargingStationWorkerMessage extends Omit, 'id'> { - id: ChargingStationWorkerMessageEvents; +export type ChargingStationWorkerMessage = Omit< +WorkerMessage, +'event' +> & { + event: ChargingStationWorkerMessageEvents }