CN112965919A - Electric energy meter data minute freezing method, storage medium and equipment - Google Patents

Electric energy meter data minute freezing method, storage medium and equipment Download PDF

Info

Publication number
CN112965919A
CN112965919A CN202110312110.1A CN202110312110A CN112965919A CN 112965919 A CN112965919 A CN 112965919A CN 202110312110 A CN202110312110 A CN 202110312110A CN 112965919 A CN112965919 A CN 112965919A
Authority
CN
China
Prior art keywords
data
freezing
minute
storage block
electric energy
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110312110.1A
Other languages
Chinese (zh)
Other versions
CN112965919B (en
Inventor
郑锦泽
黄旭钧
黄卫明
王蕾
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Friendcom Technology Co Ltd
Original Assignee
Shenzhen Friendcom Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Friendcom Technology Co Ltd filed Critical Shenzhen Friendcom Technology Co Ltd
Priority to CN202110312110.1A priority Critical patent/CN112965919B/en
Publication of CN112965919A publication Critical patent/CN112965919A/en
Application granted granted Critical
Publication of CN112965919B publication Critical patent/CN112965919B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1004Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/72Details relating to flash memory management
    • G06F2212/7202Allocation control and policies
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Quality & Reliability (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

The invention discloses a method, a storage medium and equipment for freezing data of an electric energy meter in minutes, relates to the technical field of electric power metering equipment, and solves the technical problems that time consumption is long and storage space is not fully utilized when data are frozen in the prior art. The method comprises the following steps: initializing a minute freezing index table; reading freezing parameter information of n-minute freezing schemes from a specified address; dynamically allocating m memory blocks for each minute freeze scenario; erasing part of data of the ith storage block; the data of the ith memory block is frozen. The invention also provides a single-phase electric energy meter minute freezing storage medium and equipment. The invention greatly improves the operation efficiency of the electric energy meter and simultaneously greatly optimizes the storage space of the FLASH.

Description

Electric energy meter data minute freezing method, storage medium and equipment
Technical Field
The invention relates to the technical field of electric power metering equipment, in particular to a method, a storage medium and equipment for freezing data of an electric energy meter in minutes.
Background
The electric energy meter is one of basic devices for power grid data acquisition, bears the tasks of electric energy data acquisition, metering and transmission, and is the basis for realizing information integration, analysis optimization and information display. The fixed periodic freezing is an important function of the single-phase electric energy meter, the freezing refers to the operation of storing important data at a specific moment, the fixed periodic freezing principle is shown in fig. 1, the count is accumulated once every time the data is stored, when the stored data area reaches the distribution maximum value, the storage address returns to the initial address, the stored data covers the previous data, and the serial number count is continuously accumulated unless the data is reinitialized. And when the data is read, the data of the maximum count is taken, and the data is updated. As shown in fig. 2, for example, assuming that data is divided into 13 regions of equal size by regions, each small box represents one data, and the number in the box represents a count, after the data is stored in a loop, the count of the data is updated as shown in the figure, and data with sequence number 14 should be taken during reading. The fixed periodic freezing includes minute freezing, integral freezing and day freezing, wherein the data stored by the minute freezing is called load recording. In the process of the minute freezing storage, a user selects an object method operation through an upper computer, adds a required minute freezing object attribute, configures a freezing period, an associated object attribute descriptor and a storage depth, and stores related data of the associated object attribute descriptor into a FLASH with an address allocated by software when the freezing period comes after the operation is executed.
A minute frozen data point is composed of a time mark, a flag bit and data, generally, the time mark length is 4 bytes, the flag bit length is 1 byte, the data length is dynamically changed in principle, in order to meet the length of different data types, the data length is defined as 10 bytes, and the length of a minute frozen data point is 15 bytes (4+1+10 equals to 15). According to the requirements of the latest national network technical specification, the storage space of the load record of the single-phase electric energy meter is guaranteed to store at least 300 days of frozen data volume under the condition that a minute freezing scheme is set to be 15 minutes, namely 28800 minute freezing data points (300 × 60/15) × 24 ═ 28800), and after calculation, 28800 data points of one minute freezing scheme occupy more than 0.4M of storage space (28800 (15Byte/1024)/1024 ≈ 0.412M), in order to match any minute freezing scheme configured at any time by a user and meet the condition that the scheme can store 28800 minute freezing data points, the prior art tends to allocate more than 8 spaces of 0.412M to FLASH for storing minute freezing data, and when a zero clearing event occurs, the storage space of the 8 freezing schemes is waited to be erased, and then the next operation is executed.
In the above technology, only one minute of frozen data occupies 3.3M of FLASH space (0.412M × 8 is 3.3M), and FLASH also stores other types of frozen data, event data, log data, and the like, so this method is not favorable for controlling the storage cost of FLASH, and because the amount of stored frozen data is large, it takes a long time to erase these data, and experimental tests show that erasing 4M of FLASH space and waiting for complete erasure takes more than 10 seconds, which greatly occupies program running resources.
Disclosure of Invention
The invention aims to provide a method, a storage medium and equipment for freezing data of an electric energy meter in minutes, and aims to solve the technical problems that the time consumption for freezing data is long and the storage space is not fully utilized in the prior art. The technical effects that can be produced by the preferred technical scheme in the technical schemes provided by the invention are described in detail in the following.
In order to achieve the purpose, the invention provides the following technical scheme: the invention provides a method for freezing data of an electric energy meter in minutes, which comprises the following steps:
s1, initializing a minute freezing index table;
s2, reading the freezing parameter information of the n-minute freezing scheme from the designated address; n is a natural number greater than 1;
s3, dynamically allocating m storage blocks for each minute freezing scheme according to the freezing parameter information and the initialized minute freezing index table; each of the memory blocks includes a data header and r minute frozen data points; m and r are both natural numbers larger than 1;
s4, judging whether the freezing period of the ith storage block arrives or not, if so, executing a step S5; otherwise, go to step S9; i sequentially takes 1,2, …, nxm-1, nxm +1 and …;
s5, erasing partial data of the ith storage block;
s6, whether the data writing time comes or not, if so, executing a step S7; otherwise, go to step S8;
s7, freezing the ith storage block, i equals i +1, and returning to step S4;
s8, returning to the step S6, and waiting for the arrival of the data writing time;
s9, returning to step S4, waiting for the arrival of the freeze cycle.
Further, step S3 includes the following steps:
s31, defining the data header of the storage block, and acquiring the length L1 of the data header;
s32, calculating the length L2 of each minute frozen data point of the storage block;
L2=L3+L4+datasize+a;
wherein L3 is the time scale length of the minute frozen data point, L4 is the mark bit length of the minute frozen data point, datasize is the length of the data item of the minute frozen data point, and a is 2;
s33, calculating the number r of the minute freezing data points which can be stored in each storage block;
r=(L5-L1)/L2;
wherein L5 is the size of one of the memory blocks;
s34, reading the freezing depth deep from the freezing parameter information, and calculating an initial value xBlock [ i ] of the number of the storage blocks occupied by each minute freezing scheme;
xBlock[i]=b+(deep+L2-1)/L2;
wherein i is an index value corresponding to the minute freezing scheme, and i is 1,2, …, n; b is 1;
s35, calculating the size dBlock [ i ] of the storage space of each minute freezing scheme;
dBlock[i]=((dSize-1)/xTotal)*xBlock[i];
xTotal=xBlock[1]+xBlock[2]+…+xBlock[n];
wherein dSize is a storage size required to store all of the minute freeze scenarios; i is an index value corresponding to the minute freezing scheme, i is 1,2, …, n.
Further, the step of step S5 is as follows:
s51, whether i is less than or equal to n × m, if yes, executing step S52; otherwise, go to step S53;
s52, updating the current storage block number of the minute freezing index table to block _ id which is block _ id +1, and executing the step S6;
s53, updating the current storage block number of the minute freezing index table to block _ id which is block _ id + 1;
s54, reading the information of the data header of the (i + 1) th storage block;
if the remainder of dividing S55 by n × m is equal to 0, if yes, go to step S56; otherwise, executing step S57;
s56, erasing partial data of the n × m storage blocks, and executing the step S6;
s57, returning to the jth storage block, erasing partial data of the jth storage block, and executing the step S6; j is the remainder of i divided by n m.
Further, in step S5, the erasing the partial data of the ith memory block is: and erasing the data head of the ith storage block.
Further, the step of step S7 is as follows:
s71, whether i is less than or equal to n × m, if yes, executing step S72; otherwise, go to step S73;
s72, writing new data in sequence from the 1 st minute frozen data point of the ith storage block, and executing the step S74;
s73, sequentially erasing old data from the 1 st minute frozen data point of the ith storage block, and simultaneously writing new data;
s74, whether the writing of the nth minute frozen data point is finished or not is judged, if yes, the steps S75-S76 are executed; otherwise, go to step S77;
s75, performing CRC check on the write data of the ith storage block;
s76, updating the minute freezing index table and the data header of the ith storage block, i ═ i +1, and returning to step S4;
s77, returning to the step S74, and waiting for the last minute to freeze the writing of the data point.
Further, step S73 includes the following steps:
if the remainder of dividing S731 by n × m is equal to 0, if yes, go to step S732; otherwise, go to step S733;
s732, sequentially erasing old data from the 1 st minute frozen data point of the n x m storage blocks, and simultaneously writing new data;
s733, returning to the jth storage block, sequentially erasing old data from the 1 st minute frozen data point, and simultaneously writing new data; the remainder of i divided by n × m is j.
Further, step S75 includes the following steps:
s751, reading all data written into the minute frozen data point by the ith storage block and a CRC value of the data head;
s752, whether reading is successful or not; if yes, go to step S753; otherwise, go to step S754;
s753, if the verification is successful, executing the step S76;
s754, re-executing the steps S4-S9.
Preferably, in step S754, steps S4-S9 are re-executed no more than 3 times.
According to another aspect of the invention, a single-phase electric energy meter minute freezing storage medium is further provided, and the storage medium stores a computer program which is executed to implement the electric energy meter minute freezing method.
According to another aspect of the present invention, there is also provided a minute freezing apparatus of a single-phase electric energy meter, comprising: one or more processors, and a memory for storing one or more computer programs, the one or more processors for executing the one or more computer programs stored by the memory to cause the one or more processors to perform the energy meter data minute freezing method described above.
The implementation of one of the technical schemes of the invention has the following advantages or beneficial effects:
on the premise of meeting the requirement of the latest national network technical specification, the invention adopts a dynamic allocation mode to allocate a plurality of minute freezing schemes according to the requirement, thereby achieving the purposes of saving FLASH resources and controlling FLASH storage cost. In the distribution mode, a new erasing and writing mechanism is introduced, namely when a freezing event occurs, only the head data of the storage block frozen in minutes is damaged, and when the frozen data is written in the freezing scheme, the data is erased at the same time. Therefore, the invention greatly improves the operation efficiency of the electric energy meter and simultaneously greatly optimizes the storage space of the FLASH.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without inventive efforts, wherein:
FIG. 1 is a schematic diagram of the cycle minute freezing principle and structure of the prior art;
FIG. 2 is a schematic diagram of a prior art case of the minute freeze method;
FIG. 3 is a flow chart of a method for minute freezing of data of an electric energy meter according to the present invention;
FIG. 4 is a schematic diagram of the structure of a memory block of the present invention;
FIG. 5 is a flow chart of the dynamic distribution of FLASH memory space of the electric energy meter data minute freezing method of the present invention;
FIG. 6 is a flow chart of erasing part of data of a storage block in the electric energy meter data minute freezing method according to the invention;
FIG. 7 is a flow chart of data freezing in a minute freezing method of electric energy meter data according to the present invention;
FIG. 8 is a flowchart of the step S73 of data freezing in the method for freezing the data of the electric energy meter in minutes according to the invention;
FIG. 9 is a flow chart of a CRC check in a power meter data minute freeze method of the present invention;
fig. 10 is a data freezing diagram of the n × m minute frozen data point to the 1 st minute frozen data point in the energy meter data minute freezing method of the present invention.
Detailed Description
In order that the objects, aspects and advantages of the present invention will become more apparent, various exemplary embodiments will be described below with reference to the accompanying drawings, which form a part hereof, and in which are shown by way of illustration various exemplary embodiments in which the invention may be practiced. The same numbers in different drawings identify the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. It is to be understood that they are merely examples of processes, methods, apparatus, etc. consistent with certain aspects of the present disclosure as detailed in the appended claims, and that other embodiments may be used or structural and functional modifications may be made to the embodiments set forth herein without departing from the scope and spirit of the present disclosure.
In the description of the present invention, it is to be understood that the terms "first", "second", and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implying any number of technical features indicated. The term "plurality" means two or more. The specific meanings of the above terms in the present invention can be understood by those skilled in the art according to specific situations.
In order to explain the technical solution of the present invention, the following description is made by way of specific examples, which only show the relevant portions of the embodiments of the present invention. It should be noted that the following embodiment is only a specific example, and does not indicate an implementation manner of the present invention.
The first embodiment is as follows:
as shown in fig. 3, the invention provides a method for freezing data of an electric energy meter in minutes, which comprises the following steps:
and S1, initializing a minute freezing index table. It should be noted that a FLASH memory device is provided in the electric energy meter, and the FLASH is divided into n memory spaces, where n is a natural number greater than 1. Each storage space corresponds to one minute freezing scheme, i.e. a total of n freezing schemes. In this embodiment n is preferably 8. Each freezing scheme corresponds to m memory blocks, wherein m is a natural number greater than 1. Each memory block comprises a data head and r minutes of frozen data points, wherein r is a natural number greater than 1. Each minute frozen data point is stored with electricity consumption data, namely a load record. The minute freezing index table is used for describing the storage blocks in the minute freezing scheme, and recording the maximum number, the minimum number, the size of the whole storage block, the total number of the minute freezing data points in all the storage blocks, the maximum (minimum) storage address corresponding to the maximum (minimum) number of the storage block, the freezing period and the like in the minute freezing scheme, and specifically, the structure of the minute freezing index table is defined as follows:
Figure BDA0002989817340000091
wherein datasize is the length of all minute frozen data points without data head in the ith freezing scheme (single point data length); deep is the storage depth, namely the total number of the clock freezing data points in the ith freezing scheme, and is used for calculating the address parameter; period is a freezing period; addr _ start and addr _ end are respectively the start address and the end address of the storage block in the ith minute freezing scheme, and are rounded up according to the sector (1 sector takes 4 kbytes), and the size of the addr _ start and the addr _ end depends on the number of the storage blocks distributed by the minute freezing scheme; the number of the block _ id current storage block is accumulated along with the difference of the storage blocks, and even when the address is circularly stored back to the initial value, the accumulation is continued; id _ min is the minimum id (number) of the ith freezing scheme, i.e., the id (number) of the first minute frozen data point of the first memory block of that freezing scheme; addr _ min is an address corresponding to the minimum ID of the ith freezing scheme, and the address of the 1 st minute freezing data point in the 1 st storage block of the ith freezing scheme is taken; time _ min is the earliest freezing time of the ith minute freezing scheme; ID _ max is the maximum ID of a freezing scheme, namely the value of the number block _ ID of the last storage block of the freezing scheme; addr _ max is the address of the last minute frozen data point of the last memory block of a freezing scheme; time _ max is the maximum freeze time. During initialization, period, deep and the like are all called from the specific scheme in step S2, block _ id is 0, and id _ min is-1; the remainder may be set to zero or, depending on the particular initialization, by the full minute freeze scheme and FLASH memory device size.
S2, reading the freezing parameter information of the n-minute freezing scheme from the designated address; n is a natural number greater than 1. The freeze parameter information is typically provided in the EEPROM. The method comprises the steps of setting a minute freezing scheme, namely according to the requirements of the latest national grid technical specifications, storing the load records of the single-phase electric energy meter in a storage space, and storing the frozen data volume for at least 300 days under the condition that the minute freezing scheme is set to be 15 minutes. The frozen data is divided into a plurality of minute freezing schemes, and the division may be performed in an average manner according to the sum of all frozen data. In this embodiment, an 8 minute freeze scenario is allocated to be stored in 8 memory spaces of FLASH. If the data is frozen in a cycle of year, the FLASH stores the electricity load record of 300 days when the data is frozen for the first time (for example, the first year), and the electricity load record of 300 days stored in the FLASH is stored in a covering mode when the data is frozen for the second time (the second year), and then the data stored in the last time is covered by each freezing until the set cycle end time. The structure of the freezing parameter information is defined as follows:
Figure BDA0002989817340000101
Figure BDA0002989817340000111
wherein CONS _ FREE _ MAXOAD is the maximum OAD number configurable for freezing.
S3, dynamically allocating m storage blocks for each minute freezing scheme according to the freezing parameter information and the initialized minute freezing index table; each memory block comprises a data head and r minute frozen data points; and m and r are both natural numbers larger than 1. Specifically, the size of each storage block is preferably 64 kbytes, and the specific value of m depends on the actual FLASH size, that is, m is (storage size/8)/64 of FLASH, and the storage size unit of FLASH is k bytes; see step S33 for the calculation of r. In the embodiment, a dynamic allocation mode is adopted to allocate a plurality of minute freezing schemes according to needs, so that the aims of saving FLASH storage space and controlling FLASH storage cost are achieved.
As further shown in fig. 4, each memory Block includes a data header (Block _ Head _ struct in the figure) and a plurality of minute freeze data points. Further, the size of each memory block is preferably 64 kbytes, the Data header size of each memory block is preferably 64 kbytes, and the Data structure of each minute frozen Data point includes a timestamp (e.g., a freeze time), a Flag (Flag in the figure), and Data (Data in the figure). In this embodiment, the lengths of the time stamp and the flag bit are 4 bytes and 1 byte, respectively.
As shown in fig. 5, step S3 includes the following specific steps:
s31, defining the data header of the memory block, and acquiring the length L1 of the data header. The data structure Block _ Head _ struct of the data header is defined as follows:
Figure BDA0002989817340000112
Figure BDA0002989817340000121
the length L1 of the header (minimum _ Head _ struct) is obtained in the system, and the obtaining command is as follows:
L1=sizeof(Minute_Head_struct) (1)
s32, extract the length datasize of the data from the initialized minute freeze index table, and calculate the length L2 of each minute freeze data point of the memory block. The calculation is disclosed as follows:
L2=L3+L4+datasize+a (2)
where L3 ═ 4, is the time scale length of the minute frozen data point; l4 is 1, the mark bit length of the minute frozen data point; a is 2;
and S33, calculating the number r of the minute freezing data points which can be stored in each storage block. The calculation is disclosed as follows:
r=(L5-L1)/L2 (3)
where L5 ═ 64, is the size of one memory block;
s34, reading the freezing depth deep from the freezing parameter information, and calculating the initial value xBlock [ i ] of the number of occupied storage blocks of each minute freezing scheme. The calculation is disclosed as follows:
xBlock[i]=b+(deep+L2-1)/L2 (4)
wherein i is an index value corresponding to the minute freezing scheme, and i is respectively 1,2,3,4,5,6,7 and 8; b-1, meaning that each minute freeze scheme requires a default occupation of one additional block of memory;
s35, calculating the size dBlock [ i ] of the storage space of each minute freezing scheme;
dBlock[i]=((dSize-1)/xTotal)*xBlock[i] (5)
xTotal=xBlock[1]+xBlock[2]+…+xBlock[n] (6)
wherein, the dSize is the storage size required for storing the all-minute freezing scheme, namely the storage space size of the FLASH; and i is an index value corresponding to the minute freezing scheme, and the values of i are 1,2,3,4,5,6,7 and 8 respectively.
S4, judging whether the freezing period of the ith storage block arrives or not, if so, executing the step S5; otherwise, go to step S9; i is 1,2, …, nxm-1, nxm +1 and … in sequence. The circulation is performed with a period of n × m, and the number of the circulation is determined according to actual conditions.
And S5, erasing partial data of the ith storage block. Specifically, when freezing the ith memory block, before writing a new minute frozen data point in the memory block, erasing a part of minute frozen data points of the memory block, and simultaneously erasing the rest of the un-erased part of minute frozen data points when writing the data time point. Further, erasing part of the data of the ith memory block is: the data head of the ith storage block is erased, because the data head is 64 bytes, the occupation ratio is less than 0.1% compared with the size of 64 kbytes of the storage block, partial data is erased firstly, and then writing and erasing data are carried out synchronously, so that the consumption time of freezing data is greatly reduced, and the operation efficiency of the electric energy meter is effectively improved. The new erase write greatly improves the efficiency of freezing data over the prior art erase-before-write. As shown in fig. 6, further, the steps are specifically as follows:
s51, whether i is less than or equal to n × m, if yes, executing step S52; otherwise, step S53 is executed. When i is less than or equal to nxm, the step is performed for the first time, and the ith storage block is not written with any data; if i is larger than nxm, the data is written into the ith storage block, at this time, the written data needs to be erased, and new data needs to be written again;
s52, updating the current storage block number of the min freeze index table to block _ id ═ block _ id +1 (the initial value of block _ id is zero), and executing step S6;
s53, updating the current storage block number of the minute freezing index table to block _ id which is block _ id + 1;
and S54, reading the information of the data header of the (i + 1) th storage block. The step is used for retaining the information of the data head, namely the information is retained before the data head of the (i + 1) th storage block is erased, and the information of the data head of the ith storage block is stored when the (i-1) th storage block is frozen;
if the remainder of dividing S55 by n × m is equal to 0, if yes, go to step S56; otherwise, step S57 is executed. When the remainder is equal to 0, the ith storage block is the last storage block in all the storage blocks, and the ith storage block is returned to the first storage block again when the (i + 1) th storage block is frozen;
s56, erasing partial data of the n × m storage blocks, and executing the step S6;
s57, returning to the jth memory block, erasing part of data of the jth memory block, and executing the step S6; j is the remainder of i divided by n m.
S6, whether the data writing time comes or not, if so, executing a step S7; otherwise, step S8 is executed.
S7, the ith memory block is frozen, i equals i +1, and the process returns to step S4. As shown in fig. 7, this step further includes the steps of:
s71, whether i is less than or equal to n × m, if yes, executing step S72; otherwise, go to step S73;
and S72, writing new data in sequence from the 1 st minute frozen data point of the ith storage block. When i is less than or equal to nxm, it indicates that the storage block is the first write data, and does not need to erase data, and step S74 is executed;
and S73, sequentially erasing the old data from the 1 st minute frozen data point of the ith storage block, and simultaneously writing the new data. Further, as shown in fig. 8, this step involves a coverage problem and thus comprises the steps of:
if the remainder of dividing S731 by n × m is equal to 0, if yes, go to step S732; otherwise, go to step S733;
s732, sequentially erasing the old data from the 1 st minute frozen data point of the n × m storage blocks, and simultaneously writing the new data;
s733, returning to the jth storage block, sequentially erasing the old data from the 1 st minute frozen data point, and simultaneously writing in the new data; j is the remainder of i divided by n m. In this step, if i is n × m +1, one memory block is returned to perform the operation.
S74, whether the writing of the freezing data point of the r minute is finished or not is judged, if yes, the step S75 is executed; otherwise, go to step S77;
and S75, performing CRC check on the write data of the ith storage block. As shown in fig. 9, specifically, the CRC check step is as follows:
s751, reading all data of the writing minute frozen data points of the ith storage block and the CRC value of the data head;
s752, whether reading is successful or not; if yes, go to step S753; otherwise, step S754 is executed. When reading each data of the minute frozen data points, the data is all written, and the CRC value is not null (e.g., CRC ═ 1); if the data write is incomplete, the CRC value is null (e.g., CRC no value). If the CRC value is not null, the reading is successful, otherwise, the reading is unsuccessful;
s753, if the verification is successful, executing the step S76;
s754, re-executing the steps S4-S9. In the present embodiment, the steps S4-S9 are re-executed no more than 3 times.
S76, the minute freeze index table is updated, and the data header of the i-th block, i ═ i +1, the process returns to step S4. In this step, updating the minute freezing index table mainly includes updating the minimum data number id _ min, the maximum data number id _ max, and the freezing time of the minimum data in the minute freezing index table to the number of the 1 st minute frozen data point, the number of the r-th minute frozen data point, and the freezing time of the 1 st minute frozen data point of the 1 st memory block when the one-minute freezing scheme is completed. Updating the data header of the ith storage block, namely updating the id _ block of the ith storage block to be a new id _ block after all the minute frozen data points of the ith storage block are correctly frozen, namely updating the id _ block to be the id _ block in the steps S52 and S53; updating id _ data to id of the 1 st minute frozen data point; updating datatime to the freeze time of the 1 st data; updating the size to the entire written data length;
s77, returning to the step S74, and waiting for the last minute to freeze the writing of the data point.
S8, return to step S6, wait for the arrival of the time of writing data.
S9, returning to step S4, waiting for the arrival of the freeze cycle.
As shown in FIG. 10, consider the case where the smallest block of memory is covered due to a circular store. If the initial addr _ max is at the position indicated in the figure in the first step, after adding new freezing, transferring to a new block, adding 1 to the block _ id, adding the head address to the new addr _ max, returning to the position of the second step, erasing the data of the block, moving addr _ min to the position of the third step, reading the head information of the memory block, and taking id _ data and data time as new id _ min and time _ min. It should be noted that addr _ min is larger than addr _ max at this time due to the circular storage mechanism.
Example two:
the embodiment also provides a single-phase electric energy meter minute freezing storage medium, wherein a computer program is stored on the storage medium, and the electric energy meter data minute freezing method is realized when the computer program is executed. It will be appreciated by those of ordinary skill in the art that all or part of the features/steps implementing the above-described method embodiments may be implemented by a method, a data processing system, or a computer program, and that such features may be implemented without hardware, in software or in a combination of hardware and software. The aforementioned computer program may be stored in one or more computer-readable storage media having stored thereon a computer program that, when executed (e.g., by a processor), performs steps comprising the above-described embodiments of the method for minute freezing of power meter data.
The aforementioned storage medium that can store the program code includes: an electrostatic hard disk, a solid state hard disk, a random access memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), an optical storage device, a magnetic storage device, a flash memory, a magnetic or optical disk, and/or combinations thereof, may be implemented by any type of volatile or non-volatile storage device, or combinations thereof.
Example three:
the invention also provides an embodiment of the single-phase electric energy meter minute freezing equipment, which comprises one or more processors and a memory; wherein the memory is configured to store one or more computer programs and the one or more processors are configured to execute the one or more computer programs stored in the memory, so as to cause the processor to perform the features/steps of the embodiments of the method for minute freezing of data of an electric energy meter as described above.
In summary, the present invention adopts a dynamic allocation manner to allocate the plurality of minute freezing schemes as required on the premise of meeting the requirements of the latest national network technical specification, so as to achieve the purposes of saving FLASH resources and controlling the FLASH storage cost. In the distribution mode, a new erasing and writing mechanism is introduced, namely when a freezing event occurs, only the head data of the storage block frozen in minutes is damaged, and when the frozen data is written in the freezing scheme, the data is erased at the same time.
While the invention has been described with reference to a preferred embodiment, it will be understood by those skilled in the art that various changes may be made and equivalents may be substituted for elements thereof without departing from the spirit and scope of the invention. In addition, many modifications may be made to adapt a particular situation or material to the teachings of the invention without departing from the essential scope thereof. Therefore, it is intended that the invention not be limited to the particular embodiment disclosed, but that the invention will include all embodiments falling within the scope of the appended claims.

