X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Ftypes%2FChargingStationWorker.ts;h=4d47a5e3698bb96a5bad1e9f3093af396993be32;hb=385c5e62929a2c113898706b8ec940840b7f6f4f;hp=f016d8ffba7f980cf4ddb77d6222a5c236005676;hpb=98dc07faaf264c0263d2c8de382efa9db59cd5b4;p=e-mobility-charging-stations-simulator.git diff --git a/src/types/ChargingStationWorker.ts b/src/types/ChargingStationWorker.ts index f016d8ff..4d47a5e3 100644 --- a/src/types/ChargingStationWorker.ts +++ b/src/types/ChargingStationWorker.ts @@ -1,22 +1,68 @@ -import { WorkerData, WorkerMessage, WorkerMessageEvents } from './Worker'; +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; + index: number + templateFile: string + options?: ChargingStationOptions } -enum InternalChargingStationWorkerMessageEvents { - 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 = + | ChargingStationEvents + | ChargingStationMessageEvents +export type ChargingStationWorkerMessageData = ChargingStationData | Statistics -export interface ChargingStationWorkerMessage extends Omit { - id: ChargingStationWorkerMessageEvents; +export interface ChargingStationWorkerMessage { + event: ChargingStationWorkerMessageEvents + data: T }