Control method of flat panel detector for synchrotron radiation diffraction experiment

Through the improved development method based on EPICS, the code structure and automated control are optimized, and the problems of complex development of flat panel detector control, insufficient storage and difficult equipment linkage are solved, and efficient data acquisition and equipment linkage of synchronous radiation diffraction experiments are realized.

CN119023718APending Publication Date: 2024-11-26INST OF HIGH ENERGY PHYSICS CHINESE ACAD OF SCI
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411137049.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

In the prior art, the control and development methods of flat panel detectors are complex, the workflow is cumbersome, the software storage limit is insufficient, and the equipment linkage is difficult, making it difficult to meet the complex needs of synchronous radiation diffraction experiments.

Method used

The improved development method based on EPICS is adopted to optimize the code structure, simplify the software usage method, realize the synchronization of data collection and storage, enhance automation capabilities, and realize device linkage through unified parameter configuration.

Benefits of technology

It reduces development and maintenance costs, improves automation capabilities, solves the storage upper limit problem, realizes support for multiple experimental modes, and is more smooth in linkage with other devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119023718A_ABST
    Figure CN119023718A_ABST
Patent Text Reader

Abstract

The invention discloses a control method of a flat panel detector for a synchrotron radiation diffraction experiment. The control method comprises the following steps: 1) a host initializes the flat panel detector; 2) performing parameter configuration on the flat panel detector by using a host; 3) the flat panel detector performs data acquisition according to the configured parameters; and 4) performing inverse initialization on the flat panel detector by using the host. Wherein the initialization / anti-initialization part is used for a host to control a starting stage and a disconnection stage of the flat panel detector; the parameter setting part is used for configuring parameters such as exposure mode, gain and correction, ROI range, Binning mode, synchronization mode, exposure time, exposure quantity and the like of the detector and reading parameters such as states of various modes, temperature, humidity and the like of the detector; and the data acquisition part is mainly used for completing key work such as data acquisition and transmission according to set parameters and a corresponding acquisition mode. The method can cope with various experiment modes, and the problem of long time consumption of batch reading is also solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of automatic control of detectors and relates to a control method of a flat-panel detector used in synchrotron radiation diffraction experiments. Background Art

[0002] Synchrotron radiation diffraction experiments are experiments conducted using synchrotron radiation sources. They are widely used in materials science, biological science, chemistry and other fields, and can help scientists gain a deeper understanding of the properties and behaviors of matter. Synchrotron radiation diffraction experiments generally require near-field detectors, flat-panel detectors, sample stages and a variety of optical equipment, such as Figure 1 As shown in the figure, the flat panel detector is the core component of synchrotron radiation diffraction experimental methods such as single exposure, one-dimensional / two-dimensional scanning, 3DXRD (3D X-ray Diffraction), and time resolution because of its high sensitivity, fast response, and high energy resolution.

[0003] EPICS (Experimental Physics and Industrial Control System) is an open source software toolkit for controlling and monitoring laboratory equipment and industrial control systems. EPICS provides a flexible and scalable architecture that enables users to build complex control systems, including data acquisition, equipment control, data processing and monitoring functions. More than 100 laboratories, universities and research institutions around the world use EPICS for projects, including accelerator control systems, high-energy physics experimental data acquisition systems, radio astronomy telescopes and industrial process control systems, such as LANL, ANL / APS, SLAC / Spear-3, BNL / NSLS-II, FNAL / D0, JLAB / CEBAF, ORNL / SNS, LBNL / ALS, TRIUMF in Canada, PSI / SLS, HZB / BESSY-II, DLS / Diamond, DESY, Australian Light Source AS, KEK / KEKB in Japan and PAL / PLS in South Korea. Accessing synchrotron radiation experimental equipment through EPICS is the choice of almost all synchrotron radiation sources at present. However, there are many disadvantages in accessing flat-panel detectors through traditional EPICS, such as high development difficulty, large amount of code, and high learning and maintenance costs.

[0004] At present, the control of flat-panel detectors is usually achieved by specific control software on a computer. These software are provided by detector manufacturers and developed for specific models and application scenarios. They have functions such as parameter setting, data acquisition, data analysis, control windows, and automatic control. These specific control software are difficult to use across operating systems. The control method of flat-panel detectors based on the specific control software provided by the manufacturer is more suitable for simple application scenarios with small data volumes, such as medical applications. However, it is relatively difficult to apply in the complex linkage scenarios of synchrotron radiation diffraction experiments. There are technical problems such as lack of linkage interface, upper limit of data storage, and cumbersome control workflow.