Claims (10)

1. A method for freezing data of an electric energy meter in minutes is characterized by comprising the following steps:
s1, initializing a minute freezing index table;
s2, reading the freezing parameter information of the n-minute freezing scheme from the designated address; n is a natural number greater than 1;
s3, dynamically allocating m storage blocks for each minute freezing scheme according to the freezing parameter information and the initialized minute freezing index table; each of the memory blocks includes a data header and r minute frozen data points; m and r are both natural numbers larger than 1;
s4, judging whether the freezing period of the ith storage block arrives or not, if so, executing a step S5; otherwise, go to step S9; i sequentially takes 1,2, …, nxm-1, nxm +1 and …;
s5, erasing partial data of the ith storage block;
s6, whether the data writing time comes or not, if so, executing a step S7; otherwise, go to step S8;
s7, freezing the ith storage block, i equals i +1, and returning to step S4;
s8, returning to the step S6, and waiting for the arrival of the data writing time;
s9, returning to step S4, waiting for the arrival of the freeze cycle.
2. The method for freezing the data of the electric energy meter in minutes as claimed in claim 1, wherein the step S3 includes the following steps:
s31, defining the data header of the storage block, and acquiring the length L1 of the data header;
s32, calculating the length L2 of each minute frozen data point of the storage block;
L2=L3+L4+datasize+a;
wherein L3 is the time scale length of the minute frozen data point, L4 is the mark bit length of the minute frozen data point, datasize is the length of the data item of the minute frozen data point, and a is 2;
s33, calculating the number r of the minute freezing data points which can be stored in each storage block;
r=(L5-L1)/L2;
wherein L5 is the size of one of the memory blocks;
s34, reading the freezing depth deep from the freezing parameter information, and calculating an initial value xBlock [ i ] of the number of the storage blocks occupied by each minute freezing scheme;
xBlock[i]=b+(deep+L2-1)/L2;
wherein i is an index value corresponding to the minute freezing scheme, and i is 1,2, …, n; b is 1;
s35, calculating the size dBlock [ i ] of the storage space of each minute freezing scheme;
dBlock[i]=((dSize-1)/xTotal)*xBlock[i];
xTotal=xBlock[1]+xBlock[2]+…+xBlock[n];
wherein dSize is a storage size required to store all of the minute freeze scenarios; i is an index value corresponding to the minute freezing scheme, i is 1,2, …, n.
3. The method for freezing the data of the electric energy meter in minutes according to the claim 1, wherein the step S5 is as follows:
s51, whether i is less than or equal to n × m, if yes, executing step S52; otherwise, go to step S53;
s52, updating the current storage block number of the minute freezing index table to block _ id which is block _ id +1, and executing the step S6;
s53, updating the current storage block number of the minute freezing index table to block _ id which is block _ id + 1;
s54, reading the information of the data header of the (i + 1) th storage block;
if the remainder of dividing S55 by n × m is equal to 0, if yes, go to step S56; otherwise, executing step S57;
s56, erasing partial data of the n × m storage blocks, and executing the step S6;
s57, returning to the jth storage block, erasing partial data of the jth storage block, and executing the step S6; j is the remainder of i divided by n m.
4. The method for freezing the data of the electric energy meter in minutes as claimed in claim 3, wherein in step S5, the erasing the partial data of the ith storage block is: and erasing the data head of the ith storage block.
5. The method for freezing the data of the electric energy meter in minutes according to the claim 3, wherein the step S7 is as follows:
s71, whether i is less than or equal to n × m, if yes, executing step S72; otherwise, go to step S73;
s72, writing new data in sequence from the 1 st minute frozen data point of the ith storage block, and executing the step S74;
s73, sequentially erasing old data from the 1 st minute frozen data point of the ith storage block, and simultaneously writing new data;
s74, whether the writing of the nth minute frozen data point is finished or not is judged, and if yes, the step S75 is executed; otherwise, go to step S77;
s75, performing CRC check on the write data of the ith storage block;
s76, updating the minute freezing index table and the data header of the ith storage block, i ═ i +1, and returning to step S4;
s77, returning to the step S74, and waiting for the last minute to freeze the writing of the data point.
6. The method for freezing the data of the electric energy meter in minutes as claimed in claim 5, wherein the step S73 includes the following steps:
if the remainder of dividing S731 by n × m is equal to 0, if yes, go to step S732; otherwise, go to step S733;
s732, sequentially erasing old data from the 1 st minute frozen data point of the n x m storage blocks, and simultaneously writing new data;
s733, returning to the jth storage block, sequentially erasing old data from the 1 st minute frozen data point, and simultaneously writing new data; the remainder of i divided by n × m is j.
7. The method for freezing the data of the electric energy meter in minutes as claimed in claim 5, wherein the step S75 includes the following steps:
s751, reading all data written into the minute frozen data point by the ith storage block and a CRC value of the data head;
s752, whether reading is successful or not; if yes, go to step S753; otherwise, go to step S754;
s753, if the verification is successful, executing the step S76
S754, re-executing the steps S4-S9.
8. The method for freezing the data of the electric energy meter in minutes as claimed in claim 7, wherein in the step S754, the steps S4-S9 are re-executed no more than 3 times.
9. A single-phase electric energy meter minute freezing storage medium, wherein the storage medium has stored thereon a computer program which, when executed, implements the electric energy meter minute freezing method of any one of claims 1-8.
10. A single-phase electric energy meter minute freezing apparatus, comprising: one or more processors and a memory;
the memory is configured to store one or more computer programs, and the one or more processors are configured to execute the one or more computer programs stored in the memory to cause the one or more processors to perform the method for minute freezing of power meter data according to any of claims 1-8.
CN202110312110.1A 2021-03-24 2021-03-24 Electric energy meter data minute freezing method, storage medium and equipment Active CN112965919B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110312110.1A CN112965919B (en) 2021-03-24 2021-03-24 Electric energy meter data minute freezing method, storage medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110312110.1A CN112965919B (en) 2021-03-24 2021-03-24 Electric energy meter data minute freezing method, storage medium and equipment

