Data storage method, device and equipment of human-computer interface, medium and product

By saving human-machine interface data in the cache queue and cache partition, and using the wear balance mechanism of the cache partition, the data loss problem during power outage of the human-machine interface is solved, realizing timely data storage and device reliability.

CN120508250APending Publication Date: 2025-08-19SHENZHEN CITY SAMKOON TECH
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510556228.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-29
Publication Date
2025-08-19

AI Technical Summary

Technical Problem

The data loss rate of the prior art is high when the human-computer interface is powered down, and data cannot be saved in time, resulting in data being lost during the asynchronous storage of the database.

Method used

By storing data in the cache queue and writing to the first block area of the cache partition when the queue is detected to be full, the first block area is determined based on the number of block areas in the cache partition and the number of erases, the data is stored in the database when the first block area is full or the preset synchronization time is reached, and an erase operation is performed to update the erases.

Benefits of technology

In the event of power outage, reduce the data loss rate, ensure that the data is effectively stored within the preset time, reduce wear on the storage device, extend the service life of the equipment, and improve the reliability of the data and the service life of the database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120508250A_ABST
    Figure CN120508250A_ABST
Patent Text Reader

Abstract

The invention discloses a data storage method and device for a human-computer interface, equipment, a medium and a product, and belongs to the technical field of computer processing. The method comprises the following steps: in response to an acquisition request for related data of a human-computer interface, storing the related data into a cache queue; when it is detected that the cache queue is full, related data in the cache queue is written into a first block area of the cache partition; wherein the first block region is determined according to the number of block regions in the cache partition and the erasure frequency of the cache partition; when it is detected that the first block area is fully written or the preset data synchronization time is reached, storing related data in the first block area into a database; and executing an erasure operation on the first block area, and adding one to the erasure times. According to the method, the data loss rate during database power failure can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment, medium and product for storing data on a human-computer interface. Background Art

[0002] In today's digital age, the human-machine interface (HMI), a core tool for interaction between equipment and operators, is becoming increasingly important. With the widespread adoption of industrial automation, the Internet of Things, and various smart devices, the demand for HMI data collection and storage capabilities is constantly increasing. From real-time monitoring in industrial production to recording device status in smart homes, intelligent transportation, and other fields, high-frequency, high-precision data collection and stable and reliable data storage have become key requirements.

[0003] Currently, several mainstream technical solutions have emerged for database collection and storage functions within human-machine interfaces. The basic process of these solutions is to acquire data through a timing or triggering mechanism, then store it in a database file; when the data needs to be displayed, it can be retrieved from the database and displayed. Furthermore, to address emergencies (such as power outages), existing technologies utilize the database's built-in log recovery function to restore database files, thereby ensuring data integrity and system availability. From a theoretical perspective, this technical solution is feasible and, to a certain extent, meets the basic requirements of most current application scenarios.

[0004] However, in real-world applications, data needs to pass through multiple layers (database, file system, and NAND flash) before it can be saved from the application to the final storage medium (NAND-type Flash Memory, NAND flash), and each step in this process is completed asynchronously. That is, the human-machine interface collects data at regular intervals, but because the database saves data asynchronously, the data is not actually stored in NAND flash. It takes a certain amount of time (usually one minute) for the program to execute the database submission instruction before the data is actually written to the database. If the human-machine interface loses power, the existing solution will lose one minute of data, and recovery is impossible. Therefore, it is urgent to develop an optimization method to save data in a timely manner and reduce the data loss rate during power outages.

[0005] The above content is only used to assist in understanding the technical solution of the present invention and does not constitute an admission that the above content is prior art. Summary of the Invention

[0006] The main purpose of the embodiments of the present application is to provide a method, device, equipment, medium and product for storing data in a human-computer interface, aiming to reduce the data loss rate when the database loses power.

[0007] In a first aspect, an embodiment of the present application provides a method for saving data in a human-machine interface, the method comprising:

[0008] In response to a request for collecting relevant data of the human-machine interface, saving the relevant data into the cache queue;

[0009] When it is detected that the cache queue is full, writing the relevant data in the cache queue into a first block area of the cache partition; wherein the first block area is determined according to the number of block areas in the cache partition and the number of times the cache partition is erased;

[0010] When it is detected that the first block area is full or a preset data synchronization time has been reached, the relevant data in the first block area is stored in the database;

[0011] An erase operation is performed on the first block area, and the erase count is increased by one.

[0012] In a second aspect, an embodiment of the present application provides a method and apparatus for saving data in a human-machine interface, the apparatus comprising:

[0013] A saving module, configured to save the relevant data into a cache queue in response to a request for collecting relevant data of the human-machine interface;

