CN108052456A - A kind of electricity data storage method, system and a kind of electricity data storage device - Google Patents

A kind of electricity data storage method, system and a kind of electricity data storage device Download PDF

Info

Publication number
CN108052456A
CN108052456A CN201711463338.0A CN201711463338A CN108052456A CN 108052456 A CN108052456 A CN 108052456A CN 201711463338 A CN201711463338 A CN 201711463338A CN 108052456 A CN108052456 A CN 108052456A
Authority
CN
China
Prior art keywords
pages
integer
data
electricity
electricity data
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
CN201711463338.0A
Other languages
Chinese (zh)
Other versions
CN108052456B (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.)
Hangzhou Hi Tech Ltd By Share Ltd
Original Assignee
Hangzhou Hi Tech Ltd By Share 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 Hangzhou Hi Tech Ltd By Share Ltd filed Critical Hangzhou Hi Tech Ltd By Share Ltd
Priority to CN201711463338.0A priority Critical patent/CN108052456B/en
Publication of CN108052456A publication Critical patent/CN108052456A/en
Application granted granted Critical
Publication of CN108052456B publication Critical patent/CN108052456B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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

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 kind of electricity data storage methods to include:When generate unit quantity of electricity it is cumulative when, inquire about current time electricity data integer part integer storage number of pages, and according to integer part calculate electricity data fractional part decimal store number of pages;The integer part of electricity data is stored to integer and stores number of pages, fractional part stores to decimal and stores number of pages;Wherein, the integer part of electricity data is stored in N pages in flash, and fractional part is stored in M pages in the flash, and M, N are the integer more than 1, and M is the integral multiple of N.Electricity data storage method disclosed by the invention, using having the function of the flash stored programs of IAP and energy data, it is ensured that electricity data security.The invention also discloses a kind of electricity data storage system and a kind of electricity data storage device and a kind of computer readable storage mediums, equally can realize above-mentioned technique effect.

Description

