X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Ftypes%2FChargingStationWorker.ts;h=ff3c5ef0fe56ed6b29d11745279dd334741a3b92;hb=57c0ba059e47d46ad545d9783920b53ee56c7184;hp=5cd731600db3c7311540003c74064dae77338b3b;hpb=a6ef1ece74c0d08e86a905571f4f6045c28131cb;p=e-mobility-charging-stations-simulator.git diff --git a/src/types/ChargingStationWorker.ts b/src/types/ChargingStationWorker.ts index 5cd73160..ff3c5ef0 100644 --- a/src/types/ChargingStationWorker.ts +++ b/src/types/ChargingStationWorker.ts @@ -1,64 +1,82 @@ -import type { WebSocket } from 'ws'; +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'; +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' -interface ChargingStationWorkerOptions extends JsonObject { - 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 } export type EvseStatusWorkerType = Omit & { - connectors?: ConnectorStatus[]; -}; + connectors?: ConnectorStatus[] +} export interface ChargingStationData extends WorkerData { - started: boolean; - stationInfo: ChargingStationInfo; - connectors: ConnectorStatus[]; - evses: EvseStatusWorkerType[]; - ocppConfiguration: ChargingStationOcppConfiguration; + 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; + | typeof WebSocket.CONNECTING + | typeof WebSocket.OPEN + | typeof WebSocket.CLOSING + | typeof WebSocket.CLOSED + bootNotificationResponse?: BootNotificationResponse + automaticTransactionGenerator?: ChargingStationAutomaticTransactionGeneratorConfiguration } enum ChargingStationMessageEvents { - performanceStatistics = 'performanceStatistics', + performanceStatistics = 'performanceStatistics' } export const ChargingStationWorkerMessageEvents = { ...WorkerMessageEvents, ...ChargingStationEvents, - ...ChargingStationMessageEvents, -} as const; + ...ChargingStationMessageEvents +} as const +// eslint-disable-next-line @typescript-eslint/no-redeclare export type ChargingStationWorkerMessageEvents = | WorkerMessageEvents | ChargingStationEvents - | ChargingStationMessageEvents; + | ChargingStationMessageEvents + +export interface ChargingStationWorkerEventError extends WorkerData { + event: WorkerMessageEvents + name: string + message: string + stack?: string +} -export type ChargingStationWorkerMessageData = ChargingStationData | Statistics; +export type ChargingStationWorkerMessageData = + | ChargingStationData + | Statistics + | ChargingStationWorkerEventError export type ChargingStationWorkerMessage = Omit< - WorkerMessage, - 'event' +WorkerMessage, +'event' > & { - event: ChargingStationWorkerMessageEvents; -}; + event: ChargingStationWorkerMessageEvents +}