[0014] a writing module, configured to write the relevant data in the cache queue into a first block area of the cache partition when detecting that the cache queue is full; wherein the first block area is determined according to the number of block areas in the cache partition and the number of times the cache partition is erased;

[0015] A storage module, storing the relevant data in the first block area into the database when detecting that the first block area is full or a preset data synchronization time has been reached;

[0016] The erasing module performs an erasing operation on the first block area and increases the erasure count by 1. In a third aspect, an embodiment of the present application provides a data preservation method and device for a human-computer interface, the device comprising: a memory, a processor, and a computer processing program stored in the memory and executable on the processor, the computer processing program being configured to implement the data preservation method for the human-computer interface as described in the first aspect.

[0017] In a fourth aspect, an embodiment of the present application provides a storage medium having a computer processing program stored thereon, and when the computer processing program is executed by a processor, the human-computer interface data saving method as described in the first aspect is implemented.

[0018] In a fifth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and executed by at least one processor to implement the data storage method of the human-computer interface as described in the first aspect.

[0019] This application proposes a data preservation method, apparatus, device, medium, and product for a human-machine interface. The method comprises: responding to a request to collect relevant data from the human-machine interface and saving the relevant data to a cache queue; upon detecting that the cache queue is full, writing the relevant data in the cache queue to the first block area of a cache partition; wherein the first block area is determined based on the number of blocks in the cache partition and the number of erases of the cache partition; upon detecting that the first block area is full or a preset data synchronization time has been reached, storing the relevant data in the first block area in a database; performing an erase operation on the first block area and updating the erase count; wherein the erase count increases by one each time an erase operation is performed. Compared to existing solutions that store data asynchronously in a database, which require a preset data synchronization time and a database commit command to be executed before the data is actually written to the database, the present application writes data to the cache partition within the preset data synchronization time or when the first block area is full. Data written within the preset data synchronization time is actually valid. This allows for effective data preservation. Even in the event of a power outage, existing solutions can lose one minute of data. However, the present application, through cache partitioning, can save data in a timely manner, reducing the data loss rate during power outages. At the same time, the first block area is determined based on the number of blocks in the cache partition and the number of cache partition erases to achieve wear leveling. Furthermore, wear leveling and regular data synchronization ensure data reliability and database lifespan. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 This is one of the flow charts of the data storage method of the human-machine interface provided in the embodiment of the present application;

[0021] Figure 2 This is a schematic diagram of the location of cache partitions in the data storage method for the human-machine interface provided by an embodiment of the present application;

[0022] Figure 3 This is a schematic diagram of the interface reading and writing of the data storage method of the human-machine interface provided by the embodiment of the present application;

[0023] Figure 4 Schematic diagram of a cache partition write operation of the human-machine interface data storage method provided in an embodiment of the present application;

[0024] Figure 5 Schematic diagram of data recovery after power-on in the data preservation method of the human-machine interface provided in an embodiment of the present application;

[0025] Figure 6 Schematic diagram of a read operation of a cache partition in a data storage method for a human-machine interface provided in an embodiment of the present application;

[0026] Figure 7 Schematic diagram of database storage of the human-machine interface data storage method provided in an embodiment of the present application;

[0027] Figure 8 This is a data schematic diagram of the data storage method of the human-computer interface provided by an embodiment of the present application;

[0028] Figure 9 This is a structural diagram of a method and device for saving data in a human-machine interface provided by an embodiment of the present application;

[0029] Figure 10 This is one of the structural diagrams of the electronic device provided in the embodiment of the present application;

[0030] Figure 11 This is the second structural diagram of the electronic device provided in the embodiment of the present application;

[0031] The realization of the objectives, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0032] The following will be combined with the accompanying drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the embodiments described are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field are within the scope of protection of this application.

[0033] The terms "first," "second," and the like in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of this application can be implemented in an order other than that illustrated or described herein, and that the objects distinguished by "first," "second," and the like are generally of the same type, and do not limit the number of objects; for example, the first object can be one or more. In addition, the term "and / or" in the specification and claims refers to at least one of the connected objects, and the character " / " generally indicates that the objects connected are in an "or" relationship.

[0034] The data storage method of the human-machine interface provided by the embodiment of the present application is described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.

[0035] The embodiment of the present application provides a data storage method for a human-machine interface, which is applied to an electronic device, wherein the electronic device includes a cache queue, a cache partition and a database, wherein the cache partition includes multiple block areas, such as Figure 1 As shown, the data storage method of the human-machine interface of the embodiment of the present application may include the following steps:

[0036] Step 101, in response to a request for collecting relevant data of the human-machine interface, saving the relevant data into the cache queue;