A kind of electricity data storage method, system and a kind of electricity data storage device
Technical field
The present invention relates to electric energy meter technical field, more specifically to a kind of electricity data storage method, system and one Kind electricity data storage device and a kind of computer readable storage medium.
Background technology
In electric energy meter design, most important data are exactly electricity data, in the typical design, can all be used dedicated outer Portion's storaging chip, such as EEPROM (English full name:Electrically-Erasable Programmable Read-Only Memory, Chinese full name:The electronics formula of erasing can make carbon copies read-only memory) store these data.But as IAP technologies are in core Popularization in piece, while chip is used for flash (a kind of storage chip, the English full name of stored program:Flash EEPROM Memory while) space is also increasing, price does not accordingly increase, and many designers are intended to (applying by IAP It is programmable, English full name:In-Application programmable) function, electricity data is stored in internal flash. Cost so can be both greatlyd save, can also improve the reliability of data-storing.
Since flash can only carry out page erasing, usual 512 byte of one page can not carry out some data repeatedly erasable. In addition the erasable numbers of flash usually only 2~100,000 times compare the erasable number of EEPROM as 1,000,000 times, therefore store similary Electricity, it is necessary to use more flash spaces.In the prior art when electric energy meter has electricity, internal RAM (English full name is utilized: Random access memory, Chinese full name:Random access memory) storage electricity data, when detect will have a power failure when, Electricity data in RAM is copied in flash.
In the prior art, when program has little time to respond power loss event, the loss of electricity data, and this be will result in The electricity data of loss is uncontrollable, that is to say, that the time for having electricity operation is longer, if having little time to store when power down Electricity data, the then electricity lost will be more.
Therefore, even if how to ensure that the erasing of flash does not interfere with depositing for electricity data when frequently electrically operated up and down Storage is those skilled in the art's problem to be solved.
The content of the invention
It is an object of the invention to provide a kind of electricity data storage method, system and a kind of electricity data storage device and A kind of computer readable storage medium, it is ensured that even if when frequently electrically operated up and down, the erasing of flash does not all interfere with electricity Measure the storage of data.
To achieve the above object, an embodiment of the present invention provides a kind of electricity data storage method, including:
When generate unit quantity of electricity it is cumulative when, inquire about current time electricity data integer part integer storage number of pages, And the decimal that the fractional part of the electricity data is calculated according to the integer part stores number of pages;
The integer part of the electricity data is stored to the integer and stores number of pages, fractional part is stored to the decimal Store number of pages;
Wherein, the integer part of the electricity data is stored in N pages in flash, the fractional part of the electricity data M pages be stored in the flash, M, N are the integer more than 1, and M is the integral multiple of N.
Wherein, the integer part of the electricity data is stored to the integer and stores number of pages, fractional part is stored to institute Decimal storage number of pages is stated, including:
S221:The first address and offset address of number of pages are stored according to the decimal, obtains the fractional part of the electricity data The storage address divided, and the fractional part is stored into the storage address;
S222:Judge whether the integer part changes;If so, into S223, if it is not, then entering S224;
S223:The integer storage number of pages of the integer part is inquired about, the integer part is stored to the integer and is stored In the offset address of number of pages;
S224:Detect whether the integer storage number of pages is filled with;If so, put the erasing mark of the integer storage number of pages Position.
Wherein, the idle fractional part of the electricity data is stored in Q pages in the flash, and Q is the integer more than 1.
Wherein, further include:
When detecting power down failure, the CF mantissa parts of the electricity data are stored into the flash.
Wherein, the unit quantity of electricity is 0.01 degree.
Wherein, if N=2, the electricity data storage method further includes:
S401:It detects after recovering data command, judging the integer data of the peak excursion address of integer storage number of pages is It is no legal, if so, into S402, if it is not, then subtracting one by the peak excursion address, and reenter S401;
S402:Recover the integer data of the peak excursion address of integer storage number of pages;
S403:The decimals of page two that corresponding fraction data is calculated according to the integer data store number of pages, and described in recovery Decimal stores the fraction data of number of pages.
Wherein, the fraction data of the decimal storage number of pages is recovered, including:
Judge whether the fraction data of the peak excursion address of the second page in the decimal of page two storage number of pages is legal;
If so, the first page in the detection decimal of page two storage number of pages whether there is valid data, if so, recovering The legal fraction data of offset address maximum, the erasing flag bit of second page described in juxtaposition, if it is not, then recovering the second page The legal fraction data of offset address maximum, the erasing flag bit of first page described in juxtaposition;
If it is not, the second page then detected in the decimal of page two storage number of pages whether there is valid data, if so, recovering The legal fraction data of offset address maximum, the erasing flag bit of first page described in juxtaposition, if it is not, then set to 0 fraction data, and Put the erasing flag bit of the first page and the second page.
To achieve the above object, an embodiment of the present invention provides a kind of electricity data storage system, including:
Computing module, for when generate unit quantity of electricity it is cumulative when, inquire about the integer part of current time electricity data Integer stores number of pages, and stores number of pages according to the decimal of the fractional part of the integer part calculating electricity data;
Memory module stores number of pages, fractional part for storing the integer part of the electricity data to the integer It stores to the decimal and stores number of pages;
Wherein, the integer part of the electricity data is stored in N pages in flash, the fractional part of the electricity data M pages be stored in the flash, M, N are the integer more than 1, and M is the integral multiple of N.
To achieve the above object, an embodiment of the present invention provides a kind of electricity data storage device, including:
Memory, for storing computer program;
Processor is realized such as the step of above-mentioned electricity data storage method during for performing the computer program.
To achieve the above object, an embodiment of the present invention provides a kind of computer readable storage medium, the computer can It reads to be stored with computer program on storage medium, be realized when the computer program is executed by processor as above-mentioned electricity data is deposited Method for storing.
By above scheme, a kind of electricity data storage method provided in an embodiment of the present invention includes:It is single when generating Position electricity it is cumulative when, the integer storage number of pages of the integer part of current time electricity data is inquired about, and according to the integer portion Divide the decimal storage number of pages for the fractional part for calculating the electricity data;The integer part of the electricity data is stored to described Integer stores number of pages, and fractional part stores to the decimal and stores number of pages;Wherein, the integer part of the electricity data is stored in N pages in flash, the fractional part of the electricity data is stored in M pages in the flash, and M, N are the integer more than 1.
Electricity data storage method provided by the invention, using having the function of the flash of IAP, while stored program Store energy data, often generate unit quantity of electricity it is cumulative when store an electricity data, it is ensured that the security of electricity data;It is right It in the integer part and fractional part of electricity data, is stored respectively at least page two of flash, it is ensured that even if above and below frequently When electrically operated, the erasing of flash does not all interfere with the storage of electricity data, and the electricity data stored will not occupy it is too many Flash memory spaces.The invention also discloses a kind of electricity data storage system and a kind of electricity data storage devices and one kind Computer readable storage medium equally can realize above-mentioned technique effect.
Description of the drawings
It in order to illustrate more clearly about the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing There is attached drawing needed in technology description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this Some embodiments of invention, for those of ordinary skill in the art, without creative efforts, can be with Other attached drawings are obtained according to these attached drawings.
Fig. 1 is a kind of flow chart of electricity data storage method disclosed by the embodiments of the present invention;
Fig. 2 is the flow chart of another electricity data storage method disclosed by the embodiments of the present invention;
Fig. 3 is the flow chart of flash disclosed by the embodiments of the present invention erasings;
Fig. 4 is the flow chart of another electricity data storage method disclosed by the embodiments of the present invention;
Fig. 5 is the flow chart of the recovery of another electricity data storage method fractional part disclosed by the embodiments of the present invention;
Fig. 6 is a kind of structure chart of electricity data storage system disclosed by the embodiments of the present invention;
Fig. 7 is a kind of structure chart of electricity data storage device disclosed by the embodiments of the present invention.
Specific embodiment
Below in conjunction with the attached drawing in the embodiment of the present invention, the technical solution in the embodiment of the present invention is carried out clear, complete Site preparation describes, it is clear that described embodiment is only part of the embodiment of the present invention, instead of all the embodiments.It is based on Embodiment in the present invention, those of ordinary skill in the art are obtained every other without creative efforts Embodiment belongs to the scope of protection of the invention.
The embodiment of the invention discloses a kind of electricity data storage methods, it is ensured that even if when frequently electrically operated up and down, The erasing of flash does not all interfere with the storage of electricity data.
Referring to Fig. 1, a kind of flow chart of electricity data storage method disclosed by the embodiments of the present invention, as shown in Figure 1, bag It includes:
S101:When generate unit quantity of electricity it is cumulative when, inquire about current time electricity data integer part integer storage Number of pages, and number of pages is stored according to the decimal of the fractional part of the integer part calculating electricity data;
In specific implementation, electricity often generates the cumulative of unit quantity of electricity, can all store an electricity data, it is ensured that electricity Data can never lose.In general, unit quantity of electricity is 0.01 degree, i.e., often generates cumulative, the storage one of 0.01 degree of electricity Secondary electricity data.The concrete numerical value of unit quantity of electricity is not defined herein, those skilled in the art can be according to actual conditions Flexibly set.
S102:The integer part of the electricity data is stored to the integer and stores number of pages, fractional part is stored to institute State decimal storage number of pages;
Wherein, the integer part of the electricity data is stored in N pages in flash, the fractional part of the electricity data M pages be stored in the flash, M, N are the integer more than 1, and M is the integral multiple of N.
In specific implementation, the integer part of electricity data and fractional part are respectively stored in depositing more than page 1 in flash Storage is spatially, it is ensured that even if when frequently electrically operated up and down, the erasing of flash does not interfere with the storage of electricity data, that is, works as When flash carries out the also erasing operation of certain one page, other storage numbers of pages can continue the storage operation of electricity data.
It is understood that since identical integer can correspond to multiple fractional parts, even unit quantity of electricity is 0.01 degree, phase Same integer corresponds to 100 fractional parts, therefore, can be grouped fractional part according to integer part, is preferably five groups, Each group of occupy flash memory spaces respectively at least page two.
When generate unit quantity of electricity it is cumulative when, first according to the integer part of electricity data inquire about integer part it is current whole Number storage number of pages, and the corresponding decimal of fractional part is calculated according to integer part and stores number of pages, further according to decimal storage number of pages First address and offset address calculate the storage address of fractional part, and the fractional part is stored into the storage address, The integer part of number of pages storing electricity data is finally stored according to current integer.
The integer part of storing electricity data, it is necessary first to judge to generate unit quantity of electricity it is cumulative after, electricity data it is whole Whether number part changes, if so, storing the integer part after variation to the offset address of integer storage number of pages, and adjusts Whole offset address, will the offset address add one, and check the need for skipping;If the integer part of electricity data does not occur Variation is then directly entered and the step of whether integer storage number of pages skips is checked, if so, putting the erasing of the integer storage number of pages Flag bit, if it is not, then terminating flow.
On the basis of above-described embodiment, preferably, the idle fractional part storage of the electricity data Q pages in the flash, Q is the integer more than 1.
When detecting power down failure, the CF mantissa parts of the electricity data are stored into the flash.
Electricity data storage method provided in an embodiment of the present invention, using having the function of the flash of IAP, in stored program While store energy data, often generate unit quantity of electricity it is cumulative when store an electricity data, it is ensured that the peace of electricity data Quan Xing;For the integer part and fractional part of electricity data, stored respectively at least page two of flash, it is ensured that even if When frequently electrically operated up and down, the erasing of flash does not all interfere with the storage of electricity data, and the electricity data stored will not account for With too many flash memory spaces.
The embodiment of the invention discloses a kind of electricity data storage methods, and compared with a upper embodiment, the present embodiment is to skill Art scheme has made further instruction and optimization.Specifically:
Referring to Fig. 2, the flow chart of another kind electricity data storage method provided in an embodiment of the present invention, as shown in Fig. 2, bag It includes:
S201:When generate unit quantity of electricity it is cumulative when, inquire about current time electricity data integer part integer storage Number of pages, and number of pages is stored according to the decimal of the fractional part of the integer part calculating electricity data;
For example, electricity data is made of six integer parts and two-decimal part, the storage mode of integer part is as follows Shown in table, it is divided into the storages of page two, every page is stored 25 times, every time 3 parts of storage.
Table 1 has, idle integer part storage mode
The storage mode of active fractional part is as shown in the table, is divided into five groups, every group page two, page totally ten.
The correspondence of 2 active decimal of table and integer:
Idle fractional part occupies the memory spaces of page two of flash altogether, in addition, there are two the mantissa for being less than 0.01 degree (CF mantissa) occupies one page memory space of flash altogether, is only preserved in power down.Storage format is:First character section is deposited The CF0 mantissa of power component are stored up, the CF1 mantissa of the second section byte storage reactive component, the 3rd byte is CF0+CF1+0x33.
By mode stored above, for the maximum storage electricity of power component, integer part 25*2*20000 =10000000 times (degree), fractional part are 512*2*20000*5=102400000 times, i.e., 10240000 degree;For idle portion The maximum storage electricity divided, idle decimal can only store 512*2*20000=20480000 times, i.e., 204800 degree.Idle portion It point can only ensure 200,000 degree of memory space, power-off event have occurred after capacity of idle power is more than 200,000 degree, then fractional part It may malfunction, in normal use, since power factor all can be very high, an idle simply small data, 200,000 degree The idle requirement for being enough to ensure that user.
In conclusion for storing the FLASH space sizes of electricity for page 15, wherein electricity integer page 2, active decimal 10 Page, idle decimal page 2, CF mantissa page 1.To the different piece of electricity data using different storage modes, so since, even if Electricity data of every 0.01 degree of storage, can also occupy less flash memory spaces.
S221:The first address and offset address of number of pages are stored according to the decimal, obtains the fractional part of the electricity data The storage address divided, and the fractional part is stored into the storage address;
S222:Judge whether the integer part changes;If so, into S223, if it is not, then entering S224;
S223:The integer storage number of pages of the integer part is inquired about, the integer part is stored to the integer and is stored In the offset address of number of pages;
S224:Detect whether the integer storage number of pages is filled with;If so, put the erasing mark of the integer storage number of pages Position;If otherwise terminate flow.
In specific implementation, the erasing flow of flash is as shown in figure 3, for the reliability service of program, the wiping to flash Division operation is completed by special module in program, and it is per second an erasing operation can only be at most done to flash, every time erasing before all It to be severe in judgment to erasing voltage and address.The integer and decimal of electricity have page two to store data in turn simultaneously, so its When middle one page is as data-storing page, have sufficient time to another page of progress erasing operation.
The embodiment of the invention discloses a kind of electricity data storage method, the recovery to electricity data after power down is further included, Specifically, work as N=2, and referring to Fig. 4, the flow chart of another electricity data storage method provided in an embodiment of the present invention, such as Fig. 4 It is shown, including:
S401:It detects after recovering data command, judging the integer data of the peak excursion address of integer storage number of pages is It is no legal, if so, into S402, if it is not, then subtracting one by the peak excursion address, and reenter S401;
S402:Recover the integer data of the peak excursion address of integer storage number of pages;
S403:The decimals of page two that corresponding fraction data is calculated according to the integer data store number of pages, and described in recovery Decimal stores the fraction data of number of pages.
In specific implementation, to power on the recovery of data can be divided into three parts, i.e. the recovery of integer part, fractional part Recover and recover less than the data of unit quantity of electricity.In the present embodiment, since integer part is divided to the storages of page two, and the mode stored To be stored from low address to high address, when recovering integer part, it is necessary to be inquired about from high address to low address, first inquired Part valid data is the integer part of the electricity data of last time storage, in the present embodiment, takes and judges to verify sum Mode judges whether integer data is legal.
When recovering the electricity data of fractional part, the decimals of page two for calculating fractional part according to integer part first are deposited Number of pages is stored up, then recovers the fraction data in this decimal storage number of pages of page two.Wherein, the decimal number of the decimal storage number of pages is recovered According to, as shown in figure 5, including:
S501:Judge whether the fraction data of the peak excursion address of the second page in the decimal of page two storage number of pages closes Method;If so, into S502;If it is not, then enter S503;
In specific implementation, whether can be that binary-coded decimal is sentenced by the fraction data for the peak excursion address for judging second page Whether the disconnected fraction data is legal, since the data format after the erasing of flash is 0xff, if the fraction data is Binary-coded decimal is then valid data, otherwise is illegal data.
S502:The first page in the decimal of page two storage number of pages is detected with the presence or absence of valid data, if so, recovering inclined Move the legal fraction data of address maximum, the erasing flag bit of second page described in juxtaposition, if it is not, then recovering the inclined of the second page Move the legal fraction data of address maximum, the erasing flag bit of first page described in juxtaposition;
In with implementation, if the fraction data of the peak excursion address of second page is valid data, illustrate second page It is filled with, it is necessary to first page be retrieved from low address to high address with the presence or absence of valid data, if in the presence of the last one valid data The as fractional part of the electricity data of last time storage, recovers the data, the erasing flag bit of juxtaposition second page;If it does not deposit , then the legal fraction data of the offset address maximum of second page as last time storage electricity data fractional part, The erasing flag bit of juxtaposition first page.
S502:The second page in the decimal of page two storage number of pages is detected with the presence or absence of valid data, if so, recovering inclined Move the legal fraction data of address maximum, the erasing flag bit of first page described in juxtaposition, if it is not, then setting to 0 fraction data, juxtaposition The erasing flag bit of the first page and second page.
In with implementation, if the fraction data of the peak excursion address of second page is not valid data, illustrate second page It is not filled with, it is necessary to second page be retrieved from high address to low address with the presence or absence of valid data, if in the presence of first valid data The as fractional part of the electricity data of last time storage, recovers the data, the erasing flag bit of juxtaposition first page;If it does not deposit Then fraction data is being set to 0, the erasing flag bit of juxtaposition first page and second page.
It is understood that since CF mantissa are stored in fixed position, when recovering CF mantissa, if the 3rd byte=the first A+the second byte+0x33 of byte, then it is assumed that data are legal, recover the data, juxtaposition erasing flag bit.
A kind of electricity data storage system provided in an embodiment of the present invention is introduced below, a kind of electricity described below Measuring data-storage system can be cross-referenced with a kind of above-described electricity data storage method.
Referring to Fig. 6, a kind of structure chart of electricity data storage system provided in an embodiment of the present invention, as shown in fig. 6, bag It includes:
Computing module 601, for when generate unit quantity of electricity it is cumulative when, inquire about current time electricity data integer part Integer storage number of pages, and the decimal for calculating according to the integer part fractional part of the electricity data stores number of pages;
Memory module 602 stores number of pages, fractional part for storing the integer part of the electricity data to the integer Divide to store to the decimal and store number of pages;
Wherein, the integer part of the electricity data is stored in N pages in flash, the fractional part of the electricity data M pages be stored in the flash, M, N are the integer more than 1.
Electricity data storage system provided in an embodiment of the present invention, using having the function of the flash of IAP, in stored program While store energy data, often generate unit quantity of electricity it is cumulative when store an electricity data, it is ensured that the peace of electricity data Quan Xing;For the integer part and fractional part of electricity data, stored respectively at least page two of flash, it is ensured that even if When frequently electrically operated up and down, the erasing of flash does not all interfere with the storage of electricity data, and the electricity data stored will not account for With too many flash memory spaces.
On the basis of above-described embodiment, preferably, the memory module 602 includes:
First storage unit for storing the first address and offset address of number of pages according to the decimal, obtains the electricity The storage address of the fractional part of data, and the fractional part is stored into the storage address;
Judging unit, for judging whether the integer part changes;If so, start the work of the second storage unit Make flow, if it is not, then starting the workflow of detection unit;
For inquiring about the integer of integer part storage number of pages, the integer part is deposited for second storage unit It stores up into the offset address of integer storage number of pages;
The detection unit, for detecting whether the integer storage number of pages is filled with;If so, put the integer memory page Several erasing flag bits.
On the basis of above-described embodiment, preferably, further include:
Power down module, for when detecting power down failure, storing the CF mantissa parts of the electricity data to described In flash.
On the basis of above-described embodiment, preferably, if M=N=2, the electricity data storage system System further includes:
Recover integer module, after detecting recovery data command, judge the peak excursion address of integer storage number of pages Integer data it is whether legal, if so, recover integer storage number of pages peak excursion address integer data, if it is not, then will The peak excursion address subtracts one, and restarts the workflow of the recovery integer module, until integer storage number of pages The integer data of peak excursion address is legal, starts the workflow for recovering decimal module;
Recover decimal module, for calculating the decimal memory pages of page two of corresponding fraction data according to the integer data Number, and recover the fraction data of the decimal storage number of pages.
On the basis of above-described embodiment, preferably, the recovery decimal module includes:
Computing unit stores number of pages for calculating the decimals of page two of corresponding fraction data according to the integer data;
Judging unit, for judging the decimal number of the peak excursion address of the second page in the decimal of page two storage number of pages According to whether legal;
First recovery unit, for working as the decimal of the peak excursion address of the second page in the decimal of page two storage number of pages When data are legal, the first page in the decimal of page two storage number of pages is detected with the presence or absence of valid data, if so, recovering offset The legal fraction data of address maximum, the erasing flag bit of second page described in juxtaposition, if it is not, then recovering the offset of the second page The legal fraction data of address maximum, the erasing flag bit of first page described in juxtaposition;
Second recovery unit, for working as the decimal of the peak excursion address of the second page in the decimal of page two storage number of pages When data are illegal, the second page in the decimal of page two storage number of pages is detected with the presence or absence of valid data, if so, recovering inclined Move the legal fraction data of address maximum, the erasing flag bit of first page described in juxtaposition, if it is not, then setting to 0 fraction data, juxtaposition The erasing flag bit of the first page and second page.
Present invention also provides a kind of electricity data storage devices, referring to Fig. 7, a kind of electricity provided in an embodiment of the present invention The structure chart of data storage device, as shown in fig. 7, comprises:
Memory 701, for storing computer program;
Processor 702, for performing computer program when, can realize the step of above-described embodiment provides.Certainly The electricity data storage device can also include the components such as various network interfaces, power supply.
Electricity data storage device provided in an embodiment of the present invention, using having the function of the flash of IAP, in stored program While store energy data, often generate unit quantity of electricity it is cumulative when store an electricity data, it is ensured that the peace of electricity data Quan Xing;For the integer part and fractional part of electricity data, stored respectively at least page two of flash, it is ensured that even if When frequently electrically operated up and down, the erasing of flash does not all interfere with the storage of electricity data, and the electricity data stored will not account for With too many flash memory spaces.
Present invention also provides a kind of computer readable storage mediums, are stored thereon with computer program, the computer Program can realize the step of above-described embodiment provides when being executed by processor.The storage medium can include:USB flash disk, movement Hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), the various media that can store program code such as magnetic disc or CD.
Each embodiment is described by the way of progressive in this specification, the highlights of each of the examples are with other The difference of embodiment, just to refer each other for identical similar portion between each embodiment.
The foregoing description of the disclosed embodiments enables professional and technical personnel in the field to realize or use the present invention. A variety of modifications of these embodiments will be apparent for those skilled in the art, it is as defined herein General Principle can be realized in other embodiments without departing from the spirit or scope of the present invention.Therefore, it is of the invention The embodiments shown herein is not intended to be limited to, and is to fit to and the principles and novel features disclosed herein phase one The most wide scope caused.
Each embodiment is described by the way of progressive in specification, the highlights of each of the examples are with other realities Apply the difference of example, just to refer each other for identical similar portion between each embodiment.For system disclosed in embodiment Speech, since it is corresponded to the methods disclosed in the examples, so description is fairly simple, related part is referring to method part illustration .It should be pointed out that for those skilled in the art, on the premise of the application principle is not departed from, also Can to the application, some improvement and modification can also be carried out, these improvement and modification also fall into the application scope of the claims It is interior.
It should also be noted that, in the present specification, relational terms such as first and second and the like be used merely to by One entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operation Between there are any actual relationship or orders.Moreover, term " comprising ", "comprising" or its any other variant meaning Covering non-exclusive inclusion, so that process, method, article or equipment including a series of elements not only include that A little elements, but also including other elements that are not explicitly listed or further include for this process, method, article or The intrinsic element of equipment.In the absence of more restrictions, the element limited by sentence "including a ...", is not arranged Except also there are other identical elements in the process, method, article or apparatus that includes the element.

