// This file is auto-generated by @hey-api/openapi-ts import { type DefaultError, queryOptions, type UseMutationOptions } from '@tanstack/react-query'; import { client } from '../client.gen'; import { getConfigAzimInt, getConfigBraggIntegration, getConfigDarkMask, getConfigDetector, getConfigFileWriter, getConfigImageFormat, getConfigIndexing, getConfigInstrument, getConfigMask, getConfigMaskTiff, getConfigRoi, getConfigSelectDetector, getConfigSpotFinding, getConfigUserMask, getConfigUserMaskTiff, getConfigZeromqMetadata, getConfigZeromqPreview, getDetectorStatus, getFpgaStatus, getImageBufferImageCbor, getImageBufferImageJpeg, getImageBufferImageTiff, getImageBufferStartCbor, getImageBufferStatus, getImagePusherStatus, getPreviewPedestalTiff, getPreviewPlot, getPreviewPlotBin, getResultScan, getStatistics, getStatisticsCalibration, getStatisticsDataCollection, getStatus, getVersion, getXfelEventCode, getXfelPulseId, type Options, postCancel, postConfigImageFormatConversion, postConfigImageFormatRaw, postDeactivate, postImageBufferClear, postInitialize, postPedestal, postStart, postTrigger, postWaitTillDone, postWaitUntilRunning, putConfigAzimInt, putConfigBraggIntegration, putConfigDarkMask, putConfigDetector, putConfigFileWriter, putConfigImageFormat, putConfigIndexing, putConfigInstrument, putConfigInternalGeneratorImage, putConfigInternalGeneratorImageTiff, putConfigRoi, putConfigSelectDetector, putConfigSpotFinding, putConfigUserMask, putConfigUserMaskTiff, putConfigZeromqMetadata, putConfigZeromqPreview } from '../sdk.gen'; import type { getConfigAzimIntData, getConfigAzimIntResponse, getConfigBraggIntegrationData, getConfigBraggIntegrationResponse, getConfigDarkMaskData, getConfigDarkMaskResponse, getConfigDetectorData, getConfigDetectorResponse, getConfigFileWriterData, getConfigFileWriterResponse, getConfigImageFormatData, getConfigImageFormatResponse, getConfigIndexingData, getConfigIndexingResponse, getConfigInstrumentData, getConfigInstrumentResponse, getConfigMaskData, getConfigMaskResponse, getConfigMaskTiffData, getConfigMaskTiffResponse, getConfigRoiData, getConfigRoiResponse, getConfigSelectDetectorData, getConfigSelectDetectorResponse, getConfigSpotFindingData, getConfigSpotFindingResponse, getConfigUserMaskData, getConfigUserMaskResponse, getConfigUserMaskTiffData, getConfigUserMaskTiffResponse, getConfigZeromqMetadataData, getConfigZeromqMetadataResponse, getConfigZeromqPreviewData, getConfigZeromqPreviewResponse, getDetectorStatusData, getDetectorStatusError, getDetectorStatusResponse, getFpgaStatusData, getFpgaStatusResponse, getImageBufferImageCborData, getImageBufferImageCborError, getImageBufferImageCborResponse, getImageBufferImageJpegData, getImageBufferImageJpegError, getImageBufferImageJpegResponse, getImageBufferImageTiffData, getImageBufferImageTiffResponse, getImageBufferStartCborData, getImageBufferStartCborError, getImageBufferStartCborResponse, getImageBufferStatusData, getImageBufferStatusError, getImageBufferStatusResponse, getImagePusherStatusData, getImagePusherStatusError, getImagePusherStatusResponse, getPreviewPedestalTiffData, getPreviewPedestalTiffResponse, getPreviewPlotBinData, getPreviewPlotBinError, getPreviewPlotBinResponse, getPreviewPlotData, getPreviewPlotError, getPreviewPlotResponse, getResultScanData, getResultScanError, getResultScanResponse, getStatisticsCalibrationData, getStatisticsCalibrationResponse, getStatisticsData, getStatisticsDataCollectionData, getStatisticsDataCollectionResponse, getStatisticsResponse, getStatusData, getStatusResponse, getVersionData, getVersionResponse, getXfelEventCodeData, getXfelEventCodeResponse, getXfelPulseIdData, getXfelPulseIdResponse, postCancelData, postConfigImageFormatConversionData, postConfigImageFormatConversionError, postConfigImageFormatRawData, postConfigImageFormatRawError, postDeactivateData, postDeactivateError, postImageBufferClearData, postImageBufferClearError, postInitializeData, postInitializeError, postPedestalData, postPedestalError, postStartData, postStartError, postTriggerData, postWaitTillDoneData, postWaitTillDoneError, postWaitUntilRunningData, postWaitUntilRunningError, putConfigAzimIntData, putConfigAzimIntError, putConfigBraggIntegrationData, putConfigBraggIntegrationError, putConfigDarkMaskData, putConfigDarkMaskError, putConfigDetectorData, putConfigDetectorError, putConfigFileWriterData, putConfigFileWriterError, putConfigImageFormatData, putConfigImageFormatError, putConfigIndexingData, putConfigIndexingError, putConfigInstrumentData, putConfigInstrumentError, putConfigInternalGeneratorImageData, putConfigInternalGeneratorImageError, putConfigInternalGeneratorImageTiffData, putConfigInternalGeneratorImageTiffError, putConfigRoiData, putConfigRoiError, putConfigSelectDetectorData, putConfigSelectDetectorError, putConfigSpotFindingData, putConfigSpotFindingError, putConfigUserMaskData, putConfigUserMaskError, putConfigUserMaskTiffData, putConfigUserMaskTiffError, putConfigZeromqMetadataData, putConfigZeromqMetadataError, putConfigZeromqPreviewData, putConfigZeromqPreviewError } from '../types.gen'; /** * Initialize detector and data acquisition * * Should be used in two cases: * - Detector is in `Inactive` state * - Detector is in `Error` state * X-ray shutter must be closed. * This operation will reconfigure network interface of the detector. * During operation of the detector it is recommended to use the `POST /pedestal` operation instead. * If storage cells are used, the execution time might be few minutes. * * This is async function - one needs to use `POST /wait_till_done` to ensure operation is done. * */ export const postInitializeMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await postInitialize({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; /** * Collect dark current for the detector * * Updates calibration of the JUNGFRAU detector. Must be in `Idle` state. * * X-ray shutter must be closed. Recommended to run once per hour for long integration times (> 100 us). * * This is async function - one needs to use `POST /wait_till_done` to ensure operation is done. * */ export const postPedestalMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await postPedestal({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; /** * Start detector * * Start data acquisition. * Detector must be in `Idle` state. * Default behavior is for the call to block until detector is ready to accept soft/TTL triggers. * However, this behavior can be changed by settings `async_start` to true in the request body, * in which case the call will return immediately and one needs to use `/wait_until_running` to ensure detector is ready to run. * */ export const postStartMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await postStart({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; /** * Wait for acquisition running * * Block execution of external script till detector and Jungfraujoch are ready to collect data. * To not block web server for a indefinite period of time, the procedure is provided with a timeout. * Extending timeout is possible, but requires to ensure safety that client will not close the connection and retry the connection. * */ export const postWaitUntilRunningMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await postWaitUntilRunning({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; /** * Wait for acquisition done * * Block execution of external script till initialization, data collection or pedestal is finished. * Running this command does not affect (cancel) running data collection, it is only to ensure synchronous execution of other software. * * To not block web server for a indefinite period of time, the procedure is provided with a timeout. * Extending timeout is possible, but requires to ensure safety that client will not close the connection and retry the connection. * */ export const postWaitTillDoneMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await postWaitTillDone({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; /** * Send soft trigger to the detector * * Generate soft trigger */ export const postTriggerMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await postTrigger({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; /** * Cancel running data collection * * Command will inform FPGA network card to stop pedestal or data collection at the current stage. * Any frame that is currently being processed by CPU will be finished and sent to writer. * Given the command is making sure to gracefully stop data acquisition and detector, it might take some time to switch back after command finished to `Idle` state. * * If data collection is not running, the command has no effect. * */ export const postCancelMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await postCancel({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; /** * Prepare detector to turn off * * Should be in `Idle` or `Error` state. * Command deactivates data acquisition and turns off detector high voltage and ASIC. * Should be used always before turning off power from the detector. * */ export const postDeactivateMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await postDeactivate({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; export type QueryKey = [ Pick & { _id: string; _infinite?: boolean; tags?: ReadonlyArray; } ]; const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } if (tags) { params.tags = tags; } if (options?.body) { params.body = options.body; } if (options?.headers) { params.headers = options.headers; } if (options?.path) { params.path = options.path; } if (options?.query) { params.query = options.query; } return [params]; }; export const getConfigDetectorQueryKey = (options?: Options) => createQueryKey('getConfigDetector', options); /** * Get detector configuration * * Can be done anytime */ export const getConfigDetectorOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getConfigDetector({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getConfigDetectorQueryKey(options) }); /** * Change detector configuration * * Detector settings are ones that have effect on calibration, i.e., pedestal has to be collected again after changing these settings. * This can only be done when detector is `Idle`, `Error` or `Inactive` states. * If detector is in `Idle` state , pedestal procedure will be executed automatically - there must be no X-rays on the detector during the operation. * If detector is in `Inactive` or `Error` states, new settings will be saved, but no calibration will be executed. * */ export const putConfigDetectorMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await putConfigDetector({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; export const getConfigIndexingQueryKey = (options?: Options) => createQueryKey('getConfigIndexing', options); /** * Get indexing configuration * * Can be done anytime */ export const getConfigIndexingOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getConfigIndexing({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getConfigIndexingQueryKey(options) }); /** * Change indexing algorithm settings * * This can only be done when detector is `Idle`, `Error` or `Inactive` states. * */ export const putConfigIndexingMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await putConfigIndexing({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; export const getConfigBraggIntegrationQueryKey = (options?: Options) => createQueryKey('getConfigBraggIntegration', options); /** * Get Bragg integration configuration * * Can be done anytime */ export const getConfigBraggIntegrationOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getConfigBraggIntegration({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getConfigBraggIntegrationQueryKey(options) }); /** * Change Bragg integration settings * * This can only be done when detector is `Idle`, `Error` or `Inactive` states. * */ export const putConfigBraggIntegrationMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await putConfigBraggIntegration({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; export const getConfigFileWriterQueryKey = (options?: Options) => createQueryKey('getConfigFileWriter', options); /** * Get file writer settings * * Can be done anytime */ export const getConfigFileWriterOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getConfigFileWriter({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getConfigFileWriterQueryKey(options) }); /** * Change file writer settings * * This can only be done when detector is `Idle`, `Error` or `Inactive` states. * */ export const putConfigFileWriterMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await putConfigFileWriter({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; export const getConfigInstrumentQueryKey = (options?: Options) => createQueryKey('getConfigInstrument', options); /** * Get instrument metadata * * Can be done anytime */ export const getConfigInstrumentOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getConfigInstrument({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getConfigInstrumentQueryKey(options) }); /** * Change instrument metadata * * This can only be done when detector is `Idle`, `Error` or `Inactive` states. * */ export const putConfigInstrumentMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await putConfigInstrument({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; export const getConfigImageFormatQueryKey = (options?: Options) => createQueryKey('getConfigImageFormat', options); /** * Get image output format * * Can be done anytime */ export const getConfigImageFormatOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getConfigImageFormat({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getConfigImageFormatQueryKey(options) }); /** * Change image output format * * This can only be done when detector is `Idle`, `Error` or `Inactive` states. * */ export const putConfigImageFormatMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await putConfigImageFormat({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; /** * Configure format for raw data collection * * This can only be done when detector is `Idle`, `Error` or `Inactive` states. * */ export const postConfigImageFormatRawMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await postConfigImageFormatRaw({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; /** * Configure format for data collection with full conversion * * This can only be done when detector is `Idle`, `Error` or `Inactive` states. * */ export const postConfigImageFormatConversionMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await postConfigImageFormatConversion({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; export const getConfigSpotFindingQueryKey = (options?: Options) => createQueryKey('getConfigSpotFinding', options); /** * Get data processing configuration * * Can be done anytime */ export const getConfigSpotFindingOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getConfigSpotFinding({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getConfigSpotFindingQueryKey(options) }); /** * Configure spot finding * * Can be done anytime, also while data collection is running */ export const putConfigSpotFindingMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await putConfigSpotFinding({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; export const getConfigAzimIntQueryKey = (options?: Options) => createQueryKey('getConfigAzimInt', options); /** * Get azimuthal integration configuration * * Can be done anytime */ export const getConfigAzimIntOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getConfigAzimInt({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getConfigAzimIntQueryKey(options) }); /** * Configure azimuthal integration * * Can be done when detector is Inactive or Idle */ export const putConfigAzimIntMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await putConfigAzimInt({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; /** * Load binary image for internal FPGA generator * * Load image for internal FPGA generator. This can only happen in Idle state of the detector. * Requires binary blob with 16-bit integer numbers of size of detector in raw/converted coordinates * (depending on detector settings). * */ export const putConfigInternalGeneratorImageMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await putConfigInternalGeneratorImage({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; /** * Load TIFF image for internal FPGA generator * * Load image for internal FPGA generator. This can only happen in Idle state of the detector. * Requires TIFF with 16-bit integer numbers of size of detector in raw/converted coordinates * (depending on detector settings). * */ export const putConfigInternalGeneratorImageTiffMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await putConfigInternalGeneratorImageTiff({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; export const getConfigSelectDetectorQueryKey = (options?: Options) => createQueryKey('getConfigSelectDetector', options); /** * List available detectors * * Configured detectors that can be selected by used */ export const getConfigSelectDetectorOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getConfigSelectDetector({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getConfigSelectDetectorQueryKey(options) }); /** * Select detector * * Jungfraujoch allows to control multiple detectors and/or region-of-interests. * The command allows to choose one detector from the list (ID has to be consistent with one provided by GET response). * Changing detector will set detector to `Inactive` state and will require reinitialization. * */ export const putConfigSelectDetectorMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await putConfigSelectDetector({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; export const getConfigZeromqPreviewQueryKey = (options?: Options) => createQueryKey('getConfigZeromqPreview', options); /** * Get ZeroMQ preview settings */ export const getConfigZeromqPreviewOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getConfigZeromqPreview({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getConfigZeromqPreviewQueryKey(options) }); /** * Set ZeroMQ preview settings * * Jungfraujoch can generate preview message stream on ZeroMQ SUB socket. * Here settings of the socket can be adjusted. * While the data structure contains also socket_address, this cannot be changed via HTTP and is ignore in PUT request. * Options set with this PUT request have no effect on HTTP based preview. * */ export const putConfigZeromqPreviewMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await putConfigZeromqPreview({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; export const getConfigZeromqMetadataQueryKey = (options?: Options) => createQueryKey('getConfigZeromqMetadata', options); /** * Get ZeroMQ metadata socket settings */ export const getConfigZeromqMetadataOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getConfigZeromqMetadata({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getConfigZeromqMetadataQueryKey(options) }); /** * Set ZeroMQ metadata settings * * Jungfraujoch can generate metadata message stream on ZeroMQ PUB socket. This stream covers all images. * Here settings of the socket can be adjusted. * While the data structure contains also socket_address, this cannot be changed via HTTP and is ignore in PUT request. * */ export const putConfigZeromqMetadataMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await putConfigZeromqMetadata({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; export const getConfigDarkMaskQueryKey = (options?: Options) => createQueryKey('getConfigDarkMask', options); /** * Get settings for dark data collection to calculate mask */ export const getConfigDarkMaskOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getConfigDarkMask({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getConfigDarkMaskQueryKey(options) }); /** * Set configuration for dark data collection to calculate mask * * This is only possible when operating DECTRIS detectors at the moment; it will be also available for PSI EIGER at some point. * This can only be done when detector is `Idle`, `Error` or `Inactive` states. * */ export const putConfigDarkMaskMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await putConfigDarkMask({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; export const getStatusQueryKey = (options?: Options) => createQueryKey('getStatus', options); /** * Get Jungfraujoch status * * Status of the data acquisition */ export const getStatusOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getStatus({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getStatusQueryKey(options) }); export const getFpgaStatusQueryKey = (options?: Options) => createQueryKey('getFpgaStatus', options); /** * Get status of FPGA devices */ export const getFpgaStatusOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getFpgaStatus({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getFpgaStatusQueryKey(options) }); export const getXfelPulseIdQueryKey = (options?: Options) => createQueryKey('getXfelPulseId', options); /** * Return XFEL pulse IDs for the current data acquisition * * Return array of XFEL pulse IDs - (-1) if image not recorded */ export const getXfelPulseIdOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getXfelPulseId({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getXfelPulseIdQueryKey(options) }); export const getXfelEventCodeQueryKey = (options?: Options) => createQueryKey('getXfelEventCode', options); /** * Return XFEL event codes for the current data acquisition * * Return array of XFEL event codes */ export const getXfelEventCodeOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getXfelEventCode({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getXfelEventCodeQueryKey(options) }); export const getImagePusherStatusQueryKey = (options?: Options) => createQueryKey('getImagePusherStatus', options); /** * Get status of image pusher */ export const getImagePusherStatusOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getImagePusherStatus({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getImagePusherStatusQueryKey(options) }); export const getDetectorStatusQueryKey = (options?: Options) => createQueryKey('getDetectorStatus', options); /** * Get detector status * * Status of the JUNGFRAU detector */ export const getDetectorStatusOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getDetectorStatus({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getDetectorStatusQueryKey(options) }); export const getConfigRoiQueryKey = (options?: Options) => createQueryKey('getConfigRoi', options); /** * Get ROI definitions */ export const getConfigRoiOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getConfigRoi({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getConfigRoiQueryKey(options) }); /** * Upload ROI definitions */ export const putConfigRoiMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await putConfigRoi({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; export const getStatisticsQueryKey = (options?: Options) => createQueryKey('getStatistics', options); /** * Get general statistics */ export const getStatisticsOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getStatistics({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getStatisticsQueryKey(options) }); export const getStatisticsDataCollectionQueryKey = (options?: Options) => createQueryKey('getStatisticsDataCollection', options); /** * Get data collection statistics * * Results of the last data collection */ export const getStatisticsDataCollectionOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getStatisticsDataCollection({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getStatisticsDataCollectionQueryKey(options) }); export const getStatisticsCalibrationQueryKey = (options?: Options) => createQueryKey('getStatisticsCalibration', options); /** * Get calibration statistics * * Statistics are provided for each module/storage cell separately */ export const getStatisticsCalibrationOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getStatisticsCalibration({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getStatisticsCalibrationQueryKey(options) }); export const getConfigMaskQueryKey = (options?: Options) => createQueryKey('getConfigMask', options); /** * Get mask of the detector (binary) * * Detector must be Initialized. * Get full pixel mask of the detector. * See NXmx standard for meaning of pixel values. * */ export const getConfigMaskOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getConfigMask({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getConfigMaskQueryKey(options) }); export const getConfigUserMaskQueryKey = (options?: Options) => createQueryKey('getConfigUserMask', options); /** * Detector must be Initialized. * Get user mask of the detector (binary) * * * Get user pixel mask of the detector in the actual detector coordinates: 0 - good pixel, 1 - masked */ export const getConfigUserMaskOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getConfigUserMask({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getConfigUserMaskQueryKey(options) }); /** * Upload user mask of the detector (binary) * * Should be in `Idle` state. * Upload user mask of the detector - this is for example to account for beam stop shadow or misbehaving regions. * If detector is conversion mode the mask can be both in raw (1024x512; stacked modules) or converted coordinates. * In the latter case - module gaps are ignored and don't need to be assigned value. * Mask is expected as binary array (4-byte; unsigned). * 0 - good pixel, other value - masked * User mask is stored in NXmx pixel mask (bit 8), as well as used in spot finding and azimuthal integration. * */ export const putConfigUserMaskMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await putConfigUserMask({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; export const getConfigMaskTiffQueryKey = (options?: Options) => createQueryKey('getConfigMaskTiff', options); /** * Get mask of the detector (TIFF) * * Should be in `Idle` state. * Get full pixel mask of the detector * See NXmx standard for meaning of pixel values * */ export const getConfigMaskTiffOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getConfigMaskTiff({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getConfigMaskTiffQueryKey(options) }); export const getConfigUserMaskTiffQueryKey = (options?: Options) => createQueryKey('getConfigUserMaskTiff', options); /** * Detector must be Initialized. * Get user mask of the detector (TIFF) * * * Get user pixel mask of the detector in the actual detector coordinates: 0 - good pixel, 1 - masked */ export const getConfigUserMaskTiffOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getConfigUserMaskTiff({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getConfigUserMaskTiffQueryKey(options) }); /** * Upload user mask of the detector * * Should be in `Idle` state. * Upload user mask of the detector - this is for example to account for beam stop shadow or misbehaving regions. * If detector is conversion mode the mask can be both in raw (1024x512; stacked modules) or converted coordinates. * In the latter case - module gaps are ignored and don't need to be assigned value. * Mask is expected as a single-channel TIFF (8-, 16- or 32-bit integer, signed or unsigned). * 0 - good pixel, other value - masked * User mask is stored in NXmx pixel mask (bit 8), as well as used in spot finding and azimuthal integration. * User mask is not automatically applied - i.e. pixels with user mask will have a valid pixel value in the images. * */ export const putConfigUserMaskTiffMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await putConfigUserMaskTiff({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; export const getPreviewPedestalTiffQueryKey = (options: Options) => createQueryKey('getPreviewPedestalTiff', options); /** * Get pedestal in TIFF format */ export const getPreviewPedestalTiffOptions = (options: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getPreviewPedestalTiff({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getPreviewPedestalTiffQueryKey(options) }); export const getPreviewPlotQueryKey = (options: Options) => createQueryKey('getPreviewPlot', options); /** * Generate 1D plot from Jungfraujoch */ export const getPreviewPlotOptions = (options: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getPreviewPlot({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getPreviewPlotQueryKey(options) }); export const getPreviewPlotBinQueryKey = (options: Options) => createQueryKey('getPreviewPlotBin', options); /** * Generate 1D plot from Jungfraujoch and send in raw binary format. * Data are provided as (32-bit) float binary array. * This format doesn't transmit information about X-axis, only values, so it is of limited use for azimuthal integration. * */ export const getPreviewPlotBinOptions = (options: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getPreviewPlotBin({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getPreviewPlotBinQueryKey(options) }); export const getResultScanQueryKey = (options?: Options) => createQueryKey('getResultScan', options); /** * Get full scan result */ export const getResultScanOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getResultScan({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getResultScanQueryKey(options) }); export const getImageBufferStartCborQueryKey = (options?: Options) => createQueryKey('getImageBufferStartCbor', options); /** * Get Start message in CBOR format * * Contains metadata for a dataset (e.g., experimental geometry) */ export const getImageBufferStartCborOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getImageBufferStartCbor({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getImageBufferStartCborQueryKey(options) }); export const getImageBufferImageCborQueryKey = (options?: Options) => createQueryKey('getImageBufferImageCbor', options); /** * Get image message in CBOR format * * Contains full image data and metadata. The image must come from the latest data collection. */ export const getImageBufferImageCborOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getImageBufferImageCbor({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getImageBufferImageCborQueryKey(options) }); export const getImageBufferImageJpegQueryKey = (options?: Options) => createQueryKey('getImageBufferImageJpeg', options); /** * Get preview image in JPEG format using custom settings */ export const getImageBufferImageJpegOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getImageBufferImageJpeg({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getImageBufferImageJpegQueryKey(options) }); export const getImageBufferImageTiffQueryKey = (options?: Options) => createQueryKey('getImageBufferImageTiff', options); /** * Get preview image in TIFF format */ export const getImageBufferImageTiffOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getImageBufferImageTiff({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getImageBufferImageTiffQueryKey(options) }); /** * Clear image buffer * * Turns off image buffer for the last data collection. Can be only run when Jungfraujoch is not collecting data. */ export const postImageBufferClearMutation = (options?: Partial>): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await postImageBufferClear({ ...options, ...fnOptions, throwOnError: true }); return data; } }; return mutationOptions; }; export const getImageBufferStatusQueryKey = (options?: Options) => createQueryKey('getImageBufferStatus', options); /** * Get status of the image buffers * * Can be run at any stage of Jungfraujoch operation, including during data collection. * The status of the image buffer is volatile during data collection - if data collection goes for more images than available buffer slots, * then image might be replaced in the buffer between calling /images and /image.cbor. * */ export const getImageBufferStatusOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getImageBufferStatus({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getImageBufferStatusQueryKey(options) }); export const getVersionQueryKey = (options?: Options) => createQueryKey('getVersion', options); /** * Get Jungfraujoch version of jfjoch_broker */ export const getVersionOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getVersion({ ...options, ...queryKey[0], signal, throwOnError: true }); return data; }, queryKey: getVersionQueryKey(options) });