Compression method and device for power consumption data of intelligent electric meter

By performing binary conversion and running length optimization on the power consumption data of smart meter and inserting the optimal step length, the problem of low compression efficiency of traditional run encoding is solved, and more efficient data transmission and monitoring is achieved.

CN119945459APending Publication Date: 2025-05-06国网河北省电力有限公司营销服务中心 +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411808642.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-10
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

Traditional game encoding has low compression efficiency and poor effect on users' real-time power consumption data, resulting in a reduced data transmission efficiency and affecting the timeliness of monitoring abnormal power consumption behavior.

Method used

By obtaining the power consumption data to be transmitted, performing binary conversion, obtaining the difference sequence based on the run length sequence, determining the target run length, and adding 0 characters to the binary data sequence to optimize the run length distribution. Then, for each type of target run, the optimal insertion step size is determined, the corresponding characters are inserted, and the inserted binary data sequence is formed, and the compressed data is finally obtained.

Benefits of technology

It improves the compression efficiency of electricity consumption data, enhances data transmission efficiency, and improves the timeliness of monitoring users' abnormal electricity consumption behavior.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119945459A_ABST
    Figure CN119945459A_ABST
Patent Text Reader

Abstract

The invention is suitable for the technical field of data processing, and provides a compression method and device for power consumption data of an intelligent electric meter. The method comprises the steps of determining a target run length based on a run length sequence corresponding to a binary data sequence of power consumption data; according to the position of a target binary substring corresponding to the target run length, adding a character 0 to the binary data sequence to obtain an optimized binary data sequence; aiming at each type of target run length, determining a corresponding optimal insertion step length, and inserting a corresponding character into the obtained optimized binary data sequence according to the optimal insertion step length; and determining code words corresponding to each new run length in a new run length sequence corresponding to the inserted binary data sequence, and obtaining compressed data according to all the code words. According to the method and the device, the new run length sequence is in a sequentially increasing or unchanged state as far as possible, so that the compression efficiency of the inserted binary data sequence is improved, and the data transmission efficiency is enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method and device for compressing electricity consumption data of a smart meter. Background Art

[0002] At present, the electricity consumption behavior of users is usually supervised based on the electricity consumption data provided by smart meters. When real-time electricity consumption data is transmitted, run-length encoding is usually used to compress the real-time electricity consumption data, and then the compressed real-time electricity consumption data is transmitted.

[0003] Among them, run-length coding is simple, has a fast decompression speed, and is lossless compression. However, traditional run-length coding has a better processing effect when processing data with a high degree of redundancy, and the user's electricity consumption data will vary with the user's electricity consumption behavior, and the corresponding real-time electricity consumption data will also be different, and its redundancy is relatively small. Therefore, when the user's real-time electricity consumption data is compressed using traditional run-length coding, the compression efficiency of the real-time electricity consumption data is low and the compression effect is poor, which reduces the data transmission efficiency of the compressed real-time electricity consumption data, thereby affecting the timeliness of monitoring the user's abnormal electricity consumption behavior. Summary of the invention

[0004] In view of this, an embodiment of the present application provides a method and device for compressing electricity consumption data of a smart meter to solve the technical problem that traditional run-length encoding has low efficiency and poor effect in compressing real-time electricity consumption data.

[0005] In a first aspect, an embodiment of the present application provides a method for compressing electricity consumption data of a smart meter, comprising:

[0006] Acquire power consumption data to be transmitted, perform binary conversion on the power consumption data to obtain a binary data sequence; obtain a difference sequence based on a run length sequence corresponding to the binary data sequence, and determine a target run length according to the difference sequence; the target run length meets a preset condition;

[0007] According to the position of the target binary substring corresponding to the target run length in the binary data sequence, adding a 0 character to the binary data sequence to obtain an optimized binary data sequence;

[0008] For each type of target run, according to the interval distance of the type of target run in the optimized binary data sequence, determine the optimal insertion step length of the type of target run, and according to the optimal insertion step length, insert the corresponding character in the optimized binary data sequence to obtain the inserted binary data sequence;

[0009] Determine the code words corresponding to each new run length in the new run length sequence corresponding to the inserted binary data sequence, and obtain compressed data according to the code words corresponding to all the new run lengths.

[0010] In a possible implementation, there are multiple power usage data, and the binary data sequence includes binary data corresponding to each power usage data;

[0011] The step of obtaining a difference sequence based on a run length sequence corresponding to the binary data sequence comprises:

[0012] Determining a run length sequence based on the binary data sequence;

[0013] A difference sequence is obtained according to the difference between every two adjacent run lengths in the run length sequence; the difference is the difference corresponding to the latter run length obtained by subtracting the former run length from the latter run length.

[0014] In a possible implementation, the preset condition is that the run type is 0 run, and the corresponding difference is a negative value;

[0015] Determining a target run length according to the difference sequence includes:

[0016] The difference in the difference sequence, which is a negative value and has a run type of 0 run, is used as the target difference;

[0017] The run length corresponding to the target difference in the run length sequence is determined as the target run length.

[0018] In a possible implementation, the adding a 0 character to the binary data sequence according to the position of the target binary substring corresponding to the target run length in the binary data sequence to obtain an optimized binary data sequence includes:

[0019] In the binary data sequence, a corresponding target binary substring is determined according to the target run length; the target binary substring is a character string corresponding to the target run length in the binary data corresponding to the target run length in the binary data sequence;

[0020] Determine whether the target binary substring is located at the end of the corresponding binary data;

[0021] If the target binary substring is located at the end of the corresponding binary data, a preset number of 0 characters are added to the first position of the binary substring adjacent to the target binary substring to obtain an optimized binary data sequence;

[0022] The binary data corresponding to the subsequent adjacent binary substring is the subsequent adjacent data of the binary data corresponding to the target binary substring.

[0023] In a possible implementation, the target run includes a 0 run and a 1 run;

[0024] The method of determining the optimal insertion step length of each type of target run according to the interval distance of the type of target run in the optimized binary data sequence includes:

[0025] For each type of target run, according to the position of the target run in the optimized binary data sequence, the interval distance between every two adjacent target runs in the target run is obtained;

[0026] Determine a first addition result according to a run length of a first target run in the target run of the type and a first interval distance between the first target run and a second target run; determine a second addition result according to the run length of the first target run, the run length of the second target run and the first interval distance;

[0027] Based on the first addition result and the second addition result, obtaining an insertion step range;

[0028] Check whether there is a marker insertion step within the insertion step range. If it is detected that there is a marker insertion step within the insertion step range, all marker insertion steps within the insertion step range are inserted into the marker insertion step, and the marker insertion step with the largest value is used as the optimal insertion step for this type of target run.

