Electric energy meter daily frozen data query method and device, intelligent electric energy meter and medium

By calculating the first interval value and setting termination query conditions, the daily frozen data query process of smart meters has been optimized, solving the problem of low query efficiency and realizing fast-response daily frozen data query.

CN121880374APending Publication Date: 2026-04-17SHENZHEN TECHRISE ELECTRONICS
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN TECHRISE ELECTRONICS
Filing Date
2025-12-08
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

In the process of querying daily frozen data of smart meters, existing technologies suffer from low query efficiency and excessively long response times, mainly due to frequent access to external memory caused by multiple interactions and redundant operations.

Method used

The query interval is determined by calculating the first interval value within the request start and end time intervals, and daily frozen records are searched within the query interval using a sequential query method. Termination conditions are set to reduce external storage access.

Benefits of technology

It improves query efficiency, reduces the number of external storage accesses, significantly improves the copying response rate, and shortens the response time to 90~398ms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121880374A_ABST
    Figure CN121880374A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data processing, in particular to an electric energy meter daily frozen data query method and device, an intelligent electric energy meter and a medium. When a query request is received, request starting time and request ending time are determined, and the first interval value of continuous interval values in two time intervals is calculated to determine a query interval; and sequentially querying the daily freezing records in the query interval, and terminating the query once the accessed timestamp exceeds the maximum value of the request range. According to the method, the access frequency of the external memory is reduced, redundant operation is avoided, and the query efficiency of the daily frozen data of the electric energy meter is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a method, apparatus, smart meter, and medium for querying daily frozen data of an electricity meter. Background Technology

[0002] Smart meters have a large amount of frozen data per day, which is usually stored in external memory FLASH or EEPROM. The main control chip usually reads data from the external memory via SPI. The data interaction process takes a lot of time, and multiple interactions may be required during the data query process, which will cause the frozen data query to take a lot of time, thus affecting the query response time.

[0003] The specific storage method for daily frozen data is as follows: 1) Each frozen record data storage content includes a timestamp. Frozen records are written sequentially into a circular cache according to the timestamp order and stored in external FLASH. 2) For each stored record, a "serial number" N (0, 1, 2, ...) is generated. 3) When power failure or time synchronization causes discontinuous timestamps, the timestamp may suddenly jump, but the serial number continues to increment. The query target is as follows: Using Selector2 in the record row selection descriptor RSD of DL / T 698.45, the input values ​​include the request start time Tst, the request end time Tend, and the request time interval TI (common request time intervals are 0 (no interval) or 1 day). The query requires the return of the number of consecutive interval values ​​n_rec within the interval [Tst, Tend), and then the return of consecutive interval values ​​within the interval [Tst, Tend). That is, the frozen time of each record should be an integer multiple of the read start time + read interval, and records with smaller timestamps are returned first. According to the data requirements of Selector2 in RSD of DL / T 698.45, the number of consecutive interval values ​​within the interval [Tst, Tend) should be returned first, and then the consecutive interval values ​​within the interval [Tst, Tend) should be returned. Therefore, the general query method is to first calculate and return the count n_rec, and then query and return the consecutive interval values ​​within the interval. Obviously, the existing technology has two problems: firstly, the process design is redundant, with many repetitive operations and extremely low query efficiency; secondly, the query algorithm is inefficient. Summary of the Invention

[0004] To overcome the shortcomings of the prior art, the present invention provides a method, device, smart meter and medium for querying daily frozen data of electricity meters, which reduces the number of times external FLASH is accessed, thereby improving the reading response rate of daily frozen data.

[0005] The first aspect of this application provides a method for querying daily frozen data of an electricity meter, the method comprising: When a query request is received, the start time and end time of the query request are determined. Calculate the first interval value among the consecutive interval values ​​within the interval between the request start time and the request end time; The query interval is determined based on the first interval value; The system uses a sequential query method to search for daily frozen records within the query range. The query is terminated when the timestamp of a daily frozen record exceeds the maximum value of the requested range. The system obtains the set of valid records and the total number of valid records, and outputs all valid daily frozen data.

[0006] In an optional implementation, before calculating the first interval value among consecutive interval values ​​within the interval between the request start time and the request end time, the method further includes: Determine the request interval time in the query request, the preset base time of the electricity meter, and the storage period of the electricity meter's daily frozen records; Convert the request start time and request end time into values ​​in seconds relative to the base time; Convert the request interval and the storage period into seconds.