[0037] Step 102: When it is detected that the cache queue is full, write the relevant data in the cache queue into a first block area of the cache partition; wherein the first block area is determined according to the number of block areas in the cache partition and the number of times the cache partition is erased;

[0038] Step 103: When it is detected that the first block area is full or the preset data synchronization time has been reached, the relevant data in the first block area is stored in the database;

[0039] Step 104: perform an erase operation on the first block area, and increase the erase count by one.

[0040] In an embodiment of the present application, in response to a request to collect data related to a human-machine interface, the relevant data is saved in a cache queue; upon detecting that the cache queue is full, the relevant data in the cache queue is written to the first block area of the cache partition; wherein the first block area is determined based on the number of blocks in the cache partition and the erase count of the cache partition; upon detecting that the first block area is full or a preset data synchronization time has been reached, the relevant data in the first block area is stored in a database; an erase operation is performed on the first block area and the erase count is updated; wherein the erase count increases by one each time an erase operation is performed. Compared to existing solutions that store data asynchronously in the database, which require data to be submitted to the database after a preset data synchronization time, the present application can write data to the cache partition within the preset data synchronization time or when the first block area is full. Data written within the preset data synchronization time is actually valid. In this way, effective data storage can be achieved. Even in the event of a power outage, the existing solution will lose one minute of data. However, through cache partitioning, the present application can save data in a timely manner, reducing the data loss rate during power outages. Even in the worst-case scenario, the cache queue will only lose a preset amount of data (1 second), minimizing data loss during power outages. Furthermore, wear leveling is achieved by determining the first block based on the number of blocks in the cache partition and the number of erases per partition. Furthermore, wear leveling and regular data synchronization ensure data reliability and database lifespan.

[0041] In some embodiments, in the above step 101, when the human-machine interface collects data, the data is first stored in a cache queue.

[0042] In this embodiment, it should be noted that the cache queue can be a temporary storage area for temporarily storing collected data. The cache queue can improve data collection efficiency, reduce the number of writes to the storage device, and extend the service life of the storage device.

[0043] In some embodiments, in the above step 102, when the data in the cache queue reaches a certain amount (ie, the cache queue is full), the data are written in batches to the first area of the cache partition.

[0044] In this embodiment, it should be noted that the cache queue stores data for a maximum of a preset time (which may be 1 second). When 1 second is up or the cache queue is full, data will be written to the cache partition.

[0045] A cache partition can be a non-volatile storage area used to temporarily store data until it is synchronized to the database. The cache partition can provide an intermediate storage layer to ensure that data is not lost before being synchronized to the database and to achieve wear leveling.

[0046] The cache partition can be a ubifs file system (Unsorted Block File System, ubifs) for the storage medium (NAND-type Flash Memory, nandflash), which divides a cache partition including multiple block areas (block areas) in the nandflash as a storage area for cache data. The purpose of the cache partition is to limit the frequent erase and write functions of the nandflash to the cache partition, and physically separate it from the main area where ubifs is located. This can prevent the nandflash from being erased and written, resulting in failure of the entire file system on the nandflash. See the corresponding description of this paragraph. Figure 2 , Figure 2 This is a schematic diagram of the location of the cache partition. The primary partition is the primary partition where ubifs is located, and other partitions are partitions other than the cache partition and the primary partition.

[0047] Block regions can be divided into multiple block regions for the cache partition, and each block region can be erased and written independently. By properly allocating block regions, wear leveling can be achieved, extending the life of the cache partition.

[0048] The erase count records the number of times a block has been erased. This is a global variable, with only one erase count for all blocks. The erase count can be used to sequentially select blocks or select blocks with fewer erase counts for write operations to achieve wear leveling.

[0049] In some embodiments, in step 103 above, the selection of the first block area is determined based on the number of block areas in the cache partition and the number of erase times.

[0050] In this embodiment, it should be noted that the database can be a persistent storage system for long-term data storage. The database can ensure persistent storage of data and reduce the risk of data loss.

[0051] When the first block is full, or the preset synchronization time (e.g., once per minute) is reached, the data in the first block is synchronized to the database. A database is a persistent storage device used to store data over a long period of time. The time it takes for the first block to be full is typically less than the preset synchronization time. For example, the time it takes for the first block to be full can be 1 second.

[0052] In some embodiments, in step 104, after the data is synchronized to the database, the data in the first block area is no longer needed, so an erase operation is performed on the first block area so that the block area can be reused later. At the same time, the erase count of the block area is updated for subsequent block area selection.