[0029] In a possible implementation, for each type of target run, detecting whether there is a marked insertion step within the insertion step range includes:

[0030] For each insertion step within the insertion step range, taking the first character of the first target run of the type of target run in the optimized binary data sequence as a starting point, and sliding in the optimized binary data sequence with the insertion step as a window;

[0031] If the position after each sliding movement belongs to this type of target run, the insertion step is used as the marked insertion step; otherwise, there is no insertion step within the insertion step range.

[0032] In a possible implementation, the method further includes:

[0033] If no marked insertion step is detected within the insertion step range, a third addition result is determined according to the run length of a second target run in the target run of the type and a second interval distance between the second target run and a third target run; a fourth addition result is determined according to the run length of the second target run, the run length of the third target run and the second interval distance;

[0034] Based on the third addition result and the fourth addition result, a new insertion step range is obtained, and the new insertion step range is used as the insertion step range, and the step of detecting whether there is a marked insertion step in the insertion step range is re-executed until the optimal insertion step for this type of target run is determined.

[0035] In one possible implementation, the character corresponding to a run of 0 is 0, and the character corresponding to a run of 1 is 1;

[0036] For each type of target run, inserting corresponding characters into the optimized binary data sequence according to the optimal insertion step length to obtain the inserted binary data sequence includes:

[0037] Taking the first character of the first target run of the type of target run in the optimized binary data sequence as the starting point, sliding in the optimized binary data sequence with the optimal insertion step length as a window;

[0038] A character corresponding to the target run of this type is inserted after the starting point and after the position after each sliding, to obtain a binary data sequence after insertion.

[0039] In a possible implementation, determining the codewords corresponding to the new run lengths in the new run length sequence corresponding to the inserted binary data sequence, and obtaining compressed data according to the codewords corresponding to all the new run lengths, includes:

[0040] Obtaining a new difference sequence according to a new run length sequence corresponding to the inserted binary data sequence;

[0041] Determine a codeword corresponding to each new run length in the new run length sequence based on the new difference sequence, a preset coding table and a preset coding rule;

[0042] The code words corresponding to all new run lengths constitute compressed data corresponding to the power consumption data to be transmitted.

[0043] In a second aspect, an embodiment of the present application provides a device for compressing electricity consumption data of a smart meter, comprising:

[0044] An acquisition module, used for acquiring the power consumption data to be transmitted, and performing binary conversion on the power consumption data to obtain a binary data sequence;

[0045] A determination module, configured to obtain a difference sequence based on a run length sequence corresponding to the binary data sequence, and determine a target run length according to the difference sequence; the target run length satisfies a preset condition;

[0046] an obtaining module, configured to add a 0 character to the binary data sequence according to the position of the target binary substring corresponding to the target run length in the binary data sequence, so as to obtain an optimized binary data sequence;

[0047] An obtaining module is used to determine, for each type of target run, the optimal insertion step length of the target run according to the interval distance of the target run in the optimized binary data sequence, and insert corresponding characters into the optimized binary data sequence according to the optimal insertion step length to obtain the inserted binary data sequence;

[0048] The compression module is used to determine the code words corresponding to each new run length in the new run length sequence corresponding to the inserted binary data sequence, and obtain compressed data according to the code words corresponding to all the new run lengths.

[0049] It can be understood that the beneficial effects of the second aspect mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here.

[0050] The compression method and device of the smart meter electricity consumption data provided by the embodiment of the present application performs binary conversion on the electricity consumption data to be transmitted, and obtains the target run length that meets the preset conditions based on the run length sequence corresponding to the obtained binary data sequence, and then adds 0 characters to the binary data sequence according to the position of the target binary substring corresponding to the target run length, and then determines the optimal insertion step length of each type of target run length for the type of target run length, and inserts the corresponding characters into the optimized binary data sequence according to the optimal insertion step length, thereby determining the code words corresponding to each new run length in the new run length sequence corresponding to the inserted binary data sequence, and obtaining compressed data according to all the code words. The embodiment of the present application determines the position where 0 characters and 1 characters need to be added in the binary data sequence according to the run length distribution, so as to adaptively change the run length, so that the run length sequence of the inserted binary data sequence is as much as possible in a state of increasing or unchanged in sequence, thereby improving the compression efficiency of the inserted binary data sequence and enhancing the data transmission efficiency.

[0051] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present specification. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0053] Figure 1 It is a schematic diagram of an application scenario provided by an embodiment of the present application;

[0054] Figure 2 It is a flowchart of a method for compressing electricity consumption data of a smart meter provided in an embodiment of the present application;

[0055] Figure 3 is a schematic diagram of a binary data sequence provided by an embodiment of the present application;

[0056] Figure 4 It is a schematic diagram of inserting characters in one run provided by an embodiment of the present application;

[0057] Figure 5 It is a structural schematic diagram of a device for compressing electricity usage data of a smart meter provided in one embodiment of the present application. DETAILED DESCRIPTION

[0058] The present application is described more clearly below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the effects of the present application, but are not intended to limit the present application in any form. It should be noted that, for those of ordinary skill in the art, several variations and improvements may be made without departing from the concept of the present application. These all fall within the scope of protection of the present application.

[0059] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0060] It should also be understood that the term “and / or” used in the specification and appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

[0061] In the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0062] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0063] In addition, the “plurality” mentioned in the embodiments of the present application should be interpreted as two or more.

[0064] With the idea of ​​improving the compression efficiency of electricity consumption data to be transmitted, the inventors have discovered through research that the electricity consumption data can first be converted into binary to obtain a binary data sequence, and based on the number of 0 characters and 1 characters in the binary data sequence, a corresponding run length sequence can be obtained. Then, based on the run length distribution in the run length sequence, the positions in the binary data sequence where 0 characters and 1 characters need to be added can be determined to adaptively change the run length, so that the run length sequence of the inserted binary data sequence is as increasing or unchanged as possible, thereby improving the compression efficiency of the inserted binary data sequence.

[0065] In order to make the purpose, technical solutions and advantages of the present invention more clear, specific embodiments will be described below in conjunction with the accompanying drawings.

[0066] First reference Figure 1 , Figure 1 The application scenario of the present application is schematically illustrated, in which an electronic device and power consumption data to be transmitted are included.

[0067] The electronic device performs binary conversion on the acquired power consumption data to be transmitted to obtain a binary data sequence, and obtains a difference sequence based on the run length sequence corresponding to the binary data sequence. According to the difference sequence, a target run length is determined. Then, according to the position of a target binary substring corresponding to the target run length in the binary data sequence, a 0 character is added to the binary data sequence to obtain an optimized binary data sequence.

