Periodic freezing and quick access method for intelligent instrumented electric energy meter
By employing a high-frequency write EE algorithm to store frozen record serial numbers in smart IoT energy meters and optimizing the binary search strategy, the problems of energy meter damage and long response time caused by uneven storage of frozen data are solved, achieving the effects of fast access and extended energy meter lifespan.
Patent Information
- Application Number
- CN202411575046.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-02-28
AI Technical Summary
Smart IoT energy meters are prone to damage and data loss when the frozen record serial number is frequently modified. Furthermore, the inconsistent time intervals between data storage result in long response times for the energy meters, which affects customer satisfaction.
The method of trading space for time is used to store the frozen data index, the high-frequency write EE algorithm is used to store the frozen record sequence number, and the binary search strategy is adjusted according to the copying and reading time parameter to narrow the search range and optimize the storage and retrieval process of frozen data.
It extends the lifespan of the electricity meter, shortens the freeze time, improves data reading speed, and reduces the response time of the smart IoT electricity meter.
Smart Images

Figure CN119536639A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electric energy meters, and more specifically, to a method for periodically freezing and quickly accessing an intelligent Internet of Things electric energy meter. Background Art
[0002] The write life of EE is about 1 million times (may vary slightly for different products). However, the IoT energy meter requires a life of 16 years. Frequent modification of the sequence number of the frozen record during freezing may cause EE damage and data loss. For minute freezing, the IoT energy meter requires the ability to store one year's data at 1-minute intervals. Based on 365 days a year, the amount of data for one year is 525,600.
[0003] At present, the IoT electric energy meter adopts the object-oriented electricity consumption information data exchange protocol--DL / T698.45-2017. Among them, method 2 reads the data between two time points, and supports reading data at a certain time interval; method 1 reads the data at a certain time point, and if it does not exist, it returns the next data in the direction of time increase at that time point.
[0004] When reading the data of the electric energy meter, although the stored data is sorted by time, due to power failure, time calibration and other reasons, the data is not necessarily stored at equal time intervals, and the time difference between the previous frozen record and the next frozen record may be large. Faced with such a huge amount of data, using general retrieval methods or ordinary binary search methods will cause the meter to respond in a long time, affecting the normal operation of other services in the meter, and taking a long time to read the data, affecting customer satisfaction. Summary of the invention
[0005] The purpose of the present invention is to solve the problem that the amount of periodic freezing data of the intelligent Internet of Things electric energy meter is large and the reading of data takes a long time. A method for quick access of periodic freezing of the intelligent Internet of Things electric energy meter is proposed. Firstly, the method of exchanging space for time is adopted to store the frozen data index of the Internet of Things electric energy meter, thereby extending the EE life; secondly, the freezing time is compressed and the search range of the binary search method is narrowed. Compared with the ordinary binary search method, the data reading speed is improved and the response time of the intelligent Internet of Things electric energy meter is reduced.
[0006] The technical solution of the present invention is:
[0007] The present invention provides a method for periodically freezing and quickly accessing an intelligent IoT electric energy meter, comprising:
[0008] Obtaining a frozen associated object, a frozen record serial number and the number of frozen records, wherein the frozen associated object is stored in the electric energy meter EE, and the frozen record serial number is stored using a high-frequency writing EE algorithm;
[0009] Obtain the freeze records stored in the electric energy meter Flash, each sector stores an integer number of freeze records, and a freeze record includes a freeze sequence number, a freeze time, and associated object data;
[0010] According to the time parameters of the communication reading, it is determined whether the reading is data between two time points or data at a certain time point. If it is data between two time points, the binary search method is used to find the frozen record corresponding to the modified search time. If it is data at a certain time point, the binary search method is used to find the frozen record corresponding to the search time.
[0011] Furthermore, the 32-bit address is divided into three upper bytes and one lower byte, multiple storage spaces are allocated to the lower byte, and the specific storage location is determined by taking the modulus of the storage space number for the three upper bytes according to the address.
[0012] Furthermore, the obtaining of the freezing record stored in the electric energy meter Flash includes:
[0013] The freezing time is the time interval from the preset time, which compresses the storage space.
[0014] Furthermore, the data between two time points includes:
[0015] Calculate the theoretical maximum number of frozen records, and modify the start index of the binary search according to the start time, current time, and freezing interval to narrow the search range.
[0016] Furthermore, the step of searching for the frozen record corresponding to the modified search time by using a binary search method includes:
[0017] Modify the search time to an integer multiple of the interval according to the communication copying interval, and determine whether the modified search time is greater than the communication copying end time. If so, end the search.
[0018] Furthermore, the method of searching for the frozen record corresponding to the modified search time by using the binary search method further includes:
[0019] If there is an exact match, the data is encoded and the start index of the next search is updated. If there is no match, the start index of the next search is updated to the returned index.
[0020] Furthermore, after the binary search method is used to search for the frozen record corresponding to the modified search time, the method further includes:
[0021] The binary search end index is updated according to the communication copying interval, and it is determined whether the search start index is less than the end index of the frozen record. If so, the above binary search steps are executed cyclically.
[0022] Furthermore, the data at a certain time point includes:
[0023] Calculate the theoretical maximum number of frozen records, and modify the start index of the binary search based on the start time, current time, and freezing interval to narrow the search range;
[0024] Use binary search to find the frozen record corresponding to the search time. If found, encode the data. If not found, return the next data greater than the search time.
[0025] Beneficial effects of the present invention:
[0026] The intelligent IoT electric energy meter periodic freezing fast access method of the present invention adopts a high-frequency EE writing algorithm in storing frozen data sequence numbers, compresses the data freezing time storage space in storing frozen records, reduces the binary search range in reading frozen records, prolongs the EE life, reduces the workload of the intelligent IoT electric energy meter MCU, and improves the response speed of the electric energy meter
[0027] Aiming at the business scenario of frozen data storage and rapid retrieval of electric energy meters, the present invention adopts a high-frequency write EE algorithm to store the frozen record serial number, and flexibly adjusts the binary search strategy according to the reading time parameters. For data reading between two time points, the binary search process is optimized by correcting the search start index, adjusting the search time to an integer multiple of the interval, etc. For data reading at a single time point, the target record is directly binary searched or the closest next data is returned. The present invention significantly improves the access efficiency of massive periodically frozen data by optimizing the storage structure and retrieval algorithm, and provides an efficient solution for data management of smart IoT electric energy meters.
[0028] Other features and advantages of the present invention will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The above and other objects, features and advantages of the present invention will become more apparent through a more detailed description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, wherein like reference numerals generally represent like components throughout the exemplary embodiments of the present invention.
[0030] Figure 1 Schematic diagram of how frozen records are stored and the composition of a record.
[0031] Figure 2 High frequency writing EE schematic.
[0032] Figure 3 A flowchart of copying and reading of method 2 according to an embodiment of the present invention is shown.
[0033] Figure 4 A flowchart of copying and reading of method 1 according to an embodiment of the present invention is shown.
[0034] Figure 5A bisection flow chart according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0035] The preferred embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the preferred embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein.
[0036] The present invention provides a method for periodically freezing and quickly accessing an intelligent IoT electric energy meter, comprising:
[0037] Obtaining a frozen associated object, a frozen record serial number and the number of frozen records, wherein the frozen associated object is stored in the electric energy meter EE, and the frozen record serial number is stored using a high-frequency writing EE algorithm;
[0038] Obtain the freeze records stored in the electric energy meter Flash, each sector stores an integer number of freeze records, and a freeze record includes a freeze sequence number, a freeze time, and associated object data;
[0039] According to the time parameters of the communication reading, determine whether the reading is data between two time points or data at a certain time point;
[0040] If the data is between two time points, the binary search method is used to find the frozen records corresponding to the modified search time; specifically, the method includes calculating the theoretical maximum number of frozen records, correcting the start index of the binary search according to the start time, the current time and the freezing interval, and narrowing the search range; updating the binary search end index according to the communication reading interval, and judging whether the search start index is less than the end index of the frozen record. If so, the above binary search steps are executed repeatedly.
[0041] Wherein; the method of using binary search to find the frozen record corresponding to the modified search time includes:
[0042] Modify the search time to an integer multiple of the interval according to the communication reading interval, and determine whether the modified search time is greater than the communication reading end time. If it is greater, end the search. If it is an exact match, encode the data and update the start index of the next search. If it is not a match, update the start index of the next search to the returned index.
[0043] If the data is from a certain point in time, the binary search method is used to find the frozen records corresponding to the search time; specifically, this method includes calculating the theoretical maximum number of frozen records, and correcting the starting index of the binary search according to the start time, current time, and freezing interval to narrow the search range; the binary search method is used to find the frozen records corresponding to the search time, and if found, the data is encoded; if not found, the next data greater than the search time is returned.
[0044] When implementing:
[0045] The data storage part of the present invention is designed as follows:
[0046] The information that needs to be stored for freezing is divided into two types: stored in EE and stored in Flash. The information stored in EE includes associated objects, frozen record sequence numbers, and frozen record numbers; the information stored in Flash is frozen records. The associated objects frozen by the IoT table are stored in EE and refreshed to RAM after power-on. Therefore, the frozen associated objects are configurable.
[0047] The IoT table requires a lifespan of 16 years and a freeze type that freezes once every minute. Each freeze requires the storage of a freeze sequence number. Calculated based on 365 days in a year, 16 years requires 8,409,600 times of storage. However, the EE lifespan is about 1 million times, which is not enough. The 32-bit address is divided into the upper three bytes and the lower one byte. The upper three bytes of 8,409,600 times require a total of 32,850 times, which is far less than 1 million times. Therefore, only the lower 8 bytes need to be considered. This design uses the method of exchanging space for time, such as Figure 1 As shown, 13 blocks are allocated for the lower byte, and the specific storage location is obtained by taking the modulo 13 of the address of the upper three bytes. The frozen record numbers are continuous and monotonically increasing. The number of frozen records will no longer increase after reaching the maximum. The number of frozen records does not need to use the high-frequency write EE algorithm, and only needs ordinary four bytes for storage.
[0048] The frozen records stored in Flash are composed of Figure 2 As shown, each sector stores an integer number of m frozen records, that is, the frozen records do not cross sectors. When the remaining position of the sector is less than the length of one record, the record starts from the next sector, which reduces the write time and the probability of write failure. Moreover, the address of the frozen record can be easily located according to the number of frozen records stored in each sector. Since Flash is erased by sector, at least one sector is erased at a time. In order to meet the number of frozen records, one more sector is allocated, and a total of (n+1) sectors are allocated. Each frozen record includes the frozen sequence number, the frozen time, and the data corresponding to the frozen associated object. When storing data, the frozen time increases, but due to reasons such as time calibration and power failure, it may not be evenly spaced.
[0049] When deleting data (calibrating or clearing), only the frozen record number and the number of records are modified, and the file data does not need to be modified. When modifying the time or powering on, if the time is found to be rolled back, clear the data that is greater than the calibration time. Every time data is written to the Flash, if it is the sector start address, the entire sector will be erased before writing data.
[0050] The freezing time stored in the freezing record is the time interval from 0:0:0:0 on January 1, 2000, which compresses the amount of data that needs to be stored and facilitates binary search and comparison.
[0051] The data copying and reading part of the present invention is designed as follows:
[0052] According to the start time of the reading data, the interval of the periodic freeze, and the current time, the search range of the binary search is reduced; the binary search returns the start index of the search rather than the intermediate index, which meets the standard of the IoT table. When no data is found, a piece of data in the direction of increasing time is returned, while reducing the complexity of the algorithm.
[0053] The design of method 2 copy reading is as follows:
[0054] Search by freezing sequence number, read the time corresponding to the frozen record, compare it with the search time, and find the required data. The flowchart of method 2 is as follows Figure 3 As shown, searchStartTime is the interval in seconds between the start time of the search and 00:00 on January 1, 2000, searchEndTime is the interval in seconds between the end time of the search and 00:00 on January 1, 2000, startSN is the earliest frozen record number, endSN is the latest frozen record number + 1, searchStartSN is the search start index, searchEndSN is the search end index, readInterval is the read interval, planInterval is the frozen storage interval, searchTime is the search time, findTime is the found time, and findSN is the found index.
[0055] Step 1: Check the parameters.
[0056] If searchStartTime is 0, or searchEndTime is 0, or searchStartTime is greater than searchEndTime, 0 data items are returned.
[0057] Step 2: endSN is assigned the serial number of the frozen record in EE, and startSN is assigned the serial number of the frozen record - the number of frozen records. The serial number of the frozen record in EE is the latest frozen record serial number + 1.
[0058] Step 3: Assign searchTime to searchStartTime and searchEndSN to endSN
[0059] Step 4: Modify searchStartSN to reduce the binary search range.
[0060] Step 4.1: Calculate the maximum number of records from the search start time to the current time. Correct the search start index according to the following formula and calculate the earliest index corresponding to the search start time.
[0061] searchNum=(CurrMin-searchMin) / cycle+1;
[0062] CurrMin is the difference between the minute corresponding to the current time and 00:00:00 on January 1, 2000, searchMin is the search start time, that is, searchStartTime, cycle is the frozen storage interval, that is, planInterval, and searchNum is the maximum number of records from the search start time to the current time.
[0063] Step 4.2: The calculated maximum number of records must meet the following conditions before it can be used. If not, searchStartSN uses startSN, which is the earliest frozen record number, and step 4 ends here.
[0064] startSN+searchNum <endSN;
[0065] Where startSN is the earliest frozen record number, searchNum is the maximum number of records calculated in step 1, and endSN is the latest frozen record number + 1. This condition is intended to verify that the maximum number of records calculated theoretically actually exists.
[0066] Step 4.3: Calculate new searchStartSN; searchStartSN = endSN - searchNum
[0067] At this step, the search range of the binary search is successfully narrowed down, and the starting index of the binary search is narrowed down from startSN to endSN-searchNum.
[0068] Step 5: Search Algorithm:
[0069] Step 5.1: Correct the search time algorithm. If the search time (searchTime) is not an integer multiple of the reading time interval, correct the search time to an integer multiple of the reading time interval. If the corrected search time is greater than the search end time (searchEndTime), the entire search algorithm, i.e., step 5, ends.
[0070] Step 5.2: Use binary search to find the search time. The search range is from the search start index to the search end index - 1, and the searched index is returned. If the search time is found, the corresponding index is returned. If not found, the index corresponding to the next stored record of the search time is returned.
[0071] The binary method flow chart is as follows Figure 5 As shown, specifically including:
[0072] Step 5.2.1: Check the input parameters. If the start index of the binary search is greater than the end index, the end index + 1 is returned. At the same time, the exact match parameter returns the default value 1 to indicate that it is not an exact match.
[0073] Step 5.2.2: Determine whether the start index is less than or equal to the end index. If so, continue to execute. If not, go to step 5.2.6.
[0074] Step 5.2.3: Calculate the intermediate index, read the freezing record information corresponding to the intermediate index, and extract the freezing time information therefrom, which is hereinafter referred to as the intermediate index time.
[0075] Middle index = (start index + end index) / 2
[0076] Step 5.2.4: Compare intermediate indexing times to search times
[0077] (1) If the intermediate index time is less than the search time, the binary search starts at index + 1
[0078] (2) If the middle index time is equal to the search time, the start index is assigned to the middle index, the exact match parameter is set to 0, and go to step 5.2.6
[0079] (3) If the intermediate index time is greater than the search time, the binary search ends at index -1
[0080] Step 5.2.5: Repeat steps 5.2.2-5.2.4
[0081] Step 5.2.6: If the starting index is equal to the middle index, the frozen data in the temporary variable is directly used. If they are not equal, the frozen data corresponding to the starting index is re-read, and the starting index and the corresponding data are returned, and the binary search ends.
[0082] Step 5.3: Determine whether it is an exact match. If it is an exact match, encode the data into the communication return data area, and at the same time search the start index and adjust it to the next index of the binary search return index; if it is not an exact match, adjust the search start index to the index returned by the binary search.
[0083] Step 5.4: Parameter adjustment.
[0084] The search end index (searchEndSN) is assigned the search start index plus the read interval, and the calculation formula is as follows:
[0085] searchEndSN=searchStartSN+(readInterval+planInterval-1) / planInterval;
[0086] The search end index does not exceed the end index of the EE storage. If it exceeds, it is changed to the end index of the EE storage.
[0087] The corrected search start time is the freezing time of the data returned by the binary search method, the search time is the search start time, and the actual search time is obtained after correction in step 5.1.
[0088] Step 5.5: End condition judgment. Check whether the search start index is less than the end index (endSN) of the entire record. If not, step 5 ends. If satisfied, step 5 is executed repeatedly.
[0089] The design of method 1 copy reading is as follows:
[0090] Compared with method 2, method 1 only needs to find one piece of data. If it is found, it returns the data. If it is not found, it returns a piece of data in the direction of increasing time.
[0091] The flowchart of method 1 is as follows Figure 4 As shown in FIG. 1 , the steps of the entire algorithm are as follows, where startSN is the earliest frozen record number, endSN is the latest frozen record number + 1, searchStartSN is the search start index, readInterval is the reading interval, planInterval is the frozen storage interval, searchTime is the communication reading search time, findTime is the found time, and findSN is the found index.
[0092] Step 1: Check the parameters.
[0093] If searchTime is 0, 0 data items are returned.
[0094] Step 2: endSN is assigned the serial number of the frozen record in EE, and startSN is assigned the serial number of the frozen record - the number of frozen records. The serial number of the frozen record in EE is the latest frozen record serial number + 1.
[0095] Step 3: Modify searchStartSN to reduce the binary search range.
[0096] Step 3.1: Calculate the maximum number of records from the search start time to the current time. Correct the search start index according to the following formula and calculate the earliest index corresponding to the search start time.
[0097] searchNum=(CurrMin-searchMin) / cycle+1;
[0098] CurrMin is the difference between the minute corresponding to the current time and 00:00:00 on January 1, 2000, searchMin is the search start time, that is, searchStartTime, cycle is the frozen storage interval, that is, planInterval, and searchNum is the maximum number of records from the search start time to the current time.
[0099] Step 3.2: The calculated maximum number of records must meet the following conditions before it can be used. If not, searchStartSN uses startSN, which is the earliest frozen record number, and step 4 ends here.
[0100] startSN+searchNum <endSN
[0101] Where startSN is the earliest frozen record number, searchNum is the maximum number of records calculated in step 1, and endSN is the latest frozen record number + 1. This condition is intended to verify that the maximum number of records calculated theoretically actually exists.
[0102] Step 3.3: Calculate new searchStartSN
[0103] searchStartSN=endSN-searchNum
[0104] At this step, the search range of the binary search is successfully narrowed down, and the starting index of the binary search is narrowed down from startSN to endSN-searchNum.
[0105] Step 4: Binary Search Data
[0106] Binary search for search time. The search range is from the search start index to the end index - 1, that is, endSN-1, and the searched index is returned. If the search time is found, the corresponding index is returned. If it is not found, the index corresponding to the next storage record of the search time is returned. The binary search flow chart is as follows Figure 5 As shown, the dichotomy details are as follows:
[0107] Step 4.1: Check the input parameters. If the start index of the binary search is greater than the end index, the end index + 1 is returned. At the same time, the exact match parameter returns the default value 1 to indicate that it is not an exact match.
[0108] Step 4.2: Determine whether the start index is less than or equal to the end index. If so, continue to execute. If not, go to step 4.6
[0109] Step 4.3: Calculate the intermediate index, read the freezing record information corresponding to the intermediate index, and extract the freezing time information therefrom, which is hereinafter referred to as the intermediate index time.
[0110] Middle index = (start index + end index) / 2
[0111] Step 4.4: Compare the intermediate indexing time with the search time
[0112] (1) If the intermediate index time is less than the search time, the binary search starts at index + 1
[0113] (2) If the middle index time is equal to the search time, the start index is assigned to the middle index, the exact match parameter is set to 0, and go to step 4.6
[0114] (3) If the intermediate index time is greater than the search time, the binary search ends at index -1
[0115] Step 4.5: Repeat steps 4.2-4.4
[0116] Step 4.6: If the starting index is equal to the middle index, the frozen data in the temporary variable is directly used. If they are not equal, the frozen data corresponding to the starting index is re-read, and the starting index and the corresponding data are returned, and the binary search ends.
[0117] Step 5: Determine whether the return index is less than the EE end index endSN. If it is satisfied, the data is encoded into the communication return data area; if it is not satisfied, 0 data is returned.
[0118] The embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments.
Claims
1. A method for periodically freezing and quickly accessing an intelligent IoT electric energy meter, characterized in that: include: Obtaining a frozen associated object, a frozen record serial number and the number of frozen records, wherein the frozen associated object is stored in the electric energy meter EE, and the frozen record serial number is stored using a high-frequency writing EE algorithm; Obtain the freeze records stored in the electric energy meter Flash, each sector stores an integer number of freeze records, and a freeze record includes a freeze sequence number, a freeze time, and associated object data; According to the time parameters of the communication reading, it is determined whether the reading is data between two time points or data at a certain time point. If it is data between two time points, the binary search method is used to find the frozen record corresponding to the modified search time. If it is data at a certain time point, the binary search method is used to find the frozen record corresponding to the search time.
2. The method for periodically freezing and quickly accessing a smart IoT electric energy meter according to claim 1 is characterized in that: The 32-bit address is divided into three high bytes and one low byte, multiple storage spaces are allocated to the low byte, and the three high bytes are determined by taking the modulus of the storage space number according to the address to determine the specific storage location.
3. The method for periodically freezing and quickly accessing a smart IoT electric energy meter according to claim 1 is characterized in that: The step of obtaining the frozen records stored in the electric energy meter Flash includes: The freezing time is the time interval from the preset time, which compresses the storage space.
4. The method for periodically freezing and quickly accessing a smart IoT electric energy meter according to claim 1, characterized in that: The data between two time points include: Calculate the theoretical maximum number of frozen records, and modify the start index of the binary search according to the start time, current time, and freezing interval to narrow the search range.
5. The method for periodically freezing and quickly accessing a smart IoT electric energy meter according to claim 4 is characterized in that: The method of using the binary search method to search for frozen records corresponding to the modified search time includes: Modify the search time to an integer multiple of the interval according to the communication copying interval, and determine whether the modified search time is greater than the communication copying end time. If so, end the search.
6. The method for periodically freezing and quickly accessing a smart IoT electric energy meter according to claim 5 is characterized in that: The method of using the binary search method to search for the frozen record corresponding to the modified search time also includes: If there is an exact match, the data is encoded and the start index of the next search is updated. If there is no match, the start index of the next search is updated to the returned index.
7. The method for periodically freezing and quickly accessing a smart IoT electric energy meter according to claim 4, characterized in that: After the binary search method is used to find the frozen record corresponding to the modified search time, the method further includes: The binary search end index is updated according to the communication copying interval, and it is determined whether the search start index is less than the end index of the frozen record. If so, the above binary search steps are executed cyclically.
8. The method for periodically freezing and quickly accessing a smart IoT electric energy meter according to claim 1, characterized in that: If the data is data at a certain point in time, it includes: Calculate the theoretical maximum number of frozen records, and modify the start index of the binary search based on the start time, current time, and freezing interval to narrow the search range; Use binary search to find the frozen record corresponding to the search time. If found, encode the data. If not found, return the next data greater than the search time.
Citation Information
Cited By
Electric energy data transmission method and device, electric energy meter and storage medium
CN120892433A