[0005] Therefore, a control method for a flat-panel detector capable of realizing a synchrotron radiation diffraction experiment has important engineering value and economic benefits in many synchrotron radiation light source fields, and can also provide important reference significance for medical applications, etc. Summary of the invention

[0006] In order to overcome technical problems such as complex development methods, cumbersome control workflow, software storage limit and difficulty in equipment linkage in synchrotron radiation diffraction experiments, the purpose of the present invention is to provide a control method for a flat-panel detector for synchrotron radiation diffraction experiments, which can be better applied to synchrotron radiation diffraction experiments.

[0007] In view of the complex development method of flat-panel detector control programs, an improved development method based on EPICS is provided to optimize the code structure, reduce the amount of code to one-half of the original, and make the overall structure clear. In view of the cumbersome existing software control workflow, by integrating the initialization process and application workflow, a single command can be used to regenerate the Offset template when the parameters are changed, simplifying the software usage and improving automation capabilities. As for the problem of software storage limit, by changing the method of first collecting and then storing to the method of collecting and storing simultaneously, the storage limit is released, which can cope with a variety of experimental modes and eliminate the problem of time-consuming batch readout. As for the problem of difficulty in equipment linkage, the flat-panel detector is based on EPICS access, which is suitable for the vast majority of current synchrotron radiation experiments and can be used in conjunction with most equipment.

[0008] The technical solution of the present invention is:

[0009] A control method for a flat panel detector for synchrotron radiation diffraction experiment, the steps comprising:

[0010] 1) The host initializes the flat panel detector and starts the flat panel detector;

[0011] 2) Utilizing the host to configure parameters of the flat panel detector;

[0012] 3) The flat panel detector performs data acquisition according to the configured parameters; wherein the data acquisition method is:

[0013] 301) setting the acquisition state parameter of the flat panel detector to idle and creating a pointer *pArray pointing to the NDArray type;

[0014] 302) obtaining acquisition switch parameters of the current flat panel detector;

[0015] 303) judging whether the flat panel detector is currently executing a task of collecting data frames according to the collection switch parameters;

[0016] If not, execute step 304), if yes, execute step 305);

[0017] 304) Waiting for the triggering of the data event thread, when the data event thread is triggered, executing step 305) to start collecting data;

[0018] 305) looping and iteratively processing the unprocessed data in the data queue and counting the unprocessed data frames, and then executing step 306);

[0019] 306) judging whether there are any uncleared data frames in the data queue according to the unprocessed data frame counting result; if yes, executing step 307); if no, executing step 308);

[0020] 307) Displaying the number of lost frames on the host, and then executing step 308);

[0021] 308) Obtaining the flat panel detector image mode set in the parameter configuration phase, and obtaining the number of image frames set for a single acquisition trigger; obtaining parameters for controlling whether to execute a callback function to receive data;

[0022] 309) Setting the acquisition frame counter of the flat panel detector to 0 and setting the acquisition state parameter to the acquisition state

[0023] Then execute the parameter callback program to make the set acquisition frame counter value and acquisition state parameters take effect in the

[0024] Flat panel detector;

[0025] 310) Send the Cmd_StartAcq command to the flat panel detector to start data acquisition; create frame count and data frame

[0026] Uniquely identify two variables and assign them a value of 0;

[0027] 311) determining whether the flat panel detector successfully performs the data acquisition operation; if it fails, executing step 325), indicating that the data acquisition is terminated; if it succeeds, executing step 312);

[0028] 312) obtaining the current acquisition status of the flat panel detector;

[0029] 313) Determine whether the current acquisition state parameter is in the acquisition end state or the image mode is in the non-continuous acquisition mode

[0030] The data frame has been collected; if yes, execute step 320), if not, execute steps 314-319) and continue the cycle

[0031] Ring collection;

[0032] 314) receiving the NDArray type data collected by the flat panel detector from the data queue, and storing it in the NDArray variable pointed to by the *pArray pointer;

[0033] 315) Determine whether an error or timeout occurs in the reception, if so, return to step 312) to continue the next cycle, otherwise, execute step 316);

[0034] 316) Check whether the unique identifier of the received data frame is inconsistent with the frame count and no data is received. If so,

[0035] Execute step 317), if otherwise, execute step 318);

[0036] 317) Print error information, including the lost frame number and the currently received frame number, and update the data frame only

[0037] The value of an identifier is the value of the latest frame;

