CN108108413B - Method and system for automatically generating data pointer based on stored data - Google Patents

Method and system for automatically generating data pointer based on stored data Download PDF

Info

Publication number
CN108108413B
CN108108413B CN201711323961.6A CN201711323961A CN108108413B CN 108108413 B CN108108413 B CN 108108413B CN 201711323961 A CN201711323961 A CN 201711323961A CN 108108413 B CN108108413 B CN 108108413B
Authority
CN
China
Prior art keywords
pointer
sequence number
storage
storage sequence
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.)
Active
Application number
CN201711323961.6A
Other languages
Chinese (zh)
Other versions
CN108108413A (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.)
Ningbo Sanxing Medical and Electric Co Ltd
Original Assignee
Ningbo Sanxing Medical and Electric 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 Ningbo Sanxing Medical and Electric Co Ltd filed Critical Ningbo Sanxing Medical and Electric Co Ltd
Priority to CN201711323961.6A priority Critical patent/CN108108413B/en
Publication of CN108108413A publication Critical patent/CN108108413A/en
Application granted granted Critical
Publication of CN108108413B publication Critical patent/CN108108413B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24553Query execution of query operations
    • G06F16/24562Pointer or reference processing operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof

Abstract

The invention relates to a method for automatically generating a data pointer based on stored data, which comprises the following steps: before power failure, sequentially storing data to a storage area according to a pointer cyclic moving sequence, and simultaneously writing a storage sequence number formed according to the sequence; traversing the pointer after power-on to obtain a storage sequence number A corresponding to the current position of the pointer and a storage sequence number B corresponding to the next position of the pointer; and obtaining the position of the pointer in the power failure according to the storage sequence number A corresponding to the current position of the pointer, the storage sequence number B corresponding to the next position of the pointer and the difference value of the two. Compared with the prior art, the method can effectively obtain the specific direction of the pointer during power failure, does not need to occupy an external storage space additionally, and has high reliability.

Description