[0068] Afterwards, the electronic device determines the optimal insertion step length of each type of target run according to the spacing distance of the target run in the optimized binary data sequence, and inserts corresponding characters into the optimized binary data sequence according to the optimal insertion step length to obtain the inserted binary data sequence. Finally, the electronic device determines the code words corresponding to each new run length in the new run length sequence corresponding to the inserted binary data sequence, and obtains compressed data based on the code words corresponding to all the new run lengths.

[0069] The application scenario may also include a smart meter, which collects real-time electricity usage data of users as electricity usage data to be transmitted, and the electronic device obtains the electricity usage data to be transmitted collected by the smart meter.

[0070] Combine the following Figure 1 ,refer to Figure 2 A method for compressing electricity usage data of a smart meter provided according to an exemplary embodiment of the present application is described below.

[0071] Figure 2 FIG. 1 is a flow chart of a method for compressing electricity consumption data of a smart meter provided in an embodiment of the present application. Figure 2 As shown, the method in the embodiment of the present application may include:

[0072] Step 201: Obtain power consumption data to be transmitted, perform binary conversion on the power consumption data, and obtain a binary data sequence.

[0073] For example, the power consumption data to be transmitted in this embodiment refers to the real-time power consumption data of users collected by smart meters. The power consumption data collected by smart meters involves multiple aspects, such as total power consumption, time-sharing power consumption, power factor, current and voltage, and demand data, etc. The following are some typical power consumption data and their collection methods.

[0074] Total power consumption (total active power): a floating point number in kilowatt-hours (kWh). Smart meters measure the current and voltage of related circuits in real time and calculate the power to obtain the total power consumption.

[0075] Time-of-use electricity consumption: electricity consumption within a period of time, in kilowatt-hours. Smart meters usually support time-of-use billing and use different electricity prices for billing. Smart meters record electricity consumption in each time period, such as peak hours, off-peak hours, and normal hours.

[0076] Power factor: A floating point number, usually a value between 0 and 1. Smart meters calculate the power factor by measuring the active power and reactive power in the relevant circuit.

[0077] Current and Voltage: Smart meters measure current (amperes) and voltage (volts), providing real-time current and voltage data.

[0078] Demand data: Indicates the maximum power demand of the relevant circuit within a certain time range. Smart meters periodically record and update demand data, usually in a cycle of 15 minutes or 30 minutes.

[0079] Optionally, this embodiment obtains any of the above-mentioned types of data within a preset time period based on a smart meter as the electricity consumption data to be transmitted. The electricity consumption data to be transmitted will be subsequently transmitted to the terminal for data analysis to achieve the purpose of supervising the user's electricity consumption behavior. In order to improve the timeliness of supervision, the electricity consumption data needs to be compressed before transmission, and the transmission efficiency of the electricity consumption data is enhanced by improving the compression efficiency. Therefore, here, the acquired electricity consumption data (there are multiple electricity consumption data) is converted into one-dimensional binary data, that is, the decimal data is converted into binary data, so as to obtain a binary data sequence, and the binary data sequence includes the binary data corresponding to each electricity consumption data, in preparation for subsequent data compression.

[0080] Step 202: Based on the run length sequence corresponding to the binary data sequence, a difference sequence is obtained, and a target run length is determined according to the difference sequence; the target run length meets a preset condition.

[0081] In a binary data sequence, there are only two types of characters, 0 and 1. Several consecutive 0 characters constitute a run of 0, and several consecutive 1 characters constitute a run of 1. By run-length encoding the binary data sequence, we can obtain the length of each run of 0 and each run of 1, thereby forming a run length sequence corresponding to the binary data sequence.

[0082] Since the run type includes a 0 run and a 1 run, the number of identifiers can be reduced by discarding the run type. The inventor has found that each run length in the run length sequence can be encoded by a preset coding table to achieve data compression. The coding table is shown in Table 1.

[0083] Table 1 Coding table

[0084]

[0085]

[0086] The coding table includes prefixes and suffixes. Prefixes are used for classification and positioning and are encoded in a fixed format. Suffixes are used for encoding. Codewords are composed of prefixes and suffixes. Codewords are the information that is finally stored and transmitted (compressed data after electrical data compression). When reading information, after reading the corresponding prefix, the corresponding group number can be obtained. The suffix length is obtained according to the group number, and then the decimal is restored according to the suffix code to obtain the corresponding run length.

[0087] However, when encoding according to the above-mentioned coding table, if the run length is long, the codeword length at this time will also be very long, occupying a large storage space and affecting the compression effect. At this time, if the difference method is adopted, the adjacent run lengths are subtracted to obtain the corresponding difference run length sequence (referred to as difference sequence), the difference will be much smaller than the value of the run length itself, but the difference will have a negative value. If the difference is a negative value, it is encoded in the form of the original prefix plus suffix, and if the difference is not a negative value, it is encoded using special coding. Special coding is specifically: the difference is recorded as a, if a is not a negative number, and a+1 is less than the corresponding codeword length, then a+1 0s are used as special codewords to replace the original codewords, and the number of coding bits can be reduced at this time, that is, the codeword length is reduced.

[0088] For example, the binary data sequence is 0000111110000001110000, and the run length sequence is (4, 5, 6, 3, 4). The first run length is 4. According to the grouping rules in the coding table, the group number is 2, and the corresponding prefix is ​​110. The suffix length is equal to the group number 2, so the suffix is ​​01, and the corresponding code word is 11001. The grouping rules of the coding table are explained here. In practical applications, the corresponding code word can be obtained by directly querying the coding table according to the first run length 4. Similarly, the second run length is 5, and the corresponding code word length is 11010. The difference between the second run length and the previous run length (the first run length) is 1. The difference is a positive value, and the corresponding special code word is 00. The length of 00 is less than the length of 11010, so the special code word is selected here as the code word corresponding to the second run length for storage. Similarly, the third run length is 6, and the corresponding codeword length is 11011. The difference between the third run length and the previous run length (the second run length) is 1, and the corresponding special codeword is 00. The length of 00 is less than the length of 11011, so the special codeword is selected as the codeword corresponding to the third run length for storage. The same applies to other run lengths.

