Search

CN-122001389-A - PLC equipment data optimized storage method, device, equipment and medium

CN122001389ACN 122001389 ACN122001389 ACN 122001389ACN-122001389-A

Abstract

The invention discloses a method, a device, equipment and a medium for optimally storing PLC equipment data, which relate to the technical field of data compression, the method adopts the quaternary Huffman coding to optimize the construction process of the coding tree through a virtual node processing mechanism, and under the condition of the same data distribution, the average code length is lower than that of the traditional binary Huffman coding, thereby obviously improving the compression rate. For sensor data, control parameters and the like which are common in the PLC equipment, the compression efficiency can be improved, and the occupied storage space can be greatly reduced. Meanwhile, the window size can be adjusted in real time according to the data change rate by adopting a dynamic sliding window mechanism, a larger window is used when the data distribution is stable, and a smaller window is used when the data change is frequent, so that the coding rule can timely reflect the change of the data distribution, and the adaptability and the stability of coding are improved.

Inventors

  • ZHANG LING
  • GUAN YANWEI
  • CHEN RUNXING
  • ZHENG LINSHENG
  • WU CHANGHAO
  • PENG JIEWEN

Assignees

  • 中国兵器装备集团自动化研究所有限公司

Dates

Publication Date
20260508
Application Date
20260104

Claims (10)

  1. 1. The PLC equipment data optimizing and storing method is characterized by comprising the following steps of: Determining a target quantization granularity according to the type of the collected PLC equipment data; using a dynamic frequency statistics method, and counting symbol frequencies in real time through a sliding window mechanism and a self-adaptive updating strategy; based on the statistical result of the symbol frequency, constructing a quaternary Huffman coding tree by utilizing an improved node merging rule and a memory optimized coding tree storage structure; Extracting quaternary codes from the quaternary Huffman coding tree, generating a coding table, and carrying out version control and increment update; the generated encoding table and compressed data are stored in the PLC device for subsequent decoding and data recovery.
  2. 2. The method for optimally storing data of a PLC device according to claim 1, wherein the sliding window mechanism includes a sliding window triggered periodically, counting data frequencies in a most recent window, to avoid outdated static frequencies.
  3. 3. The PLC device data optimized storage method of claim 1, wherein the adaptive update policy includes dynamically adjusting a window size according to a rate of change of data.
  4. 4. The PLC device data optimized storage method of claim 1, wherein the modified node merge rule includes adding virtual nodes to ensure that 4 nodes are merged at a time when fewer than 4 nodes remain.
  5. 5. The PLC device data optimized storage method of claim 1, wherein the memory optimized code tree storage structure comprises: storing quaternary tree nodes as a structured array, each node containing only weights, child node indices and encoded values; adopting a quadtree structure array representation method, and calculating the positions of the sub-nodes through indexes; a quaternary encoding table is pre-generated, mapping symbols directly to symbols.
  6. 6. The PLC device data optimized storage method of claim 1, wherein frequency statistics and code tree reconstruction are triggered in PLC timing interrupts for ensuring dynamic adaptability of the code tree.
  7. 7. The PLC device data optimized storage method of claim 1, wherein the incremental update includes an incremental update to frequently changing data for reducing computational overhead of a full reconstruction.
  8. 8. A PLC device data optimized storage apparatus for performing the PLC device data optimized storage method of any one of claims 1-7, the apparatus comprising: the data sampling and quantizing unit is used for determining target quantization granularity according to the type of the collected PLC equipment data; The frequency statistics unit is used for counting the symbol frequency in real time by using a dynamic frequency statistics method through a sliding window mechanism and a self-adaptive updating strategy; the coding tree construction unit is used for constructing a quaternary Huffman coding tree by utilizing an improved node merging rule and a memory optimized coding tree storage structure based on the statistical result of the symbol frequency; the code table generating unit is used for extracting quaternary codes from the quaternary Huffman code tree, generating a code table and carrying out version control and increment updating; and the compressed data storage unit is used for storing the generated encoding table and the compressed data in the PLC equipment so as to be used for subsequent decoding and data recovery.
  9. 9. A PLC device data optimized storage device, the device comprising a processor and a memory: The memory is used for storing program codes and transmitting the program codes to the processor; the processor is configured to execute the PLC device data optimized storage method of any one of claims 1-7 according to instructions in the program code.
  10. 10. A computer-readable storage medium storing program code for performing the PLC device data optimized storage method of any one of claims 1 to 7.