[0038] 318) Execute the EPICS callback function to receive the data frame collected by the flat panel detector to realize data collection and storage

[0039] Simultaneous;

[0040] 319) releasing the *pArray pointer resource, increasing the frame count and the data frame unique identifier by 1;

[0041] The frame number counter is incremented by 1; then the process returns to step 312) and a new cycle is started to complete data acquisition;

[0042] 320) After the acquisition is completed, a Cmd_StopAcq instruction for stopping data acquisition is sent to the flat panel detector;

[0043] 321) Read the acquisition status of the flat panel detector and determine whether the acquisition status parameters of the flat panel detector are successful

[0044] Change to stop acquisition state, if yes, execute step 325), if not, execute step 322)

[0045] 322) Circularly access the data queue to check whether there is unprocessed data, and clear the data in the data queue;

[0046] 323) setting the acquisition parameter ADAcquire of the flat panel detector to 0, indicating that data acquisition has been terminated;

[0047] The acquisition state parameters of the flat panel detector are set to the idle state; the parameter callback program is executed to make the set acquisition parameters

[0048] ADAcquire parameters and acquisition status parameters take effect;

[0049] 324) Return to step 302) and continue to prepare to execute a new data collection task;

[0050] 325) Setting the acquisition parameter ADAcquire of the flat panel detector to 0, indicating that data acquisition has been terminated; setting the acquisition state parameter of the flat panel detector to the terminated state; executing the parameter callback program to make the set acquisition parameter ADAcquire parameter and acquisition state parameter effective, and returning to step 302);

[0051] 4) Deinitialize the flat panel detector by using the host, and disconnect the host from the flat panel detector. Further, the method for initializing the flat panel detector is:

[0052] 101) Create an EPICS command queue and data queue for inter-task communication;

[0053] 102) Determine whether the command queue and the data queue are created successfully; if they are created successfully, execute step 103);

[0054] If it fails, execute step 115);

[0055] 103) Create a flat panel detector software object according to the flat panel detector and load the detector configuration in the specified file path.

[0056] If successful, execute step 104); if failed, execute step 115);

[0057] 104) adding the created flat panel detector software object to the detector list;

[0058] 105) Associating the host with the flat panel detector software object; if the association is successful, executing step 106);

[0059] If it fails, execute step 115);

[0060] 106) The host sends a command to set the working mode of the flat panel detector;

[0061] 107) The host loads the calibration template of the flat panel detector and sets the actual scene of the synchrotron radiation diffraction experiment.

[0062] Describing the calibration mode of the flat panel detector;

[0063] 108) Determine whether the calibration template exists and whether it matches the model parameters of the flat panel detector. If so, execute step 110); if not, execute step 109);

[0064] 109) Reselect the calibration according to the type and working mode of the flat panel detector and the requirements of the synchrotron radiation diffraction experiment.

[0065] Template, return to execute step 107);

[0066] 110) According to the type and requirements of the synchrotron radiation diffraction experiment, modify the exposure mode of the flat panel detector and write the

[0067] User RAM for flat panel detectors;

[0068] 111) creating flat panel detector parameters for use in parameter configuration and data acquisition processes;

[0069] 112) The host reads the resolution size of the flat panel detector and assigns it to the parameters ADMaxSizeX, ADMaxSizeY, ADSizeX and ADSizeY in the EPICS program; wherein ADMaxSizeX and ADMaxSizeY are the maximum resolution sizes of the flat panel detector in the X and Y directions, and ADSizeX and ADSizeY are the maximum resolution sizes of the flat panel detector in the X and Y directions.

[0070] The size of the area read in the Y direction;

[0071] 113) Create EPICS data events and data collection thread DataTask for processing data in the data collection thread;

[0072] If the creation is successful, execute step 114), if it fails, execute step 115);

[0073] 114) Register the exit callback function to be executed when the program exits, and end the initialization;

[0074] 115) Terminate the device initialization operation and print an error message to end the initialization.

[0075] Furthermore, the method for configuring the parameters of the flat panel detector is:

[0076] 201) The host receives the parameter type and parameter value input by the user;

[0077] 202) Determine whether the data type of the parameter is int32 type, if yes, execute step 203), if not, execute step 206);

[0078] 203) After obtaining the acquisition status of the flat panel detector, execute step 204);

[0079] 204) determining whether the acquisition state of the flat panel detector is acquisition in progress, if not, executing step 205), if yes, executing step 211);

[0080] 205) calling the program module corresponding to the int32 type to set the parameters according to the input parameter type and parameter value, and then ending the parameter configuration process;