[0089] According to the above analysis, the inventors found that when the run length in the run length sequence is increasing or unchanged, that is, when the current run length is greater than or equal to the previous run length, the difference obtained is not a negative value, and it is likely to be converted into a special codeword. The length of the special codeword is less than the codeword length obtained according to the programming table. At this time, the codeword result is shorter. However, it is difficult to achieve the situation that the run length in the run length sequence is increasing or unchanged in practice. Therefore, the inventors have found that it is possible to obtain the run length sequence and perform conversion judgment based on the run length sequence. Since adding 0 to the first bit of binary data will not affect the value of the corresponding decimal number, for example, 6 is 110 in binary, and recording it as 0110 will not affect the value of the decimal number. According to this property, by adding 0 characters in front of some binary substrings in the binary data sequence, the distribution of the run length sequence is changed, so that the run length sequence can satisfy the state of increasing or unchanged in sequence as much as possible.

[0090] Therefore, in this embodiment, a difference sequence is obtained based on the run length sequence corresponding to the binary data sequence, and the target run length is determined according to the difference sequence.

[0091] In some embodiments, when obtaining the difference sequence, a run length sequence can be determined based on the binary data sequence, and then the difference sequence is obtained according to the difference between every two adjacent run lengths in the run length sequence. The difference in the difference sequence is the difference corresponding to the latter run length obtained by subtracting the former run length from the latter run length in two adjacent run lengths.

[0092] Exemplarily, in this embodiment, the difference is obtained by subtracting the previous run length from the next run length, and the difference is used as the difference corresponding to the next run length. Since the first run length in the run length sequence has no corresponding difference, the first run length sequence is added to the first bit of the difference sequence to obtain an updated difference sequence as the difference sequence.

[0093] In some embodiments, the preset condition is that the stroke type is 0 stroke and the corresponding difference is a negative value. When determining the target stroke length, the difference in the difference sequence, whose value is a negative value and whose corresponding stroke length is 0 stroke type, can be used as the target difference. Then, the stroke length corresponding to the target difference in the stroke length sequence is determined as the target stroke length.

[0094] For example, the run length sequence corresponding to the binary data sequence is recorded as: [l1, l2, l3, l4, ..., l n ], where l1 represents the first run length, l n represents the nth run length, and n represents the number of run lengths in the run length sequence. Get the difference sequence corresponding to the run length sequence, recorded as [l1,L1,L2,L3,…Ln-1 ] In the difference sequence, when the negative difference is closer to 0, it is easier to convert it into an increasing or constant run length sequence by adding 0 characters. Therefore, in this embodiment, the difference values ​​of -1 and -2 in the difference sequence can also be taken as the target difference.

[0095] As can be seen from the above, the run length can only be changed by adding the 0 character. Therefore, if the difference corresponding to the run length is a negative number and the corresponding run type is 1 run, it cannot be processed. For example: the binary data sequence is 000011000011100, the corresponding run length sequence is (4, 2, 4, 3, 2), and the corresponding difference sequence is (4, -2, 2, -1, -1). At this time, the negative numbers in the difference are -2, -1, -1. The run types of the run lengths corresponding to the differences of -2, -1, and -1 in the difference sequence are 1, 1, and 0 respectively. Since the 1 run cannot be changed, only the 0 run can be changed. Therefore, -2 and the first -1 in the difference are invalid negative differences, which cannot be processed at this time. Such differences should be discarded to retain the valid negative differences (i.e., the target differences). Afterwards, the run lengths corresponding to the valid negative difference values ​​are obtained in the run length sequence as target run lengths, and these target run lengths are the run lengths for optimal processing.

[0096] Step 203: according to the position of the target binary substring corresponding to the target run length in the binary data sequence, add the character 0 to the binary data sequence to obtain an optimized binary data sequence.

[0097] In some embodiments, when an optimized binary data sequence is obtained, the corresponding target binary substring can be determined in the binary data sequence according to the target run length, and it can be determined whether the target binary substring is located at the end of the corresponding binary data. If the target binary substring is located at the end of the corresponding binary data, a preset number of 0 characters are added to the first position of the binary substring adjacent to the target binary substring to obtain the optimized binary data sequence.

[0098] The target binary substring is a string corresponding to the target run length in the binary data sequence corresponding to the target run length. The binary data corresponding to the subsequent binary substring is the subsequent adjacent data of the binary data corresponding to the target binary substring.

[0099] Optionally, if the target binary substring is not located at the end of the corresponding binary data, the binary data sequence is not processed, that is, a preset number of 0 characters are not added to the first position of the binary substring adjacent to the target binary substring.

[0100] Exemplarily, after the target run length is determined, the target binary substring corresponding to each target run length can be determined in the binary data sequence. For example, the binary data sequence is converted from the decimal voltage and current values, and the binary data sequence is: 11110001 (241), 111000 (56), 110 (6), 1111 (15), the corresponding run length sequence is (4, 3, 4, 3, 2, 1, 4), and the corresponding difference sequence is (4, -1, 1, -1, -1, -1, 3). The target difference can be obtained as the first -1, the second -1 and the fourth -1 in the difference sequence. According to these three target differences, the target run length is obtained in the run length sequence, that is, the target run length is 3, 3, 1 in the run length sequence (4, 3, 4, 3, 2, 1, 4). Then, the target binary substring corresponding to each target run length is obtained in the binary data sequence. For example, if the first target run length is 3 and the run type is a 0 run, the corresponding target binary substring is a substring consisting of 3 0s in 11110001 (241). So far, the target binary substring corresponding to each target run length can be obtained in the binary data sequence.

[0101] After that, after determining the target binary substring corresponding to each target run length, this embodiment can perform adaptive 0 character addition processing on the binary data sequence according to the position of each target binary substring in the binary data sequence to obtain an optimized binary data sequence. For each target binary substring, if the target binary substring is located at the tail of the corresponding binary data, then according to the position of the target binary substring in the binary data sequence, obtain the subsequent adjacent binary substring of the target binary substring, the subsequent critical binary substring corresponds to a binary data, and then add a preset number of 0 characters to the first position of the subsequent adjacent binary substring to obtain the optimized binary data sequence.

[0102] It should be noted that, considering that adding 0 characters to a binary data sequence will change the run length, if too many 0 characters are added, the amount of extra data added will be too large, which is not conducive to the final compression effect. Therefore, the number of added 0 characters can be controlled within 2, that is, the number of 0 characters to be added is 1 or 2, and the preset number is 1 or 2. In other words, as described in the above embodiment, the difference between the values ​​of -1 and -2 in the difference sequence is taken as the target difference, so that the number of added 0 characters is 1 or 2, which is conducive to improving the final compression effect. For the convenience of description and understanding, the preset number is set to 1 in this embodiment, that is, 1 0 character is added.