Publications (2)

Publication Number Publication Date
CN112965919A true CN112965919A (en) 2021-06-15
CN112965919B CN112965919B (en) 2023-06-06

Family

ID=76278287

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110312110.1A Active CN112965919B (en) 2021-03-24 2021-03-24 Electric energy meter data minute freezing method, storage medium and equipment

Country Status (1)

Country Link
CN (1) CN112965919B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114356792A (en) * 2021-11-18 2022-04-15 国电南瑞三能电力仪表(南京)有限公司 Electric energy meter frozen data storage method based on FLASH pre-erasing technology and electric energy meter
CN118276788A (en) * 2024-06-03 2024-07-02 浙江正泰仪器仪表有限责任公司 Electric energy meter system and minute freezing method and device applied to electric energy meter system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102567184A (en) * 2011-12-27 2012-07-11 青岛海信宽带多媒体技术有限公司 Journal storage method based on Flash
US20150113210A1 (en) * 2013-10-22 2015-04-23 Renesas Electronics Corporation Data storage flash memory management method and program
CN105426317A (en) * 2015-10-29 2016-03-23 宁波卓奥电子科技有限公司 Storage method for storing user data into Flash and read method
CN108255981A (en) * 2017-12-28 2018-07-06 国网江苏省电力有限公司电力科学研究院 The storage and lookup method that section timestamp serial number index minute continuous time freezes
CN109614447A (en) * 2018-10-15 2019-04-12 国网新疆电力有限公司阿克苏供电公司 A kind of intelligent electric meter divides the storage method, querying method and device of freezing data

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102567184A (en) * 2011-12-27 2012-07-11 青岛海信宽带多媒体技术有限公司 Journal storage method based on Flash
US20150113210A1 (en) * 2013-10-22 2015-04-23 Renesas Electronics Corporation Data storage flash memory management method and program
CN105426317A (en) * 2015-10-29 2016-03-23 宁波卓奥电子科技有限公司 Storage method for storing user data into Flash and read method
CN108255981A (en) * 2017-12-28 2018-07-06 国网江苏省电力有限公司电力科学研究院 The storage and lookup method that section timestamp serial number index minute continuous time freezes
CN109614447A (en) * 2018-10-15 2019-04-12 国网新疆电力有限公司阿克苏供电公司 A kind of intelligent electric meter divides the storage method, querying method and device of freezing data

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114356792A (en) * 2021-11-18 2022-04-15 国电南瑞三能电力仪表(南京)有限公司 Electric energy meter frozen data storage method based on FLASH pre-erasing technology and electric energy meter
CN114356792B (en) * 2021-11-18 2023-03-10 国电南瑞三能电力仪表(南京)有限公司 Electric energy meter frozen data storage method based on FLASH pre-erasing technology and electric energy meter
CN118276788A (en) * 2024-06-03 2024-07-02 浙江正泰仪器仪表有限责任公司 Electric energy meter system and minute freezing method and device applied to electric energy meter system