Claims (10)

1. a kind of electricity data storage method, which is characterized in that including:
When generate unit quantity of electricity it is cumulative when, inquire about the integer storage number of pages of the integer part of current time electricity data, and root The decimal that the fractional part of the electricity data is calculated according to the integer part stores number of pages;
The integer part of the electricity data is stored to the integer and stores number of pages, fractional part is stored to the decimal and stored Number of pages;
Wherein, the integer part of the electricity data is stored in N pages in flash, the fractional part storage of the electricity data M pages in the flash, M, N are the integer more than 1, and M is the integral multiple of N.
2. electricity data storage method according to claim 1, which is characterized in that deposit the integer part of the electricity data Storage to the integer stores number of pages, and fractional part stores to the decimal and stores number of pages, including:
S221:The first address and offset address of number of pages are stored according to the decimal, obtains the fractional part of the electricity data Storage address, and the fractional part is stored into the storage address;
S222:Judge whether the integer part changes;If so, into S223, if it is not, then entering S224;
S223:The integer storage number of pages of the integer part is inquired about, the integer part is stored to the integer and stores number of pages Offset address in;
S224:Detect whether the integer storage number of pages is filled with;If so, put the erasing flag bit of the integer storage number of pages.
3. electricity data storage method according to claim 1, which is characterized in that the idle fractional part of the electricity data Q pages be stored in the flash, Q are the integer more than 1.
4. electricity data storage method according to claim 1, which is characterized in that further include:
When detecting power down failure, the CF mantissa parts of the electricity data are stored into the flash.
5. electricity data storage method according to claim 1, which is characterized in that the unit quantity of electricity is 0.01 degree.
6. according to any one of the claim 1-5 electricity data storage methods, which is characterized in that if N=2, the electricity Date storage method further includes:
S301:It detects after recovering data command, judges whether the integer data of the peak excursion address of integer storage number of pages closes Method if so, into S302, if it is not, then subtracting one by the peak excursion address, and reenters S301;
S302:Recover the integer data of the peak excursion address of integer storage number of pages;
S303:The decimals of page two that corresponding fraction data is calculated according to the integer data store number of pages, and recover the decimal Store the fraction data of number of pages.
7. electricity data storage method according to claim 6, which is characterized in that recover the decimal of the decimal storage number of pages Data, including:
Judge whether the fraction data of the peak excursion address of the second page in the decimal of page two storage number of pages is legal;
If so, the first page in the detection decimal of page two storage number of pages whether there is valid data, if so, recovering offset The legal fraction data of address maximum, the erasing flag bit of second page described in juxtaposition, if it is not, then recovering the offset of the second page The legal fraction data of address maximum, the erasing flag bit of first page described in juxtaposition;
If it is not, the second page then detected in the decimal of page two storage number of pages whether there is valid data, if so, recovering offset The legal fraction data of address maximum, the erasing flag bit of first page described in juxtaposition, if it is not, then setting to 0 fraction data, juxtaposition institute State the erasing flag bit of first page and the second page.
8. a kind of electricity data storage system, which is characterized in that including:
Computing module, for when generate unit quantity of electricity it is cumulative when, inquire about current time electricity data integer part integer Number of pages is stored, and number of pages is stored according to the decimal of the fractional part of the integer part calculating electricity data;
Memory module stores number of pages, fractional part storage for storing the integer part of the electricity data to the integer Number of pages is stored to the decimal;
Wherein, the integer part of the electricity data is stored in N pages in flash, the fractional part storage of the electricity data M pages in the flash, M, N are the integer more than 1, and M is the integral multiple of N.
9. a kind of electricity data storage device, which is characterized in that including:
Memory, for storing computer program;
Processor realizes the electricity data storage side as described in any one of claim 1 to 7 during for performing the computer program The step of method.
10. a kind of computer readable storage medium, which is characterized in that be stored with computer on the computer readable storage medium Program realizes the electricity data storage side as described in any one of claim 1 to 7 when the computer program is executed by processor Method.
CN201711463338.0A 2017-12-28 2017-12-28 Electric quantity data storage method and system and electric quantity data storage equipment Active CN108052456B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711463338.0A CN108052456B (en) 2017-12-28 2017-12-28 Electric quantity data storage method and system and electric quantity data storage equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711463338.0A CN108052456B (en) 2017-12-28 2017-12-28 Electric quantity data storage method and system and electric quantity data storage equipment

