Wave recording method and device, electronic equipment, storage medium and product
Through the combination of DMA unidirectional transmission and ring-linked list memory pool, the problem of low wave recording efficiency caused by excessive processor load is solved, and a more efficient data recording process is achieved.
Patent Information
- Application Number
- CN202411997503.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-05-02
AI Technical Summary
When processing data scenarios with large data volumes or high sampling rates, the processor load increases significantly, resulting in low wave recording efficiency.
The sampling data and sampling time of the target system are obtained through the DMA one-way transmission method and written to the memory pool of the ring linked list. Determine the historical recording request based on these data and the specified data range, add it to the queue, and obtain the target recording request from the queue to implement the recording.
The processor controls data transmission and allocates memory areas, reduces the processor load, and thus improves wave recording efficiency.
Smart Images

Figure CN119917430A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a wave recording method, device, electronic equipment, storage medium and product. Background Art
[0002] For application scenarios with high-precision data or real-time data, waveform recording technology can enable users to capture key instantaneous data and perform subsequent analysis and processing based on the instantaneous data, thereby improving the reliability and performance of the system.
[0003] In the related art, the wave recording technology is executed by controlling the processor, and the operations such as data sampling and data transmission in the wave recording technology are executed by controlling the processor.
[0004] However, when faced with large amounts of data or data scenarios with high sampling rates, the processor load will increase significantly, leading to low recording efficiency. Summary of the invention
[0005] The present application provides a wave recording method, device, electronic device, storage medium and product to improve wave recording efficiency.
[0006] In a first aspect, the present application provides a recording method, comprising: obtaining multiple sampling data of a target system and multiple sampling times corresponding to the multiple sampling data through a DMA unidirectional transmission method, and writing the multiple sampling data and the multiple sampling times into a circular linked list memory pool; determining multiple historical recording requests based on the multiple sampling data, the multiple sampling times, and a specified data range; adding the multiple historical recording requests to a target queue; obtaining a target recording request from the target queue, and executing the target recording request according to the circular linked list memory pool to realize recording.
[0007] Optionally, the method as described above obtains multiple sampling data of the target system and multiple sampling moments corresponding to the multiple sampling data through the DMA unidirectional transmission method, including: obtaining multiple data packets, the multiple data packets are transmitted through the DMA unidirectional transmission method; parsing and processing the multiple data packets to obtain the multiple sampling data and the multiple sampling moments; writing the multiple sampling data and the multiple sampling moments into the circular linked list memory pool, including: determining the node change information of the memory pool, the pointer information of the memory information structure of the memory pool, and the multiple historical sequence numbers corresponding to the multiple historical data in the circular linked list memory pool; determining the multiple target sequence numbers corresponding to the multiple sampling data according to the pointer information and the multiple historical sequence numbers, the multiple target sequence numbers are different from the multiple historical sequence numbers; writing the multiple sampling data, the multiple sampling moments, and the multiple target sequence numbers into the circular linked list memory pool.
[0008] Optionally, the method as described above determines multiple target sequence numbers corresponding to the multiple sampling data based on the pointer information and the multiple historical sequence numbers, including: aligning the multiple sampling data based on the multiple sampling moments to obtain multiple data groups, and the multiple sampling data in each data group correspond to the same sampling moment; determining multiple target sequence numbers corresponding to the multiple sampling data based on the pointer information, the multiple historical sequence numbers, and the multiple data groups, and the multiple sampling data in each data group correspond to multiple adjacent target sequence numbers.
[0009] Optionally, the method as described above determines multiple historical recording requests based on the multiple sampling data, the multiple sampling moments, and the specified data range, including: determining multiple abnormal data from the multiple sampling data based on the specified data range, the abnormal data not being within the specified data range; determining multiple abnormal moments corresponding to the multiple abnormal data from the multiple sampling moments; and determining the multiple historical recording requests based on the multiple abnormal data and the multiple abnormal moments.
[0010] Optionally, the method as described above executes the target recording request, including: determining the target time corresponding to the target recording request, and determining the target time range according to the target time and a preset duration; determining the target data corresponding to the target time range from the circular linked list memory pool through a range lock, multiple historical sequence numbers, and pointer information control; converting the target data according to a preset format to obtain target format data, and writing the target format data into a cache; if the amount of format data in the cache is greater than or equal to a data amount threshold, writing the format data in the cache to the disk in batches to complete the target recording request.
[0011] Optionally, the method as described above determines the target data corresponding to the target time range from the circular linked list memory pool, including: determining the current number of requests of the target queue, and the corresponding relationship between the number of requests and the recording frequency; sliding the target recording frequency according to the current number of requests and the corresponding relationship; and obtaining the target data from the circular linked list memory pool at intervals according to the target recording frequency.
[0012] In a second aspect, the present application provides a recording device, comprising: a transmission module, used to obtain multiple sampling data of a target system and multiple sampling times corresponding to the multiple sampling data through a DMA unidirectional transmission method, and write the multiple sampling data and the multiple sampling times into a circular linked list memory pool; a trigger module, used to determine multiple historical recording requests based on the multiple sampling data, the multiple sampling times, and a specified data range; an adding module, used to add the multiple historical recording requests to a target queue; an execution module, used to obtain a target recording request from the target queue, and execute the target recording request according to the circular linked list memory pool to realize recording.
[0013] Optionally, in the device as described above, the transmission module is specifically used to obtain multiple data packets, and the multiple data packets are transmitted through the DMA unidirectional transmission method; the transmission module is also specifically used to parse and process the multiple data packets to obtain the multiple sampling data and the multiple sampling times; the transmission module is also specifically used to determine the node change information of the memory pool, the pointer information of the memory information structure of the memory pool, and the multiple historical sequence numbers corresponding to the multiple historical data in the circular linked list memory pool; the transmission module is also specifically used to determine the multiple target sequence numbers corresponding to the multiple sampling data based on the pointer information and the multiple historical sequence numbers, and the multiple target sequence numbers are different from the multiple historical sequence numbers; the transmission module is also specifically used to write the multiple sampling data, the multiple sampling times, and the multiple target sequence numbers into the circular linked list memory pool.
[0014] Optionally, in the device as described above, the transmission module is specifically used to align the multiple sampling data according to the multiple sampling moments to obtain multiple data groups, and the multiple sampling data in each data group correspond to the same sampling moment; the transmission module is specifically used to determine the multiple target sequence numbers corresponding to the multiple sampling data according to the pointer information, the multiple historical sequence numbers, and the multiple data groups, and the multiple sampling data in each data group correspond to multiple adjacent target sequence numbers.
[0015] Optionally, in the device as described above, the trigger module is specifically used to determine a plurality of abnormal data from the plurality of sampled data according to the specified data range, and the abnormal data is not within the specified data range; the trigger module is also specifically used to determine a plurality of abnormal moments corresponding to the plurality of abnormal data from the plurality of sampling moments; the trigger module is also specifically used to determine the plurality of historical recording requests based on the plurality of abnormal data and the plurality of abnormal moments.
[0016] Optionally, as described above, the device further comprises: an acquisition module, used for the acquisition module, specifically used to determine the target time corresponding to the target recording request, and determine the target time range according to the target time and a preset duration; the acquisition module is also used for the acquisition module, specifically used to determine the target data corresponding to the target time range from the circular linked list memory pool through a range lock, multiple historical sequence numbers, and pointer information control; the acquisition module is also used for the acquisition module, specifically used to convert the target data according to a preset format to obtain target format data, and write the target format data into a cache; the acquisition module is specifically used to write the format data in the cache to the disk in batches if the amount of format data in the cache is greater than or equal to a data amount threshold, so as to complete the target recording request.
[0017] Optionally, in the device as described above, the acquisition module is specifically used to determine the current number of requests of the target queue, and the corresponding relationship between the number of requests and the recording frequency; the acquisition module is also specifically used to slide the target recording frequency according to the current number of requests and the corresponding relationship; the acquisition module is also specifically used to obtain the target data from the circular linked list memory pool at intervals according to the target recording frequency.
[0018] In a third aspect, the present application provides an electronic device comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement any method described in the first aspect.
[0019] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by a processor as described in any one of the methods in the first aspect.
[0020] In a fifth aspect, the present application provides a computer program product, comprising a computer program, wherein the computer program is executed by a processor as in any one of the methods in the first aspect.
[0021] The recording method, device, electronic device, storage medium and product provided by the present application include: obtaining multiple sampling data of the target system and multiple sampling moments corresponding to the multiple sampling data through the DMA one-way transmission method, and writing the multiple sampling data and the multiple sampling moments into the circular linked list memory pool; determining multiple historical recording requests according to the multiple sampling data, the multiple sampling moments, and the specified data range; adding the multiple historical recording requests to the target queue; obtaining the target recording request from the target queue, and executing the target recording request according to the circular linked list memory pool to realize recording. The above scheme, combined with DMA one-way transmission and the circular linked list memory pool, can reduce the operations of the processor to control data transmission and allocate memory areas, thereby reducing the load of the processor to improve the recording efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0023] Figure 1 A schematic diagram of an application scenario of a wave recording method provided in an embodiment of the present application;
[0024] Figure 2 A schematic diagram of a flow chart of a wave recording method provided in an embodiment of the present application;
[0025] Figure 3 A schematic diagram of a flow chart of a wave recording method provided in an embodiment of the present application;
[0026] Figure 4 A schematic diagram of writing a circular linked list memory pool provided in an embodiment of the present application;
[0027] Figure 5 A schematic diagram of a trigger recording request provided in an embodiment of the present application;
[0028] Figure 6 A schematic diagram of executing a recording request provided in an embodiment of the present application;
[0029] Figure 7 A schematic diagram of an access mechanism provided in an embodiment of the present application;
[0030] Figure 8 A schematic diagram of the structure of a wave recording device provided in an embodiment of the present application;
[0031] Fig. 9 A schematic diagram of the structure of a wave recording device provided in an embodiment of the present application;
[0032] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0033] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0034] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0035] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, processing, transmission, provision, disclosure and application of the relevant data comply with the relevant laws, regulations and standards of the relevant countries and regions, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0036] It should be noted that the recording method, device, electronic device, storage medium and product of the present application can be used in the field of data processing technology, and can also be used in any field except data processing. The application field of the recording method, device, electronic device, storage medium and product of the present application is not limited.
[0037] Figure 1 A schematic diagram of an application scenario of a recording method provided in an embodiment of the present application is given by way of example in combination with the scenario shown in the diagram: sampling data is obtained from system 1, the sampled data is analyzed, abnormal data with abnormalities is determined therefrom, and the abnormal data is stored in disk 2.
[0038] Exemplarily, the working data of the system is recorded, and the recording can be performed synchronously when the system is working, so as to timely discover problems existing in the system.
[0039] Combined with the scenario example, users can use the abnormal data obtained from recording to determine the abnormal problems in the system and solve the abnormal problems in a targeted manner.
[0040] In the related art, the processor participates in the execution of wave recording. Specifically, the processor dynamically allocates the size of a fixed memory area according to the amount of data, the processor transfers the sampled data to the memory area, and the processor transfers the abnormal data from the memory area to the disk. If the amount of working data of the system is too large or the sampling rate is too high, the processor load will increase significantly, and the processor needs to frequently process a large amount of data and cannot obtain the processing results in time, which leads to the problem of low wave recording efficiency. The processor includes but is not limited to the CPU, etc.
[0041] The wave recording method provided in this application is intended to solve the above technical problems in the prior art.
[0042] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0043] Figure 2 A schematic flow chart of a recording method provided in an embodiment of the present application, the method comprising the following steps:
[0044] S201. Acquire multiple sampling data of a target system and multiple sampling times corresponding to the multiple sampling data through a DMA unidirectional transmission method, and write the multiple sampling data and the multiple sampling times into a circular linked list memory pool.
[0045] The sampling time is the time when the sampling data is obtained.
[0046] Among them, the system of the present application is an electric power system.
[0047] Optionally, the sampled data may be three-phase power data.
[0048] Optionally, sampling is performed by an analog-to-digital converter card (ADC card for short) to obtain the sampled data. The ADC card converts the data of the analog signal of the system operation into the sampled data of the digital signal.
[0049] For example, through the DMA one-way transmission method, the sampled data can be directly transmitted without the need for a processor, thereby reducing the operation of the processor. The maximum threshold of the circular linked list memory pool can be set. After each DMA transfer is completed, the data will be written to the next available location in the memory pool, forming a loop structure. The digital signal needs to be converted into voltage and current data, which specifically includes unpacking, conversion, and packaging processes.
[0050] Exemplarily, the memory area of the ring linked list memory pool can be used cyclically. When the memory area actually used exceeds a threshold, the memory area occupied by old data is released, thereby avoiding the generation of new memory areas and saving space in the memory area.
[0051] S202. Determine multiple historical recording requests according to multiple sampling data, multiple sampling time points, and a specified data range.
[0052] The specified data range is determined according to the parameters specified by the user. The specified data range is used to determine whether the sampled data is abnormal.
[0053] Optionally, the sampled data is calculated and processed according to preset rules to obtain a calculation result, and it is determined whether there is an abnormality in the calculation result according to a specified data range.
[0054] Optionally, the historical recording request is triggered by the judgment result of the specified data range. If abnormal data is judged, the historical recording request is triggered.
[0055] It should be noted that the present application does not limit the relative relationship between the number of sampling data, sampling time, and historical recordings.
[0056] It should be noted that the present application does not limit the relative relationship between the number of sampling data, sampling time, and historical recordings.
[0057] Combined with the scenario example, for example, the sampling data includes frequency data, and the specified data range is 45 Hz to 50 Hz. If the sampling data is 53 Hz, it is determined that the sampling data is abnormal.
[0058] S203: Add multiple historical recording requests to the target queue.
[0059] The target queue is used to store and manage the data structure of multiple historical recording requests.
[0060] Optionally, a corresponding priority is determined for each historical recording request, and the historical recording requests in the target queue are arranged and processed in order of priority to ensure that requests with higher priorities are processed first.
[0061] S204, obtaining a target recording request from the target queue, and executing the target recording request according to the ring linked list memory pool to realize recording.
[0062] Exemplarily, the circular linked list memory pool stores all sampled data, and according to the target recording request, the target data is obtained from the all sampled data to perform recording. The target data is the abnormal data and data related to the abnormal data.
[0063] The wave recording method provided in the embodiment of the present application obtains multiple sampling data of the target system and multiple sampling moments corresponding to the multiple sampling data through the DMA unidirectional transmission method, and writes the multiple sampling data and the multiple sampling moments into the circular linked list memory pool; determines multiple historical wave recording requests according to the multiple sampling data, the multiple sampling moments, and the specified data range; adds the multiple historical wave recording requests to the target queue; obtains the target wave recording request from the target queue, and executes the target wave recording request according to the circular linked list memory pool to realize wave recording. The above scheme, combined with DMA unidirectional transmission and the circular linked list memory pool, can reduce the operations of the processor controlling data transmission and allocating memory areas, thereby reducing the load of the processor to improve the wave recording efficiency.
[0064] Based on any of the above embodiments, Figure 3 , the detailed process of recording is explained.
[0065] Figure 3 A schematic diagram of a wave recording method provided in an embodiment of the present application. Figure 3 As shown, the method includes:
[0066] S301, acquiring multiple data packets, where the multiple data packets are transmitted through a DMA unidirectional transmission method.
[0067] Each data packet includes a plurality of sampling data.
[0068] Optionally, multiple sampling data are packaged into one data packet according to the correlation of the sampling data.
[0069] Combined with the scenario example, take three-phase electricity as an example. A group of three-phase electricity 3-way voltage data and 3-way current data have a circuit logic relationship. A group of three-phase electricity data is packaged into a data packet. The three-way voltage and three-way current data of three-phase electricity are interrelated, and they have a strict circuit logic relationship at the same time point. If these data are stored or transmitted separately, it may cause time misalignment, which in turn affects subsequent analysis and processing. By packaging the three-phase electricity data at the same time into a data packet, it can ensure that all related data are recorded at the same time, avoiding the problem caused by time deviation. There is a complex circuit logic relationship between the voltage and current data of three-phase electricity, such as power calculation, phase difference, etc. If these data are stored at different times, it may lead to inaccurate calculation results or even wrong fault judgment. By packaging a group of three-phase electricity data into a data packet, it can ensure that all related voltage and current data are logically consistent, which is convenient for subsequent judgment.
[0070] S302: parse and process multiple data packets to obtain multiple sampling data and multiple sampling times.
[0071] Combined with the scenario example, it is transmitted in the form of data packets during the transmission process, and parsed after the transmission is completed to obtain multiple sampling data in multiple data packets and multiple sampling moments.
[0072] Based on the above implementation methods, the network layer overhead can be reduced by packaging multiple data into one data packet. Compared with the method of transmitting each sampled data one by one, the processing time of the communication protocol is greatly reduced.
[0073] S303: Determine the node change information of the memory pool, the pointer information of the memory information structure of the memory pool, and multiple historical sequence numbers corresponding to multiple historical data in the circular linked list memory pool.
[0074] The pointer information is used to track the current state in the ring list memory pool, including the head pointer and the tail pointer. The historical sequence number assigns a unique sequence number to each node to identify the time sequence of the historical data stored in the node.
[0075] Optionally, the head pointer of the memory pool information structure pointer information points to the earliest node at the head of the linked list, and the tail pointer of the memory pool information structure pointer information points to the latest node at the tail of the linked list, forming a circular linked list memory pool for fast query access.
[0076] S304: Determine multiple target sequence numbers corresponding to the multiple sampling data according to the pointer information and the multiple historical sequence numbers, where the multiple target sequence numbers are different from the multiple historical sequence numbers.
[0077] The multiple target serial numbers are serial numbers assigned to the multiple sampling data.
[0078] For example, multiple target serial numbers are different from multiple historical serial numbers, which can ensure that valid sampling data is obtained from the circular linked list memory pool, rather than historical data that has been overwritten or removed, thereby avoiding the loss of key data due to data overwriting and ensuring the integrity and accuracy of the recording.
[0079] Optionally, when reading data from the circular linked list memory pool, the data in the nodes are read sequentially starting from the head pointer to ensure that the latest request is processed first. When the circular linked list memory pool is full, the new data will overwrite the node pointed to by the head pointer to ensure the circular use of the circular linked list memory pool. When new sampled data is received, the sampled data will be inserted into the node pointed to by the tail pointer to ensure that the latest data is always added to the end of the circular linked list memory pool. The tail pointer will continue to move as the sampled data is inserted to ensure that the sampled data can be continuously written into the circular linked list memory pool.
[0080] A feasible implementation method can determine multiple target sequence numbers by the following method: align multiple sampling data according to multiple sampling moments to obtain multiple data groups, and multiple sampling data in each data group correspond to the same sampling moment; determine multiple target sequence numbers corresponding to multiple sampling data according to pointer information, multiple historical sequence numbers, and multiple data groups, and multiple sampling data in each data group correspond to multiple adjacent target sequence numbers.
[0081] Combined with the scenario example, taking three-phase electricity as an example, there is a close logical relationship between the voltage and current data of three-phase electricity. Especially in the case of multiple groups of three-phase electricity, the data must be aligned at the same time point to ensure the accuracy of subsequent analysis. Any group of three-phase electricity sampling data corresponds to a sampling moment, and the sampling data corresponding to a sampling moment are divided into the same data group.
[0082] Exemplarily, the sampled data is written according to the data group. The target sequence numbers corresponding to the multiple sampled data in a data group are adjacent sequence numbers, so that the multiple sampled data in a data group are arranged adjacently in the ring-linked list memory pool, and when obtaining information from the ring-linked list memory pool, the complete sampled data of each data group can be accurately obtained according to the adjacent relationship.
[0083] In this feasible implementation, by corresponding multiple sampling data in each data group to multiple adjacent target serial numbers, it is possible to avoid missing data in a data group when obtaining information from the circular linked list memory pool, thereby improving the accuracy of recording.
[0084] S305, writing a plurality of sampling data, a plurality of sampling times, and a plurality of target sequence numbers into a circular linked list memory pool.
[0085] Optionally, the writing position is determined according to the target sequence number, and each sampling data and the corresponding sampling time are written to the determined writing position to ensure that each sampling data and the corresponding sampling time are stored in the same position.
[0086] Based on the above implementation mode, the sampling data and the corresponding sampling time are stored in the same location, which can ensure the time synchronization of the data, thereby improving the accuracy of the recording.
[0087] Next, combine Figure 4 Writing to the circular linked list memory pool is described.
[0088] Figure 4 A schematic diagram of writing a circular linked list memory pool provided in an embodiment of the present application. Figure 4As shown, sample data is obtained from the system. Data writing is triggered by a callback function. The data writing process includes determining the node change information of the memory pool, the pointer information of the memory information structure of the memory pool, and determining the writing position according to the node change information and the pointer information and writing the sample data into the ring linked list memory pool.
[0089] Exemplarily, the implementation scheme of the circular linked list memory pool includes: when the cached data does not meet the preset time length data volume, the memory pool size continues to expand. At this time, the next pointer of the head pointer always points to the first generated data, and the prev pointer is updated to the latest inserted node. When the cached data has reached the preset time length data volume, the oldest data is cleaned up for new data insertion. At this time, the next pointer of the head pointer is updated to point to the next oldest data, and the prev pointer is updated to the latest inserted node. Each time a new node is generated, its node sequence number is incremented based on the previous node + 1, and starts from 0 after reaching the maximum value. Each node corresponds to the node sequence number, node size, node sampling number and other information. When acquiring the sampled data, the latest timestamp of the sampled data must be brought. When the calculation generates the result and inserts it into the calculation result memory pool, the timestamp is brought together, thereby realizing the alignment of the data in time and logic. Whenever a new data node is successfully inserted, the sequence number of the node must be updated to the information structure of the calculation result memory pool to ensure that the information structure always records the latest data node in the storage memory pool for subsequent reading and processing. Before deleting the oldest data node, the sequence number of the node must be updated to the information structure of the calculation result memory pool to ensure that the information structure always records the oldest data node in the storage memory pool to facilitate fast access to the object.
[0090] Optionally, when obtaining data from the circular linked list memory pool, a range is determined based on the access node sequence number and the latest and oldest node sequence numbers in the information structure of the memory pool to determine whether the access object is delayed. If delayed, data acquisition is stopped to avoid out-of-bounds access.
[0091] S306. Determine multiple historical recording requests according to multiple sampling data, multiple sampling time points, and a specified data range.
[0092] Next, combine Figure 5 Describe the trigger recording request.
[0093] Figure 5 Schematic diagram of triggering a recording request provided in an embodiment of the present application. Figure 5As shown, the configuration file is initialized: the user can modify the configuration file dynamically. Determine whether to start the recording function, if so, go to the next step. If not, the recording thread is automatically terminated. Recording trigger condition: Determine whether the dead zone is triggered, if so, trigger the recording start event. If not, continue to judge. Determine whether to exit the dead zone, if so, trigger the recording close event. If not, continue to judge. Real-time recording event processing: The power calculation module performs power calculation and determines whether the triggering conditions are met. If the recording start event is triggered, the recording channel flag is set to 1. The latest recording event is inserted into the head of the recording event queue to achieve the highest priority processing: before deleting the old data in the data memory pool, quickly enter all the data in the data memory pool so that each recording event can record the historical data of the previous 5 seconds of the time of occurrence for abnormal analysis. If the recording close event is triggered, the recording channel flag is set to 0. The process of inserting sampled data into the memory pool determines whether there is new data. If so, check whether the memory pool head pointer L_newest has space. If there is space, insert the new data into L_newest. If there is no space, delete the head node L_oldest and release the memory. Complete the L_oldest record and unlock the memory of the L_oldest node. Wait for new data to be inserted into L_newest. If the continuous time that the recording data has returned to the normal range has reached 10s (adjustable), and the total recording time is not less than 1 minute (adjustable), then the recording event is completely ended and the recording node is deleted from the recording request queue. API call record_event_api: set recording configuration, set trigger and exit dead zone values, storage characteristics and other parameters. Create a recording thread and generate a recording configuration file. Simulate or obtain AI configuration recording data. Process the recording event, insert the event into the queue, and take the event out of the queue for processing. Summarize the above solutions and initialize the configuration: the user can dynamically modify the configuration file and start or end the recording function according to the configuration. Recording trigger: determine whether to trigger the recording start or shutdown event through the power calculation module. Data storage: new data is inserted into the end of the memory pool L_newest. If there is insufficient memory, delete the head node L_oldest. API call: A series of API calls are used to implement functions such as wave recording configuration, creation, simulation or data acquisition, and event processing.
[0094] A feasible implementation method can determine multiple historical recording requests by the following method: according to a specified data range, determine multiple abnormal data from multiple sampled data, and the abnormal data is not within the specified data range; determine multiple abnormal moments corresponding to the multiple abnormal data from multiple sampling moments; determine multiple historical recording requests based on the multiple abnormal data and the multiple abnormal moments.
[0095] Optionally, whether to trigger a historical recording request is based on whether the sampled data or the calculation result corresponding to the sampled data is within the specified data range. If the sampled data or the calculation result corresponding to the sampled data is not within the specified data range, abnormal data is obtained. The abnormal time corresponding to the abnormal data is determined, and a historical recording request is triggered.
[0096] Optionally, create a historical recording request for each abnormal data. These requests will be used to retroactively collect and save detailed data during the abnormal period for post-analysis, fault diagnosis, or performance optimization. Each historical recording request should clearly indicate the type of data to be collected, the time range, or any other necessary parameters.
[0097] In this feasible implementation, the historical recording request is triggered according to the abnormal data obtained, and the callback trigger can be realized to ensure that the key data when the abnormality occurs is captured at the first time. This real-time response mechanism can prevent the loss of important information, thereby improving the accuracy of the recording.
[0098] S307: Add multiple historical recording requests to the target queue.
[0099] It should be noted that the execution process of S307 refers to S203 and will not be repeated here.
[0100] S308, obtaining a target recording request from the target queue, and executing the target recording request according to the ring linked list memory pool to realize recording.
[0101] A feasible implementation method can execute the target recording request through the following method: determine the target time corresponding to the target recording request, and determine the target time range according to the target time and the preset duration; determine the target data corresponding to the target time range from the circular linked list memory pool through range lock, multiple historical sequence numbers, and pointer information control; convert the target data according to the preset format to obtain the target format data, and write the target format data into the cache; if the amount of format data in the cache is greater than or equal to the data amount threshold, the format data in the cache is batch written to the disk to complete the target recording request.
[0102] Among them, the preset duration is used to control the continuation of recording.
[0103] Exemplarily, when the system abnormality is resolved, data of a preset time length continues to be recorded to achieve complete wave recording.
[0104] Optionally, starting from the target time, obtaining a range of a preset time forward is determined as the target time range. Starting from the target time, obtaining a range of a preset time backward is determined as the target time range. The range of a preset time around the target time is determined as the target time range.
[0105] Exemplarily, the data within the target time range is obtained through range lock, multiple historical serial numbers, and pointer information control. The range lock is used to lock nodes within a specific time range to prevent other threads from modifying or deleting these nodes during this period. This ensures that the acquired data is complete and consistent. Through pointer information, nodes within the target time range can be quickly located, which can improve positioning efficiency compared to traversal.
[0106] Combined with the scenario example, taking the data format as double type as an example, the double type is converted bit by bit into character type, and then composed into a byte stream to improve the formatting speed.
[0107] Exemplarily, for a multi-level cache, the format data in the multi-level cache is written to the disk in batches, which can reduce the number of disk accesses compared to writing the target format data generated each time to the disk, thereby improving the efficiency of wave recording.
[0108] Next, combine Figure 6 Describes the execution of the recording request.
[0109] Figure 6 A schematic diagram of executing a recording request provided in an embodiment of the present application. Figure 6 As shown, determine the target time range corresponding to the target recording request, and obtain the target data from the ring list memory pool according to the range lock, historical sequence number, pointer information, and target time range. Format the target data into target format data, and write the target format data into the cache. Until the amount of format data in is greater than or equal to the data amount threshold, the data in the cache is written to the disk in batches.
[0110] Next, combine Figure 7 Describe the access mechanism.
[0111] Figure 7 Schematic diagram of the access mechanism provided by the embodiment of the present application. Figure 7As shown, the memory information structure FIFO_MEMPOOL_STRUCT of the circular linked list memory pool includes the node serial number newest_idx of the latest data, the node serial number oldest_idx of the oldest data, and the head pointer pLinkHeader pointing to the memory pool. The pointer static_node of the last processed node and the serial number static_node_index of the last processed node are recorded in the access object. When new data is inserted, a semaphore is triggered according to the period of the read length. Judge the value of the serial number static_node_index of the last processed node static_node and the lengths of the old data before the static_node node to be read and the new data after the static_node node. Compare it with the newest_idx and oldest_idx of the memory information structure FIFO_MEMPOOL_STRUCT. Check whether static_node_idx + length > newest_idx or static_node_idx < oldest_idx holds. Here, length is the length to be accessed. If so, return failure to avoid out-of-bounds memory access. If not, continue to the next step. According to the prev / next pointers of static_node, perform memory copying or file writing and reading operations in units of nodes. After completing the above operations, mark it as successful. The entire process ensures the correct reading and processing of data, while avoiding the problem of out-of-bounds memory access. Optionally, the access mechanism includes but is not limited to waveform recording access or calculation access.
[0112] In this feasible implementation, the efficiency of waveform recording can be effectively improved through range locks, multiple historical serial numbers, pointer information, and caching schemes.
[0113] A feasible implementation can determine the target data through the following method: determine the current request quantity of the target queue and the corresponding relationship between the request quantity and the waveform recording frequency; according to the current request quantity and the corresponding relationship, shift the target waveform recording frequency; according to the target waveform recording frequency, obtain the target data at intervals from the circular linked list memory pool.
[0114] Here, the waveform recording frequency is the number of times to obtain the target data per unit time interval.
[0115] Optionally, the current request quantity is determined by reading the length or counter of the target queue.
[0116] Optionally, the corresponding relationship is represented by a mapping table.
[0117] Exemplarily, between the request quantity and the waveform recording frequency with a corresponding relationship, the waveform recording frequency is adapted to the request quantity.
[0118] Combined with the scenario example, the number of requests affects the operating frequency of the disk. If the number of requests is too high, it may cause the disk to exit abnormally. By controlling the recording frequency, we can avoid the disk exiting abnormally due to the number of requests.
[0119] The current number of requests is the actual number of requests currently in the target queue.
[0120] Optionally, the target recording frequency is determined by looking up a table.
[0121] Exemplarily, a target recording frequency adapted to the current request quantity is determined according to the corresponding relationship.
[0122] Combined with the scenario example, if the current number of requests is too large, data can be obtained from the circular linked list memory pool at intervals according to the target recording frequency to reduce the operation frequency of the disk.
[0123] For example, when the recording event queue increases, the disk operation frequency increases significantly, and the processing time of the recording event is longer than the update time of the memory pool data, resulting in a lag in the recording processing, which in turn causes a gap in the recording data. The recording system slides the recording storage frequency according to the number of recording events (not lower than the minimum recording frequency) and extracts the data at intervals.
[0124] Based on the above implementation methods, by dynamically adjusting the recording frequency, the recording frequency can be reduced when the load is high, reducing the processing pressure of the system and preventing overload; the recording frequency can be increased when the load is low to ensure the integrity and accuracy of the data.
[0125] Figure 8 This is a schematic diagram of the structure of a wave recording device provided in an embodiment of the present application. Figure 8 As shown, the wave recording device 80 may include: a transmission module 81, a trigger module 82, an adding module 83, and an execution module 84, wherein:
[0126] The transmission module 81 is used to obtain multiple sampling data of the target system and multiple sampling times corresponding to the multiple sampling data through a DMA unidirectional transmission method, and write the multiple sampling data and the multiple sampling times into a ring linked list memory pool.
[0127] The trigger module 82 is used to determine multiple historical recording requests according to multiple sampling data, multiple sampling moments, and a specified data range.
[0128] The adding module 83 is used to add multiple historical recording requests to the target queue.
[0129] The execution module 84 is used to obtain the target recording request from the target queue, and execute the target recording request according to the ring linked list memory pool to realize the recording.
[0130] Optionally, the transmission module 81 may execute Figure 2 S201 in the embodiment.
[0131] Optionally, the trigger module 82 may execute Figure 2 S202 in the embodiment.
[0132] Optionally, the add module 83 may execute Figure 2 S203 in the embodiment.
[0133] Optionally, the execution module 84 may execute Figure 2 S204 in the embodiment.
[0134] It should be noted that the recording device shown in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.
[0135] In a possible implementation manner, the transmission module 81 is specifically configured to:
[0136] Acquire multiple data packets, where the multiple data packets are transmitted through a DMA unidirectional transmission method;
[0137] Analyze and process multiple data packets to obtain multiple sampling data and multiple sampling times;
[0138] Determine node change information of the memory pool, pointer information of a memory information structure of the memory pool, and multiple historical sequence numbers corresponding to multiple historical data in the ring-linked list memory pool;
[0139] Determine multiple target sequence numbers corresponding to the multiple sampling data according to the pointer information and the multiple historical sequence numbers, where the multiple target sequence numbers are different from the multiple historical sequence numbers;
[0140] Write multiple sampling data, multiple sampling times, and multiple target sequence numbers into the circular linked list memory pool.
[0141] In a possible implementation manner, the transmission module 81 is specifically configured to:
[0142] According to the multiple sampling moments, the multiple sampling data are aligned to obtain multiple data groups, and the multiple sampling data in each data group correspond to the same sampling moment;
[0143] A plurality of target sequence numbers corresponding to the plurality of sampled data are determined according to the pointer information, the plurality of historical sequence numbers, and the plurality of data groups, wherein the plurality of sampled data in each data group correspond to a plurality of adjacent target sequence numbers.
[0144] In a possible implementation, the trigger module 82 is specifically configured to:
[0145] According to the specified data range, a plurality of abnormal data are determined from the plurality of sampled data, wherein the abnormal data are not within the specified data range;
[0146] Determine multiple abnormal moments corresponding to multiple abnormal data from multiple sampling moments;
[0147] A plurality of historical recording requests are determined according to a plurality of abnormal data and a plurality of abnormal time points.
[0148] Fig. 9 A schematic diagram of the structure of a wave recording device provided in an embodiment of the present application. Figure 8 Based on the embodiment shown, Fig. 9 As shown, the wave recording device 90 further includes: an acquisition module 85, wherein:
[0149] The acquisition module 85 is used to:
[0150] Determine the target time corresponding to the target recording request, and determine the target time range according to the target time and the preset duration;
[0151] Through range locks, multiple historical serial numbers, and pointer information control, the target data corresponding to the target time range is determined from the ring-linked list memory pool;
[0152] Convert the target data according to the preset format to obtain the target format data, and write the target format data into the cache;
[0153] If the amount of format data in the cache is greater than or equal to the data amount threshold, the format data in the cache is written to the disk in batches to complete the target recording request.
[0154] In a possible implementation, the acquisition module 85 is specifically configured to:
[0155] Determine the current number of requests in the target queue and the corresponding relationship between the number of requests and the recording frequency;
[0156] According to the current request quantity and the corresponding relationship, the target recording frequency is shifted;
[0157] According to the target recording frequency, the target data is obtained from the circular linked list memory pool at intervals.
[0158] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Fig.10 As shown, the electronic device includes:
[0159] The electronic device includes a processor 291 and a memory 292; it may also include a communication interface 293 and a bus 294. The processor 291, the memory 292, and the communication interface 293 may communicate with each other through the bus 294. The communication interface 293 may be used for information transmission. The processor 291 may call the logic instructions in the memory 292 to execute the method of the above embodiment.
[0160] In addition, the logic instructions in the above-mentioned memory 292 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.
[0161] The memory 292 is a computer-readable storage medium that can be used to store software programs and computer executable programs, such as program instructions / modules corresponding to the methods in the embodiments of the present application. The processor 291 executes functional applications and data processing by running the software programs, instructions, and modules stored in the memory 292, that is, implementing the methods in the above method embodiments.
[0162] The memory 292 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 292 may include a high-speed random access memory and may also include a non-volatile memory.
[0163] An embodiment of the present application provides a non-temporary computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the method as described in the above embodiment.
[0164] An embodiment of the present application provides a computer program product, including a computer program, which implements the method of the aforementioned embodiment when the computer program is executed by a processor.
[0165] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0166] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0167] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.
[0168] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.
[0169] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. The processor may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, and an ASIC, etc. The storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc.
[0170] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes 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 various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0171] In the above embodiments, the description of each embodiment has its own emphasis. For the part not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0172] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0173] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A wave recording method, characterized in that: include: Acquire multiple sampling data of the target system and multiple sampling times corresponding to the multiple sampling data through a DMA unidirectional transmission method, and write the multiple sampling data and the multiple sampling times into a ring linked list memory pool; Determining a plurality of historical recording requests according to the plurality of sampling data, the plurality of sampling moments, and a specified data range; Adding the multiple historical recording requests to a target queue; A target recording request is obtained from the target queue, and the target recording request is executed according to the ring-linked list memory pool to realize recording.
2. The method according to claim 1, characterized in that Acquiring multiple sampling data of a target system and multiple sampling moments corresponding to the multiple sampling data by using a DMA unidirectional transmission method, including: Acquire multiple data packets, wherein the multiple data packets are transmitted through a DMA unidirectional transmission method; Parsing the plurality of data packets to obtain the plurality of sampling data and the plurality of sampling times; Writing the plurality of sampling data and the plurality of sampling times into a circular linked list memory pool comprises: Determine node change information of the memory pool, pointer information of a memory information structure of the memory pool, and multiple historical sequence numbers corresponding to multiple historical data in the ring-linked list memory pool; Determine, according to the pointer information and the plurality of historical sequence numbers, a plurality of target sequence numbers corresponding to the plurality of sampled data, wherein the plurality of target sequence numbers are different from the plurality of historical sequence numbers; The plurality of sampling data, the plurality of sampling moments, and the plurality of target sequence numbers are written into the circular linked list memory pool.
3. The method according to claim 2, characterized in that Determining a plurality of target sequence numbers corresponding to the plurality of sampled data according to the pointer information and the plurality of historical sequence numbers includes: According to the multiple sampling moments, the multiple sampling data are aligned to obtain multiple data groups, wherein the multiple sampling data in each data group correspond to the same sampling moment; A plurality of target sequence numbers corresponding to the plurality of sampled data are determined according to the pointer information, the plurality of historical sequence numbers, and the plurality of data groups, wherein the plurality of sampled data in each data group corresponds to a plurality of adjacent target sequence numbers.
4. The method according to claim 1, characterized in that: Determining multiple historical recording requests according to the multiple sampling data, the multiple sampling moments, and the specified data range includes: According to the specified data range, determining a plurality of abnormal data from the plurality of sampled data, the abnormal data not being within the specified data range; Determine a plurality of abnormal moments corresponding to the plurality of abnormal data from the plurality of sampling moments; The multiple historical recording requests are determined according to the multiple abnormal data and the multiple abnormal time points.
5. The method according to any one of claims 1 to 4, characterized in that Executing the target recording request includes: Determine a target time corresponding to the target recording request, and determine a target time range according to the target time and a preset duration; Determine the target data corresponding to the target time range from the ring linked list memory pool through range locks, multiple historical sequence numbers, and pointer information control; Convert the target data into a target format according to a preset format, and write the target format data into a cache; If the amount of format data in the cache is greater than or equal to the data amount threshold, the format data in the cache is written to the disk in batches to complete the target recording request.
6. The method according to claim 5, characterized in that Determining target data corresponding to the target time range from the ring linked list memory pool includes: Determine the current number of requests in the target queue and the corresponding relationship between the number of requests and the recording frequency; According to the current request quantity and the corresponding relationship, sliding the target recording frequency; According to the target recording frequency, the target data is obtained from the circular linked list memory pool at intervals.
7. A wave recording device, characterized in that: include: A transmission module, used for acquiring a plurality of sampling data of a target system and a plurality of sampling moments corresponding to the plurality of sampling data through a DMA unidirectional transmission method, and writing the plurality of sampling data and the plurality of sampling moments into a ring linked list memory pool; A trigger module, used for determining a plurality of historical recording requests according to the plurality of sampling data, the plurality of sampling moments, and a specified data range; An adding module, used for adding the plurality of historical recording requests to a target queue; The execution module is used to obtain the target recording request from the target queue, and execute the target recording request according to the ring linked list memory pool to realize the recording.
8. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 6 when executed by a processor.
10. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 6 when being executed by a processor.
Citation Information
Cited By
Multi-channel fault recording data construction method and device
CN122261902A