chargingStationWorkerOptions?: ChargingStationWorkerOptions;
}
-type EvseStatusType = Omit<EvseStatus, 'connectors'> & {
+export type EvseStatusWorkerType = Omit<EvseStatus, 'connectors'> & {
connectors?: ConnectorStatus[];
};
started: boolean;
stationInfo: ChargingStationInfo;
connectors: ConnectorStatus[];
- evses: EvseStatusType[];
+ evses: EvseStatusWorkerType[];
ocppConfiguration: ChargingStationOcppConfiguration;
wsState?:
| typeof WebSocket.CONNECTING
type ChargingStationWorkerMessage,
type ChargingStationWorkerMessageData,
ChargingStationWorkerMessageEvents,
+ type EvseStatusWorkerType,
} from './ChargingStationWorker';
export type { ChargingStationInfo } from './ChargingStationInfo';
export type {
ChargingStationAutomaticTransactionGeneratorConfiguration,
ConnectorStatus,
EvseStatusConfiguration,
+ EvseStatusWorkerType,
} from '../types';
export const buildChargingStationAutomaticTransactionGeneratorConfiguration = (
export const enum OutputFormat {
configuration = 'configuration',
- ipc = 'ipc',
+ worker = 'worker',
}
export const buildEvsesStatus = (
chargingStation: ChargingStation,
outputFormat: OutputFormat = OutputFormat.configuration
-): EvseStatusConfiguration[] => {
+): (EvseStatusWorkerType | EvseStatusConfiguration)[] => {
return [...chargingStation.evses.values()].map((evseStatus) => {
const connectorsStatus = [...evseStatus.connectors.values()].map(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
({ transactionSetInterval, ...connectorStatusRest }) => connectorStatusRest
);
- if (outputFormat === OutputFormat.ipc) {
- return {
- ...evseStatus,
- connectors: connectorsStatus,
- };
- } else if (outputFormat === OutputFormat.configuration) {
- const status = {
- ...evseStatus,
- connectorsStatus,
- };
- delete status.connectors;
- return status;
+ let status: EvseStatusConfiguration;
+ switch (outputFormat) {
+ case OutputFormat.worker:
+ return {
+ ...evseStatus,
+ connectors: connectorsStatus,
+ };
+ case OutputFormat.configuration:
+ status = {
+ ...evseStatus,
+ connectorsStatus,
+ };
+ delete (status as EvseStatusWorkerType).connectors;
+ return status;
}
});
};
started: chargingStation.started,
stationInfo: chargingStation.stationInfo,
connectors: buildConnectorsStatus(chargingStation),
- evses: buildEvsesStatus(chargingStation, OutputFormat.ipc),
+ evses: buildEvsesStatus(chargingStation, OutputFormat.worker),
ocppConfiguration: chargingStation.ocppConfiguration,
wsState: chargingStation?.wsConnection?.readyState,
bootNotificationResponse: chargingStation.bootNotificationResponse,