[0007] In an optional implementation, calculating the first interval value among the consecutive interval values ​​within the interval between the request start time and the request end time includes: The smallest positive integer x is determined by the formula (tst_s + x * ti_s) mod (cycle_s) = 0; tst_s is the start time of the request to convert to seconds, ti_s is the interval time of the request to convert to seconds, and cycle_s is the storage cycle of the conversion to seconds. Substituting the smallest positive integer x into the formula Tf_s=tst_s+x*ti_s, we obtain the first interval value that is aligned with the storage period within the interval between the request start time and the request end time; Tf_s is the first interval value.

[0008] In an optional implementation, determining the query interval based on the first interval value includes: Construct an ascending-order sorted time series array T_array[0...n-1] based on the daily freeze record timestamps; The theoretical query interval range is determined by using the array index corresponding to the first interval value as the starting boundary and the upper limit of the array index as the ending boundary; The first interval value is located in the sequentially stored daily frozen records using a binary search. When the first interval value is found, the query interval is set according to the array index corresponding to the first interval value and the upper limit of the array index; If the first interval value cannot be found, then the smallest timestamp in the ordered time series array that is not less than the first interval value is selected, and the query interval is set according to the array index corresponding to the smallest timestamp and the upper limit of the array index.

[0009] In an optional implementation, the daily frozen records are queried within the query interval using a sequential query method. The query terminates when the timestamp of a daily frozen record exceeds the maximum value of the requested range, resulting in a set of valid records and a total number of valid records. All valid daily frozen data is output, including: The query pointer pos is initialized based on the query interval and is set to the array index corresponding to the first interval value. Construct the target record formula, where the timestamp of the target record satisfies T_array[pos] = tst_s + x*ti_s, where x is any positive integer. The target record formula is transformed into (T_array[pos] - tst_s) mod (ti_s) = 0; The query interval starts from the daily frozen records sequentially, and the timestamp of the frozen records is compared to determine whether the target record meets the target record formula. If the target record formula is satisfied, the record is added to the memory buffer; If the target record formula is not met, skip it; After each access to a daily frozen record, check whether the timestamp of the currently accessed record exceeds the maximum value of the requested range; The query is terminated when the timestamp of the currently accessed record exceeds the maximum value of the requested range, and the valid record set is obtained.

[0010] In an optional implementation, the method further includes: Based on the set of valid records in the memory cache, calculate the total number of valid daily frozen data records that meet the query conditions in the memory cache; The total number of records and all valid daily frozen data in the memory cache are returned to the query terminal, and the memory cache is cleared to release resources.

[0011] A second aspect of this application provides a device for querying daily frozen data of an electricity meter, the device comprising: The receiving module is used to determine the request start time and request end time in the query request when it receives a query request; The calculation module is used to calculate the first interval value among the consecutive interval values ​​within the interval between the request start time and the request end time; The determination module is used to determine the query interval based on the first interval value; The query module is used to query daily frozen records within the query range using a sequential query method. When the timestamp of the accessed daily frozen record exceeds the maximum value of the requested range, the query is terminated, and the set of valid records and the total number of valid records are obtained. All valid daily frozen data are then output.

[0012] A third aspect of this application provides a smart energy meter, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the daily frozen data query method for the energy meter.

[0013] A fourth aspect of this application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the above-described method for querying daily frozen data of an electricity meter.

[0014] In summary, the method, apparatus, smart meter, and medium for querying daily frozen data of electricity meters provided in this application, upon receiving a query request, directly determine the request start time and request end time, calculate the first interval value among the continuous interval values ​​within the interval, and determine the query interval based on the first interval value. Then, the query is performed within this query interval. The query terminates when the timestamp of the accessed daily frozen record exceeds the maximum value of the requested range, and all valid daily frozen data are output. This combines the two steps of counting and data querying, allowing the number of records meeting the conditions to be determined during the data query process, avoiding repeated access and data processing, simplifying the query process, and improving query efficiency. Furthermore, determining the query interval by calculating the first interval value makes the query range more accurate, avoiding queries in invalid data areas and reducing the amount of data that needs to be accessed. The query termination condition, which immediately terminates the query when the timestamp of the accessed daily frozen record exceeds the maximum value of the requested range, avoids unnecessary access to external memory and further improves query efficiency. Attached Figure Description

[0015] Figure 1 This is a flowchart illustrating a method for querying daily frozen data of an electricity meter, as shown in an embodiment of this application. Figure 2 This is a schematic diagram illustrating a process of searching using a binary search method in daily frozen records based on sequential storage, as shown in an embodiment of this application. Figure 3 This is a schematic diagram illustrating a data cache counting process according to an embodiment of this application; Figure 4 This is a functional block diagram of a daily frozen data query device for an electricity meter, as shown in an embodiment of this application. Figure 5 This is a schematic diagram of the structure of a smart energy meter shown in an embodiment of this application. Detailed Implementation