[0053] It should be noted that the read and write of the cache partition uses the memory technology device (mtd) interface to read and write directly, skipping the file system layer, speeding up the read and write speed of data to nand flash and saving faster. Figure 3 , Figure 3 Schematic diagram for interface reading and writing.

[0054] In some embodiments, before writing the relevant data in the cache queue into the first block area of the cache partition, the method further includes:

[0055] Determining candidate block regions according to the number of block regions in the cache partition and the number of erasures of the cache partition;

[0056] If the candidate block area is not damaged, determining the candidate block area as the first block area;

[0057] In the event that a candidate block area is damaged, the erase count is updated to obtain a new erase count, and the process of determining the candidate block area based on the number of block areas in the cache partition and the erase count of the cache partition is returned to execution; wherein, the erase count is increased by one for each damaged candidate block area.

[0058] In this implementation, by selecting candidate blocks based on their number and erase count, verifying their damage, and updating the erase count and reselecting if damaged, data can be written to undamaged blocks, improving data reliability and the lifespan of the storage medium. This method effectively handles damaged blocks and ensures stability and reliability when writing data.

[0059] Query the total number of block areas in the cache partition, query the number of erase times of the block area, and select a block area as a candidate block area based on the total number of block areas and the number of erase times. Read the status information of the candidate block area to determine whether it is damaged. If the candidate block area is not damaged (the status information shows normal), it is determined as the first block area for writing data. If the candidate block area is damaged (the status information shows damaged or cannot be read), the erase count is updated. The erase count is increased by one, indicating that the block area has been skipped. Using the updated erase count, re-execute the step of selecting the candidate block area until an undamaged block area is found.

[0060] In this embodiment, it should be noted that the candidate block region may be a block region currently being considered during the selection process, and whether to use the candidate block region as a writing target is determined by verifying its status.

[0061] In some embodiments, before writing the relevant data in the cache queue into the first block area of the cache partition, the method further includes:

[0062] Obtaining the total number of block areas in the cache partition;

[0063] Obtain the current erase count of the cache partition;

[0064] Calculating a sequence number value according to the total number of the block areas and the number of erasures; wherein the sequence number value is used to determine the position of the first block area;

[0065] According to the sequence number value, a block area in the cache partition is used as the first block area.

[0066] In this implementation, a sequence number is calculated by obtaining the total number of blocks in the cache partition and the number of times the blocks have been erased. This sequence number is then used to dynamically select the block to be written. This approach can extend the life of the storage medium, improve data storage reliability, and reduce write latency by properly arranging the write sequence.

[0067] Query the cache partition configuration information to determine the total number of blocks. Assuming the cache partition has 20 blocks, the total number is 20. Query the number of erase counts for a block. Calculate a sequence number based on the total number of blocks and the number of erase counts. Based on the calculated sequence number, select the corresponding block as the first block.

[0068] In some implementations, after the serial number value is calculated based on the total number of block areas and the number of erasures, the first block area is selected using the correspondence between the serial number value and the block area.

[0069] In some implementations, after calculating a sequence number based on the total number of block regions and the number of erases, candidate block regions are determined using the correspondence between the sequence number and the block regions. If the candidate block region is not damaged, the candidate block region is determined as the first block region. If the candidate block region is damaged, the number of erases is updated to obtain a new number of erases, and the process returns to determine the candidate block region based on the number of block regions in the cache partition and the number of erases for the cache partition. The number of erases is incremented by one for each damaged candidate block region.

[0070] For example, for cache partition write operations: In order to ensure the erase and write life of nandflash, a corresponding erase and write management mechanism is implemented. The first byte of the block stores the erase and write count value (errNum), and the serial number of the block storing the data (block2) is calculated based on this value. When the erase command arrives, the erase and write count increases by one (errNum), and the serial number of the block used to store the data will also change accordingly (from block2 to block3). This method ensures that the 20 blocks can be used evenly. See the corresponding Figure 4 , Figure 4 Schematic diagram of cache partition write operation.

[0071] In some implementations, the erase count is a global variable that only needs to be maintained throughout the program. The index value can be determined by taking the modulo of the erase count and the total number of blocks. For example, if the erase count is represented by a and the total number of blocks is 16, then this value modulo 16 is calculated. During an erase, a is incremented by 1, and the remainder is calculated when a is divided by 16. This remainder is the block index. This allows for a loop from blocks 1 to 16.

[0072] In other implementations, the serial number value may be determined by recording the number of erasures for each block area, then comparing the erasure times to determine the serial number value corresponding to the one with the least erasure times, and using the serial number value to determine the corresponding first block area.

[0073] In this embodiment, it should be noted that the sequence number value can be a calculation result used to determine the write location. Through the sequence number value, a block area in the cache partition is dynamically selected as the write target to avoid concentrated writing in a fixed area.

[0074] In some embodiments, when the human-machine interface loses power, the method further comprises:

[0075] When the human-machine interface is powered on again, the cache partition is initialized, and the beginning information of the block area in the cache partition is read;

[0076] Determine the block containing the number of erasures in the beginning information as the second block area;

[0077] The data in the second block area is stored in the database.

[0078] In this embodiment, by initializing the cache partition, reading the beginning information of the block area, determining the block area containing valid data, and restoring this data to the database, it is possible to ensure that the system can safely restore data after power failure, thereby ensuring system reliability and data integrity.

[0079] Initialize the cache partition, which may include checking whether the block area is bad, the integrity of the partition, etc., to prepare for subsequent data recovery operations. Read the beginning information of each block area, which may contain the status of the block area (such as whether it has been erased, whether it contains valid data, etc.) and the number of erases. According to the number of erases in the beginning information, determine which block area contains valid data. The block area containing valid data is called the "second block area". Assuming that the beginning information of a block area shows that it has been erased many times but still contains valid data, then this block area will be marked as the second block area. Read data from the second block area and write it to the database.

[0080] In this embodiment, it should be noted that the human-machine interface may be an interface for interaction between a user and a device or system, and is used to display information and receive user input.

[0081] The header information may be the first 4 bytes at the beginning of the block and may include the number of erase times of the block area.

[0082] The second block area may be a block area determined to contain valid data during the power-on recovery process. The second block area may be the same block area as the first block area, or may not be the same block area.

[0083] For example, after power-on, initialize the cache partition, traverse all block numbers of the partition, read the block beginning information, determine the block number of the data storage, then read all the data in the block, parse out the cache database commands before the power outage, and re-execute these database commands. In this way, part of the database data lost before the power outage can be restored. Among them, one implementation can be to determine the block number of the data storage, store the data in the block in the cache queue; generate database commands based on the data in the buffer queue, and the database commands are used to restore the database data lost during power outage; execute the database commands in the buffer queue to restore the data that was not saved during power outage. Correspondingly, if there is collected data, it is basically reading and writing to the cache partition every second. When the power is cut off, even in the worst case, the cache partition is damaged, the human-machine interface will only lose the data of this block, and the main partition ubifs file system will not be damaged, and the device can still operate normally. See Figure 5 , Figure 5 This is a diagram of data recovery after power-on.

[0084] In some implementations, initializing the cache partition and reading the beginning information of each block includes:

[0085] Reading status information of each block area of the cache partition;

[0086] discarding a block region in the cache partition where the status information indicates damage;

[0087] The beginning information of the undamaged block area indicated by the status information in the cache partition is read.

[0088] In this embodiment, by reading the status information of each block area, discarding those damaged block areas, and then reading only the beginning information of the undamaged block areas, it is possible to ensure that only reliable data is processed, thereby improving the stability and performance of the system.

[0089] Check the status information of each block area to determine whether it is damaged. Based on the status information, determine which block areas are damaged. If the status information of a block area indicates that it is damaged (for example, it has an error flag or cannot be read), it is marked as "damaged" and no further read operations are performed. For those block areas whose status information indicates that they are not damaged, further read their initial information.

[0090] In this embodiment, it should be noted that the status information may be information stored in the header of each block area, which is used to describe the status of the block area, including whether it is erased or damaged.

[0091] In some embodiments, storing the data in the second block area in the database includes:

[0092] Parsing the second block to obtain a database command; wherein the database command is used to restore the database data lost during power failure;

[0093] The database command is executed to store the restored data of the database into the database.

[0094] In this embodiment, by parsing the data in the second block, obtaining database commands, and executing these commands, it is possible to ensure that the lost data can be completely recovered and stored in the database. This method can improve system reliability and data integrity, ensuring that the system can operate normally after a power outage.

[0095] In this embodiment, it should be noted that database commands can be instructions for operating the database, such as insert, restore, update, and delete. By executing these commands, data can be stored in the database or modified. The second area can include data such as human-machine interface related data, as well as database commands.

[0096] In some implementations, the second area is parsed to obtain parsed data; the parsed data is stored in a buffer queue; a database command is generated based on the data in the buffer queue, and the database command is used to restore the database data lost during power failure; the database command is executed to store the restored database data in the database.

[0097] In other implementations, the second area is parsed to obtain database commands, which are used to restore the database data lost during power failure; the database commands are stored in a buffer queue; and the database commands in the buffer queue are executed to store the restored database data in the database.

[0098] For example, see Figure 6 , Figure 6 This is a diagram of a cache partition read operation. A cache partition read operation initializes the entire cache partition, as only one block stores data, leaving all other blocks empty. After reading the cache partition's block header information (the first word) and the global variable erase count, the system determines whether each block's header information indicates an empty block (0xFFFF). If not, the system calculates the current data block based on the erase count of the data block, obtaining block 2 (where data is stored). The data in this block is read and stored in the buffer queue before being saved to the database.

[0099] In view of the above embodiment, this application also provides a schematic diagram of database storage. Figure 7 .

[0100] Database data storage:

[0101] After the human-machine interface collects data, for example, a set of data (time, date, temperature, humidity, output, flow), data diagram, see Figure 8. It is stored in the database through the database command. The database does not actually store the data in the database at this time, and it needs to be saved in the database after the database is synchronized. The technical solution of the embodiment of the present application will record the insert command in the program at this time and save it to the cache queue. Specifically, the working process of the human-machine interface: during normal operation, the human-machine interface collects data once every 0.5s and twice in 1s (trigger collection). When the 1s time is up, the data collected during this period will be written to the buffer partition. At the same time, the database itself will also record these two data, but because the database is saved asynchronously, these two data have not actually been stored in the nandflash. It is necessary to wait for 1 minute for the program to execute the database submission command (regular submission) before the database can actually write to the flash (corresponding to inserting into the database). In this 1 minute, the data written to the cache partition is valid (corresponding to joining the cache queue). It keeps working like this. Among them, before writing to the cache partition, it will be detected whether the cache queue is full to save resources. Suddenly, the human-machine interface is powered off. For the database, it will take up to 1 minute to save. But at this time, the cache partition data has been saved. When the human-machine interface is powered on and started, the data is taken out from the buffer partition and the 1-minute data is sent back to the database, thus restoring the data collected before the power outage.

[0102] Accordingly, when a cache partition block is full of data or the synchronization time expires, a database synchronization operation is performed, effectively storing the previously collected data in the database file. Simultaneously, the cache partition data is cleared, the erase count is incremented by 1, and the next block number for storing buffered data is calculated based on the erase count. An example of calculating a block number is: Cache queue data is periodically checked every 1 second and written to a block in the cache partition. The block number written is calculated based on the erase count.

[0103] Calculate the block number: For example, if the cache partition is set to 20 blocks, the number of erases (errNum) and the target block number is index.

[0104] index = remainder when errNum is divided by 20;

[0105] When errNum changes linearly, index is a value in [0,19], from 0 to 19, then back to 0, and so on. This achieves the effect of cyclically reading and writing these 20 blocks.

[0106] The human-machine interface checks every 1 second whether there is any collected data. If there is, it will save the collected data within this 1 second to the cache partition. In this way, considering the power outage situation, we can know the worst case scenario. The data of the last 1 second cannot be written or saved due to the power outage.

[0107] In the existing solution, the human-machine interface collects data at regular intervals. However, due to asynchronous storage in the database, the data is not actually stored in the nand flash. The data can only be written to the database after a certain period of time (usually 1 minute) has passed and the program executes the database submission instruction. In addition to the high data loss rate of the human-machine interface during power failure, the following problems may also exist:

[0108] Asynchronous saving problem: Since the database uses asynchronous saving method, it cannot be guaranteed that the data collected each time can be saved in the database in a timely and stable manner.

[0109] Impact of file system characteristics: The NAND flash-based UBIFS file system has certain read and write characteristics that prevent the stable storage of database logs to the NAND flash. In extreme cases, this can even affect the normal recovery of the UBIFS file system on the NAND flash, causing the entire device to fail.

[0110] Processor load problem: Frequent use of commit operations to improve the stability of data storage can alleviate the problem of data loss to a certain extent, but it will significantly increase the computing load of the embedded processor.

[0111] Based on this, an embodiment of the present application provides a data preservation method for a human-computer interface. First, the frequent write operations of the database are concentrated in the cache partition instead of being directly written to the main area where the ubifs file system is located. In this way, even if the data is lost during the asynchronous preservation process, it will only affect the cache partition. By regularly synchronizing the data in the cache partition to the main area, the final consistency of the data is ensured (corresponding to the asynchronous preservation problem). Secondly, by physically separating the cache partition from the main area where the ubifs file system is located, the instability that may occur in the ubifs file system during frequent erasures is avoided. The ubifs file system itself has a limit on the number of erases and writes, and frequent write operations may cause damage to the file system. By limiting write operations to the cache partition, the direct impact on the ubifs file system can be reduced (corresponding to the file system characteristic problem). Finally, by concentrating frequent write operations on the cache partition, the frequency of writes to the main area is reduced. Write operations in the main area can be performed in batches when the system load is low, thereby reducing the real-time load of the processor (corresponding to the processor load problem).

[0112] Reference Figure 9One embodiment of the present application provides a method and apparatus for saving data on a human-machine interface, the apparatus comprising:

[0113] A saving module 901 is configured to save the relevant data to the cache queue in response to a request for collecting relevant data of the human-machine interface;

[0114] a writing module 902 configured to write the relevant data in the cache queue into a first block area of the cache partition when detecting that the cache queue is full; wherein the first block area is determined based on the number of block areas in the cache partition and the number of times the cache partition has been erased;

[0115] The storage module 903 stores the relevant data in the first block area into the database when it is detected that the first block area is full or the preset data synchronization time has been reached;

[0116] The erasing module 904 performs an erasing operation on the first block area and increases the erasing count by 1. It should be noted that this device embodiment and the above method embodiment are based on the same inventive concept, so the content of the above method embodiment is also applicable to this device embodiment and will not be repeated here.

[0117] Alternatively, as Figure 10 As shown, an embodiment of the present application also provides an electronic device 1000, including a processor 1001 and a memory 1002, and the memory 1002 stores a program or instruction that can be run on the processor 1001. When the program or instruction is executed by the processor 1001, the various steps of the above-mentioned human-computer interface data saving method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0118] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.

[0119] Figure 11 A schematic diagram of the hardware structure of an electronic device implementing an embodiment of the present application.

[0120] The electronic device 1100 includes but is not limited to components such as a radio frequency unit 1101 , a network module 1102 , an audio output unit 1103 , an input unit 1104 , a sensor 1105 , a display unit 1106 , a user input unit 1107 , an interface unit 11011 , a memory 1109 , and a processor 1110 .

[0121] Those skilled in the art will understand that the electronic device 1100 may also include a power source (such as a battery) to power each component, and the power source may be logically connected to the processor 1110 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system. Figure 11 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be repeated here.

[0122] The processor 1110 is configured to: in response to a request for collecting relevant data of the human-machine interface, save the relevant data into the cache queue;

[0123] In response to a request for collecting relevant data of the human-machine interface, the relevant data is saved in the cache queue;

[0124] When it is detected that the cache queue is full, writing the relevant data in the cache queue into a first block area of the cache partition; wherein the first block area is determined according to the number of block areas in the cache partition and the number of times the cache partition is erased;

[0125] When it is detected that the first block area is full or a preset data synchronization time has been reached, the relevant data in the first block area is stored in the database;

[0126] An erase operation is performed on the first block area, and the erase count is increased by one.

[0127] In some embodiments, the processor 1110 is further configured to: determine a candidate block region based on the number of block regions in the cache partition and the number of erase times of the cache partition;

[0128] If the candidate block area is not damaged, determining the candidate block area as the first block area;

[0129] In the event that a candidate block area is damaged, the erase count is updated to obtain a new erase count, and the process of determining the candidate block area based on the number of block areas in the cache partition and the erase count of the cache partition is returned to execution; wherein, the erase count is increased by one for each damaged candidate block area.

[0130] In some implementations, the processor 1110 is further configured to: obtain a total number of block regions in the cache partition;

[0131] Obtain the current erase count of the cache partition;

[0132] Calculating a sequence number value according to the total number of the block areas and the number of erasures; wherein the sequence number value is used to determine the position of the first block area;

[0133] According to the sequence number value, a block area in the cache partition is used as the first block area.

[0134] In some embodiments, the processor 1110 is further configured to: initialize the cache partition and read the beginning information of the block area in the cache partition when the human-machine interface is powered on again;

[0135] Determine the block containing the number of erasures in the beginning information as the second block area;

[0136] The data in the second block area is stored in the database.

[0137] In some implementations, the processor 1110 is further configured to: read status information of each of the block areas of the cache partition;

[0138] discarding a block region in the cache partition where the status information indicates damage;

[0139] The beginning information of the undamaged block area indicated by the status information in the cache partition is read.

[0140] In some embodiments, the processor 1110 is further configured to: parse the second block area to obtain a database command; wherein the database command is used to restore the database data lost during power failure;

[0141] The database command is executed to store the restored data of the database into the database.

[0142] It should be understood that in an embodiment of the present application, the input unit 1105 may include a graphics processing unit (GPU) 11051 and a microphone 11052, and the graphics processor 11051 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 1106 may include a display panel 11061, and the display panel 11061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1107 includes a touch panel 11071 and at least one of other input devices 11072. The touch panel 11071 is also called a touch screen. The touch panel 11071 may include two parts: a touch detection device and a touch controller. Other input devices 11072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and an operating stick, which will not be repeated here.

