Method for refreshing data table based on spectrum analyzer
By using the drawing interface in the spectrum analyzer to preprocess and extract data, fixedly allocate memory, and loop draw grid lines and titles, the performance problems caused by frequent memory applications and recycling are solved, and the stability of high frame rates and large data volume is achieved. renew.
Patent Information
- Application Number
- CN202411451015.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-17
- Publication Date
- 2024-12-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
When the existing spectrum analyzer refreshes the data table, frequent application and memory recovery leads to an increase in memory usage, affecting system performance, and may lead to software crashes and system jamming, especially when high frame rate updates.
Data is preprocessed and extracted through multiple drawing interfaces, initialize table drawing objects, fixed allocated memory space, loop grid lines and titles, enforce image operations, free buffers, control data update rate and sorting processing, and avoid frequent Memory application and recycling.
It realizes stable management of memory resources, supports high frame rate updates (more than 60 frames per second), avoids software crashes and system jams, and meets the high-speed drawing needs of large data volumes.
Smart Images

Figure CN119201327A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of spectrum analyzers, and in particular to a method for refreshing a data table based on a spectrum analyzer. Background Art
[0002] In the pulse signal analysis and transient signal analysis of the spectrum analyzer, the display controls provided by the software are often used to refresh and display the data results. Figure 1 As shown, the existing technical solution for updating data results is that the data scanned by the spectrum analyzer bottom layer is processed and then returned to the upper interface. Each time the result is refreshed, a space in the memory will be opened to process the data. The next data update will open up another space in the memory. The memory will continue to increase. When it increases to a certain extent, the software's built-in garbage collector (hereinafter referred to as GC) will recycle the abandoned memory. However, this solution has the following risks: 1. Check the software running status in the task manager. The program has a memory increase of tens of megabytes per second (the program memory occupies more than 2G), and other software except this task will be stuck and the system will slow down. 2. The more memory is occupied by the interface update data results, the more memory space is applied for calculation after the analyzer bottom layer collects data, which will affect the calculation speed after collecting data, and seriously affect the speed of signal acquisition and analysis of the analyzer as a whole, especially for millisecond-level pulse signals, where there is signal loss. 3. Since the solution relies on GC to recycle waste memory, after the system and software have been running for a long time, GC cannot save and recycle waste memory on time every time. When GC fails to recycle in time, the program memory will continue to increase. At this time, the application for memory space will fail, causing the software to crash. In severe cases, it will cause Windows system jamming and blue screen failures. 4. The above defects only apply to the case of updating a single piece of data. If the entire data table is updated (such as 100 rows and 10 columns of data), the defects of this solution are particularly obvious. The memory growth of the data table once updated is more obvious as the number of rows increases. For example, if the update of 3 columns and 10 rows of data increases by hundreds of megabytes of memory per second, the software interface will be directly jammed and cannot be operated. 5. After the analyzer collects short-term data (such as microsecond level), that is, the update frame rate is greater than 60 frames per second, the data update to the interface will also cause the update to jam or the software to crash. Summary of the invention
[0003] The purpose of the present invention is to overcome the shortcomings of the prior art, provide a method for refreshing a data table based on a spectrum analyzer, and solve the deficiencies of the prior art.
[0004] The object of the present invention is achieved by the following technical solution: a method for refreshing a data table based on a spectrum analyzer, the method comprising: Step 1: Pre-process the data through various drawing interfaces and then perform drawing operations. If data extraction is required, extract the data according to the extraction mode and then draw the data; Step 2: Initialize the table drawing object, calculate the total length and width of the drawing area according to the number of rows and columns of the passed data, and then draw the grid lines of a single row and column; Step 3: Draw the title according to the row and column title set, and then draw the corresponding string data according to the set font size and pen color; Step 4: Force the drawing object to execute all pending image operations and notify the canvas to update, release the canvas object from the background buffer, display the graphics cache in the drawing object on the interface, and complete a table drawing; Step 5. After drawing is completed, click the column header in the data table control interface to sort. After sorting is completed, perform corresponding drawing processing according to the execution status of the spectrum analyzer.
[0005] The step 1 specifically includes the following contents: A1. Pre-process the data through the original drawing source data interface, update rate interface, data frame extraction mode interface and column sorting interface provided by the encapsulated data table, and then perform the drawing operation after the processing; A2. When drawing a data table, extraction is required according to the data frame extraction mode interface and then drawing is performed. After the extraction is completed, the data is sorted according to the descending and ascending order set by the column sorting interface.
[0006] The initialization table drawing object includes: Create a canvas object and a drawing object. The initial length of the canvas is equal to the preset column width multiplied by the number of columns, and the initial width of the canvas is equal to the preset row height multiplied by the number of columns. If the data size of each frame is fixed, the memory space allocated will remain unchanged. If the data size of a frame is larger than that of the previous frame, the length and width of the canvas will be expanded and more memory space will be allocated. If the data size of the next frame is less than the highest single-frame data size in history, the maximum canvas length and width will be used as the basis and memory will be allocated in a fixed manner.
[0007] The step three comprises: Loop through the column set, draw the row title according to the first row of data in each column, and then loop through the row set, draw the column title according to the first column of data in each row; Get the y coordinate of a single row of data, loop through the column set, get the x coordinate of the column, pass the (x, y) coordinate into the drawing method of a single table data, fill in the corresponding brush color, and draw each table content in turn.
[0008] The steps of A1 include: After the original data is passed into the data table object, the data validity is verified to ensure that every data in the row and column number set exists. If the data is incorrect, it is directly returned without drawing. Set the update rate to a. When a>60 frames, a is equal to the data input rate. When a<60 frames, if a>n, a=b, b is the data input rate. If a<b, a=a, and data extraction operation is performed when a<b.
[0009] The step five comprises: When the spectrum analyzer is in the continue state, click the column title to switch the reverse / ascending mode, enter step A1, transfer the reverse / ascending mode to the interface, and sort when drawing the next frame of data; When the spectrum analyzer is in the pause state, there is no new data frame to be updated, and the process directly enters step A2, where the data is only sorted and then plotted once and the interface display is updated.
[0010] The present invention has the following advantages: 1. Save memory resources: Taking the update of a single row of data as an example, memory is no longer requested cyclically, the software uses memory relatively stably, and there will be no frequent calls to GC to reclaim memory.
[0011] 2. It can meet the update speed of 60 frames per second, and the maximum data drawing volume is 1000 rows * 10 columns of data update drawing, which can fully meet the drawing requirements of thousands of pulses per frame after pulse signal analysis.
[0012] 3. The rate at which the external data source is transmitted to the data table can be controlled internally, and the frame data can be extracted according to the extraction type to avoid the situation where the external data source is uncontrollable and the data update speed is too fast, affecting the overall performance of the analyzer. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 It is a schematic diagram of the process of the prior art; Figure 2 This is a flowchart of the data table object interface processing; Figure 3 Schematic diagram of the data extraction process; Figure 4 A flow chart for a single drawing table. DETAILED DESCRIPTION
[0014] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of this application. Apparently, the described embodiments are only some, rather than all, of the embodiments of this application. The components of the embodiments of this application described and illustrated in the accompanying drawings here can be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of this application provided below with reference to the accompanying drawings is not intended to limit the protection scope of the claimed application, but merely represents the selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative efforts belong to the protection scope of this application. The following further describes the present invention with reference to the accompanying drawings.
[0015] The present invention specifically relates to a method for refreshing a data table based on a spectrum analyzer. First, through data processing, using fixed-allocation memory for drawing, etc., it solves many problems such as excessive memory occupation caused by traditional interface updates and inability to update data smoothly at high speed. The specific contents are as follows: S1. Drawing interface: The encapsulated data table object provides four interfaces to the outside, namely the original drawing source data, update rate (frames updated per second, with a default maximum update of 60 frames), data frame extraction mode (average, maximum, minimum), and column sorting (unsorted / descending / ascending). The data is pre-processed through these four interfaces, and then the drawing operation is executed after the processing is completed.
[0016] Further, as Figure 2 shown, after the original data is passed into the data table object, the data validity is verified to ensure that each data in the row and column data sets exists. If the data is incorrect, it directly returns without drawing; the update rate is set to a. If a > 60 frames, then a = the incoming rate. When a < 60 frames, it needs to be determined according to the incoming rate of the data. The incoming rate is set to b. If a > b, then a = b. If a < b, then a = a; when a < b, a data extraction operation is performed, and different extraction algorithms are used according to the extraction mode.
[0017] S2. Data extraction: When drawing the data table requires extraction, corresponding extraction is performed according to the extraction mode and then drawing is carried out. After the extraction is completed, the data is sorted again according to the descending and ascending orders set by the column sorting interface.
[0018] Further, as Figure 3As shown, for example, if the data input speed is 50 frames / second and the update speed is set to 20 frames, the data needs to be extracted. Set the input rate to m and the update speed to n, then the extraction ratio = m / n and round up. For example, 50 / 20=2.5 is rounded up to 3, which means 1 frame is extracted from 3 frames of data. Group the data frame cache within each second into 3 groups, and extract according to the extraction mode. In the average mode, the data in 3 frames is averaged and then synthesized into 1 frame. In the maximum and minimum mode, the data in 3 frames is compared and the maximum and minimum values are taken and then synthesized into 1 frame. By default, the column sorting interface finally passes the processed data to the drawing method for drawing.
[0019] S3. Initialize the table drawing object: lock the canvas object to reserve the background buffer for updating, clear the entire drawing object, and fill it with the specified black background color.
[0020] Furthermore, if Figure 4 As shown, create a canvas object and a drawing object. The initial length and width of the canvas are calculated based on the preset number of rows and columns. Canvas length = preset column width * number of columns, canvas width = preset row height * number of columns (single canvas). If the data size of each frame is fixed, the memory space allocated will remain unchanged. If the data size of the next frame is larger than that of the previous frame, the length and width of the canvas will be expanded and more memory space will be allocated. If the data size of the next frame is smaller than the highest single frame data size in history, the maximum canvas length and width will be used as the standard, and memory will be allocated fixedly.
[0021] S4. Draw table lines: Calculate the total length and width of the drawing area based on the number of rows and columns of the input data, and then draw single-row and single-case grid lines.
[0022] Further, draw column lines: loop column number i, 0≤i<total number of columns, set the y-axis coordinate of the upper edge of the canvas to y1, the y-axis coordinate of the lower edge of the canvas to y2, and the x-axis coordinate to x1=i*column width. Create the upper edge point object point1 (x1, y1), the lower edge point object point2 (x1, y2), and finally connect point1 and point2.
[0023] Draw a line: loop the number of lines j, 0≤j<total number of lines, set the x-axis coordinate of the left edge of the canvas to x3, the x-axis coordinate of the bottom edge of the canvas to x4, and the y-axis coordinate to y3=j*line width. Create the left edge point object point3 (x3, y3), the right edge point object point4 (x4, y3), and finally connect point3 and point4.
[0024] S5. Draw row and column headers and data: Draw row and column headers according to the row and column header set, loop the data table to calculate the specific position (x / y value) of each data to be drawn on the canvas, and then draw the corresponding string data according to the set font size and pen color.
[0025] Furthermore, loop the column set, draw the row title for the first row of data in each column, loop the row set again (k = 0; k <= total number of rows), draw the column title for the first column of data in each row, and then get the y coordinate of the single row of data. There are three alignment methods for row data: Top, Center, and Bottom. Top alignment method: y coordinate = k*row height, Center alignment method: y coordinate = k*row height + row height / 2, Bottom alignment method: y coordinate = (k+1)*row height. Loop the column set again (p = 0; p <= total number of rows), get the x coordinate of the single row of data = p*column width + (column width-character content width)*0.5, pass the (x, y) coordinates to the drawing method of a single table data, fill in the corresponding brush color, draw each table content in turn, and complete the drawing of all table data.
[0026] S6. Refresh the table drawing object: force the drawing object to execute all pending graphics operations and notify the canvas to update, release the background buffer of the canvas object, display the graphics cache in the drawing object on the interface, and complete a table drawing.
[0027] Furthermore, after step S5 is completed, the drawing object data stream is cleared and related resources are released, the canvas object bitmap area is set to a fixed area, and the bitmap is released to the back buffer so that it can be used for display. The software framework notifies the interface control to refresh the bitmap of all pixels in the area, completing a complete drawing of the data.
[0028] S7. Table column sorting function setting: After drawing is completed, click the column title in the data table control interface to sort. After sorting is completed, the corresponding drawing process is performed according to the analyzer execution status.
[0029] Furthermore, the analyzer test has a continue / pause state: when in the continue state, click the column header to switch the reverse / ascending mode, enter the S1 step, pass the reverse / ascending mode to the interface, and sort when the next frame of data is drawn. When in the pause state, there is no new data frame to be updated, directly enter the S2 step, only sort the data and then draw it again and update the interface display.
[0030] The above is only a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the form disclosed herein, and should not be regarded as excluding other embodiments, but can be used for various other combinations, modifications and improvements, and can be modified within the scope of the concept described herein through the above teachings or the technology or knowledge of the relevant field. The changes and modifications made by those skilled in the art do not deviate from the spirit and scope of the present invention, and should be within the scope of protection of the claims attached to the present invention.
Claims
1. A method for refreshing a data table based on a spectrum analyzer, characterized in that: The method comprises: Step 1: Pre-process the data through various drawing interfaces and then perform drawing operations. If data extraction is required, extract the data according to the extraction mode and then draw the data; Step 2: Initialize the table drawing object, calculate the total length and width of the drawing area according to the number of rows and columns of the passed data, and then draw the grid lines of a single row and column; Step 3: Draw the title according to the row and column title set, and then draw the corresponding string data according to the set font size and pen color; Step 4: Force the drawing object to execute all pending image operations and notify the canvas to update, release the canvas object from the background buffer, display the graphics cache in the drawing object on the interface, and complete a table drawing; Step 5. After drawing is completed, click the column header in the data table control interface to sort. After sorting is completed, perform corresponding drawing processing according to the execution status of the spectrum analyzer.
2. The method for refreshing a data table based on a spectrum analyzer according to claim 1, characterized in that: The step 1 specifically includes the following contents: A1. Pre-process the data through the original drawing source data interface, update rate interface, data frame extraction interface and column sorting interface provided by the encapsulated data table, and then perform the drawing operation after the processing; A2. When drawing a data table, extraction is required. The data is then drawn according to the data frame extraction interface. After the extraction is completed, the data is sorted according to the descending and ascending order set by the column sorting interface.
3. The method for refreshing a data table based on a spectrum analyzer according to claim 1, characterized in that: The initialization table drawing object includes: Create a canvas object and a drawing object. The initial length of the canvas is equal to the preset column width multiplied by the number of columns, and the initial width of the canvas is equal to the preset row height multiplied by the number of columns. If the data size of each frame is fixed, the memory space allocated will remain unchanged. If the data size of the next frame is larger than that of the previous frame, the length and width of the canvas will be expanded and more memory space will be allocated. If the data size of the next frame is less than the highest single-frame data size in history, the maximum canvas length and width will be used as the basis and memory will be allocated in a fixed manner.
4. The method for refreshing a data table based on a spectrum analyzer according to claim 1, characterized in that: The step three comprises: Loop through the column set, draw the row headers based on the first row of data in each column, and then loop through the row set, draw the column headers based on the first column of data in each row; Get the y coordinate of a single row of data, loop through the column set, get the x coordinate of the column, pass the (x, y) coordinate into the drawing method of a single table data, fill in the corresponding brush color, and draw each table content in turn.
5. The method for refreshing a data table based on a spectrum analyzer according to claim 2, characterized in that: The steps of A1 include: After the original data is passed into the data table object, the data validity is verified to ensure that every data in the row and column number set exists. If the data is incorrect, it is directly returned without drawing. Set the update rate to a. When a>60 frames, a is equal to the data input rate. When a<60 frames, if a>n, a=b, b is the data input rate. If a<b, a=a, and data extraction operation is performed when a<b.
6. The method for refreshing a data table based on a spectrum analyzer according to claim 2, characterized in that: The step five comprises: When the spectrum analyzer is in the continue state, click the column title to switch the reverse / ascending mode, enter step A1, transfer the reverse / ascending mode to the interface, and sort when drawing the next frame of data; When the spectrum analyzer is in the pause state, there is no new data frame to be updated, and the process directly enters step A2, where the data is only sorted and then plotted once and the interface display is updated.
Citation Information
Patent Citations
Web-based visual algorithm animation development system
CN102866886A
Graph drawing method and system supporting large data volume fast refreshing
CN104156427A
Frequency spectrum analysis real-time waterfall plot implementing method
CN106771589A
Table drawing method and system based on HTML5 Canvas
CN109491654A
Method and device for constructing webpage table with high operability
CN116414373A