[0016] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0017] The following will clearly and completely describe the concept, specific structure, and technical effects of the present invention in conjunction with embodiments and accompanying drawings, so as to fully understand the purpose, features, and effects of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of them. Other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are all within the scope of protection of the present invention. Furthermore, all connections / linkages involved in the patent do not simply refer to direct contact between components, but rather to the ability to form a better connection structure by adding or reducing connecting accessories according to specific implementation conditions. The various technical features in this invention can be combined interactively without contradicting each other.

[0018] In the existing technology, according to the data requirements returned by Selector2 in RSD of DL / T 698.45, it is necessary to first return the number of consecutive interval values ​​within the interval [Tst, Tend), and then return the consecutive interval values ​​within the interval [Tst, Tend). Therefore, the general query method is to first calculate and return the number of records n_rec, and then query and return the consecutive interval values ​​within the interval. The specific steps are as follows: Step 1: Count the number of valid consecutive interval values ​​n_rec within the interval [Tst, Tend).

[0019] The records in the external FLASH are accessed sequentially using a sequential query method: n_rec is initially 0. Records with smaller timestamps are accessed first, followed by records with larger timestamps. If the accessed record time conforms to the formula (n is any integer) Tq=Tst+n*TI, the record count n_rec is incremented by 1. After traversing all frozen records, n_rec is returned.

[0020] Step 2: Query and extract the consecutive interval values ​​within the range [Tst, Tend).

[0021] The system uses a sequential query method to access records in the external FLASH memory one by one. Records with smaller timestamps are accessed first, followed by records with larger timestamps. If the accessed record time matches the formula (n is any integer) Tq=Tst+n*TI, then the record is returned. The query ends after all frozen records have been traversed.

[0022] As can be seen, the external FLASH contains a large number of records, and a single traversal requires a large number of FLASH read / write operations and conditional judgment operations. Due to the need to meet the constraints of the DL / T 698.45 protocol, two complete traversals are required (step 1: counting + step 2: data extraction), which is equivalent to scanning all records twice, prolonging the query time. Secondly, the sequential search method has a time complexity of O(n). When the query target is the last record, all frozen records need to be accessed before returning, which means n interactions with the external FLASH are required, resulting in a significant time consumption during the query process and reducing the response rate of the copying process. Using this method, the response time for copying a single record is in the range of 905~1715ms (see Table 1 below), and the overall effect is a response time in the range of 905~4875ms (see Tables 1~3 below). Table 1 shows the existing technology for copying one frozen data record (unit: ms); Table 2 shows the existing technology for copying multiple frozen data records (unit: ms); Table 3 shows the existing technology for copying error response response time (unit: ms).

[0023] Table 1:

[0024] Table 2:

[0025] Table 3:

[0026] As can be seen, the number of data entries copied from Tables 1 to 3 is different, and the more data entries copied, the longer the response time.

[0027] The following explains how to query daily frozen data from smart meters. (Refer to...) Figure 1 The diagram shown is a flowchart illustrating a method for querying daily frozen data of an electricity meter according to an embodiment of this application. The method includes the following steps.

[0028] S11, When a query request is received, determine the request start time and request end time in the query request.

[0029] When a smart meter receives a query request sent by a user through a query terminal, it can determine the request start time (Tst) and end time (Tend) contained in the query request. For example, the request start time Tst = 2025-01-01 00:00:00 and the request end time Tend = 2025-01-05 23:59:59.

[0030] In an optional implementation, before calculating the first interval value among consecutive interval values ​​within the interval between the request start time and the request end time, the method further includes: Determine the request interval time in the query request, the preset base time of the electricity meter, and the storage period of the electricity meter's daily frozen records; Convert the request start time and request end time into values ​​in seconds relative to the base time; Convert the request interval and the storage period into seconds.

[0031] In computer systems, integer operations are generally much faster than complex date and time calculations (such as conversions involving years, months, and days). Converting time to seconds simplifies all time calculations to simple integer addition, subtraction, multiplication, and division. For example, calculating the interval between two frozen record timestamps can be done by simply subtracting the number of seconds, without needing to consider differences in the number of days in different months or leap years. Therefore, in this embodiment, the time of the frozen records is converted to seconds for storage.