Method and system for automatically generating data pointer based on stored data
Technical Field
The invention relates to the field of data processing, in particular to a method and a system for automatically generating a data pointer based on stored data.
Background
With the continuous increase of network services and capacities, the data processing capability of electronic products is more and more demanding. For example, the intelligent electric energy meter needs to record a large amount of periodic data in the operation process, such as settlement electric quantity, settlement demand, frozen data, event record and the like. In order to realize large-scale data management and control, a linked list method is often adopted, and the positions of current data and historical data are positioned through pointers, so that the pointer data also needs to be stored while the data is stored.
However, because the length and the interval time of the stored data are different, each storage channel needs an independent pointer, the pointer needs to be stored in an external EEPROM when the power is off, and needs to be recovered from the external EEPROM after the power is on. Such a pointer saving and restoring mechanism wastes storage space and storage time on the one hand, and also increases unreliability on the other hand, because this approach may have the problem that the stored data is correct, and the pointer is in error, so that the correct data cannot be acquired.
Disclosure of Invention
In view of the above problems, an object of the present invention is to provide a method and a system for automatically generating a data pointer based on stored data, in which only data needs to be stored, the pointer is only temporarily opened in a RAM, and the pointer does not need to be stored when power is turned on or off. When the power is on every time, the position pointed by the pointer in the power failure can be calculated from the stored data by adopting the method, so that the external storage space is reduced, and the storage reliability is improved.
In order to achieve the purpose, the invention adopts the technical scheme that: a method for automatically generating data pointers based on stored data is characterized in that:
before power failure, sequentially storing data to a storage area according to a pointer cyclic moving sequence, and simultaneously writing a storage sequence number formed according to the sequence;
traversing the pointer after power-on to obtain a storage sequence number A corresponding to the current position of the pointer and a storage sequence number B corresponding to the next position of the pointer;
and obtaining the position of the pointer in the power failure according to the storage sequence number A corresponding to the current position of the pointer, the storage sequence number B corresponding to the next position of the pointer and the difference value of the two.
Further, if the storage sequence number a corresponding to the current position of the obtained pointer is not null and the storage sequence number B corresponding to the next position of the pointer is null, the position of the pointer when the power is off is the position of the storage sequence number B.
Further, if the storage sequence number a corresponding to the current position of the acquired pointer and the storage sequence number B corresponding to the next position of the pointer are both non-empty, and the difference is not 1, it is obtained that the position of the pointer is the position of the storage sequence number B when the power failure occurs.
Furthermore, the linked list corresponding to the pointer is a circular single linked list.
Further, the storage area can store the latest N times of data records at most.
Further, the value of N is 10.
Further, the length of data stored each time is fixed to L.
Further, the length of the sequence number is 2 bytes.
A system for automatically generating data pointers based on stored data, comprising: the system is provided with a plurality of devices,
the storage module is used for sequentially storing data according to the circular moving sequence of the pointer before power failure and simultaneously writing a storage serial number formed according to the sequence;
the acquisition module is used for acquiring a storage sequence number A corresponding to the current position of the pointer and a storage sequence number B corresponding to the next position of the pointer during the pointer passing after power-on;
and the calculation judgment module is used for obtaining the position of the pointer in the power failure according to the value of the storage serial number A, B and the difference value of the value and the value.
Further, the calculation and judgment module is used for judging that the position of the pointer is the position of the storage serial number B when the power failure occurs when the storage serial number A corresponding to the current position of the acquired pointer is not empty and the storage serial number B corresponding to the next position of the pointer is empty; and when the acquired storage sequence number A corresponding to the current position of the pointer and the acquired storage sequence number B corresponding to the next position of the pointer are both non-null and the difference value is greater than 1, judging that the position of the pointer is the position of the storage sequence number B in the power failure.
Compared with the prior art, the invention has the advantages that: the method only stores data to be stored in a meter memory, stores a moving sequence number every time, does not store a pointer, judges the position of the pointer before power failure by analyzing a storage sequence number corresponding to the current position of the pointer, a storage sequence number corresponding to the next position of the pointer and the difference value of the two after power on, and only temporarily opens up the pointer in an RAM area without occupying extra storage space, thereby saving resources and simultaneously increasing the reliability of storage.
Drawings
FIG. 1 is a flowchart illustrating the determination process according to an embodiment of the present invention.
Fig. 2 is a schematic structural diagram of a system according to an embodiment of the present invention.
Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the accompanying drawings are illustrative only for the purpose of explaining the present invention, and are not to be construed as limiting the present invention.
The method and the corresponding system are mainly used for data storage and event storage of the intelligent electric energy meter, and are specifically described as follows. When the memory stores data each time, a 2-byte serial number is written in while the data to be stored is stored, the serial number is formed according to the pointer moving sequence of the circular linked list, the length of the data to be stored is L fixed, namely the length of the total data to be stored each time is L +2, and the created storage space can store the latest N times of data records at most.
If the system is not powered down, the memory units passed by the pointer have data and serial numbers, and the serial numbers are sequentially increased. In order to obtain the position of the pointer before power failure, the specific judgment mode is as follows:
when the power is on, the pointer can acquire a storage serial number A corresponding to the current position, and simultaneously acquire a storage serial number B corresponding to the next position of the pointer, and through judgment, if A is not null and B is null, the position where the pointer is located before the power failure points to A; if A, B is not null, and the difference between a and B is not 1, it is determined that the pointer points to the location of storage sequence number B when power is lost.
For example, when the system loses power when storing the 5 th data, the corresponding data and the sequence number are not stored in the 5 th storage unit, the pointer traverses from the head after power-on, when the pointer acquires that the current sequence number is 3 and the next sequence number is 4, and the difference between the two is 1, it indicates that the pointer does not point to any of the two before power-off, the pointer continues to travel, when the acquired sequence number is 4 and the next sequence number is null, that is, when a is 4 and B is blank, it can be determined that the system loses power when the pointer points to the position 5, that is, when the pointer points to the 5 th storage unit during power-off, that is, the pointer is located in the 5 th storage unit during power-off, as shown in yellow bottom color in table 1. In fact, it can also be obtained from table 1 below that the storage area is not full and the serial number is not flipped.
1 2 3 4 5 Blank space Blank space Blank space Blank space Blank space
If the memory stores a plurality of times continuously, that is, the number of times exceeds 10, for example, 13 times, it indicates that the storage pointer is turned over, and since the storage is a circular covering type storage, in a normal case, when the 13 th time of storage, the original storage serial number 3 corresponding to the current position of the pointer will be covered by the current serial number 13, but since the system is powered off during storage, the original storage serial number 3 of the storage unit is not covered. After power-on, the pointer starts traversing, and when the traversing obtains that a is 12 and the sequence number B corresponding to the next position is 3, and the difference between the two is not 1, it is determined that the pointer points to the position of the sequence number 3 before power-off, as shown in the yellow bottom color in table 2 below.
11 12 3(13) 4 5 6 7 8 9 10
Even if the pointer is turned over for multiple times subsequently, the specific position can be accurately found by adopting the method.
Meanwhile, the method corresponds to a system which comprises a storage module 1, wherein the storage module 1 is used for sequentially storing data according to a pointer cyclic movement sequence before power failure and simultaneously writing a storage sequence number formed according to the sequence;
the acquisition module 2 is used for acquiring a storage sequence number A corresponding to the current position of the pointer and a storage sequence number B corresponding to the next position of the pointer during the pointer traversal after power-on;
the calculation judgment module 3 is used for obtaining the position of the pointer in the power failure according to the value of the storage serial number A, B and the difference value of the storage serial number A, B; specifically, the calculation and judgment module 3 is configured to, when the storage serial number a corresponding to the current position of the obtained pointer is not empty and the storage serial number B corresponding to the next position of the pointer is empty, judge that the position of the pointer is the position of the storage serial number B when the power failure occurs; and when the acquired storage sequence number A corresponding to the current position of the pointer and the acquired storage sequence number B corresponding to the next position of the pointer are both non-null and the difference value is greater than 1, judging that the position of the pointer is the position of the storage sequence number B in the power failure.
By adopting the method, only the data required to be stored is stored in the meter memory, the pointer is only temporarily opened up in the RAM area, the pointer is not stored when the power is on and off, and the position pointed by the current pointer can be calculated from the stored data by using the method and the system when the power is on every time, so that the external storage space is reduced, and the storage reliability is improved.
In addition to the above-mentioned modifications, other similar modifications are also included in the scope of the modifications of the present invention, and are not described herein in detail. While embodiments of the invention have been shown and described, it will be understood by those skilled in the art that: various changes, modifications, substitutions and alterations can be made to the embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.