[0103] A simple example is that the binary data sequence is 11110001 (241), 111000 (56), 110 (6), 1111 (15), the corresponding run length sequence is (4, 3, 4, 3, 2, 1, 4), and the corresponding difference sequence is (4, -1, 1, -1, -1, -1, 3). The target difference is the first -1, the second -1 and the fourth -1 in the difference sequence. Based on these three target differences, the target run length is obtained in the run length sequence, that is, the target run length is 3, 3, 1 in the run length sequence (4, 3, 4, 3, 2, 1, 4). For example, the first target run length is 3 and the run type is 0 run, and the corresponding target binary substring is a substring consisting of 3 zeros in the corresponding binary data 11110001(241). Since the target binary substring is located in the middle part of the binary data 11110001(241), if the first bit of the adjacent binary substring of the target binary substring is added with a 0 character, the value of 11110001(241) will be changed. Therefore, the binary data sequence is not processed at this time, that is, the binary data sequence is not processed with a 0 character according to the position of the target binary substring corresponding to the target run length of 3.

[0104] The second target run length is 3 and the run type is 0 run. The corresponding target binary substring is a substring consisting of 3 zeros in the corresponding binary data 111000(56). Since the target binary substring is located at the end of the binary data 111000(56), a 0 character is added to the first position of the binary substring 11 following the target binary substring to obtain 011. Here, adding a 0 character to the first position of the binary data 110(6) does not change the value of 110(6). After adding the 0 character, 110(6) becomes 0110(6). At this time, the second target run length changes from 3 to 4, and the optimized binary data sequence is: 11110001 (241), 111000 (56), 0110 (6), 1111 (15), the corresponding run length sequence is (4, 3, 4, 4, 2, 1, 4), and the corresponding difference sequence is (4, -1, 1, 0, -2, -1, 3). It can be seen that the difference sequence (4, -1, 1, 0, -2, -1, 3) corresponding to the optimized binary data sequence is reduced by 1 compared with the difference sequence (4, -1, 1, -1, -1, -1, 3) corresponding to the original binary data sequence.

[0105] The third target run length is 1 and the run type is 0 run. The corresponding target binary substring is a substring consisting of 1 0 in the corresponding binary data 110(6). Since the target binary substring is located at the end of the binary data 110(6), a 0 character is added to the first position of the binary substring 1111 following the target binary substring, resulting in 01111. Here, adding a 0 character to the first position of the binary data 1111(15) does not change the value of 1111(15). After adding the 0 character, 1111(15) becomes 01111(15). At this time, the third target run length changes from 1 to 2, and the optimized binary data sequence is: 11110001 (241), 111000 (56), 0110 (6), 01111 (15). The corresponding run length sequence is (4, 3, 4, 4, 2, 2, 4), and the corresponding difference sequence is (4, -1, 1, 0, -2, 0, 2). Compared with the difference sequence corresponding to the original binary data sequence (4, -1, 1, -1, -1, -1, 3), the number of negative differences is reduced by 2.

[0106] In this way, the run length sequence corresponding to the optimized binary data sequence is as close to increasing as possible or unchanged as possible.

[0107] Step 204: for each type of target run, determine the optimal insertion step length of the type of target run according to the interval distance of the type of target run in the optimized binary data sequence, and insert the corresponding character into the optimized binary data sequence according to the optimal insertion step length to obtain the inserted binary data sequence.

[0108] It can be seen from the above embodiments that the number of negative difference values ​​in the difference sequence corresponding to the optimized binary data sequence is reduced, and the position where the 0 character is added does not need to be recorded. However, there are other binary substrings corresponding to the difference values ​​in the difference sequence located in the middle part or tail of the corresponding binary data. At this time, adding 0 characters or 1 characters will cause the decimal value corresponding to the original binary data to change. Therefore, in order to further improve the efficiency of data compression, this embodiment periodically inserts the target run length into the optimized binary data sequence.

[0109] Optionally, the target run includes run 0 and run 1. Since there are only run 0 and run 1 in the optimized binary data sequence, run 0 and run 1 are respectively used as target runs, and then 0 characters and 1 characters are inserted into the optimized binary data sequence to obtain a binary data sequence after insertion.

[0110] In some embodiments, for each type of target run, when determining the optimal insertion step length of this type of target run, steps A1 to A4 may be included.

[0111] A1. For each type of target run, according to the position of the target run in the optimized binary data sequence, the interval distance between every two adjacent target runs in the target run is obtained.

[0112] A2. Determine the first addition result based on the stroke length of the first target stroke in this type of target stroke and the first interval distance between the first target stroke and the second target stroke; determine the second addition result based on the stroke length of the first target stroke, the stroke length of the second target stroke and the first interval distance.

[0113] A3. Based on the first addition result and the second addition result, obtain an insertion step range.

[0114] A4. Detect whether there is a marker insertion step within the insertion step range. If it is detected that there is a marker insertion step within the insertion step range, all markers within the insertion step range are inserted into the step, and the marker insertion step with the largest value is used as the optimal insertion step for this type of target run.

[0115] In this embodiment, for each type of target run, the sum of the run length of the first target run in the type of target run and the first interval distance is taken as the first addition result, and the sum of the run length of the second target run in the type of target run and the first interval distance is taken as the second addition result. Afterwards, the first addition result and the second addition result are respectively taken as the boundary values ​​of the insertion step range to obtain the insertion step range.

[0116] For example, taking a 1-run as an example, the run length of each 1-run in the optimized binary data sequence and the interval distance between each two adjacent 1-runs are counted respectively. Here, the interval distance is the run length of the 0-run between two adjacent 1-runs. Starting from the first 1-run in the optimized binary data sequence, taking the first 1 in the first 1-run as the starting point, the sum of the first 1-run and the first interval distance is obtained. 11 +l 01 , as the first addition result, where l 11 Indicates the length of the first run in a run, l 01 Indicates the length of the first 0 run in the 0 run, that is, the interval between the first 1 run and the second 1 run. At the same time, obtain the sum of the difference between the length of the first 1 run and the constant 1, the first interval distance and the length of the second 1 run. 11 -1+l 01 +l 12 , as the second addition result, l 12Indicates the length of the second run in the run. Then add the first addition result l 11 +l 01 and the second addition result l 11 -1+l 01 +l 12 Composition insertion step range [(l 11 +l 01 ), (l 11 -1+l 01 +l 12 )].

[0117] Exemplarily, for each type of target run, when detecting whether there is a marked insertion step within the insertion step range, for each insertion step within the insertion step range, the first character of the first target run of this type of target run in the optimized binary data sequence can be used as the starting point, and the insertion step can be used as a window to slide in the optimized binary data sequence. If the position after each sliding belongs to this type of target run, the insertion step is used as a marked insertion step. Otherwise, there is no insertion step within the insertion step range.