Publications (2)

Publication Number Publication Date
CN108052456A true CN108052456A (en) 2018-05-18
CN108052456B CN108052456B (en) 2020-11-06

Family

ID=62128533

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711463338.0A Active CN108052456B (en) 2017-12-28 2017-12-28 Electric quantity data storage method and system and electric quantity data storage equipment

Country Status (1)

Country Link
CN (1) CN108052456B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112763777A (en) * 2020-12-28 2021-05-07 华立科技股份有限公司 Electric quantity storage method, device, equipment and medium for intelligent electric meter
CN114115736A (en) * 2021-11-22 2022-03-01 北京煜邦电力技术股份有限公司 Electric quantity data processing method, device, equipment and medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102063941A (en) * 2010-12-07 2011-05-18 中国电力科学研究院 EEPROM (Electrically Erasable Programmable Read-Only Memory) loss balancing method for prolonging life of electric energy meter
CN102722456A (en) * 2012-05-30 2012-10-10 深圳市江波龙电子有限公司 Flash memory device and data writing method thereof
CN103207834A (en) * 2013-03-25 2013-07-17 杭州乾程弘泰电力科技有限公司 Electric energy data storage method
CN103487619A (en) * 2013-07-16 2014-01-01 深圳市航天泰瑞捷电子有限公司 Electric energy data storage method
CN106443171A (en) * 2016-08-31 2017-02-22 北京智联信技术有限公司 System and method for metering data of power bus during power failure of power utilization equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102063941A (en) * 2010-12-07 2011-05-18 中国电力科学研究院 EEPROM (Electrically Erasable Programmable Read-Only Memory) loss balancing method for prolonging life of electric energy meter
CN102722456A (en) * 2012-05-30 2012-10-10 深圳市江波龙电子有限公司 Flash memory device and data writing method thereof
CN103207834A (en) * 2013-03-25 2013-07-17 杭州乾程弘泰电力科技有限公司 Electric energy data storage method
CN103487619A (en) * 2013-07-16 2014-01-01 深圳市航天泰瑞捷电子有限公司 Electric energy data storage method
CN106443171A (en) * 2016-08-31 2017-02-22 北京智联信技术有限公司 System and method for metering data of power bus during power failure of power utilization equipment

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112763777A (en) * 2020-12-28 2021-05-07 华立科技股份有限公司 Electric quantity storage method, device, equipment and medium for intelligent electric meter
CN114115736A (en) * 2021-11-22 2022-03-01 北京煜邦电力技术股份有限公司 Electric quantity data processing method, device, equipment and medium
CN114115736B (en) * 2021-11-22 2024-03-19 北京煜邦电力技术股份有限公司 Electric quantity data processing method, device, equipment and medium