Description

PLC equipment data optimized storage method, device, equipment and medium Technical Field The invention relates to the technical field of data compression, in particular to a PLC (programmable logic controller) equipment data optimized storage method, device, equipment and medium based on quaternary Huffman tree. Background In a device data storage scenario, direct storage of raw data is often accompanied by significant storage space consumption problems. Especially in a high-frequency acquisition scene, the unprocessed data volume can reach PB level, so that not only is storage resource wasted, but also hardware cost and operation and maintenance complexity can be increased. To address this challenge, efficient data compression algorithms are introduced that significantly reduce storage overhead and improve overall system efficiency by eliminating redundant information and optimizing coding structures. Huffman coding is used as a classical lossless compression algorithm, and has the core advantage of a dynamic variable length coding mechanism based on character frequency. The algorithm has obvious compression effect on data sets with highly skewed frequency distribution (such as few characters and high frequency repetition), namely high frequency character allocation short codes and low frequency character allocation long codes, so that the overall coding length is reduced, and meanwhile, the decompression efficiency is maintained. However, there are often a large number of equipotential characters (such as uniformly distributed parameters acquired by the sensor) in the device data, so that the huffman tree structure tends to be balanced, and the coding length cannot be further optimized. At this time, the compression ratio is significantly lower than the theoretical optimum value, and it is difficult to satisfy the high compression ratio requirement scene. CN 116865768A, an invention patent of a PLC equipment data optimizing storage method, is summarized and arranged as the closest technical proposal to the invention. The invention provides a PLC (programmable logic controller) equipment data optimizing and storing method, which comprises the steps of collecting PLC equipment data and carrying out Huffman coding to obtain a Huffman tree, wherein the Huffman tree is pre-combined according to the occurrence frequency of characters with the same coding length, and the optimizing degree of the characters with higher frequency after the pre-combination on the coding combination is analyzed, namely the PLC equipment data is recoded and compressed and stored according to the optimizing degree. Collecting PLC equipment data, counting the occurrence frequency of each character in the PLC equipment data, constructing a Huffman tree, and obtaining Huffman codes; Acquiring a pre-merging character set, and analyzing a left sequence and a right sequence of each character to be processed according to a Huffman tree of PLC equipment data to acquire the frequency of the pre-merging character set of each character to be processed, the frequency of a first merging character after merging and the frequency of a second merging character after merging; Acquiring a character sequence in a merging character area according to the frequency of a pre-merging character group of each character to be processed, acquiring the average coding length of each character to be processed according to the first merging character frequency after merging and the second merging character frequency after merging in the character sequence in the merging character area, calculating the pre-merging factor of the pre-merging character group of each character to be processed, acquiring the number of characters contained in equipment data, calculating the coding reduction length of each character to be processed after pre-merging by utilizing the pre-merging factor and the average coding length, and measuring the coding reduction length of each character to be processed after pre-merging in the length of Huffman coding to acquire the optimization degree of each character to be processed after being merged on the Huffman tree; And merging the device data according to the optimization degree of the Huffman tree after merging each character to be processed to obtain merged device data, carrying out Huffman coding on the merged device data to obtain optimized codes, and storing the optimized codes in a storage space to finish the optimized storage of the device data. It can be seen that the contradiction between the limited memory resources of the PLC and the explosive growth of industrial data drives the application of efficient compression techniques. Huffman coding is an ideal choice with its lossless and low complexity. The traditional PLC equipment data storage method has the following main technical defects in industrial automation application, and the defects directly affect the reliability, efficiency and maintenance cost of the system: 1. the memor