[0118] In this embodiment, after determining the insertion step range, it is determined whether there is a marked insertion step in the insertion step range. The marked insertion step refers to an insertion step within the insertion step range that can be slid in the optimized binary data sequence with the insertion step as a window, starting from character 1 each time, and the corresponding character after each sliding is also 1. Therefore, if it is detected that there is a marked insertion step within the insertion step range, and after obtaining all the marked insertion steps within the insertion step range, the largest marked insertion step is used as the optimal insertion step of 1 run. Similarly, according to the method for obtaining the optimal insertion step of 1 run, the optimal insertion step of 0 run in the optimized binary data sequence can be obtained.

[0119] For example, take 1 run as an example, refer to Figure 3 , Figure 3 The dark box belongs to the 1-run, and the white box belongs to the 0-run. The insertion step range corresponding to the 1-run is [5, 7]. For the insertion step 5, starting from the first deep box in the first 1-run, after sliding 5 frames, it falls on the first dark box in the second 1-run, and then starting from the first dark box in the second 1-run, after sliding 5 frames, it falls on the second dark box in the third 1-run, and then starting from the second dark box in the third 1-run, after sliding 5 frames, it falls on the last dark box in the fourth 1-run, which meets the requirements of the mark insertion step, so the insertion step 5 belongs to the mark insertion step. Similarly, the insertion step 6 does not belong to the mark insertion step, and the insertion step 7 also belongs to the mark insertion step, so the optimal insertion step of 1-run is determined to be 7.

[0120] Optionally, this embodiment can also determine a third addition result based on the run length of the second target run in this type of target run and the second interval distance between the second target run and the third target run when no marked insertion step is detected in the insertion step range, and determine a fourth addition result based on the run length of the second target run, the run length of the third target run and the second interval distance, then obtain a new insertion step range based on the third addition result and the fourth addition result, use the new insertion step range as the insertion step range, and re-execute the step of detecting whether there is a marked insertion step in the insertion step range until the optimal insertion step for this type of target run is determined.

[0121] In this embodiment, for each type of target run, the sum of the run length of the second target run in the type of target run and the second interval distance is used as the third addition result, and the sum of the run length of the third target run in the type of target run and the second interval distance is used as the fourth addition result. Afterwards, the third addition result and the fourth addition result are used as boundary values ​​of the insertion step range respectively, and a new insertion step range is obtained as the insertion step range.

[0122] That is to say, taking the 1-run as an example, considering that the run length of the 0-run between the first 1-run and the second 1-run in the optimized binary data sequence is too large, the insertion step in the insertion step range obtained for the first time cannot fall exactly at the 1-run after each sliding, that is, there is no marked insertion step in the insertion step range obtained for the first time. In this embodiment, the first 1-run in the optimized binary data sequence is discarded, and instead, starting from the second 1-run, a new insertion step range is re-acquired according to the method for obtaining the insertion step range obtained for the first time, and then the new insertion step range is used as the insertion step range to re-detect whether there is a marked insertion step in the insertion step range. If no marked insertion step is detected in the insertion step range, the second 1-run in the optimized binary data sequence is continued to be discarded, the new insertion step range is re-acquired, and the new insertion step range is continued to be used as the insertion step range to re-detect whether there is a marked insertion step in the insertion step range until a marked insertion step is detected in the insertion step range.

[0123] In some embodiments, for each type of target run, when obtaining the inserted binary data sequence, the first character of the first target run of the type of target run in the optimized binary data sequence can be used as the starting point, and the optimal insertion step length can be used as a window to slide in the optimized binary data sequence, and a character corresponding to the type of target run is inserted after the starting point and after each sliding position to obtain the inserted binary data sequence. The character corresponding to the 0 run is 0, and the character corresponding to the 1 run is 1.

[0124] For example, take 1 run as an example, refer to Figure 4 , Figure 4 The dark boxes in the middle belong to the 1 run, the white boxes belong to the 0 run, and the arrows indicate insertions. With 5 as the optimal insertion step, a 1 character is inserted after the first character of the first 1 run, that is, a 1 character is inserted after the first dark box in the first 1 run. Then after sliding 5 boxes, it reaches the first dark box of the second 1 run, and a 1 character is inserted after the first dark box of the second 1 run. After that, after sliding 5 boxes again, similarly, a 1 character is inserted after the second dark box in the third 1 run, and a 1 character is inserted after the second dark box in the fourth 1 run.

[0125] Thus, by inserting 1 characters and 0 characters adaptively into the optimized binary data sequence, the inserted binary data sequence can be obtained. Meanwhile, when inserting 1 characters or 0 characters, the inserted character type, starting point, optimal insertion step length and end point are recorded respectively.

[0126] Step 205: determine the code words corresponding to each new run length in the new run length sequence corresponding to the inserted binary data sequence, and obtain compressed data based on the code words corresponding to all the new run lengths.

[0127] In this embodiment, after obtaining the inserted binary data sequence, the corresponding new run length sequence can be obtained according to the continuous 0 characters and the continuous 1 characters in the inserted binary data sequence. Thus, according to each new run length in the new run length sequence, the corresponding new difference sequence is obtained, and then, according to the new run length sequence and the new difference sequence, based on the coding table and the special coding, the code words corresponding to each new run length are obtained, and then the code words corresponding to each new run length are combined into compressed data, that is, the compressed data corresponding to the power consumption data to be transmitted is obtained, and the compression of the power consumption data to be transmitted is completed.

[0128] Among them, according to the new run length sequence and the new difference sequence, based on the coding table and special coding, the specific implementation process and principle of obtaining the codewords corresponding to each new run length can be referred to the relevant description in the aforementioned embodiment and will not be repeated here.

[0129] After obtaining the compressed data corresponding to the power consumption data to be transmitted, the compressed data is transmitted to the terminal, so that after receiving the compressed data, the terminal performs an inverse operation of decompression on the compressed data to obtain the restored power consumption data, and compares the restored power consumption data with the historical power consumption data of the corresponding user to determine the abnormal power consumption behavior results of the corresponding user. If the abnormal power consumption behavior result is to determine that the user has abnormal power consumption behavior, a timely warning is issued. It should be noted that how to compare the restored power consumption data with the historical power consumption data of the corresponding user to determine the abnormal power consumption behavior results of the corresponding user is not the focus of the present invention and will not be described in detail here.