[0081] 206) Determine whether the data type of the parameter is float64 type; if yes, execute step 207); if not, execute step 210);

[0082] 207) After obtaining the acquisition status of the flat panel detector, execute step 208);

[0083] 208) determining whether the acquisition state of the flat panel detector is acquisition in progress, if not, executing step 209), if yes, executing step 211);

[0084] 209) According to the input parameter data type and parameter value, the program module corresponding to the float64 type is called to set the parameters and end the parameter configuration process;

[0085] 210) Print an error message, indicating that the input parameters are incorrect, and end the parameter configuration process;

[0086] 211) Print an error message, indicating that parameter setting cannot be performed during the data collection process and ending the parameter configuration process.

[0087] Furthermore, the host deinitializes the flat panel detector by disconnecting the host from the flat panel detector, removing the flat panel detector software object from the detector list detList, and then closing the hardware connection between the flat panel detector and the host and releasing the corresponding object memory.

[0088] Furthermore, the working mode includes Bining mode, ROI initial size and frame rate.

[0089] Furthermore, the flat panel detector parameters include offset, gain level, and exposure time percentage.

[0090] Furthermore, the correction template includes an offset correction template, a gain correction template and a defect correction template.

[0091] The advantages of the present invention are as follows:

[0092] The present invention can better link with other devices; because the parameter configuration process and configuration process are unified, the code content is simplified; the data storage task can be completed at the same time as the detector data is collected. The control method of the present invention releases the storage limit, can cope with a variety of experimental modes, and also eliminates the problem of long batch reading time.

[0093] 1. The control method of the flat panel detector of the synchrotron radiation diffraction experiment mentioned in the present invention is developed using the optimized EPICS program. The optimization is mainly reflected in optimizing the code logic, compressing the overall code volume, reducing the learning and development costs, and making the code itself more concise. At the same time, it is also more conducive to development and later maintenance.

[0094] 2. The method of the present invention adopts the improved EPICS method as the access scheme, which can be linked with other equipment in the synchrotron radiation diffraction experiment.

[0095] 3. The flat panel detector control method involved in the present invention adopts acquisition and storage synchronization technology, which can solve the problem of upper storage limit of flat panel detector control software, cope with various experimental modes, and eliminate the problem of long time consumption of batch reading. BRIEF DESCRIPTION OF THE DRAWINGS

[0096] Figure 1 This is a structural diagram of the synchrotron radiation diffraction experimental system.

[0097] Figure 2 Flowchart for initialization of flat panel detector.

[0098] Figure 3 This is the flow chart for deinitializing the flat panel detector.

[0099] Figure 4 Flowchart for parameter setting of flat panel detector.

[0100] Figure 5 This is a flow chart of data acquisition for a flat panel detector. DETAILED DESCRIPTION

[0101] The present invention is further described in detail below in conjunction with the accompanying drawings. The examples given are only used to explain the present invention but not to limit the scope of the present invention.

[0102] The control method of the flat panel detector of the present invention consists of three parts: device initialization / deinitialization, parameter setting and data acquisition. The initialization / deinitialization part is mainly used for the host to control the startup stage and disconnection stage of the flat panel detector; the parameter setting part is mainly used to configure the detector's exposure mode, gain and correction, ROI range, Binning mode, synchronization mode, exposure time, exposure quantity and other parameters, as well as read the status of various modes, detector temperature, humidity and other parameters. The data acquisition part mainly completes key tasks such as data acquisition and transmission according to the corresponding acquisition mode based on the set parameters.

[0103] The operating platform of this method is mainly a Windows 10 operating system host or a Centos 7 operating system host. The above required hosts all need to install the EPICS 7.0 related development environment. And the flat panel detector is connected to the host by hardware.

[0104] 1. Initialization / deinitialization of flat panel detector equipment

[0105] 1) The workflow of the equipment initialization phase of the flat-panel detector of the synchrotron radiation diffraction experiment is as follows Figure 2 As shown, the steps include:

[0106] 1. Create EPICS command queues and data queues for inter-task communication.

[0107] 2. Determine whether the command queue and data queue are created successfully. If successful, execute step 3; if unsuccessful, execute step 15, terminate the device initialization operation and print an error message, and end the program.

[0108] 3. Initialize the flat panel detector software object and load the detector configuration file in the specified file path. If successful, execute step 4; if failed, execute step 15, terminate the device initialization operation and print an error message, and end the program.

[0109] 4. Add the created flat panel detector software object to the detector list (detList).

[0110] 5. Connect to the flat panel detector through the host software, so that the flat panel detector software object on the host side is associated with the flat panel detector hardware. If successful, execute step 6; if unsuccessful, execute step 15, terminate the device initialization operation and print an error message, and end the program.

[0111] 6. Send commands through the host software to set the default working mode of the flat panel detector, including Bining mode, ROI initial size, frame rate, etc.

[0112] 7. In combination with different experimental scenarios in synchrotron radiation diffraction experiments, the host software loads a suitable default correction template into the flat-panel detector to set the flat-panel detector correction mode.

[0113] 8. Determine whether the loaded calibration template exists and whether it matches the flat panel detector model. If it does exist and matches, proceed to step 10. If it does not exist or does not match, proceed to step 9.

[0114] 9. According to the flat panel detector type and working mode and the requirements of the synchrotron radiation diffraction experiment, select and regenerate the correction template, namely, the Offset correction template, the Gain correction template or the Defect correction template, and return to step 7.

[0115] 10. Modify the flat panel detector exposure mode (such as external trigger or internal trigger) according to the type and requirements of the synchrotron radiation diffraction experiment

[0116] And other parameters are written into the user RAM of the corresponding flat panel detector.

[0117] 11. Create flat panel detector parameters such as offset, gain level, exposure time percentage, etc. for use in subsequent parameter setting and data acquisition.

[0118] 12. Read the resolution size of the flat panel detector through the host and assign it to the ADMaxSizeX, ADMaxSizeY, ADSizeX and ADSizeY parameters in the EPICS program, where ADMaxSizeX and ADMaxSizeY are the maximum resolution sizes of the flat panel detector in the X and Y directions, and ADSizeX and ADSizeY are the sizes of the areas to be read in the X and Y directions of the flat panel detector, which can be modified according to experimental requirements. This is used for subsequent parameter setting and data acquisition processes.

[0119] 13. Create EPICS data events (dataEvent) and data collection process threads (DataTask) for processing data in the data collection thread. If the creation is successful, execute step 14. If it fails, execute step 15, terminate the device initialization operation and print an error message, and end the program.

[0120] 14. Register the exit callback function to be executed when the program exits. After that, execute step 16 to end the initialization phase.

[0121] 15. Terminate the device initialization operation and print an error message, then proceed to step 16 to end the program.

[0122] 16. Complete the initialization operation.

[0123] 2) After the flat-panel detector of the synchrotron radiation diffraction experiment is used, the deinitialization process workflow is as follows Figure 3 As shown, the steps include:

[0124] 1. Check whether the flat panel detector is disconnected. If it is not disconnected, proceed to step 2. If it is disconnected, end the workflow directly.

[0125] 2. Remove the flat panel detector software object from the detector list detList.

[0126] 3. Close the hardware connection between the flat panel detector and the host and release the corresponding object memory. Then end the workflow.

[0127] 2. Flat Panel Detector Parameter Settings

[0128] The parameter setting program of the flat panel detector is divided into two types according to the data type of the parameter: int32 and float64. In the control program, the int32 type is often used to store the value of integer parameters, while the float64 type is often used to store the value of floating point parameters. For example, the acquisition switch, acquisition status, image mode, offset control switch, trigger mode, etc. are all int32 type, while the parameters used to represent the exposure cycle are float64 type. Some key control parameters of the flat panel detector are shown in Table 1.

[0129] Table 1. Table of some control parameters of flat panel detector

[0130]

[0131] The workflow for setting the parameters of the flat panel detector in synchrotron radiation diffraction experiments is as follows: Figure 4 As shown, the steps include:

[0132] 1. In the host software, obtain the user input parameter type (function) and parameter value (value).

[0133] 2. Determine whether the data type of the parameter is int32. If yes, go to step 3. If no, go to step 6.

[0134] 3. After obtaining the current detector's acquisition status, proceed to step 4.

[0135] 4. Determine whether the detector is in the acquisition state. If not, proceed to step 5. If yes, proceed to step 11.

[0136] 5. According to the input parameter (function) type and parameter value, the corresponding program module of int32 type is automatically called to set parameters. The process ends after the operation is completed.

[0137] 6. Determine whether the data type of the input parameter is float64. If yes, go to step 7. If no, go to step 10.

[0138] 7. After obtaining the current detector's acquisition status, proceed to step 8.

[0139] 8. Determine whether the detector is in the acquisition state. If not, proceed to step 9. If yes, proceed to step 11.