Claims (7)

1. A method for automatically generating data pointers based on stored data is characterized in that:
before power failure, sequentially storing data to a storage area according to a pointer cyclic moving sequence, and simultaneously writing a storage sequence number formed according to the sequence;
traversing the pointer after power-on to obtain a storage sequence number A corresponding to the current position of the pointer and a storage sequence number B corresponding to the next position of the pointer;
judging whether a storage sequence number A corresponding to the current position of the pointer and a storage sequence number B corresponding to the next position of the pointer are empty or not and judging whether the storage sequence number A corresponding to the current position of the pointer and the storage sequence number B corresponding to the next position of the pointer are the difference values of the storage sequence number A and the storage sequence number B, if the storage sequence number A corresponding to the current position of the pointer is not empty and the storage sequence number B corresponding to the next position of the pointer is empty, obtaining that the position of the pointer is the position of the storage sequence number B when the power is off, and if the storage sequence number A corresponding to the current position of the pointer and the storage sequence number B corresponding to the next position of the pointer are not empty and the difference value is not 1, obtaining that the position of the pointer is the position of the storage sequence number B when the power is off.
2. The method of claim 1, wherein: and the linked list corresponding to the pointer is a circular single linked list.
3. The method of claim 2, wherein: the storage area can store the latest N times of data records at most.
4. The method of claim 3, wherein: the value of N is 10.
5. The method of claim 1, wherein: the length of data stored each time is fixed to L.
6. The method of claim 5, wherein: the sequence number is 2 bytes in length.
7. A system for automatically generating data pointers based on stored data, comprising: the system is provided with a plurality of devices,
the storage module (1) is used for sequentially storing data according to a pointer cyclic movement sequence before power failure and simultaneously writing a storage sequence number formed according to the sequence;
the acquisition module (2) is used for acquiring a storage sequence number A corresponding to the current position of the pointer and a storage sequence number B corresponding to the next position of the pointer when the pointer passes after power-on;
and the calculation judging module (3) is used for judging the position of the pointer in the power failure according to whether the storage sequence number A, B is empty correspondingly or not and the size difference between the storage sequence numbers A and B, obtaining the position of the pointer in the power failure as the position of the storage sequence number B if the storage sequence number A corresponding to the current position of the pointer is not empty and the storage sequence number B corresponding to the next position of the pointer is empty, and obtaining the position of the pointer in the power failure as the position of the storage sequence number B if the storage sequence number A corresponding to the current position of the pointer and the storage sequence number B corresponding to the next position of the pointer are not empty and the difference is not 1.
CN201711323961.6A 2017-12-12 2017-12-12 Method and system for automatically generating data pointer based on stored data Active CN108108413B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711323961.6A CN108108413B (en) 2017-12-12 2017-12-12 Method and system for automatically generating data pointer based on stored data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711323961.6A CN108108413B (en) 2017-12-12 2017-12-12 Method and system for automatically generating data pointer based on stored data

Publications (2)

Publication Number Publication Date
CN108108413A CN108108413A (en) 2018-06-01
CN108108413B true CN108108413B (en) 2022-04-26