[0032] The freeze start time is determined using the base time (base_time), which is pre-set within the electricity meter. This base time is a fixed time reference point, uniformly used within the meter, set to January 1, 2000, 00:00:00 UTC+0. It is used to convert all time parameters to relative second values, eliminating the impact of time zone and leap second differences on calculations. Using a fixed base time is a common time normalization method in the power industry (e.g., the time stamp base in the DL / T 645-2007 protocol is 2000). The request interval (TI) is explicitly specified by the requesting party (e.g., the master station system or user terminal) based on business needs. For example: TI = 1 day for daily data queries; TI = 1 hour for hourly data queries; TI = 0 days for continuous data queries (indicating no interval). The storage period is pre-set by the electricity meter according to the freeze task configuration. For example: daily freeze task: cycle = 1 day; monthly freeze task: cycle = 1 month; custom freeze task: cycle is configured by the user. In this embodiment of the application, the unit of the request time interval is set to days, and the unit of the storage period of the frozen record is also set to days, that is, TI=1 day, cycle=1 day.

[0033] The freeze point time Ta satisfies the formula: Ta = base_time + k * cycle, where k is any positive integer. The storage cycle, converted to seconds, is cycle_s = cycle * 86400. Converting the freeze point time Ta to a time relative to base_time and then to seconds, we get: Ta_s=Ta-base_time=(base_time+k*cycle)-base_time=k*cycle.

[0034] For example, assuming the cycle is 6 days and Ta is 0:00 on February 6, 2000, then Tb = 0:00 on February 6, 2000 - 0:00 on January 1, 2000 = 0:00 on February 6, 2000 = 36 days = 3110400 seconds.

[0035] Next, the request start time Tst, request end time Tend, and request time interval TI are converted into seconds. Specifically, following the same implementation method as converting the frozen record time into seconds for storage, the request start time Tst and request end time Tend are converted into second values ​​relative to base_time, and the converted values ​​are represented by tst_s and tend_s. The request time interval TI is in days, and its conversion to seconds is ti_s = TI * 86400.

[0036] S12, calculate the first interval value among the consecutive interval values ​​within the interval between the request start time and the request end time.

[0037] Once the request start time Tst and request end time Tend are determined, the interval [Tst, Tend) can be determined. The continuous interval value Tq within the interval [Tst, Tend) can be converted into seconds and represented as Tq_s = tst_s + x * ti_s (where x is any positive integer).

[0038] After standardization based on time parameters, the following values ​​are obtained: request start time (tst_s), request time interval (ti_s), and storage cycle (cycle_s). The request start time and request end time interval, i.e., the first interval value Tf_s within the interval [Tst, Tend), are determined as follows: Based on the principle of time alignment, congruence equations are constructed: (tst_s+x*ti_s)mod(cycle_s)=0; Where x is the smallest positive integer to be solved, representing the xth time point starting from the request start time tst_s and increasing by the request interval ti_s, which is aligned with an integer multiple of the storage cycle_s; The smallest positive integer x that satisfies the above congruence equation is found using an incremental traversal method, specifically including: Starting with x=0, the algorithm iterates sequentially by positive integers, with a maximum number of iterations per cycle, until it finds the smallest positive integer x that satisfies (tst_s + x×ti_s) mod (cycle_s) = 0. If, after iterations of cycle_s, no smallest positive integer x satisfying (tst_s + x×ti_s) mod (cycle_s) = 0 is found (i.e., the equation has no solution), an error code is returned, and the search for the target day's frozen records is stopped.

[0039] Substitute the smallest positive integer x obtained from the solution into the following formula: Tf_s = tst_s + x * ti_s; The first second value Tf_s that is aligned with the storage cycle within the interval [Tst, Tend) is obtained, which is also the first interval value Tf_s.

[0040] S13, determine the query interval based on the first interval value.

[0041] Since the daily frozen data is stored in ordered order according to the freezing time, the timestamps of all frozen records are arranged in ascending order, forming an ordered time series array T_array[0...n-1]. The smart meter can use a binary search method to retrieve the first interval value Tf_s in the ordered time series array T_array[0...n-1], whose corresponding array index is n_start. The time complexity of retrieving Tf_s is O(log n). Once Tf_s is retrieved, the query interval of the array index is located, i.e., the query interval is [n_start, n - 1]. The purpose of locating the query interval [n_start, n - 1] is to narrow the query range, so that subsequent data retrieval does not require obtaining all stored frozen records, thus reducing the access frequency of external storage FLASH.

[0042] Specifically, refer to Figure 2 After calculating the first interval value Tf_s, a binary search is used to find Tf_s in the ordered time series array T_array[0...n-1]. First, the left boundary of the binary search is initialized to left=0 and the right boundary to right=n-1. The following steps are repeated until left>right: Calculate the intermediate index mid = (left + right) / 2; If T_array[mid] == Tf_s, then locate the record directly and set the query range to [Tf_s, Tmax_s]; If T_array[mid] < Tf_s, then adjust the left boundary left = mid + 1; If T_array[mid] > Tf_s, then adjust the right boundary right = mid - 1; If no record corresponding to Tf_s is found after the binary search, then the smallest timestamp T_next that meets the conditions is selected from the ordered time series array, where T_next satisfies: T_next=min{T∈T_array∣T≥Tf_s}; Update the actual starting boundary n_start of the query interval to the index corresponding to T_next, keep the ending boundary n-1, and output the final query interval as [n_start, n-1].

[0043] Furthermore, the located query interval [n_start, n - 1] is used to extract the target day's frozen records within this query interval.

[0044] By using the ascending order of the timestamps of the daily frozen records, the time complexity is reduced from O(n) to O(log n) through binary search, avoiding full table scans and reducing the frequency of FLASH storage access; when Tf_s does not exist, T_next is filtered to ensure that the query range covers valid data, enhancing the robustness of the technical solution.

[0045] S14. Use sequential query to query daily frozen records within the query range. Terminate the query when the timestamp of a daily frozen record exceeds the maximum value of the requested range. Obtain the set of valid records and the total number of valid records, and output all valid daily frozen data.

[0046] Once the query range is determined, the maximum time value in seconds within the requested range, Tend, is determined based on the user's requested query range. This maximum value defines the upper limit of the valid time range for the query. For example, if the query requests daily frozen records within a certain period, Tend_s is the time value in seconds corresponding to the end point of the requested time range. Where Tend ≤ T_array[n - 1], the current query pointer pos = n_start is initialized to point to the first record within the query range [n_start, n - 1].

[0047] The query target is a continuous interval value within the interval [Tst, Tend). The timestamp of the target record satisfies the formula T_array[pos] = tst_s + x * ti_s, where x is any positive integer. The formula for the target record is transformed into (T_array[pos] - tst_s) mod (ti_s) = 0. Since the frozen records are stored in ascending order of timestamp, the request time interval is usually 0 (no interval) or 1 day (that is, the query target is usually continuous). Within the query interval [n_start, n - 1], the timestamp T_array[pos] of each frozen record is accessed in the order of storage. In this way, each access to the first data satisfies the target formula, that is, the required record can be found in one query. The time complexity is O(1), that is, the target record can be found in one access to the external FLASH, which greatly improves the query speed. The timestamp of the currently accessed record is compared with the value in the target time second value sequence: 1) If the timestamp is greater than the maximum value Tend in the interval [Tst, Tend), it is considered to be outside the current target range, and the query is terminated.

[0048] 2) If the timestamp satisfies the target formula, that is, a target record has been found, add the target record data to the memory buffer buf.

[0049] 3) If the timestamp does not meet the target formula, continue to the next record.

[0050] Once a matching target record is successfully located and output, continue querying the next target record.

[0051] After the query is terminated, the set of valid records is obtained in the memory buffer buf. After the query is terminated, the total number of valid records n_rec is added to buf, and then the data in buf is output.

[0052] By efficiently performing sequential queries of daily frozen records within the query range and promptly ending the query when the termination condition is met, valid query results are output, while reducing unnecessary external FLASH accesses.

[0053] In an optional implementation, the method further includes: Based on the set of valid records in the memory cache, calculate the total number of valid daily frozen data records that meet the query conditions in the memory cache; The total number of records and all valid daily frozen data in the memory cache are returned to the query terminal, and the memory cache is cleared to release resources.

[0054] Reference Figure 3In some embodiments, the smart meter defines a buffer `buf` to cache daily frozen records that meet the query criteria. Simultaneously, a target record count `n_rec` is defined and initialized to 0; this variable records the total number of records that meet the query criteria. Additionally, a variable `pos` is defined and initialized to the sequence number `n_start` corresponding to `Tf_s`; `pos` will serve as a query pointer for traversing the frozen records. Then, `n - 1` is set as the upper limit of the array index for this query.

[0055] During the loop query, check if pos is less than or equal to n - 1. If pos is greater than n - 1, it means the query sequence number range has been exceeded, and the loop ends. If pos is less than or equal to n - 1, then perform the following operations: Check if T_array[pos] is less than Tend_s (the value in seconds corresponding to the request end time). If T_array[pos] is greater than or equal to Tend_s, it means that the record has exceeded the requested time range. Since the records are stored in ascending order of time, subsequent records will inevitably also exceed the range, so the query is terminated.

[0056] If T_array[pos] is less than Tend_s, further check whether T_array[pos] satisfies the target formula (T_array[pos] - tst_s) mod (ti_s) = 0. If the formula is satisfied, it means that the record meets the query conditions, the record is added to the buffer buf, and the total number of target records n_rec is incremented by 1.

[0057] Regardless of whether the record conforms to the formula (T_array[pos] - tst_s) mod (ti_s) = 0, i will be incremented by 1, and the query will continue to the next record.

[0058] After caching records that meet the copying range, the total number of valid daily frozen records, n_rec, is calculated based on the set of valid records in the memory cache. The total number of records, n_rec, and all valid daily frozen records in the memory cache are then returned to the query terminal. Finally, the memory cache, buf, is cleared to release memory resources and avoid excessive memory usage affecting system performance.

[0059] Through the above optional implementation methods, in the process of querying daily frozen data of electricity meters, sequential query is adopted and a termination query condition is added. At the same time, data caching is used for counting, which effectively reduces the access frequency of external storage FLASH, improves query efficiency, and accurately returns query results.

[0060] This application significantly improves the copying response rate by reducing the number of accesses to external FLASH. Experimental data shows that the response time for copying a single record is optimized to 90~116ms (see Table 4 below), and the overall response time is shortened to 90~398ms (see Tables 4~6 below), improving system efficiency and user experience. Table 4 shows the copying of one frozen data record in this application embodiment (unit: ms); Table 5 shows the copying of multiple frozen data records in this application embodiment (unit: ms); Table 6 shows the error response time for copying in this application embodiment (unit: ms).

[0061] Table 4:

[0062] Table 5:

[0063] Table 6:

[0064] The experimental data above demonstrates the significant benefits of this application in querying daily frozen records of electricity meters. In terms of product performance, when reading daily frozen records using the DLT698 protocol Selector2, the response time is controlled within the range of 90ms to 398ms, which is 152ms or more faster than the expected target of 500ms, significantly improving reading efficiency. Regarding data security, the improved reading response rate effectively reduces communication time, lowers the probability of interference during communication, ensures data security, and thus improves the main station's call rate. In terms of economic benefits, the State Grid 2024 functional specification draft requires a communication response time of less than 500ms. This solution anticipates and successfully implements this requirement, shortening the product development cycle and helping to gain an advantage in fierce market competition. In terms of social benefits, the improved response time for daily frozen record data ensures the accurate exchange of electricity data at the agreed time, maintains the fairness and transparency of electricity transactions, and effectively reduces electricity disputes.

[0065] This application, when reading daily frozen records, ensures that the chip's operating frequency remains constant to guarantee reliability and that the storage scheme remains unchanged. It utilizes a unified time sheet to facilitate the calculation of the first interval value among consecutive intervals within the [Tst, Tend) range. Combined with a binary search method, it quickly locates the query interval. Furthermore, by employing data caching for counting, it reduces the number of traversals and accesses to external FLASH memory, thereby improving the response rate for reading daily frozen records. This application is not only applicable to daily frozen records but also to other periodic frozen records. It can be applied to various table types, including State Grid tables, Southern Power Grid tables, and overseas tables, demonstrating strong adaptability and universality.

[0066] Reference Figure 4The diagram shown is a functional block diagram of a daily frozen data query device for electricity meters, as illustrated in an embodiment of this application.

[0067] In some embodiments, the daily frozen data query device 40 for electricity meters may include multiple functional modules composed of computer program segments. The computer programs for each program segment of the daily frozen data query device 40 may be stored in the memory of the smart meter and executed by at least one processor to perform (see details). Figure 1 (Description) This application describes the function of querying daily frozen data from an electricity meter. Based on its function, it can be divided into multiple functional modules. These modules may include: a receiving module 401, a calculation module 402, a determining module 403, and a query module 404. The term "module" in this application refers to a series of computer program segments that can be executed by at least one processor and perform a fixed function, stored in memory. In this embodiment, the functions of each module will be detailed in subsequent embodiments.

[0068] The receiving module 401 is used to determine the request start time and request end time in the query request when a query request is received.

[0069] The calculation module 402 is used to calculate the first interval value among the consecutive interval values ​​within the interval between the request start time and the request end time.

[0070] The determining module 403 is used to determine the query interval based on the first interval value.

[0071] The query module 404 is used to query daily frozen records within the query interval using a sequential query method. When the timestamp of the accessed daily frozen record exceeds the maximum value of the requested range, the query is terminated, and the set of valid records and the total number of valid records are obtained. All valid daily frozen data are then output.

[0072] The determining module 403 is further configured to: determine the request interval time, the preset reference time of the electricity meter, and the storage period of the electricity meter's daily frozen records in the query request; convert the request start time and the request end time into seconds relative to the reference time; and convert the request interval time and the storage period into seconds.

[0073] The calculation module 402 is further specifically used to: solve for the smallest positive integer x according to the formula (tst_s+x*ti_s)mod (cycle_s) =0; tst_s is the request start time converted to a second value, ti_s is the request interval time converted to a second value, and cycle_s is the storage cycle converted to a second value; substitute the smallest positive integer x into the formula Tf_s=tst_s+x*ti_s to obtain the first interval value that is aligned with the storage cycle within the interval between the request start time and the request end time; Tf_s is the first interval value.

[0074] The determining module 403 is further specifically used for: constructing an ascending-order time series array T_array[0...n-1] based on the daily frozen record timestamps; determining the theoretical query interval range using the array index corresponding to the first interval value as the starting boundary and the upper limit of the array index as the ending boundary; locating the first interval value in the sequentially stored daily frozen records using binary search; when the first interval value is found, setting the query interval based on the array index corresponding to the first interval value and the upper limit of the array index; when the first interval value is not found, filtering the smallest timestamp in the ordered time series array that is not less than the first interval value, and setting the query interval based on the array index corresponding to the smallest timestamp and the upper limit of the array index.

[0075] The query module 404 is further specifically used for: initializing the query pointer pos based on the query interval as the array index corresponding to the first interval value; constructing a target record formula, wherein the timestamp of the target record satisfies T_array[pos] = tst_s + x*ti_s, where x is any positive integer, and the target record formula is transformed into (T_array[pos] - tst_s) mod(ti_s) = 0; sequentially accessing daily frozen records at the starting position of the query interval, and locating whether the target record satisfies the target record formula by comparing the timestamp of the frozen records; if the target record formula is satisfied, the record is added to the memory buffer; if the target record formula is not satisfied, it is skipped; after each access to a daily frozen record, checking whether the timestamp of the currently accessed record exceeds the maximum value of the requested range; when the timestamp of the currently accessed record exceeds the maximum value of the requested range, the query is terminated, and the valid record set is obtained.

[0076] The query module 404 is further configured to: calculate the total number of valid daily frozen data records that meet the query conditions in the memory cache based on the set of valid records in the memory cache; return the total number of records and all valid daily frozen data in the memory cache to the query terminal, and clear the memory cache to release resources.

[0077] It should be understood that the various variations and specific embodiments of the electricity meter daily frozen data query method provided in the above embodiments are also applicable to the electricity meter daily frozen data query device of this embodiment. Through the foregoing detailed description of the electricity meter daily frozen data query method, those skilled in the art can clearly understand the implementation method of the electricity meter daily frozen data query device of this embodiment. For the sake of brevity, it will not be described in detail here.

[0078] See Figure 5 The diagram shown is a schematic representation of the structure of a smart energy meter according to an embodiment of this application. In a preferred embodiment of this application, the smart energy meter 5 includes a memory 51, at least one processor 52, and at least one communication bus 53.

[0079] Those skilled in the art should understand that Figure 5 The structure of the smart energy meter shown does not constitute a limitation of the embodiments of this application. It can be a bus structure or a star structure. The smart energy meter 5 may also include more or fewer other hardware or software than shown, or different component arrangements.

[0080] In some embodiments, the smart energy meter 5 is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions. Its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits, programmable gate arrays, digital processors, and embedded devices. The smart energy meter 5 may also include user equipment, which includes, but is not limited to, any electronic product capable of human-computer interaction with the user via a keyboard, mouse, remote control, touchpad, or voice control device, such as a personal computer, tablet computer, smartphone, or digital camera.

[0081] In the embodiments provided in this application, it should be understood that the disclosed methods, apparatus, computer-readable storage media, and smart meters can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple components or modules may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings or direct couplings or communication connections may be through some interfaces; indirect couplings or communication connections between devices, components, or modules may be electrical, mechanical, or other forms.

[0082] The components described as separate parts may or may not be physically separate. The components shown as components may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the components can be selected to achieve the purpose of this embodiment according to actual needs.

[0083] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each component can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.

[0084] If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0085] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the present invention is not limited to the described order of actions, because according to the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to the present invention.