Also Published As

Publication number Publication date
CN112965919B (en) 2023-06-06

Similar Documents

Publication Publication Date Title
EP3588259B1 (en) Garbage collection method for storage media, storage medium, and program product
CN101354681B (en) Memory system, abrasion equilibrium method and apparatus of non-volatile memory
CN102693283B (en) A kind of data partition storage method of embedded system and System guides starting method
EP3518112B1 (en) Memory device and host device
US7873763B2 (en) Multi-reader multi-writer circular buffer memory
CN112965919A (en) Electric energy meter data minute freezing method, storage medium and equipment
CN110673789B (en) Metadata storage management method, device, equipment and storage medium of solid state disk
CN115292266B (en) High-reliability log storage method based on memory
CN103514249A (en) Method and system for automatic data reduction and storage device
CN101799744A (en) The solid-state drive command grouping
CN102306503A (en) Method and system for detecting false capacity memory
CN108664482B (en) FLASH memory and storage file management method
CN102169460A (en) Method and device for managing variable length data
CN114253871A (en) Method, system and device for storing and managing data of intelligent electric meter
CN112463020A (en) Data access method, device and equipment based on Flash
CN115964002B (en) Electric energy meter terminal archive management method, device, equipment and medium
CN106407130A (en) Method for managing Nandflash memory data
CN109669889A (en) A kind of light-type Nor Flash flash memory control method and device
CN111124313A (en) Data reading and writing method and device for power acquisition terminal and electronic equipment
CN102169464B (en) Caching method and device used for non-volatile memory, and intelligent card
CN113467722A (en) Data migration method and device of distributed storage system
CN107678977A (en) The reading/writing method and device of a kind of counter
CN115989485A (en) Data processing method, device and system
CN110221984A (en) Method for building up, device, storage system and the access method of storage system
CN115686362A (en) Data freezing method of intelligent electric meter

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 3rd Floor, Building 6, Guangqian Industrial Zone, Longzhu 3rd Road, Longzhu 3rd Road, Longguang Community, Taoyuan Street, Nanshan District, Shenzhen, Guangdong Province, 518000

Applicant after: SHENZHEN FRIENDCOM TECHNOLOGY DEVELOPMENT Co.,Ltd.

Address before: 518000 6th floor, building 17, Guangqian Industrial Zone, Taoyuan Street, Nanshan District, Shenzhen City, Guangdong Province

Applicant before: SHENZHEN FRIENDCOM TECHNOLOGY DEVELOPMENT Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant