A power collection terminal and data writing method thereof
By using the in-memory database to temporarily store data in the power acquisition terminal and cache it to the eMMC if necessary, the eMMC wear problem caused by frequent writes by the power acquisition terminal is solved, which extends the device life and ensures data coherence.
Patent Information
- Application Number
- CN202410474215.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-19
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2044-04-19
AI Technical Summary
The existing power acquisition terminals are scrapped early due to rapid wear of the eMMC memory, especially because the frequent writing operations of data interactions under APP design increases the wear of the eMMC.
Create a temporary database in memory, prioritizes the storage of exponential data and intermediate data, and caches it to eMMC memory when the preset period or data amount threshold is reached, and all data is immediately cached in abnormal situations to reduce the writing of eMMC. Number of inputs and data volume.
It effectively reduces the wear speed of the eMMC memory, extends the operating life of the power acquisition terminal, and ensures the normal use of data in abnormal situations.
Smart Images

Figure CN118363532B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power collection terminals, and in particular to: 1. a method for writing data into a power collection terminal; 2. a power collection terminal using the method. Background Art
[0002] The current power collection terminal (referred to as the terminal) generally uses eMMC as the storage medium (i.e., sets the eMMC memory). During the operation of the terminal, data is generated and written to the eMMC memory. Due to the limitation of the number of times the eMMC can be erased, the life of the eMMC memory is limited.
[0003] At present, the terminal adopts APP design, and the data exchanged between APPs is multiplied compared with the data generated by a single program, which leads to frequent data writing. Frequent data writing operations will significantly increase the wear of the eMMC memory, causing the terminal to be scrapped prematurely. Summary of the invention
[0004] Based on this, it is necessary to provide a power collection terminal and a data writing method thereof to address the problem that the existing power collection terminal is scrapped prematurely due to rapid wear of the eMMC.
[0005] The present invention is implemented by the following technical solutions:
[0006] In a first aspect, the present invention discloses a method for writing data to a power collection terminal, comprising the following steps:
[0007] Step 1: Start the power collection terminal, complete initialization, and start the current operation;
[0008] Step 2: The power collection terminal creates in memory a first memory database for temporarily storing index data and a second memory database for temporarily storing intermediate data;
[0009] As the current operation proceeds, the index data generated by the power collection terminal is first stored in the memory database 1, and the intermediate data generated is first stored in the memory database 2;
[0010] Step 3: If some index data in the memory database 1 reaches a preset storage period or a preset data volume threshold, the index data in the memory database 1 is first cached to the eMMC memory, and then the index data is cleared from the memory database 1;
[0011] If there are some intermediate data that have been used in the second memory database, these intermediate data are cleared from the second memory database.
[0012] This method for writing data into a power collection terminal implements a method or process according to an embodiment of the present disclosure.
[0013] In a second aspect, the present invention discloses a power collection terminal, which uses the power collection terminal data writing method disclosed in the first aspect.
[0014] The power collection terminal implements the method or process according to the embodiment of the present disclosure.
[0015] Compared with the prior art, the present invention has the following beneficial effects:
[0016] 1. The present invention adopts different storage mechanisms for different types of operating data, uses memory for temporary data storage, writes index data into the eMMC memory periodically or quantitatively, and prevents intermediate data from being written into the eMMC memory at will, thereby reducing the number of writes to the eMMC memory and the amount of data written, effectively reducing the wear rate of the eMMC memory and extending the operating life of the power collection terminal.
[0017] 2. The present invention also takes into account the use of the power collection terminal under abnormal circumstances, and provides for the complete preservation of index data and the transitional preservation of intermediate data, which can ensure the normal and continuous use of the power collection terminal's operating data next time. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0019] Figure 1 This is a brief flow chart of the method for writing data into a power collection terminal in Embodiment 1 of the present invention;
[0020] Figure 2 is a flowchart of processing index data in Example 1 of the present invention;
[0021] Figure 3 This is a flowchart of processing intermediate data in Example 1 of the present invention. DETAILED DESCRIPTION
[0022] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0023] It should be noted that when a component is referred to as being "mounted on" another component, it may be directly on the other component or there may be a central component. When a component is considered to be "set on" another component, it may be directly set on the other component or there may be a central component at the same time. When a component is considered to be "fixed to" another component, it may be directly fixed on the other component or there may be a central component at the same time.
[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "or / and" used herein includes any and all combinations of one or more of the related listed items.
[0025] Example
[0026] First, this embodiment discloses a power collection terminal, which uses a subsequently disclosed power collection terminal data writing method for data.
[0027] It should be noted that the power collection terminal includes hardware components such as MCU, memory, and eMMC memory. As the core processing component of the power collection terminal, MCU is the "brain" for the power collection terminal to achieve control. Memory is the space required for the power collection terminal to run the APP, which has the feature of clearing data when the power is turned off. eMMC memory is the space for the power collection terminal to store data.
[0028] The operating data of the power collection terminal can be divided into two types:
[0029] 1. Index data. Index data includes voltage, current, power, active power and other data, which need to be cached in the eMMC memory.
[0030] 2. Intermediate data. Intermediate data includes: pulse number, number of retries for reporting power outage events, carrier meter reading rounds, etc. Intermediate data is needed to calculate certain index data: if a certain index data has been calculated normally, then the corresponding intermediate data is equivalent to being used up, and there is no need to cache it in the eMMC memory.
[0031] See also Figure 1 , showing the data writing method of the power collection terminal provided by this embodiment, that is, it has different processing mechanisms for the above two types of operation data, including the following steps:
[0032] Step 1: Start the power collection terminal, complete initialization, and start the current operation.
[0033] This step is to correctly initialize the power collection terminal. If the power collection terminal is not started correctly, it is necessary to repair the power collection terminal.
[0034] Step 2: The power collection terminal creates in memory a first memory database for temporarily storing index data and a second memory database for temporarily storing intermediate data.
[0035] Specifically, after the MCU completes initialization, a memory database 1 and a memory database 2 are created in the memory.
[0036] The first in-memory database can be a single or multiple data tables, and the number and format of the data tables are determined by the type of index data. Similarly, the second in-memory database can be a single or multiple data tables, and the number and format of the data tables are determined by the type of intermediate data.
[0037] Generally, it is recommended to use the Sqlite database framework to build an in-memory database. Memory database 2: You can create an in-memory database through the sqlite3_open(":memory:",&mem_db_connection) statement; After the in-memory database is successfully created, call the function sqlite3_exec(mem_db_connection,sql,NULL,NULL,&pErrMsg) to create the corresponding data table.
[0038] As the current operation proceeds, the power collection terminal will generate operation data: the index data will be stored in the memory database 1 first; the intermediate data will be stored in the memory database 2 first.
[0039] Step 3,
[0040] 3.1, for index data:
[0041] If certain index data in the memory database one reaches a preset retention period or reaches a preset data volume threshold (which can be regarded as a type of index data), these index data in the memory database one (i.e., a type of index data) are first cached to the eMMC memory, and then these index data (i.e., a type of index data) are cleared from the memory database one.
[0042] It should be noted that since there is more than one specific type of index data, different types of index data adopt corresponding thresholds according to their specific needs. For example, voltage data can be cached once every 5 minutes or once it reaches 5KB.
[0043] In addition, before caching a type of index data into the eMMC memory, the memory database one can be locked to prevent the memory database one from being operated during the caching process into the eMMC memory, thereby avoiding errors or inconsistencies in data writing.
[0044] 3.2, for intermediate data:
[0045] If there are some intermediate data that have been used up (which can be regarded as a type of intermediate data) in the second in-memory database, these intermediate data (ie, the type of intermediate data) are cleared from the second in-memory database.
[0046] In this way, the index data is written into the eMMC memory periodically or quantitatively, and the intermediate data is used through temporary storage in the memory and is not written into the eMMC memory at will, which can reduce the number of write times and the amount of written data into the eMMC memory.
[0047] It should be noted that the above steps 1 to 3 are for the normal operation stage of the current operation. If an abnormal signal appears in the current operation, such as a shutdown signal, a restart signal, a power failure signal, an abnormal communication signal (including abnormal communication of the internal module of the power collection terminal, and failure of the power collection terminal to connect to the master station for a long time), etc., then additional processing is required for the memory database 1 and the memory database 2:
[0048] If the power collection terminal receives an abnormal signal, it will first process it according to the preset rules, and then execute the operation corresponding to the abnormal signal (if it is a shutdown signal, execute shutdown; if it is a restart signal, execute restart; if it is a power outage signal, execute power outage; if it is a communication abnormality signal, wait for communication to be normal; other situations are similar); otherwise, proceed to step three.
[0049] Specifically, the preset rules are:
[0050] 1. All index data in the memory database 1 (which can be regarded as the second type of index data) are cached into the eMMC memory. Similar to the above, before the second type of index data is cached into the eMMC memory, the memory database 1 can also be locked.
[0051] 2. If there is intermediate data that needs to be saved in the memory database 2 (that is, intermediate data that has not been fully used, which can be regarded as type 2 intermediate data), these intermediate data (that is, type 2 intermediate data) are cached to the eMMC memory to achieve transitional storage of the intermediate data.
[0052] That is to say, if an abnormal signal occurs, all index data of the memory database 1 must be cached immediately, and the intermediate data that needs to be saved in the memory database 2 must be cached.
[0053] In order to increase data recognition, if there are intermediate data that need to be saved in the memory database 2, these intermediate data can be marked first to distinguish them from the exponential data, and then these marked intermediate data can be cached in the eMMC memory.
[0054] Then, under this processing method, for the current run, there is a possibility that the intermediate data was written abnormally in the previous run. Therefore, it is necessary to determine whether the previous run wrote intermediate data to the eMMC memory. If so, the data must be reloaded for use in the current run, so as to achieve normal and continuous use of the running data.
[0055] That is to say: in step 2, it is determined whether the power collection terminal cached intermediate data in the eMMC memory when it was last run; if the power collection terminal cached intermediate data in the eMMC memory when it was last run, these intermediate data are loaded and stored in the memory database 2; otherwise, no processing is performed.
[0056] Among them, the specific judgment method is: the power collection terminal reads and analyzes the data in the eMMC memory; if there is intermediate data in the eMMC memory, the power collection terminal cached the intermediate data in the eMMC memory when it was last run; otherwise, the power collection terminal did not cache the intermediate data in the eMMC memory when it was last run.
[0057] It should be emphasized that the condition for writing intermediate data into the eMMC memory is that the power collection terminal receives an abnormal signal and the intermediate data written is the second type; therefore, compared with the existing writing mechanism, the number of writes and the amount of written data of this method are effectively reduced, which can reduce the wear rate of the eMMC memory and extend the operating life of the power collection terminal.
[0058] In order to facilitate the distinction and understanding, the above processing flow of index data is drawn Figure 2 The above processing flow for intermediate data is drawn Figure 3 Flowchart of the process.
[0059] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0060] The above-mentioned embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A method for writing data to a power collection terminal, characterized in that: The following steps are involved: Step 1: Start the power collection terminal, complete initialization, and start the current operation; Step 2, the power collection terminal creates in memory a first memory database for temporarily storing index data and a second memory database for temporarily storing intermediate data; Among them, the intermediate data is needed to calculate certain index data; if a certain index data has been calculated normally, then the corresponding intermediate data is equivalent to being used up; as the current operation proceeds, the index data generated by the power collection terminal is first stored in the memory database 1, and the intermediate data generated is first stored in the memory database 2; In step 2, it is determined whether the power collection terminal cached intermediate data in the eMMC memory when it was last run; wherein the power collection terminal reads and analyzes the data in the eMMC memory; if there is intermediate data in the eMMC memory, the power collection terminal cached the intermediate data in the eMMC memory when it was last run; If the power collection terminal cached intermediate data in the eMMC memory when it was last run, then load these intermediate data and store them in the second memory database; Step 3: If some index data in the memory database 1 reaches a preset storage period or a preset data volume threshold, the index data in the memory database 1 is first cached to the eMMC memory, and then the index data is cleared from the memory database 1; If there are some intermediate data that have been used in the second memory database, clear these intermediate data from the second memory database; If the power collection terminal receives an abnormal signal, it is first processed according to the preset rules, and then the operation corresponding to the abnormal signal is performed; otherwise, step three is performed; The preset rules are: Cache all index data in memory database 1 into the eMMC memory; If there is intermediate data that needs to be saved in the memory database 2, these intermediate data are cached in the eMMC memory.
2. The method for writing data to a power collection terminal according to claim 1, characterized in that: The types of index data include voltage, current, power, and active power; The types of the intermediate data include pulse number, power outage event reporting retry number, and carrier meter reading round number.
3. The method for writing data to a power collection terminal according to claim 1, characterized in that: In-memory database 1 and in-memory database 2 are built using the Sqlite database framework.
4. The method for writing data to a power collection terminal according to claim 1, characterized in that: Before the index data is cached into the eMMC memory, the memory database 1 is locked.
5. The method for writing data to a power collection terminal according to claim 1, characterized in that: The abnormal signals include shutdown signals, restart signals, power failure signals, and communication abnormality signals.
6. The method for writing data to a power collection terminal according to claim 1, characterized in that: If there are intermediate data that need to be saved in the second memory database, these intermediate data are first marked to distinguish them from the exponential data, and then the marked intermediate data are cached in the eMMC memory.
7. A power collection terminal, characterized in that: It uses the power collection terminal data writing method as described in any one of claims 1-6.
Citation Information
Patent Citations
Method and device for prolonging service life of memory, electronic equipment and storage medium
CN113900591A