Also Published As

Publication number Publication date
CN108052456B (en) 2020-11-06

Similar Documents

Publication Publication Date Title
CN102968217B (en) The datum renewal method of touch-screen, system and touch control terminal
CN104820641B (en) The method for reducing FLASH erasing times
CN201387448Y (en) Multi-functional electric energy meter with high-reliability data storage function
CN104699413B (en) Data managing method, memory storage apparatus and memorizer control circuit unit
CN102193869B (en) Memory management and write-in method, memory controller and storage system
CN100437504C (en) Hard disc data backup system and method
CN103631721A (en) Method and system for isolating bad blocks in internal storage
CN103996412A (en) Power-fail protection method applied to intelligent-card nonvolatile memories
CN105183388A (en) Obtaining method, device and system for hardware physics serial number
CN108052456A (en) A kind of electricity data storage method, system and a kind of electricity data storage device
CN101546294A (en) Method for storing data in Flash memory
CN102455952B (en) Data backup and recovery method, device and system
CN102890645A (en) Memory storage device, memory controller and data writing method
CN107992268A (en) A kind of method and relevant apparatus of bad block mark
CN103176920A (en) Nor flash power down protection method and Nor flash power down protection device
CN103578566B (en) Memory storage apparatus and restorative procedure thereof
CN101788951B (en) Storage method for network computer
CN103870319A (en) Method and device for information processing and electronic device
CN102486719B (en) Intelligent memory card and transaction-writing method thereof
CN102063342A (en) Method and system for managing data of flash memory storage equipment
CN102122233A (en) Method for managing block and writing data, flash memory storage system and controller
CN107315598A (en) A kind of system recovery method and device
CN101464814A (en) Embedded system and its implementing method, and embedded equipment
CN107193485A (en) Storage device, control unit thereof and data storage method for storage device
CN103176813A (en) Method for dormancy mechanism and computer system thereof

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
GR01 Patent grant
GR01 Patent grant