A dynamic compression method and system for power quality recording data
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JIANGSU LINYANG ENERGY CO LTD
- Filing Date
- 2026-07-08
- Publication Date
- 2026-08-04
AI Technical Summary
[0004]本发明的目的是针对当前原始录波数据量大、远程实时抄读困难,现有单一压缩算法无法动态适合环境变化等困境,提出一种嵌入式电能质量录波数据的动态压缩算法及系统,解决现场采集设备存储空间有限、自身资源适配困难的难点,达到提升存储效率、保障通信可靠、降低运维成本的目的
本发明摒弃了传统电能质量监测系统采用固定压缩算法的方式,创新性地构建了包含信道质量(误码率)、硬件资源占用状态(内存/CPU负载)及数据波形特征(平稳度)的环境感知因子。通过动态计算候选压缩算法的综合得分,系统能在高误码率通信环境、低资源受限环境以及暂态扰动环境下,切换至最适配的压缩算法。在确保数据完整性的前提下,显著提升了压缩效率,有效延长了设备本地循环存储的时长,缓解了存储空间有限性与海量录波数据之间的矛盾。
Smart Images

Figure CN122512929A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of power quality monitoring technology, specifically relating to a dynamic compression method and system for embedded power quality recording data. Background Technology
[0002] Power quality monitoring is a crucial measure to ensure the healthy and stable operation of the power system. Frequent events such as voltage swells, voltage drops, harmonic distortion, and current imbalances significantly impact the operation of the entire power grid. Therefore, it is necessary to collect long-term, continuous, and high-precision raw waveform data of the power grid's voltage and current for equipment early warning, post-event risk assessment, and fault source analysis. Only complete raw waveform data can reconstruct the transient process of a fault, pinpoint its cause, and provide large-scale data for load characteristic models.
[0003] However, if the master station reads the raw waveform data via power line carrier, the daily data transmission would take tens of hours, causing the communication system to operate under high load and easily leading to system failure. Without data compression, the local SD card has limited capacity; 32GB can only store less than 3 days' worth of data. If compression is used, existing equipment mostly employs a single compression algorithm, which cannot adapt to dynamic changes in communication quality, waveform characteristics, and its own conditions. When communication quality is poor or resources are insufficient, a fixed algorithm may cause communication congestion and affect real-time communication. Summary of the Invention
[0004] The purpose of this invention is to address the challenges of large amounts of raw power quality waveform data, difficulties in remote real-time reading, and the inability of existing single compression algorithms to dynamically adapt to environmental changes. This invention proposes a dynamic compression algorithm and system for embedded power quality waveform data, which solves the problems of limited storage space and difficulty in adapting to the resources of field acquisition equipment, thereby improving storage efficiency, ensuring reliable communication, and reducing operation and maintenance costs.
[0005] The technical solution of this invention is: In a first aspect, the present invention provides a dynamic compression method for power quality recording data, comprising: S1. Dynamically acquire the environmental perception factor F, and determine the comprehensive score of each candidate compression algorithm in the preset candidate compression algorithm set based on the environmental perception factor F, the algorithm performance scoring matrix S and the weight vector W. S2. Obtain preset sampling reference parameters, and collect raw waveform data according to the sampling reference parameters; select the current optimal compression algorithm from the preset candidate compression algorithm set according to the comprehensive score obtained in S1, and compress the raw waveform data within a preset time window to obtain compressed data; encapsulate the identification information of the current optimal compression algorithm, decompression parameters, and the compressed data into a target data frame; S3. Receive the reading request frame sent by the master station, return the target data frame according to the file format negotiated with the master station, and provide the identification information and decompression parameters of the target data frame in S2 for the master station to use during decompression; S4. Use a timer to count the current time. When the count value reaches the preset time window (5 - 30 minutes), trigger the exploration mode; take out the first compression algorithm from the candidate compression algorithm set, calculate the comprehensive score of the first compression algorithm and the current optimal compression algorithm continuously for N times, select the compression algorithm with more winning times as the operating algorithm for the next time window to compress the recorded data, and move the other algorithm to the end of the queue of the candidate compression algorithm set.
[0006] Further, the environmental perception factor in S1 includes the bit error rate factor f , the memory factor f ram , the CPU load factor f cpu and the data smoothness factor f steady .
[0007] Further, the bit error rate factor f err is used to reflect the channel quality, and the acquisition steps include: Obtain the measured bit error rate P of the current communication link error , and determine the bit error rate factor f error according to the measured bit error rate P min , the preset minimum bit error rate threshold P max and the maximum bit error rate threshold P err , and the formula is as follows: When Perror ≤ Pmin, ferr = 1; When Perror ≥ Pmax, ferr = 0; When Pmin < Perror < Pmax, .
[0008] Further, the memory factor f ram is used to reflect the occupancy of hardware storage resources and is obtained through the following formula: ; where M total is the total memory space; M used is the current used memory size; M required is the minimum memory size required to run the candidate compression algorithm.
[0009] The CPU load factor f cpu is used to reflect the occupancy of hardware storage resources and is obtained through the following formula: ; where k represents the number of the functional module, time start_k and time end_kThese are the start and end times of the k-th functional module within the load cycle, respectively, obtained by the system timer systick; T load This represents the cumulative running time of each functional module within the load cycle. The data stability factor f steady Calculated using the following formula: ; where N total N represents the total number of sampling points within the statistical interval. transient The number of sampling points identified as transient disturbances within the statistical interval is defined as follows: when the amplitude change rate or deviation of adjacent sampling points exceeds a preset disturbance threshold, the sampling point is identified as a transient disturbance point.
[0010] Furthermore, in S1, the comprehensive score Score of each candidate compression algorithm in the preset candidate compression algorithm set is determined using the following formula based on the environmental perception factor F, the algorithm performance scoring matrix S, and the weight vector W: ; Where: i represents the number of the environmental perception factor; n represents the total number of environmental perception factors; W i Let represent the weight of the i-th environmental perception factor, and satisfy . W i ∈[0,1];f i is the current normalized value of the i-th environmental perception factor, with a value range of [0, 1]; j represents the number of the candidate compression algorithm; The performance score of the j-th compression algorithm on the i-th environmental perception factor is given, with a value range of [0, 1].
[0011] Furthermore, in S2 and S4, when compressing the recorded waveform data within a preset time window to obtain compressed data, the weight vector W of the current optimal compression algorithm is monitored and updated, including: Obtain the compression ratio R and compression time T of the current optimal compression algorithm for the compression task, and determine the single compression performance score E, E = α × R + β × (1 - T / Tbase); where α and β are the preset weight coefficients of compression ratio and compression time, and Tbase is the preset baseline time. When the single compression performance score E is lower than the preset threshold Eth for a preset number of consecutive preset number of times, the environment-aware weight vector W is updated. Obtain the environmental perception factor distribution value f corresponding to the optimal compression performance score E within the current time window. i _opt and the average distribution value f of the environmental perception factors within the current time window i_avg, according to the preset learning rate γ, the weight vector W of the current best compression algorithm is updated using the following formula to obtain the updated weight vector W', 0<γ≤1; W'i = Wi × (1 + γ × (f i _opt-f i _avg)); The updated weight vector W′ is normalized to ensure that the sum of all weight coefficients equals 1.
[0012] Further, in S2, obtaining the preset sampling reference parameters and acquiring the original waveform data based on the sampling reference parameters includes: Obtain sampling configuration parameters, including the number of sampling channels, sampling rate, ADC resolution, and sampling triggering method; Obtain signal calibration parameters, including channel ratio coefficients, zero offset, and unit identifiers; Obtain time base parameters, including millisecond-level storage base timestamp; The original waveform data is collected based on the sampling configuration parameters, signal calibration parameters, and time reference parameters.
[0013] Further, in S2, the step of compressing the original waveform data using the target compression algorithm to obtain compressed data includes: Obtain the original sampling sequence from the original waveform data; The original value of the first sampling point in the original sampling sequence is retained as the first value of the difference sequence. The difference between two adjacent sampling points in the original sampling sequence is calculated, and the difference is used as the subsequent value in the difference sequence to obtain the complete difference sequence. The difference sequence is compressed using the current optimal compression algorithm to obtain the compressed data.
[0014] Furthermore, in S2, encapsulating the target data frame includes: The sampling reference parameters and the start timestamp are encapsulated into the file header information of the target data frame; The identification information and the decompression parameters are encapsulated into a compression control block for the target data frame; The compressed data is encapsulated into the compressed data area of the target data frame; Calculate the checksum of the target data frame and encapsulate the checksum into the tail check area of the target data frame.
[0015] In a second aspect, the present invention provides a dynamic compression system for power quality recording data, the system comprising: Memory, which stores executable instructions; A processor that executes the executable instructions in the memory to implement the dynamic compression method for power quality recording data; The communication interface is used to interact with the master station, receive requests to read waveform data, and send compressed data frames that conform to the protocol format.
[0016] Compared with the prior art, the present invention has the following beneficial effects: This invention abandons the traditional fixed compression algorithm approach used in power quality monitoring systems, and innovatively constructs an environmental perception factor that includes channel quality (bit error rate), hardware resource occupancy status (memory / CPU load), and data waveform characteristics (stability). By dynamically calculating the comprehensive score of candidate compression algorithms, the system can switch to the most suitable compression algorithm in high bit error rate communication environments, low resource-constrained environments, and transient disturbance environments. While ensuring data integrity, it significantly improves compression efficiency, effectively extends the duration of local circular storage on the device, and alleviates the contradiction between limited storage space and massive amounts of waveform data.
[0017] This invention designs a timer-based exploration mode. When the count value reaches a preset time window, exploration is automatically triggered. The algorithm at the head of the queue is selected from the candidate compression algorithm set and compared with the current best algorithm N times consecutively. The algorithm with the most wins is selected as the algorithm to run in the next window, and the other algorithm is moved to the tail of the queue. This mechanism avoids the algorithm selection getting trapped in local optima and ensures that the system can continuously discover better compression strategies during long-term operation.
[0018] This invention creates a dynamic weight vector adjustment mechanism based on historical compression data. By analyzing the compression ratio and time consumption of each compression iteration, the effectiveness of the strategy is evaluated, and weight updates are triggered when the performance is consistently poor. The weights are adaptively adjusted according to the optimal and average distribution of environmental factors. This self-correcting closed-loop optimization mechanism enables the system to adapt to changes in the communication environment caused by equipment aging and seasonal variations, ensuring the long-term stability of the system.
[0019] This invention embeds a self-describing compression algorithm identifier and decompression parameter set in the data frame header, encapsulates sampling reference parameters and a start timestamp in the file header, encapsulates the algorithm identifier and decompression parameters in the compression control block, and sets a checksum at the end. After receiving the response data returned by the monitoring system, the master station automatically identifies and calls the corresponding decompression algorithm without manual intervention, simplifying the communication protocol interaction process and improving the overall efficiency of the system.
[0020] In terms of underlying data processing, this invention employs a layered storage strategy combining millisecond-level reference timestamps with relative offsets, significantly reducing storage redundancy in time data. Simultaneously, it introduces differential coding preprocessing based on signal characteristics, retaining the first sampling point of the original sequence and calculating the differences between adjacent sampling points to form a difference sequence before compression. This effectively eliminates the high correlation between adjacent sampling points, creating more favorable input conditions for subsequent compression algorithms and further improving compression efficiency.
[0021] In summary, this invention provides a complete dynamic compression solution for embedded power quality recording data, encompassing algorithm selection strategies, adaptive evolution mechanisms, data frame structure design, and underlying preprocessing techniques. It effectively addresses the problems of poor adaptability and low long-term operational stability in existing technologies under complex operating conditions. While ensuring high accuracy and integrity of power grid fault analysis data, it significantly improves storage efficiency and reduces operation and maintenance costs, demonstrating extremely high engineering application value.
[0022] Other features and advantages of the present invention will be described in detail in the following detailed description section. Attached Figure Description
[0023] The above and other objects, features and advantages of the present invention will become more apparent from the more detailed description of exemplary embodiments of the invention in conjunction with the accompanying drawings, wherein the same reference numerals generally represent the same components in the exemplary embodiments of the invention.
[0024] Figure 1 This is an overall flowchart of the dynamic compression method for power quality recording data according to an embodiment of the present invention.
[0025] Figure 2 This is a flowchart of the calculation of environmental perception factors and the calculation of comprehensive score in an embodiment of the present invention.
[0026] Figure 3 This is a flowchart illustrating how the weight vector in an embodiment of the present invention is dynamically adjusted based on the compression effect of the current compression algorithm within a preset time window.
[0027] Figure 4 This is a flowchart of data acquisition and compression storage according to an embodiment of the present invention.
[0028] Figure 5 This is a flowchart of the master station communication and data return in an embodiment of the present invention. Detailed Implementation
[0029] Preferred embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While preferred embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be limited to the embodiments set forth herein.
[0030] The present invention provides a dynamic compression method for embedded power quality recording data, including: S1. Dynamically obtain an environmental perception factor F, and determine the comprehensive score Score of each candidate compression algorithm in a preset candidate compression algorithm set according to the environmental perception factor F, an algorithm performance scoring matrix S, and a weight vector W; In S1, the environmental perception factor includes an error rate factor f err , a memory factor f ram , a CPU load factor f cpu , and a data smoothness factor f steady ; The error rate factor f err is used to evaluate the reliability of the current communication link. The system regularly counts the error rate of the current communication link. Let the currently measured error rate be Perror error , the minimum error rate threshold preset by the system be Pmin min (such as 10 -6 ), and the maximum error rate threshold be Pmax max (such as 10 -3 ). The error rate factor f err is calculated by the following formula: When Perror ≤ Pmin, ferr = 1, indicating excellent communication quality; When Perror ≥ Pmax, ferr = 0, indicating extremely poor communication quality; When Pmin < Perror < Pmax, .
[0031] This formula uses a logarithmic scale, which can more sensitively reflect the change of the error rate in the low-value region, enabling the factor value to quickly respond when the communication quality deteriorates.
[0032] The memory factor f ram is used to evaluate the memory resource occupancy of the current system. The system real-time monitors the currently available memory resources. Let the currently available total memory space be M total , the currently used memory size be M used , and the minimum memory size required to run each candidate compression algorithm be M required . The calculation formula of the memory factor fram is: ; This formula represents the ratio of the currently available memory to the memory required by the compression algorithm. When the available memory is sufficient, the factor approaches 1. When the available memory is insufficient, the factor is less than 1, and the upper limit is restricted to 1 by the min function.
[0033] The CPU load factor f cpuThis is used to assess the current system's computational resource load. The system uses a system timer to track the runtime of each functional module. Here, k represents the functional module number, and time... start_k and time end_k These are the start and end times of the k-th functional module within the load cycle, respectively. The preset statistical load cycle is T. load CPU load factor f cpu The calculation formula is: ; Where Σ(time) end_k - time start_k This factor represents the cumulative runtime of the k-th functional module within the statistical period. It reflects the CPU's workload; a higher value indicates a higher CPU load, and the score corresponds to a more complex algorithm. The lower the complexity, the higher the score; conversely, the lower the complexity, the higher the score.
[0034] Data stationarity factor f steady This system is used to evaluate the stationarity characteristics of waveform data. It performs real-time analysis on the acquired waveform data, with a total of N sampling points within the statistical interval. total Of these, N sampling points were identified as "transient disturbances". transient In this embodiment, the criteria for determining transient disturbances are that the rate of change of the amplitude at the sampling point exceeds a preset threshold (e.g., 5% / ms) or the frequency offset exceeds ±0.5Hz. Data stability factor f steady The calculation formula is: ; f steady The value range is [0,1]. The larger the value, the more stable the waveform data is, and the more suitable it is to use a compression algorithm optimized for stable signals; the smaller the value, the more transient disturbances there are, and a compression algorithm with higher fidelity should be preferred.
[0035] The system pre-stores an algorithm performance scoring matrix S; where, The performance score of the j-th compression algorithm on the i-th environmental awareness factor is defined, with a value range of [0, 1]. This score matrix is obtained through offline testing or statistical analysis. For example, for the bit error rate factor, algorithms with high compression ratios and strong error resistance receive higher scores.
[0036] Let the total number of environmental perception factors be n (n=4 in this embodiment), and the perception factor weight vector W = [W1, W2, W3, W4], which correspond to the bit error rate factor f respectively. err Memory factor f ram CPU load factor f cpu and data stationarity factor f steady The weighting coefficients satisfy And Wᵢ ∈ [0,1].
[0037] The system uses the following formula to calculate the comprehensive score of the j-th candidate compression algorithm. : ; Among them, f i Let f be the current normalized value of the i-th environmental perception factor (i.e., the f calculated above). err f ram f cpu f steady This formula uses a weighted summation method to comprehensively evaluate the suitability of candidate compression algorithms for the current environment.
[0038] S2. Obtain preset sampling reference parameters, and collect raw waveform data according to the sampling reference parameters; select the current optimal compression algorithm from the preset candidate compression algorithm set according to the comprehensive score obtained in S1, and compress the raw waveform data within a preset time window to obtain compressed data; encapsulate the identification information of the current optimal compression algorithm, decompression parameters, and the compressed data into a target data frame; the system compares each candidate compression algorithm. And select the highest score.
[0039] In S2, the sampling configuration parameters are used to define the sampling method of the analog-to-digital converter (ADC), specifically including: Sampling configuration: Supports multiple sampling rates (e.g., 128 / 256 / 512 points per cycle), default 12.8kHz; supports 8-channel synchronous acquisition (three-phase voltage / current, zero sequence, etc.); uses a 16-bit ADC; hardware timer triggering to ensure equal intervals.
[0040] Signal calibration: including PT / CT ratio, zero-point offset correction, and physical unit identification (kV, A, etc.) to ensure the accuracy of the physical meaning of the data.
[0041] Time base: A hierarchical timestamp strategy is adopted. Only a 4-byte millisecond-level base timestamp and sampling interval are stored at the beginning of each data block; the time of subsequent points is calculated by "base + n × interval", which greatly saves storage space.
[0042] Before compressing the raw waveform data, the system performs a compression preprocessing step to improve compression efficiency.
[0043] In this embodiment, the compression preprocessing includes differential encoding.
[0044] Differential coding is used to eliminate the correlation between adjacent sampling points, converting the absolute value sequence into a difference sequence, making the data more concentrated. Let the original sampling sequence be x[l] (l=0,1,2,...,D-1), where D is the number of sampling points in each data block. The transformation relationship of the differentially coded sequence d[n] is as follows: d[0] = x[0] (Keep the original value of the first sampling point) d[L] = x[L] - x[L-1], L = 1, 2, ..., D-1 After differential coding, the stationary portion of the original waveform data is converted into a small-amplitude sequence close to zero, which greatly improves the compression ratio of subsequent entropy coding compression algorithms. For abrupt changes, the differential value is larger, preserving key transient information and ensuring that fault characteristics are not lost.
[0045] S3. The system receives the waveform recording and copying request frame from the master station, returns data according to the file format negotiated with the master station, and provides the master station with the compression algorithm identifier and parameters of the data frame in S2 for decompression.
[0046] In S3, the receive request frame includes: first, performing an integrity check by calculating the CRC16 value of the received data frame and comparing it with the checksum in the data frame. If the check fails, an error response frame is returned; if the check passes, the command DI, start time, end time, and data volume are parsed to determine the range of data to be copied.
[0047] Based on the parsed time range, the system performs a file system search on the local storage medium to quickly locate the first data block that meets the criteria, and then locates the waveform recording data block that meets the criteria. The index table maintains information such as the starting address, timestamp, compression algorithm identifier, and data length of each data block.
[0048] The system assembles the read compressed data into a return data frame according to the file format negotiated with the master station. In this embodiment, the file header information includes global sampling reference parameters (ratio, channel configuration, etc.) and millisecond-level start time; this part is transmitted only once during negotiation. The compression control block (each block is independent) contains a compression algorithm identifier and unique decompression parameters (such as dictionary size, quantization step size, etc.). The master station does not need to pre-agree on an algorithm; it can dynamically load the corresponding decompression plugin based on the compression algorithm identifier. The compressed data area is used to store the data compressed using differential encoding and the optimal algorithm. The tail check area is used to store the CRC checksum of this data block to ensure the correctness and integrity of the transmission.
[0049] S4. Use a timer to count the current time. When the count reaches the preset time window (5-30 minutes), trigger the exploration mode. Take the first compression algorithm from the candidate compression algorithm set, calculate the combined score of the first compression algorithm and the current best compression algorithm N times (N=5), select the compression algorithm with more winning times as the running algorithm for the next time window to compress the waveform data, and move the other algorithm to the end of the queue of the candidate compression algorithm set.
[0050] To achieve adaptability to environmental changes, the weight vector W is not fixed but dynamically adjusted based on historical compressed data. In S2 and S4, when compressing the waveform data within a preset time window to obtain compressed data, the weight vector W of the current optimal compression algorithm is monitored and updated, including:
[0051] Obtain the compression ratio R and compression time T of the current optimal compression algorithm for the compression task, and determine the single compression performance score E, E = α × R + β × (1 - T / Tbase); where α and β are preset weight coefficients for compression ratio and compression time (α=0.6, β=0.4 in this embodiment), and Tbase is a preset baseline time (e.g., 10ms); this score comprehensively considers compression efficiency and time cost, and the higher the value, the better the compression effect.
[0052] When the single compression performance score E is lower than the preset threshold Eth (e.g., 0.7) for a preset number of consecutive times (M=10), the system determines that the current weight vector is no longer suitable for the new environment and needs to trigger a weight vector update. Obtain the environmental perception factor distribution value f corresponding to the optimal compression performance score E within the current time window. i _opt and the average distribution value f of the environmental perception factors within the current time window i _avg, according to the preset learning rate γ (γ=0.1 in this embodiment), the weight vector W of the current optimal compression algorithm is updated using the following formula to obtain the updated weight vector W', 0<γ≤1; W'i = Wi × (1 + γ × (f i _opt-f i _avg)); The updated weight vector W′ is normalized to ensure that the sum of all weight coefficients equals 1.
[0053] Through the aforementioned closed-loop feedback mechanism, the weight vector can be continuously optimized and eventually stabilized, ensuring that the selected compression algorithm matches the current environment.
[0054] This invention also provides a dynamic compression system for power quality recording data, the system comprising: Memory, which stores executable instructions; A processor that executes the executable instructions in the memory to implement the dynamic compression method for power quality recording data; The communication interface is used to interact with the master station, receive requests to read waveform data, and send compressed data frames that conform to the protocol format.
[0055] In practice: like Figure 2 The diagram shows the process for calculating the environmental perception factor and the comprehensive score in this embodiment. The specific steps are as follows: (1) The system is based on the current measured bit error rate P error Combined with the preset minimum bit error rate threshold P min and the maximum bit error rate threshold P max Calculate the bit error rate factor f err ; (2) The system determines the total available memory space M based on the current total available memory space. total Current memory usage (in MB) used And the minimum memory size M required to run the candidate compression algorithm. required Calculate the memory factor f ram ; (3) The system calculates the cumulative running time Σ(time) of each functional module within the statistical period. end_k - time start_k ) and the preset statistical load period T load Calculate the CPU load factor f cpu ; (4) The system calculates the total number of sampling points N within the statistical interval. total The number of sampling points N that are identified as transient disturbances transient Calculate the data stationarity factor f steady ; (5) The system obtains the preset perception factor weight vector W and algorithm performance score matrix S from the configuration storage area, and calculates the comprehensive score of the j-th candidate compression algorithm using the weighted summation formula.
[0056] (6) The system compares the comprehensive scores of each candidate algorithm, selects the highest score as the current optimal compression algorithm, and records its algorithm identifier for use in subsequent compression steps.
[0057] (7) The system uses a timer to count the current time. When the count value reaches the preset time window (5-30 minutes), the exploration mode is triggered. The first compression algorithm is taken from the candidate compression algorithm set, and the combined score of the first compression algorithm and the current best compression algorithm is calculated N times in a row. The compression algorithm with more winning times is selected as the running algorithm for the next time window to compress the waveform data, and another algorithm is moved to the end of the queue of the candidate compression algorithm set.
[0058] like Figure 3 The diagram illustrates the process of dynamically adjusting the weight vector based on the compression effect of the current compression algorithm within a preset time window, as shown in this embodiment. The specific steps are as follows: (1) After each compression is completed, the system records the compression ratio R and compression time T, and calculates the single compression effect score E. (2) The system will distribute the E value and the corresponding environmental perception factor f each time. i Store in a queue. If the E value is lower than the preset threshold E for M consecutive times... th If the current weight vector is no longer suitable for the environment, an update is triggered; otherwise, the current weight is maintained and the process ends.
[0059] (3) The system selects the compression operation with the best compression effect (maximum E value) from the compression operations within the current time window, and obtains the environmental perception factor distribution value f corresponding to that compression operation. i _opt; (4) The system is based on the distribution value f of the environmental perception factor during optimal compression. i _opt and the average distribution value f of environmental perception factors within the current time window i Adjust the weight vector based on the difference in _avg; (5) Write the normalized weight vector W' into the configuration storage area to replace the original weight vector W.
[0060] like Figure 4 The diagram shows the data acquisition and compression storage process in this embodiment. The specific steps are as follows: (1) The system starts ADC acquisition according to the set sampling reference parameters to obtain high-precision timestamps and raw waveform data; (2) The system performs differential encoding on the original waveform data to eliminate the correlation between adjacent sampling points and convert the absolute value sequence into a difference sequence; (3) The system obtains the comprehensive score of each algorithm output in step S1. j The algorithm with the highest score is selected as the optimal compression algorithm; (4) The system encapsulates the compressed data into data frames, writes them to the local storage medium, and updates the index table to record information such as the starting address, timestamp, compression algorithm identifier, and data length of the data blocks.
[0061] like Figure 5 The diagram shows the main station communication and data return process in this embodiment. The specific steps are as follows: (1) The system receives the waveform data copying request frame sent by the master station, calculates the CRC16 check code and compares it with the check code in the frame. If the verification fails, an error response frame is returned; if the verification passes, the start timestamp, end timestamp and other data in the request are parsed to determine the range of data to be copied. (2) The system searches the file system in the index table of the local storage medium according to the parsed time range, quickly locates the first data block that meets the conditions, and locates the waveform data block that meets the conditions.
[0062] (3) The system assembles the read compressed data into a return data frame according to the file format negotiated with the main station.
[0063] The various embodiments of the present invention have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments.
Claims
1. A dynamic compression method for power quality recording data, characterized in that, include: S1. Dynamically acquire the environmental perception factor F, and determine the comprehensive score of each candidate compression algorithm in the preset candidate compression algorithm set based on the environmental perception factor F, the algorithm performance scoring matrix S and the weight vector W. S2. Obtain preset sampling reference parameters, and collect raw waveform data according to the sampling reference parameters; select the current optimal compression algorithm from the preset candidate compression algorithm set according to the comprehensive score obtained in S1, and compress the raw waveform data within a preset time window to obtain compressed data; The identification information of the current optimal compression algorithm, the decompression parameters, and the compressed data are encapsulated into a target data frame; S3. Receive the copy request frame sent by the master station, return the target data frame according to the file format negotiated with the master station, and provide the master station with the identification information and decompression parameters of the target data frame in S2 for decompression. S4. Use a timer to count the current time. When the count reaches the preset time window, trigger the exploration mode. The first compression algorithm is selected from the candidate compression algorithm set. The combined score of the first compression algorithm and the current best compression algorithm is calculated N times consecutively. The compression algorithm with more winning times is selected as the running algorithm for the next time window to compress the waveform data, and the other algorithm is moved to the tail of the candidate compression algorithm set.
2. The method as described in claim 1, characterized in that... In S1, the environment perception factor includes a bit error rate factor f err , a memory factor f ram , a CPU load factor f cpu , and a data stationarity factor f steady .
3. The method as described in claim 2, characterized in that... The bit error rate factor f err For reflecting the channel quality, the acquiring step comprises: Obtain the measured bit error rate P of the current communication link. error According to the measured bit error rate P error The preset minimum bit error rate threshold P min and the maximum bit error rate threshold P max Determine the bit error rate factor f err The formula is as follows: When Perror ≤ Pmin, ferr = 1; When Perror ≥ Pmax, ferr = 0; When Pmin < Perror < Pmax, .
4. The method as described in claim 2, characterized in that... ; The memory factor f ram For reflecting the occupation of hardware storage resource, the following formula is used: Among them, M total Total memory space; M used This represents the current amount of memory used; M required The minimum memory size required to run the candidate compression algorithm; The CPU load factor f cpu The hardware storage resource usage is reflected by the following formula: Where k represents the functional module number, and time... start_k and time end_k These are the start and end times of the k-th functional module within the load cycle, respectively, obtained by the system timer systick; T load This represents the cumulative running time of each functional module within the load cycle. The data stability factor f steady Calculated using the following formula: ; where N total N represents the total number of sampling points within the statistical interval. transient The number of sampling points identified as transient disturbances within the statistical interval is defined as follows: when the amplitude change rate or deviation of adjacent sampling points exceeds a preset disturbance threshold, the sampling point is identified as a transient disturbance point.
5. The method as described in claim 2, characterized in that... In S1, the comprehensive score Score of each candidate compression algorithm in the preset candidate compression algorithm set is determined according to the environmental perception factor F, the algorithm performance scoring matrix S, and the weight vector W using the following formula: ; Where: i represents the number of the environmental perception factor; n represents the total number of environmental perception factors; W i Let represent the weight of the i-th environmental perception factor, and satisfy . W i ∈[0,1];f i is the current normalized value of the i-th environmental perception factor, with a value range of [0, 1]; j represents the number of the candidate compression algorithm; The performance score of the j-th compression algorithm on the i-th environmental perception factor is given, with a value range of [0, 1].
6. The method as described in claim 1, characterized in that... In S2 and S4, when compressing the waveform data within a preset time window to obtain compressed data, the weight vector W of the current optimal compression algorithm is monitored and updated, including: Obtain the compression ratio R and compression time T of the current optimal compression algorithm for the compression task, and determine the single compression performance score E, E = α × R + β × (1 - T / Tbase); where α and β are the preset weight coefficients of compression ratio and compression time, and Tbase is the preset baseline time. When the single compression performance score E is lower than the preset threshold Eth for a preset number of consecutive preset number of times, the environment-aware weight vector W is updated. Obtain the environmental perception factor distribution value f corresponding to the optimal compression performance score E within the current time window. i _opt and the average distribution value f of the environmental perception factors within the current time window i _avg, according to the preset learning rate γ, the weight vector W of the current best compression algorithm is updated using the following formula to obtain the updated weight vector W', 0<γ≤1; W'i = Wi × (1 + γ × (f i _opt- f i _avg)); The updated weight vector W′ is normalized to ensure that the sum of all weight coefficients equals 1.
7. The method as described in claim 1, characterized in that... In S2, obtaining the preset sampling reference parameters and collecting the original waveform data according to the sampling reference parameters includes: Obtain sampling configuration parameters, including the number of sampling channels, sampling rate, ADC resolution, and sampling triggering method; Obtain signal calibration parameters, including channel ratio coefficients, zero offset, and unit identifiers; Obtain time base parameters, including millisecond-level storage base timestamp; The original waveform data is collected based on the sampling configuration parameters, signal calibration parameters, and time reference parameters.
8. The method as described in claim 1, characterized in that... In S2, the step of compressing the original waveform data using the target compression algorithm to obtain compressed data includes: Obtain the original sampling sequence from the original waveform data; The original value of the first sampling point in the original sampling sequence is retained as the first value of the difference sequence. The difference between two adjacent sampling points in the original sampling sequence is calculated, and the difference is used as the subsequent value in the difference sequence to obtain the complete difference sequence. The difference sequence is compressed using the current optimal compression algorithm to obtain the compressed data.
9. The method as described in claim 1, characterized in that... In S2, the encapsulation of the target data frame includes: The sampling reference parameters and the start timestamp are encapsulated into the file header information of the target data frame; The identification information and the decompression parameters are encapsulated into a compression control block for the target data frame; The compressed data is encapsulated into the compressed data area of the target data frame; Calculate the checksum of the target data frame and encapsulate the checksum into the tail check area of the target data frame.
10. A dynamic compression system for power quality recording data, characterized in that, The system includes: Memory, which stores executable instructions; A processor that executes the executable instructions in the memory to implement the dynamic compression method for power quality recording data according to any one of claims 1-9; The communication interface is used to interact with the master station, receive requests to read waveform data, and send compressed data frames that conform to the protocol format.