[0140] 9. According to the input parameter (function) type and parameter value, the corresponding program module of float64 type is automatically called to set parameters. The process ends after the operation is completed.

[0141] 10. Print an error message, indicating that the input parameters are incorrect, and end the process.

[0142] 11. Print an error message, indicating that parameter setting cannot be performed during data collection, and end the process.

[0143] 3. Flat Panel Detector Data Acquisition

[0144] The workflow of the flat-panel detector data acquisition process for synchrotron radiation diffraction experiments is as follows: Figure 5 As shown, the steps include:

[0145] 1. Set the acquisition state parameter of the flat panel detector to idle. Create a pointer (*pArray) pointing to the NDArray type.

[0146] 2. Get the acquisition switch parameters of the current flat panel detector.

[0147] 3. Determine whether the current detector is executing the data frame acquisition task according to the acquisition switch parameters. If not, execute step 4; if yes, execute step 5.

[0148] 4. Wait for the triggering of the data event thread, and start collecting data when the event is triggered. When the event is triggered, start collecting data and go to step 5.

[0149] 5. The loop iterates to process the unprocessed data in the data queue and counts the unprocessed frames, and then executes step 6.

[0150] 6. Determine whether there are any uncleared data frames based on the unprocessed frame count result. If yes, go to step 7; if no, go to step 8.

[0151] 7. Print a warning message on the host and display the number of dropped frames. Then execute step 8.

[0152] 8. Get the flat panel detector image mode set during the parameter setup phase; get the number of image frames set for a single acquisition trigger; get the parameter used to control whether to execute a callback function to receive data. This parameter controls whether the driver uses array data to call back the registered plug-in. 0 = No, 1 = Yes. If this value is set to 0, it can reduce the overhead in the following situations: the driver is only used to control the device, not to make data available to plug-ins or EPICS clients.

[0153] 9. Set the acquisition frame counter of the flat panel detector to 0 and set the acquisition state parameter to the acquisition state. Finally, execute the parameter callback program to make the parameters in this step effective for the flat panel detector.

[0154] 10. Send the "Cmd_StartAcq" command to the flat panel detector to notify the detector to start data acquisition. Create two variables, frame count and data frame unique identifier, and assign them 0.

[0155] 11. Determine whether the detector successfully performs the data collection operation. If it fails, jump to step 25, indicating that the data collection is terminated; if it succeeds, execute step 12.

[0156] 12. Get the current acquisition status of the flat panel detector.

[0157] 13. Determine whether the current acquisition state parameter is the acquisition end state or whether the data frame has been acquired in the non-continuous acquisition mode. If yes, execute step 20 to command the detector to stop acquisition. If not, execute steps 14-19 to continue the cyclic acquisition.

[0158] 14. Receive the NDArray type data collected by the detector from the data queue and store it in the data collection process

[0159] The NDArray variable pointed to by the *pArray pointer.

[0160] 15. Check whether the received return data is less than 0. If it is less than 0, it means that an error or timeout occurred during reception, and return to step 12 to continue the next cycle. Otherwise, the data reception is normal, and execute step 16.

[0161] 16. Check whether the unique identifier in the received data frame is inconsistent with the frame count and is not -1 (-1 means no data was received). If so, execute step 17; if not, execute step 18.

[0162] 17. Print error information, including which frame was lost and which frame is currently received. At the same time, in order to facilitate normal subsequent acquisition, the value of the data frame unique identifier is updated to the value of the latest frame.

[0163] 18. Execute the EPICS callback function to receive the data frame collected by the detector, so as to achieve the synchronization of data collection and storage.

[0164] 19. Release the *pArray pointer resource; increase the frame count and data frame unique identifier by 1; increase the acquisition frame counter of the flat panel detector by 1. After completion, return to step 12 and start a new cycle to complete data acquisition.

[0165] 20. After the acquisition is completed, send the "Cmd_StopAcq" command to the flat panel detector to stop data acquisition.

[0166] 21. Read the detector acquisition state and determine whether the acquisition state parameter of the flat panel detector has successfully changed to the stop acquisition state. If yes, execute step 25; if not, execute step 22.

[0167] 22. Loop through the data queue to check if there is any unprocessed data, clear the data in the data queue to prevent memory leaks.

[0168] 23. Set the acquisition parameter (ADAcquire) of the flat panel detector to 0, indicating that data acquisition has been terminated; set the acquisition state parameter of the flat panel detector to the idle state; execute the parameter callback program to make the above parameters effective.

