A method and device for synchronously collecting multi-parameter data based on ring memory double buffering
By using ring memory double buffering technology in sensor data collection, multi-parameter data is synchronously input into the ring buffer and saved on the hard disk when the saving conditions are met. This solves the problem that traditional FIFO queues cannot meet the storage requirements of multi-parameter data and achieves high efficiency. data storage and processing.
Patent Information
- Application Number
- CN202111111892.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-23
- Publication Date
- 2024-09-17
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The traditional FIFO message queue can easily lead to data loss and system failure when collecting multi-parameters, multi-channels, and large amounts of data, and cannot meet the needs for efficient storage and processing.
A multi-parameter data synchronization collection method based on ring memory double buffering is used to input multi-parameter signal data into the memory through the ring buffer area, and when the saving conditions are met, the data is read into the buffer file for hard disk storage to avoid data exceeding the memory space.
It achieves high-speed storage of multi-channel data, avoids data loss, meets the needs of multi-parameter data storage and processing, and overcomes the problem of memory capacity limitations in traditional methods.
Smart Images

Figure CN113835634B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data storage, and in particular to a method and device for synchronously recording multi-parameter data based on ring memory double buffering. Background Art
[0002] In order to obtain as accurate information as possible about the target, the current sensor sampling rate and acquisition parameters are gradually increasing. Therefore, multi-parameter big data synchronous acquisition technology has become a research topic for data storage. Common data acquisition storage adopts a queue method, according to the first-in-first-out (FIFO) principle. General FIFO message queues are based on memory, that is, all messages are stored in memory. However, in many cases, the number of messages in the message queue is difficult to determine, and may exceed the capacity of the system memory, resulting in the traditional FIFO message queue being unable to meet the needs of the application. In this case, data loss, system failure and other problems may occur, which makes it difficult to meet the current data storage and processing requirements of multi-parameters, multi-channels, and large amounts of data acquisition.
[0003] Due to the limitation of memory size, if a large amount of collected data is input in a short time, and the subsequent storage and processing speed of the data is slow, it will inevitably cause system failure and data loss. Therefore, it is necessary to invent a method that can efficiently process multi-channel data storage. Summary of the invention
[0004] The embodiment of the present invention provides a method and device for synchronously recording multi-parameter data based on ring memory double buffering, which are used to solve the above-mentioned technical problems in the prior art.
[0005] In a first aspect, an embodiment of the present invention provides a method for synchronously recording multi-parameter data based on a ring memory double buffer, comprising:
[0006] Acquire multi-parameter signal data;
[0007] Synchronize and mark multi-parameter signal data;
[0008] Inputting multi-parameter signal data into the ring buffer memory;
[0009] Determine whether the output and storage conditions are met; the output and storage conditions are that the ring buffer memory is full, or the end mark of the multi-parameter signal data is read;
[0010] If the output and storage conditions are met, the data in the ring buffer memory is read into the buffer file again; if the output and storage conditions are not met, the multi-parameter signal data continues to be input into the ring buffer memory until the output and storage conditions are met;
[0011] Save the buffer file to the hard disk.
[0012] Furthermore, the multi-parameter signal data is any one of the following or any combination thereof: seismic data, electromagnetic data, gravity data, magnetic field data, induced polarization data, electrical data, nuclear magnetic data, temperature data, radioactive data, remote sensing data, and radar data.
[0013] Furthermore, the method for synchronously marking the multi-parameter signal data is to synchronize the multi-parameter signal data with a timestamp signal.
[0014] Furthermore, the circular buffer memory is a continuous memory of a specific length in the memory, and the first bits of the memory addresses of the starting point and the end point are connected to form the circular buffer memory.
[0015] Furthermore, the collection and storage of multi-parameter data adopts a queue method and is arranged according to the first-in-first-out FIFO principle.
[0016] Furthermore, after the data in the circular buffer memory is read into the buffer file and output to the disk when the output and storage conditions are met, the data in the circular buffer memory is cleared and then new multi-parameter data is continued to be received.
[0017] Furthermore, the data of each parameter in the multi-parameter data corresponds to a channel for acquiring data, and the data of each channel is input into a corresponding circular buffer memory. After the output storage conditions are met, the buffer file is stored to the hard disk in units of files with the same number of lines as the number of channels.
[0018] In a second aspect, an embodiment of the present invention provides a multi-parameter data synchronous recording device based on a ring memory double buffer, which implements the multi-parameter data synchronous recording method based on a ring memory double buffer provided in the first aspect, including:
[0019] A data acquisition module, used to acquire real-time observation data of several channels;
[0020] A synchronization signal module is used to synchronize and mark the multi-parameter signal data of several channels;
[0021] A first buffer collection module is used to store each channel data of the multi-parameter signal data into the corresponding ring buffer memory;
[0022] The second buffer collection module is used to store and save the data in the ring buffer memory on the hard disk.
[0023] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, an internal memory, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the steps of a multi-parameter data synchronization collection method based on circular memory double buffering provided in the first aspect are implemented.
[0024] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the multi-parameter data synchronization collection method based on circular memory double buffering provided in the first aspect are implemented.
[0025] The present invention proposes a multi-parameter data synchronous collection method based on circular memory double buffering, which synchronizes the information of multiple channels and inputs them into the corresponding several circular buffer memory areas, and then inputs the files in the circular buffer memory areas into the disk as the second buffer storage, thereby realizing the high-speed storage of a large amount of data in double buffering, and preventing the situation where the data volume exceeds the memory space and causes data loss, thereby overcoming the problem in conventional methods that the multi-parameter data exceeds the capacity of the system memory and causes the FIFO message queue to be unable to meet the application requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 A schematic diagram of a method for synchronously collecting multi-parameter data based on a ring memory double buffer provided by an embodiment of the present invention;
[0027] Figure 2 A schematic diagram of the working process of a multi-parameter data synchronous collection method based on a ring memory double buffer provided by an embodiment of the present invention;
[0028] Figure 3 A schematic diagram of a multi-parameter data synchronous recording device based on a ring memory double buffer provided in an embodiment of the present invention;
[0029] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.
[0030] Figure 5 A schematic diagram of a circular queue in a circular buffer memory provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0032] Figure 1 A schematic diagram of a method for synchronously collecting multi-parameter data based on a ring memory double buffer provided by an embodiment of the present invention is shown in FIG. Figure 1 As shown, an embodiment of the present invention provides a method for synchronously recording multi-parameter data based on a ring memory double buffer, the method comprising:
[0033] Step 101, obtaining multi-parameter signal data;
[0034] Step 102, synchronously marking the multi-parameter signal data;
[0035] Step 103, inputting the multi-parameter signal data into the ring buffer memory;
[0036] Step 104, determining whether the output and storage conditions are met; the output and storage conditions are that the ring buffer memory is full, or the end mark of the multi-parameter signal data is read;
[0037] Step 105: if the output and storage conditions are met, the data in the ring buffer memory is read into the buffer file again; if the output and storage conditions are not met, the multi-parameter signal data continues to be input into the ring buffer memory until the output and storage conditions are met;
[0038] Step 106: Save the buffer file to the hard disk.
[0039] Optionally, the multi-parameter signal data is any one of the following or any combination thereof: seismic data, electromagnetic data, gravity data, magnetic field data, induced polarization data, electrical method data, nuclear magnetic data, temperature data, radioactive data, remote sensing data, and radar data.
[0040] Optionally, the method for synchronously marking the multi-parameter signal data is to synchronize the multi-parameter signal data with a timestamp signal.
[0041] Optionally, the circular buffer memory is a continuous memory of a specific length in the memory, and the first bits of the memory addresses of the starting point and the end point are connected to form the circular buffer memory.
[0042] Optionally, the collection and storage of multi-parameter data adopts a queue method and is arranged according to the first-in-first-out FIFO principle.
[0043] Optionally, after the output and storage conditions are met, the data in the circular buffer memory is read into the buffer file and output and stored, and then the data in the circular buffer memory is cleared and new multi-parameter data continues to be received.
[0044] Optionally, each parameter in the multi-parameter data corresponds to a channel for acquiring data, and each channel data is input into a corresponding circular buffer memory. After the output storage condition is met, the buffer file is stored to the hard disk in units of files with the same number of lines as the number of channels. Figure 2The working process of the multi-parameter data synchronous collection method based on the ring memory double buffer is shown in the schematic diagram. First, the timestamp signal is loaded on the data of channel 1 to channel n, and then the multi-parameter signal data loaded with the timestamp signal of each channel is sent to the ring buffer memory in the form of FIFO. When the ring buffer memory with the timestamp information is full, or the end mark of the multi-parameter signal data is read, the data in the ring buffer memory is read into the cache file again. The buffer file is stored in units of n lines of files. The first ring buffer memory corresponds to the first line of the cache file, the second ring buffer memory corresponds to the second line of the cache file, and the nth ring buffer memory corresponds to the nth line of the cache file. Finally, the buffer file is stored on the hard disk. If the cache file does not meet the requirements of the ring buffer for storing data or the current n-line cache file has not completed disk storage, the ring buffer data is stored in the next n-line cache file. In this way, the cache file relies on a large-capacity disk, and it can be considered that the cache file has almost no capacity limit. In this way, the multi-channel multi-parameter signal data is stored in the disk in a synchronous signal alignment manner, realizing efficient storage of multi-parameter signal data and meeting data storage requirements.
[0045] Figure 5 A schematic diagram of a circular queue in a circular buffer memory provided by an embodiment of the present invention. Figure 5 As shown in the figure, the circular queue in the circular buffer memory avoids the shortcomings of ordinary queues. The circular queue in the circular buffer memory is also a queue with a queue head and a queue tail, which meets the first-in-first-out (FIFO) principle. As an array, there are two pointers, one pointing to the queue head and the other pointing to the queue tail. The pointer (front) pointing to the queue head is the readable data in the circular buffer memory, and the pointer (rear) pointing to the queue tail is the writable data in the circular buffer memory. By moving these two pointers (front) and (rear), the data in the circular buffer memory can be read and written until the buffer is full, that is, the head and tail are connected, and the data can be released or output to the hard disk, and then new data can be stored. Among them, the queue head (front) is the end that allows deletion; the queue tail (rear) is the end that allows insertion.
[0046] Figure 3 A schematic diagram of a multi-parameter data synchronous recording device based on a ring memory double buffer provided in an embodiment of the present invention, as shown in FIG. Figure 3 As shown, an embodiment of the present invention provides a multi-parameter data synchronous recording device based on a ring memory double buffer, which is used to execute the method described in any of the above embodiments, specifically including a data acquisition module 301; a synchronization signal module 302; a first buffer recording module 303; and a second buffer recording module 304.
[0047] Among them: the data acquisition module 301 is used to obtain real-time observation data of multiple channels; the channel is connected to an external monitoring electronic device to obtain real-time monitoring data; the synchronization signal module 302 is used to synchronize the multi-parameter signal data of several channels by means of a synchronization timestamp; the first buffer collection module 303 is used to store each channel data of the multi-parameter signal data into its corresponding circular buffer memory; the second buffer collection module 304 is used to store the data in the circular buffer memory on a hard disk.
[0048] An embodiment of the present invention provides a multi-parameter data synchronous recording device based on circular memory double buffering, which is used to execute the method described in any of the above embodiments. The specific steps of executing the method described in any of the above embodiments by the device provided by this embodiment are the same as those of the above corresponding embodiments and will not be repeated here.
[0049] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, such as Figure 4 As shown, the electronic device includes: a processor (processor) 401, a communication interface (Communications Interface) 402, a memory (memory) 403 and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404. The processor 401 can call a computer program stored in the memory 403 and can be run on the processor 401 to perform the following steps:
[0050] Acquire multi-parameter signal data;
[0051] Synchronize and mark multi-parameter signal data;
[0052] Inputting multi-parameter signal data into the ring buffer memory;
[0053] Determine whether the output and storage conditions are met; the output and storage conditions are that the ring buffer memory is full, or the end mark of the multi-parameter signal data is read;
[0054] If the output and storage conditions are met, the data in the ring buffer memory is read into the buffer file again; if the output and storage conditions are not met, the multi-parameter signal data continues to be input into the ring buffer memory until the output and storage conditions are met;
[0055] Save the buffer file to the hard disk.
[0056] In addition, the logic instructions in the above-mentioned memory 403 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.
[0057] Furthermore, an embodiment of the present invention provides a computer program product, the computer program product comprising a computer program stored on a computer-readable storage medium, the computer program comprising program instructions, and when the program instructions are executed by a computer, the computer can perform the steps in the above-mentioned method embodiments, for example, including:
[0058] Acquire multi-parameter signal data;
[0059] Synchronize and mark multi-parameter signal data;
[0060] Inputting multi-parameter signal data into the ring buffer memory;
[0061] Determine whether the output and storage conditions are met; the output and storage conditions are that the ring buffer memory is full, or the end mark of the multi-parameter signal data is read;
[0062] If the output and storage conditions are met, the data in the ring buffer memory is read into the buffer file again; if the output and storage conditions are not met, the multi-parameter signal data continues to be input into the ring buffer memory until the output and storage conditions are met;
[0063] Save the buffer file to the hard disk.
[0064] An embodiment of the present invention provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method embodiments are implemented, for example, including:
[0065] Acquire multi-parameter signal data;
[0066] Synchronize and mark multi-parameter signal data;
[0067] Inputting multi-parameter signal data into the ring buffer memory;
[0068] Determine whether the output and storage conditions are met; the output and storage conditions are that the ring buffer memory is full, or the end mark of the multi-parameter signal data is read;
[0069] If the output and storage conditions are met, the data in the ring buffer memory is read into the buffer file again; if the output and storage conditions are not met, the multi-parameter signal data continues to be input into the ring buffer memory until the output and storage conditions are met;
[0070] Save the buffer file to the hard disk.
[0071] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0072] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0073] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for synchronously collecting multi-parameter data based on ring memory double buffering, characterized in that: include: Acquire multi-parameter signal data; Synchronize and mark multi-parameter signal data; Inputting multi-parameter signal data into the ring buffer memory; Determine whether the output and storage conditions are met; The output storage condition is that the ring buffer memory is full, or the end mark of the multi-parameter signal data is read; If the output storage condition is met, the data in the ring buffer memory is read into the buffer file again; If the output and storage conditions are not met, the multi-parameter signal data continues to be input into the ring buffer memory until the output and storage conditions are met; Save the buffer file to the hard disk; The data of each parameter in the multi-parameter data corresponds to a channel for acquiring data, and the data of each channel is input into a corresponding circular buffer memory. After the output storage condition is met, the buffer file is stored to the hard disk in units of files with the same number of lines as the number of channels. Among them, the buffer file is stored in units of n-line files, the first circular buffer area memory corresponds to the first line of the buffer file, the second circular buffer area memory corresponds to the second line of the buffer file, the nth circular buffer area memory corresponds to the nth line of the buffer file, and finally the buffer file is saved to the hard disk; if the buffer file cannot meet the requirements of storing data in the circular buffer area memory or the current n-line buffer file has not completed disk storage, the data in the circular buffer area memory will be stored in the next n-line buffer file.
2. The method for synchronously collecting multi-parameter data based on ring memory double buffering according to claim 1 is characterized in that: The multi-parameter signal data is any one of the following or any combination thereof: seismic data, electromagnetic data, gravity data, magnetic field data, induced polarization data, electrical method data, nuclear magnetic data, temperature data, radioactive data, remote sensing data, and radar data.
3. The method for synchronously collecting multi-parameter data based on ring memory double buffering according to claim 1, characterized in that: The method for synchronously marking multi-parameter signal data is to synchronize the multi-parameter signal data with a time stamp signal.
4. The method for synchronously collecting multi-parameter data based on ring memory double buffering according to claim 1 is characterized in that: The collection and storage of multi-parameter data adopts the queue method and is arranged according to the first-in-first-out FIFO principle.
5. The method for synchronously collecting multi-parameter data based on ring memory double buffering according to claim 1, characterized in that: When the output and storage conditions are met, the data in the circular buffer memory is read into the buffer file and output and stored, and then the data in the circular buffer memory is cleared and new multi-parameter data is continued to be received.
6. A multi-parameter data synchronous recording device based on ring memory double buffering, characterized in that: include: A data acquisition module, used to acquire real-time observation data of several channels; A synchronization signal module is used to synchronize and mark the multi-parameter signal data of several channels; A first buffer collection module is used to store each channel data of the multi-parameter signal data into the corresponding ring buffer memory; Determine whether the output and storage conditions are met; The output storage condition is that the ring buffer memory is full, or the end mark of the multi-parameter signal data is read; If the output storage condition is met, the data in the ring buffer memory is read into the buffer file again; If the output and storage conditions are not met, the multi-parameter signal data continues to be input into the ring buffer memory until the output and storage conditions are met; The second buffer collection module is used to store the buffer files on the hard disk; The data of each parameter in the multi-parameter data corresponds to a channel for acquiring data, and the data of each channel is input into a corresponding circular buffer memory. After the output storage condition is met, the buffer file is stored to the hard disk in units of files with the same number of lines as the number of channels. Among them, the buffer file is stored in units of n-line files, the first circular buffer area memory corresponds to the first line of the buffer file, the second circular buffer area memory corresponds to the second line of the buffer file, the nth circular buffer area memory corresponds to the nth line of the buffer file, and finally the buffer file is saved to the hard disk; if the buffer file cannot meet the storage data requirements of the circular buffer area memory or the current n-line buffer file has not completed disk storage, the data in the circular buffer area memory will be stored in the next n-line buffer file.
7. An electronic device comprising a memory, a processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the multi-parameter data synchronous collection method based on ring memory double buffering as claimed in any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the multi-parameter data synchronous collection method based on ring memory double buffering as claimed in any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Cloud computation-based distributed big data processing method and system
CN106951475A
Data storage method, storage system, and computer storage medium
CN109241010A
Data processing system and method
CN112417043A