[0130] The compression method of the smart meter electricity consumption data provided by the embodiment of the present application performs binary conversion on the electricity consumption data to be transmitted, and obtains the target run length that meets the preset conditions based on the run length sequence corresponding to the obtained binary data sequence, and then adds 0 characters to the binary data sequence according to the position of the target binary substring corresponding to the target run length, and then determines the optimal insertion step length of each type of target run for each type of target run, and inserts the corresponding characters into the optimized binary data sequence according to the optimal insertion step length, thereby determining the code words corresponding to each new run length in the new run length sequence corresponding to the inserted binary data sequence, and obtaining compressed data according to all the code words. The embodiment of the present application determines the position where 0 characters and 1 characters need to be added in the binary data sequence according to the run length distribution, so as to adaptively change the run length, so that the run length sequence of the inserted binary data sequence is as much as possible in a state of increasing or unchanged in sequence, thereby improving the compression efficiency of the inserted binary data sequence and enhancing the data transmission efficiency.

[0131] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0132] Figure 5 Schematic diagram of the structure of a device for compressing electricity consumption data of a smart meter provided in one embodiment of the present application. Figure 5 As shown, the device for compressing smart meter electricity consumption data provided in this embodiment may include: an acquisition module 501, a determination module 502, a obtaining module 503, an acquisition module 504 and a compression module 505.

[0133] The acquisition module 501 is used to acquire the power consumption data to be transmitted, and perform binary conversion on the power consumption data to obtain a binary data sequence.

[0134] The determination module 502 is used to obtain a difference sequence based on the run length sequence corresponding to the binary data sequence, and determine a target run length according to the difference sequence; the target run length meets a preset condition.

[0135] The obtaining module 503 is used to add a 0 character to the binary data sequence according to the position of the target binary substring corresponding to the target run length in the binary data sequence to obtain an optimized binary data sequence.

[0136] The acquisition module 504 is used to determine the optimal insertion step length of each type of target run according to the interval distance of the type of target run in the optimized binary data sequence, and insert the corresponding character into the optimized binary data sequence according to the optimal insertion step length to obtain the inserted binary data sequence.

[0137] The compression module 505 is used to determine the code words corresponding to each new run length in the new run length sequence corresponding to the inserted binary data sequence, and obtain compressed data according to the code words corresponding to all new run lengths.

[0138] Optionally, there are multiple power usage data, and the binary data sequence includes binary data corresponding to each power usage data; the determination module 502 is further used to:

[0139] Determining a run length sequence based on the binary data sequence;

[0140] A difference sequence is obtained according to the difference between every two adjacent run lengths in the run length sequence; the difference is the difference corresponding to the latter run length obtained by subtracting the former run length from the latter run length.

[0141] Optionally, the preset condition is that the run type is 0 run, and the corresponding difference is a negative value; the determination module 502 is further used for:

[0142] The difference in the difference sequence, which is a negative value and has a run type of 0 run, is used as the target difference;

[0143] The run length corresponding to the target difference in the run length sequence is determined as the target run length.

[0144] Optionally, the obtaining module 503 is further used for:

[0145] In the binary data sequence, a corresponding target binary substring is determined according to the target run length; the target binary substring is a character string corresponding to the target run length in the binary data corresponding to the target run length in the binary data sequence;

[0146] Determine whether the target binary substring is located at the end of the corresponding binary data;

[0147] If the target binary substring is located at the end of the corresponding binary data, a preset number of 0 characters are added to the first position of the binary substring adjacent to the target binary substring to obtain an optimized binary data sequence;

[0148] The binary data corresponding to the subsequent adjacent binary substring is the subsequent adjacent data of the binary data corresponding to the target binary substring.

[0149] Optionally, the target run includes a 0 run and a 1 run; the obtaining module 504 is further used for:

[0150] For each type of target run, according to the position of the target run in the optimized binary data sequence, the interval distance between every two adjacent target runs in the target run is obtained;

[0151] Determine a first addition result according to a run length of a first target run in the target run of the type and a first interval distance between the first target run and a second target run; determine a second addition result according to the run length of the first target run, the run length of the second target run and the first interval distance;

[0152] Based on the first addition result and the second addition result, obtaining an insertion step range;

[0153] Check whether there is a marker insertion step within the insertion step range. If it is detected that there is a marker insertion step within the insertion step range, all marker insertion steps within the insertion step range are inserted into the marker insertion step, and the marker insertion step with the largest value is used as the optimal insertion step for this type of target run.

[0154] Optionally, the obtaining module 504 is further used for:

[0155] For each insertion step within the insertion step range, taking the first character of the first target run of the type of target run in the optimized binary data sequence as a starting point, and sliding in the optimized binary data sequence with the insertion step as a window;

[0156] If the position after each sliding movement belongs to this type of target run, the insertion step is used as the marked insertion step; otherwise, there is no insertion step within the insertion step range.

[0157] Optionally, the obtaining module 504 is further used for:

[0158] If no marked insertion step is detected within the insertion step range, a third addition result is determined according to the run length of a second target run in the target run of the type and a second interval distance between the second target run and a third target run; a fourth addition result is determined according to the run length of the second target run, the run length of the third target run and the second interval distance;

[0159] Based on the third addition result and the fourth addition result, a new insertion step range is obtained, and the new insertion step range is used as the insertion step range, and the step of detecting whether there is a marked insertion step in the insertion step range is re-executed until the optimal insertion step for this type of target run is determined.

[0160] Optionally, the character corresponding to a run of 0 is 0, and the character corresponding to a run of 1 is 1; the obtaining module 504 is further used for:

[0161] Taking the first character of the first target run of the type of target run in the optimized binary data sequence as the starting point, sliding in the optimized binary data sequence with the optimal insertion step length as a window;

[0162] A character corresponding to the target run of this type is inserted after the starting point and after the position after each sliding, to obtain a binary data sequence after insertion.

[0163] Optionally, the compression module 505 is further configured to:

[0164] Obtaining a new difference sequence according to a new run length sequence corresponding to the inserted binary data sequence;

[0165] Determine a codeword corresponding to each new run length in the new run length sequence based on the new difference sequence, a preset coding table and a preset coding rule;

[0166] The code words corresponding to all new run lengths constitute compressed data corresponding to the power consumption data to be transmitted.

[0167] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0168] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0169] Those of ordinary skill in the art will appreciate that the templates, units, and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0170] If the module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory, random access memory, electrical carrier signal, telecommunication signal and software distribution medium.

[0171] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.

Claims