[0169] 24. Return to step 2 and continue preparing to execute a new data collection task.

[0170] 25. Set the acquisition parameter (ADAcquire) of the flat panel detector to 0, indicating that data acquisition has been terminated; set the acquisition status parameter of the flat panel detector to the terminated state; execute the parameter callback program to make the above parameters effective, and return to step 2.

[0171] Wait for the data collection task again.

[0172] Although the specific embodiments of the present invention are disclosed for the purpose of illustration, the purpose is to help understand the content of the present invention and implement it accordingly, those skilled in the art will understand that various substitutions, changes and modifications are possible without departing from the spirit and scope of the present invention and the appended claims. Therefore, the present invention should not be limited to the content disclosed in the best embodiment, and the scope of the present invention is subject to the scope defined in the claims.

Claims

1. A control method for a flat panel detector for synchrotron radiation diffraction experiments, comprising the steps of: 1) The host initializes the flat panel detector and starts the flat panel detector; 2) Utilizing the host to configure parameters of the flat panel detector; 3) The flat panel detector performs data acquisition according to the configured parameters; wherein the data acquisition method is: 301) setting the acquisition state parameter of the flat panel detector to idle and creating a pointer *pArray pointing to the NDArray type; 302) obtaining acquisition switch parameters of the current flat panel detector; 303) judging whether the flat panel detector is currently executing a task of collecting data frames according to the collection switch parameters; If not, execute step 304), if yes, execute step 305); 304) Waiting for the triggering of the data event thread, when the data event thread is triggered, executing step 305) to start collecting data; 305) looping and iteratively processing the unprocessed data in the data queue and counting the unprocessed data frames, and then executing step 306); 306) judging whether there are uncleared data frames in the data queue according to the unprocessed data frame counting result; If yes, execute step 307); if no, execute step 308); 307) Displaying the number of lost frames on the host, and then executing step 308); 308) Obtaining the flat panel detector image mode set in the parameter configuration phase, and obtaining the number of image frames set for a single acquisition trigger; obtaining parameters for controlling whether to execute a callback function to receive data; 309) setting the acquisition frame counter of the flat panel detector to 0 and setting the acquisition state parameter to the acquisition state, and then executing the parameter callback program to make the set acquisition frame counter value and acquisition state parameter take effect on the flat panel detector; 310) Sending a Cmd_StartAcq instruction to the flat panel detector to start data acquisition; creating two variables, frame count and data frame unique identifier, and assigning them values ​​of 0; 311) determining whether the flat panel detector successfully performs the data acquisition operation; If it fails, step 325 is executed, indicating that data collection is terminated; If successful, execute step 312); 312) obtaining the current acquisition status of the flat panel detector; 313) determining whether the current acquisition state parameter is in the acquisition end state or the image mode is in the non-continuous acquisition mode and the data frame has been acquired; If yes, execute step 320), if not, execute steps 314-319) Continue the cycle of collection; 314) receiving the NDArray type data collected by the flat panel detector from the data queue, and storing it in the NDArray variable pointed to by the *pArray pointer; 315) Determine whether an error or timeout occurs in the reception, if so, return to step 312) to continue the next cycle, otherwise, execute step 316); 316) Check whether the unique identifier of the received data frame is inconsistent with the frame count and no data is received, if yes, execute step 317), if not, execute step 318); 317) Print error information, including the lost frame number and the currently received frame number, and update the value of the data frame unique identifier to the value of the latest frame; 318) executing the EPICS callback function to receive the data frame collected by the flat panel detector, so as to realize the synchronization of data collection and storage; 319) releasing the *pArray pointer resource, increasing the frame count and the data frame unique identifier by 1; increasing the acquisition frame counter of the flat panel detector by 1; and then returning to step 312) to continue to start a new cycle to complete data acquisition; 320) After the acquisition is completed, a Cmd_StopAcq instruction for stopping data acquisition is sent to the flat panel detector; 321) reading the acquisition state of the flat panel detector, determining whether the acquisition state parameter of the flat panel detector has successfully changed to the stop acquisition state, if yes, executing step 325), if not, executing step 322) 322) Circularly access the data queue to check whether there is unprocessed data, and clear the data in the data queue; 323) Setting the acquisition parameter ADAcquire of the flat panel detector to 0, indicating that data acquisition has been terminated; setting the acquisition state parameter of the flat panel detector to an idle state; executing a parameter callback program to make the set acquisition parameter ADAcquire parameter and acquisition state parameter take effect; 324) Return to step 302) and continue to prepare to execute a new data collection task; 325) Setting the acquisition parameter ADAcquire of the flat panel detector to 0, indicating that data acquisition has been terminated; setting the acquisition state parameter of the flat panel detector to the terminated state; executing the parameter callback program to make the set acquisition parameter ADAcquire parameter and acquisition state parameter effective, and returning to step 302); 4) Deinitialize the flat panel detector by using the host, and disconnect the host from the flat panel detector.