[0143] The memory 1109 can be used to store software programs and various data. The memory 1109 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, applications or instructions required for at least one function (such as a sound playback function, an image playback function, etc.). In addition, the memory 1109 may include a volatile memory or a non-volatile memory, or the memory 1109 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct RAM bus random access memory (DRRAM). The memory 1109 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

[0144] Processor 1110 may include one or more processing units. Optionally, processor 1110 integrates an application processor and a modem processor. The application processor primarily handles operations related to the operating system, user interface, and application programs, while the modem processor primarily processes wireless communication signals, such as a baseband processor. It is understood that the modem processor may not be integrated into processor 1110.

[0145] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned human-computer interface data saving method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0146] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0147] In addition, an embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned human-computer interface data storage method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0148] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or system comprising the element. In addition, it should be noted that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in the opposite order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0149] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.

[0150] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0151] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.

Claims

1. A method for saving data of a human-machine interface, characterized in that: Applied to an electronic device, the electronic device includes a cache queue, a cache partition, and a database, the cache partition includes multiple block areas; the method includes: In response to a request for collecting relevant data of the human-machine interface, saving the relevant data into the cache queue; When it is detected that the cache queue is full, writing the relevant data in the cache queue into a first block area of the cache partition; wherein the first block area is determined according to the number of block areas in the cache partition and the number of times the cache partition is erased; When it is detected that the first block area is full or a preset data synchronization time has been reached, the relevant data in the first block area is stored in the database; An erase operation is performed on the first block area, and the erase count is increased by one.

2. The method according to claim 1, wherein Before writing the relevant data in the cache queue into the first area of the cache partition, the method further includes: Determining candidate block regions according to the number of block regions in the cache partition and the number of erasures of the cache partition; If the candidate block area is not damaged, determining the candidate block area as the first block area; In the event that a candidate block area is damaged, the erase count is updated to obtain a new erase count, and the process of determining the candidate block area based on the number of block areas in the cache partition and the erase count of the cache partition is returned to execution; wherein, the erase count is increased by one for each damaged candidate block area.

3. The method according to claim 1, wherein Before writing the relevant data in the cache queue into the first area of the cache partition, the method further includes: Obtaining the total number of block areas in the cache partition; Obtain the current erase count of the cache partition; Calculating a sequence number value according to the total number of the block areas and the number of erasures; wherein the sequence number value is used to determine the position of the first block area; According to the sequence number value, a block area in the cache partition is used as the first block area.

4. The method according to claim 1, wherein In the event that the human-machine interface loses power, the method further includes: When the human-machine interface is powered on again, the cache partition is initialized, and the beginning information of the block area in the cache partition is read; Determine the block containing the number of erasures in the beginning information as the second block area; The data in the second block area is stored in the database.

5. The method according to claim 4, wherein Initializing the cache partition and reading the beginning information of each block includes: Reading status information of each block area of the cache partition; discarding a block region in the cache partition where the status information indicates damage; The beginning information of the undamaged block area indicated by the status information in the cache partition is read.

6. The method according to claim 4, wherein Storing the data in the second block area into the database includes: Parsing the second block to obtain a database command; wherein the database command is used to restore the database data lost during power failure; The database command is executed to store the restored data of the database into the database.

7. A method and device for saving data of a human-machine interface, characterized in that: The device comprises: A saving module, configured to save the relevant data into a cache queue in response to a request for collecting relevant data of the human-machine interface; a writing module, configured to write the relevant data in the cache queue into a first block area of the cache partition when detecting that the cache queue is full; wherein the first block area is determined according to the number of block areas in the cache partition and the number of times the cache partition is erased; A storage module, storing the relevant data in the first block area into the database when detecting that the first block area is full or a preset data synchronization time has been reached; The erasing module performs an erasing operation on the first block area and increases the erasing count by one.

8. A method and device for saving data of a human-machine interface, characterized in that: The device includes: a memory, a processor, and a computer processing program stored in the memory and executable on the processor, wherein the computer processing program is configured to implement the human-machine interface data storage method according to any one of claims 1 to 6.

9. A storage medium, characterized in that: The storage medium stores a computer processing program, and when the computer processing program is executed by the processor, the human-machine interface data storage method according to any one of claims 1 to 6 is implemented.

10. A computer program product, characterized in that When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the human-machine interface data storage method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Efficient sensor historical data archiving method

    CN106557272A

  • Cache space application method, system and device, and computer readable storage medium

    CN111177032A

  • Data processing method and device and database architecture

    CN112527844A

  • Cache disk replacement method and device, equipment and storage medium

    CN115328407A

  • Wear leveling method and device, equipment and storage medium

    CN118860291A