1. A method for compressing electricity consumption data of a smart meter, characterized in that: include: Acquire power consumption data to be transmitted, and perform binary conversion on the power consumption data to obtain a binary data sequence; Based on the run length sequence corresponding to the binary data sequence, a difference sequence is obtained, and according to the difference sequence, a target run length is determined; the target run length satisfies a preset condition; According to the position of the target binary substring corresponding to the target run length in the binary data sequence, adding a 0 character to the binary data sequence to obtain an optimized binary data sequence; For each type of target run, according to the interval distance of the type of target run in the optimized binary data sequence, determine the optimal insertion step length of the type of target run, and according to the optimal insertion step length, insert the corresponding character in the optimized binary data sequence to obtain the inserted binary data sequence; Determine the code words corresponding to each new run length in the new run length sequence corresponding to the inserted binary data sequence, and obtain compressed data according to the code words corresponding to all the new run lengths.

2. The method for compressing electricity consumption data of a smart meter according to claim 1, characterized in that: There are multiple power consumption data, and the binary data sequence includes binary data corresponding to each power consumption data; The step of obtaining a difference sequence based on a run length sequence corresponding to the binary data sequence comprises: Determining a run length sequence based on the binary data sequence; A difference sequence is obtained according to the difference between every two adjacent run lengths in the run length sequence; the difference is the difference corresponding to the latter run length obtained by subtracting the former run length from the latter run length.

3. The method for compressing electricity consumption data of a smart meter according to claim 2, characterized in that: The preset condition is that the run type is 0 run and the corresponding difference is a negative value; Determining a target run length according to the difference sequence includes: The difference in the difference sequence, which is a negative value and has a run type of 0 run, is used as the target difference; The run length corresponding to the target difference in the run length sequence is determined as the target run length.

4. The method for compressing electricity consumption data of a smart meter according to claim 2, characterized in that: The step of adding a 0 character to the binary data sequence according to the position of the target binary substring corresponding to the target run length in the binary data sequence to obtain an optimized binary data sequence includes: In the binary data sequence, a corresponding target binary substring is determined according to the target run length; the target binary substring is a character string corresponding to the target run length in the binary data corresponding to the target run length in the binary data sequence; Determine whether the target binary substring is located at the end of the corresponding binary data; If the target binary substring is located at the end of the corresponding binary data, a preset number of 0 characters are added to the first position of the binary substring adjacent to the target binary substring to obtain an optimized binary data sequence; The binary data corresponding to the subsequent adjacent binary substring is the subsequent adjacent data of the binary data corresponding to the target binary substring.

5. The method for compressing electricity consumption data of a smart meter according to any one of claims 1 to 4, characterized in that: The target run includes a 0 run and a 1 run; The method of determining the optimal insertion step length of each type of target run according to the interval distance of the type of target run in the optimized binary data sequence includes: For each type of target run, according to the position of the target run in the optimized binary data sequence, the interval distance between every two adjacent target runs in the target run is obtained; Determine a first addition result according to a run length of a first target run in the target run of the type and a first interval distance between the first target run and a second target run; determine a second addition result according to the run length of the first target run, the run length of the second target run and the first interval distance; Based on the first addition result and the second addition result, obtaining an insertion step range; Check whether there is a marker insertion step within the insertion step range. If it is detected that there is a marker insertion step within the insertion step range, all marker insertion steps within the insertion step range are inserted into the marker insertion step, and the marker insertion step with the largest value is used as the optimal insertion step for this type of target run.

6. The method for compressing electricity consumption data of a smart meter according to claim 5, characterized in that: For each type of target run, detecting whether there is a marked insertion step within the insertion step range includes: For each insertion step within the insertion step range, taking the first character of the first target run of the type of target run in the optimized binary data sequence as a starting point, and sliding in the optimized binary data sequence with the insertion step as a window; If the position after each sliding movement belongs to this type of target run, the insertion step is used as the marked insertion step; otherwise, there is no insertion step within the insertion step range.

7. The method for compressing electricity consumption data of a smart meter according to claim 5, characterized in that: The method further comprises: If no marked insertion step is detected within the insertion step range, a third addition result is determined according to the run length of a second target run in the target run of the type and a second interval distance between the second target run and a third target run; a fourth addition result is determined according to the run length of the second target run, the run length of the third target run and the second interval distance; Based on the third addition result and the fourth addition result, a new insertion step range is obtained, and the new insertion step range is used as the insertion step range, and the step of detecting whether there is a marked insertion step in the insertion step range is re-executed until the optimal insertion step for this type of target run is determined.

8. The method for compressing electricity consumption data of a smart meter according to claim 5, characterized in that: The character corresponding to a run of 0 is 0, and the character corresponding to a run of 1 is 1; For each type of target run, inserting corresponding characters into the optimized binary data sequence according to the optimal insertion step length to obtain the inserted binary data sequence includes: Taking the first character of the first target run of the type of target run in the optimized binary data sequence as the starting point, sliding in the optimized binary data sequence with the optimal insertion step length as a window; A character corresponding to the target run of this type is inserted after the starting point and after the position after each sliding, to obtain a binary data sequence after insertion.

9. The method for compressing electricity consumption data of a smart meter according to any one of claims 1 to 4, characterized in that: The step of determining the code words corresponding to each new run length in the new run length sequence corresponding to the inserted binary data sequence, and obtaining compressed data according to the code words corresponding to all the new run lengths, comprises: Obtaining a new difference sequence according to a new run length sequence corresponding to the inserted binary data sequence; Determine a codeword corresponding to each new run length in the new run length sequence based on the new difference sequence, a preset coding table and a preset coding rule; The code words corresponding to all new run lengths constitute compressed data corresponding to the power consumption data to be transmitted.

10. A device for compressing electricity consumption data of a smart meter, characterized in that: include: An acquisition module, used for acquiring the power consumption data to be transmitted, and performing binary conversion on the power consumption data to obtain a binary data sequence; A determination module, configured to obtain a difference sequence based on a run length sequence corresponding to the binary data sequence, and determine a target run length according to the difference sequence; the target run length satisfies a preset condition; an obtaining module, configured to add a 0 character to the binary data sequence according to the position of the target binary substring corresponding to the target run length in the binary data sequence, so as to obtain an optimized binary data sequence; An obtaining module is used to determine, for each type of target run, the optimal insertion step length of the target run according to the interval distance of the target run in the optimized binary data sequence, and insert corresponding characters into the optimized binary data sequence according to the optimal insertion step length to obtain the inserted binary data sequence; The compression module is used to determine the code words corresponding to each new run length in the new run length sequence corresponding to the inserted binary data sequence, and obtain compressed data according to the code words corresponding to all the new run lengths.