Family

ID=62215615

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711323961.6A Active CN108108413B (en) 2017-12-12 2017-12-12 Method and system for automatically generating data pointer based on stored data

Country Status (1)

Country Link
CN (1) CN108108413B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101208669A (en) * 2005-06-30 2008-06-25 英特尔公司 Technique to write to a non-volatile memory
CN101923112A (en) * 2010-07-26 2010-12-22 珠海中慧微电子有限公司 Method for managing high reliability of electric energy measurement data
CN106648982A (en) * 2016-12-15 2017-05-10 宁波迦南智能电气股份有限公司 Electric energy meter power down protection data storing method
CN107168647A (en) * 2017-04-17 2017-09-15 武汉永力科技股份有限公司 FLASH data read-write methods and system
CN107256197A (en) * 2017-05-18 2017-10-17 深圳市晟碟半导体有限公司 A kind of date storage method, storage device and intelligent terminal

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS63175923A (en) * 1987-01-16 1988-07-20 Nec Corp Sequential organizing file retrieving system
GB2393273A (en) * 2002-09-20 2004-03-24 Sharp Kk Method and apparatus for detecting an error in writing to persistent memory
CN201600411U (en) * 2010-03-05 2010-10-06 威胜集团有限公司 Electric energy meter with data managing system
CN101944119B (en) * 2010-09-21 2013-04-10 国网电力科学研究院 Real-time event management method for intelligent electronic equipment
US9231615B2 (en) * 2012-10-24 2016-01-05 Seagate Technology Llc Method to shorten hash chains in Lempel-Ziv compression of data with repetitive symbols
CN104699727B (en) * 2014-01-15 2017-12-22 杭州海康威视数字技术股份有限公司 A kind of date storage method and device
CN105468544B (en) * 2014-09-11 2021-05-11 深圳市腾讯计算机系统有限公司 Method and device for realizing power-down prevention file system and power-down prevention file system
CN105975587B (en) * 2016-05-05 2019-05-10 诸葛晴凤 A kind of high performance memory database index organization and access method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101208669A (en) * 2005-06-30 2008-06-25 英特尔公司 Technique to write to a non-volatile memory
CN101923112A (en) * 2010-07-26 2010-12-22 珠海中慧微电子有限公司 Method for managing high reliability of electric energy measurement data
CN106648982A (en) * 2016-12-15 2017-05-10 宁波迦南智能电气股份有限公司 Electric energy meter power down protection data storing method
CN107168647A (en) * 2017-04-17 2017-09-15 武汉永力科技股份有限公司 FLASH data read-write methods and system
CN107256197A (en) * 2017-05-18 2017-10-17 深圳市晟碟半导体有限公司 A kind of date storage method, storage device and intelligent terminal

Also Published As

Publication number Publication date
CN108108413A (en) 2018-06-01

Similar Documents

Publication Publication Date Title
CN101432721B (en) Detection of potential forwarding loops in bridged networks
US8024297B2 (en) Data logging system and method thereof for heterogeneous data
EP3349126B1 (en) Method, device, storage medium, and apparatus for automatically discovering fuel station poi
CN101272276A (en) Log management implementing method
CN108664603B (en) Method and device for repairing abnormal aggregation value of time sequence data
CN106802785B (en) A kind of stack analysis method and device
CN103531246B (en) The memorizer error correction method quickly write with reading
CN109246210A (en) Internet of Things communication means and device
CN109254839A (en) It determines the method in task triggered time, construct the method and system of task timer
CN105608919A (en) Method and device for determining station position
CN103778120A (en) Global file identification generation method, generation device and corresponding distributed file system
CN108108413B (en) Method and system for automatically generating data pointer based on stored data
CN105138329B (en) A kind of method for changing in-orbit task
CN104750814B (en) The automatic storage method of polynary heterogeneous data flow based on multisensor
CN103761194B (en) A kind of EMS memory management process and device
CN105930839A (en) Electric railway overhead line system pole number intelligent identification method
US20170083531A1 (en) Selecting an incremental backup approach
CN106774397A (en) A kind of four redundance flight control systems computer synchronous method
US20160110245A1 (en) Method for saving fault wave data
CN107342944B (en) A kind of distribution of ID mark and persistence method and system
CN103532758B (en) Be applicable to the configuration processing method of transmission of future generation, data equipment fusion
CN109521954A (en) A kind of distribution FTU fixed point file management method and device
CN112766741B (en) Query method, system, terminal and storage medium
CN105117177B (en) A kind of big data management method based on single hard disk multi partition
US8902890B2 (en) Memory saving packet modification

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