2. The method according to claim 1, characterized in that The method for initializing the flat panel detector is: 101) Create an EPICS command queue and data queue for inter-task communication; 102) Determine whether the command queue and the data queue are successfully created; if they are successfully created, execute step 103); if they fail, execute step 115); 103) creating a flat panel detector software object according to the flat panel detector and loading the detector configuration file in the specified file path, if successful, executing step 104); if failed, executing step 115); 104) adding the created flat panel detector software object to the detector list; 105) Associating the host with the flat panel detector software object; If the association is successful, execute step 106); If it fails, execute step 115); 106) The host sends a command to set the working mode of the flat panel detector; 107) The host loads the calibration template of the flat panel detector and sets the calibration mode of the flat panel detector in combination with the actual scene of the synchrotron radiation diffraction experiment; 108) Determine whether the calibration template exists and whether it matches the model parameters of the flat panel detector. If so, execute step 110); if not, execute step 109); 109) reselecting a calibration template according to the type and working mode of the flat panel detector and the requirements of the synchrotron radiation diffraction experiment, and returning to step 107); 110) modifying the exposure mode of the flat panel detector and writing it into the user RAM of the flat panel detector according to the type and requirements of the synchrotron radiation diffraction experiment; 111) creating flat panel detector parameters for use in parameter configuration and data acquisition processes; 112) The host reads the resolution size of the flat panel detector and assigns it to the ADMaxSizeX, ADMaxSizeY, ADSizeX and ADSizeY parameters in the EPICS program; wherein ADMaxSizeX and ADMaxSizeY are the maximum resolution sizes of the flat panel detector in the X direction and Y direction, and ADSizeX and ADSizeY are the sizes of the areas to be read in the X direction and Y direction of the flat panel detector; 113) Create EPICS data events and data collection thread DataTask for processing data in the data collection thread; If the creation is successful, execute step 114); if it fails, execute step 115); 114) Register the exit callback function to be executed when the program exits, and end the initialization; 115) Terminate the device initialization operation and print an error message to end the initialization.

3. The method according to claim 2, characterized in that The method for configuring the parameters of the flat panel detector is as follows: 201) The host receives the parameter type and parameter value input by the user; 202) Determine whether the data type of the parameter is int32 type, if yes, execute step 203), if not, execute step 206); 203) After obtaining the acquisition status of the flat panel detector, execute step 204); 204) determining whether the acquisition state of the flat panel detector is acquisition in progress, if not, executing step 205), if yes, executing step 211); 205) calling the program module corresponding to the int32 type to set the parameters according to the input parameter type and parameter value, and then ending the parameter configuration process; 206) Determine whether the data type of the parameter is float64 type; If yes, execute step 207), if not, execute step 210); 207) After obtaining the acquisition status of the flat panel detector, execute step 208); 208) determining whether the acquisition state of the flat panel detector is acquisition in progress, if not, executing step 209), if yes, executing step 211); 209) According to the input parameter data type and parameter value, the program module corresponding to the float64 type is called to set the parameters and end the parameter configuration process; 210) Print an error message, indicating that the input parameters are incorrect, and end the parameter configuration process; 211) Print an error message, indicating that parameter setting cannot be performed during the data collection process and ending the parameter configuration process.

4. The method according to claim 1, 2 or 3, characterized in that: The method for the host to deinitialize the flat panel detector is: disconnecting the host from the flat panel detector, removing the flat panel detector software object from the detector list detList, and then closing the hardware connection between the flat panel detector and the host and releasing the corresponding object memory.

5. The method according to claim 1, 2 or 3, characterized in that: The working mode includes Bining mode, ROI initial size and frame rate.

6. The method according to claim 1, 2 or 3, characterized in that: The flat panel detector parameters include offset, gain level, and exposure time percentage.

7. The method according to claim 1, 2 or 3, characterized in that: The correction template includes an offset correction template, a gain correction template and a defect correction template.

Citation Information

Cited By

  • MicroED data acquisition and image correction system and method based on software linkage

    CN121595616A