[0086] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0087] The above is a detailed description of the preferred embodiments of the present invention. However, the present invention is not limited to the embodiments described. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the present invention. All such equivalent modifications or substitutions are included within the scope defined by the claims of this application.

Claims

1. A method for querying daily frozen data of an electricity meter, characterized in that, The method includes: When a query request is received, the start time and end time of the query request are determined. Calculate the first interval value among the consecutive interval values ​​within the interval between the request start time and the request end time; The query interval is determined based on the first interval value; The system uses a sequential query method to search for daily frozen records within the query range. The query is terminated when the timestamp of a daily frozen record exceeds the maximum value of the requested range. The system obtains the set of valid records and the total number of valid records, and outputs all valid daily frozen data.

2. The method for querying daily frozen data of an electricity meter according to claim 1, characterized in that, Before calculating the first interval value among consecutive interval values ​​within the interval between the request start time and the request end time, the method further includes: Determine the request interval time in the query request, the preset base time of the electricity meter, and the storage period of the electricity meter's daily frozen records; Convert the request start time and request end time into values ​​in seconds relative to the base time; Convert the request interval and the storage period into seconds.

3. The method for querying daily frozen data of an electricity meter according to claim 2, characterized in that, The calculation of the first interval value among the consecutive interval values ​​within the interval between the request start time and the request end time includes: The smallest positive integer x is determined by the formula (tst_s + x * ti_s) mod (cycle_s) = 0; tst_s is the start time of the request to convert to seconds, ti_s is the interval time of the request to convert to seconds, and cycle_s is the storage cycle of the conversion to seconds. Substituting the smallest positive integer x into the formula Tf_s=tst_s+x*ti_s, we obtain the first interval value that is aligned with the storage period within the interval between the request start time and the request end time; Tf_s is the first interval value.

4. The method for querying daily frozen data of an electricity meter according to claim 3, characterized in that, Determining the query interval based on the first interval value includes: Construct an ascending-order sorted time series array T_array[0...n-1] based on the daily freeze record timestamps; The theoretical query interval range is determined by using the array index corresponding to the first interval value as the starting boundary and the upper limit of the array index as the ending boundary; The first interval value is located in the sequentially stored daily frozen records using a binary search. When the first interval value is found, the query interval is set according to the array index corresponding to the first interval value and the upper limit of the array index; If the first interval value cannot be found, then the smallest timestamp in the ordered time series array that is not less than the first interval value is selected, and the query interval is set according to the array index corresponding to the smallest timestamp and the upper limit of the array index.

5. The method for querying daily frozen data of an electricity meter according to claim 1, characterized in that, The method employs a sequential query to search for daily frozen records within the query interval. The query terminates when the timestamp of a found daily frozen record exceeds the maximum value of the requested range. This yields a set of valid records and the total number of valid records. All valid daily frozen data is output, including: The query pointer pos is initialized based on the query interval and is set to the array index corresponding to the first interval value. Construct the target record formula, where the timestamp of the target record satisfies T_array[pos] = tst_s + x*ti_s, where x is any positive integer. The target record formula is transformed into (T_array[pos] - tst_s) mod (ti_s) = 0; The query interval starts from the daily frozen records sequentially, and the timestamp of the frozen records is compared to determine whether the target record meets the target record formula. If the target record formula is satisfied, the record is added to the memory buffer; If the target record formula is not met, skip it; After each access to a daily frozen record, check whether the timestamp of the currently accessed record exceeds the maximum value of the requested range; The query is terminated when the timestamp of the currently accessed record exceeds the maximum value of the requested range, and the valid record set is obtained.

6. The method for querying daily frozen data of an electricity meter according to claim 5, characterized in that, The method further includes: Based on the set of valid records in the memory cache, calculate the total number of valid daily frozen data records that meet the query conditions in the memory cache; The total number of records and all valid daily frozen data in the memory cache are returned to the query terminal, and the memory cache is cleared to release resources.

7. A device for querying daily frozen data of an electricity meter, characterized in that, The device includes: The receiving module is used to determine the request start time and request end time in the query request when it receives a query request; The calculation module is used to calculate the first interval value among the consecutive interval values ​​within the interval between the request start time and the request end time; The determination module is used to determine the query interval based on the first interval value; The query module is used to query daily frozen records within the query range using a sequential query method. When the timestamp of the accessed daily frozen record exceeds the maximum value of the requested range, the query is terminated, and the set of valid records and the total number of valid records are obtained. All valid daily frozen data are then output.

8. A smart energy meter, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method for querying daily frozen data of an electricity meter as described in any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the daily frozen data query method for electricity meters as described in any one of claims 1 to 6.