Low latency storage method for a universal controller of a construction machine

CN120821875BActive Publication Date: 2026-10-09JIANGSU ADVANCED CONSTR MASCH INNOVATION CENT LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510889677.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-30
Publication Date
2026-10-09
Estimated Expiration
2045-06-30

AI Technical Summary

Technical Problem

[0004]大数据量数据存储时,无法有效的保证程序的运行周期控制在较小范围内

Benefits of technology

[0040](1) When a large amount of data needs to be synchronized to Flash, the present invention can store the data in time-sharing to ensure that the running cycle of a program is strictly less than 10ms. The remaining data will be synchronized in the next running cycle. In order to improve the indexing speed of the data, the data elements will be organized in memory according to the B+ tree structure and a sliding window will be opened in memory to improve the hit rate of data search. The stored data elements are classified and stored according to size. This scheme can easily locate the position of each stored data element in the external storage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120821875B_ABST
    Figure CN120821875B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of data storage, and discloses a low-delay storage method for a general controller of engineering machinery, wherein an optimal synchronization data amount M value in a program running period is calculated according to the program running period; data elements are classified according to the number and size of the data elements, and the number of metadata data areas in the memory is determined according to the classification; the data elements of each metadata data area in the memory are organized by using a B+ tree, and a metadata data area with the same data amount as the metadata data area in the memory and one-to-one correspondence is also developed in an external storage; the data elements of the metadata data area in the memory are synchronized to the metadata data area of the external storage; M data elements are synchronized in each program running period until all the data elements in the memory are synchronized to the external storage. The application can guarantee that the process of large data storage does not affect the running efficiency of a program, and is suitable for occasions with high requirements on program running periods during data storage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of data storage technology and relates to a low-latency storage method for a general-purpose controller for engineering machinery. Background Technology

[0002] In the field of construction machinery, some controllers have strict requirements on program execution cycles, with a cycle limit of 10ms. If a timeout occurs, the solenoid valve's current request will not be responded to in time, resulting in gearbox jerking. The underlying modules of the controller include digital output, constant current control, CAN communication, and data storage. Some variables generated during the control process need to be stored in Flash memory. This stored data is used in calculations, and Flash storage consumes considerable time. Therefore, with large amounts of data, this can affect the program's execution cycle and pose challenges to the control task.

[0003] The existing data storage process stores generated data in real time, maintaining a copy identical to the data in memory and Flash memory. The location of the data in memory relative to the Flash memory is calculated using a specific method. When data synchronization is needed, this data is written to Flash memory based on the specified location. To improve program robustness, two storage spaces are typically allocated in Flash memory. Each time data is synchronized, it is written to both storage areas simultaneously. This way, if one storage area fails, the data can be recovered from the other, ensuring data integrity. The data recovery process only fails if both storage areas fail. To prevent duplicate data writes, before each write to Flash memory, the newly written data is compared to the previous data. If they match, the current data write process is skipped, and the next data is compared. This improves program efficiency and reduces program execution cycle time.

[0004] When storing large amounts of data, it is difficult to effectively ensure that the program's runtime is kept within a short range. The lack of a control mechanism for when data is synchronized to external storage poses a challenge to the lifespan of the external storage. Summary of the Invention

[0005] The purpose of this invention is to provide a low-latency storage method for general-purpose controllers of engineering machinery, which can ensure that the process of storing large amounts of data will not affect the running efficiency of the program, and is suitable for occasions where the program running cycle is required when storing data.

[0006] To solve the above-mentioned technical problems, the present invention is implemented using the following technical solution.

[0007] This invention proposes a low-latency storage method for a general-purpose controller of engineering machinery, comprising:

[0008] The optimal value of the amount of synchronized data M within a program execution cycle is calculated based on the program's execution cycle.

[0009] The metadata data elements are categorized according to their size and quantity, and the number of metadata data areas in memory is determined based on the categorization. The data elements in each metadata data area in memory are organized using a B+ tree. A metadata data area with the same amount of data as the metadata data area in memory is also allocated in external storage, and they correspond one-to-one. The data elements in the metadata data area in memory are synchronized to the metadata data area in external storage. M data elements are synchronized in each program cycle until all data elements in memory are synchronized to external storage.

[0010] Furthermore, the step of calculating the optimal amount of synchronized data M within a program execution cycle based on the program execution cycle includes:

[0011] The method to calculate the time t for synchronizing M bytes of data to external memory is as follows: record the current time t1 before writing M bytes of data, record the time when all M bytes of data are written to external memory as t2, and the time difference between t2 and t1 is the time t for synchronizing M bytes to external memory.

[0012] The difference between t2 and t1 is compared with the preset time period. If the value of t2-t1 is much smaller than the preset time period, the value of M is increased, and a new value of M is calculated again using the same method until the optimal value of M is found.

[0013] Furthermore, the preset time period is 10ms.

[0014] Furthermore, to improve the hit rate of data retrieval and ensure that the program execution cycle is strictly less than 10ms, the storage method also includes a step of determining the number of data elements contained in the sliding window based on the processor memory size. This step specifically involves:

[0015] The concept of a sliding window is introduced, which is a fixed-size memory space allocated in memory. Its data composition includes timestamp information, data content, data index, and access count; the data index is unique, and the index value starts from 0 and increases sequentially.

[0016] Use the sliding window as the primary index for the data;

[0017] The data in the sliding window is dynamically updated by using the timestamp information and access count in the data element composition to update the data in the sliding window. The timestamp information is used to record the time information of the last access of the data element, and the access count refers to the number of times the data element is read and written. Data with timestamp information less than a preset threshold is updated periodically, and data with access count greater than a preset upper limit is updated with data with access count less than a preset lower limit.

[0018] Furthermore, the process of classifying data elements according to their size and quantity, determining the number of data areas in memory based on the classification, organizing the data elements in each metadata data area in memory using a B+ tree, and also allocating a corresponding metadata data area with the same amount of data in external storage; and synchronizing the data elements in the metadata data area in memory to the metadata data area in external storage; includes:

[0019] The data area is partitioned as follows: To facilitate the calculation of data location information in external storage, the data is first classified before processing. Data elements of the same size are organized into a metadata data area. Each metadata data area uses a B+ tree for organization, resulting in multiple B+ trees in memory. A metadata data area of ​​the same size is also allocated in external storage, corresponding one-to-one with the metadata data areas in memory. The advantage of this classification is that it facilitates the calculation of the storage location of data in memory within external storage. When a data element needs to be deleted from external storage, it is removed from the B+ tree in memory, and the data element is then stored in memory. The index of a deleted data element is recorded in a linked list within the free data area. This linked list records the index of the deleted data element. The number of linked lists corresponds to the number of metadata data areas. The location of the data element stored in external storage does not need to be changed. When a data element needs to be added, the index assigned to the new data element needs to be retrieved from the free index linked list. Each time, it is only retrieved from the head of the linked list. After retrieval, the index of the data element is removed from the linked list, indicating that the index number of the data element has been used by a data element. At the same time, the data element is added to the B+ tree in the metadata data area. During data synchronization, the location in external storage only needs to be calculated based on the newly assigned index number, and the data at the corresponding location is updated. The free linked list elements also need to be updated in external storage periodically.

[0020] Furthermore, before synchronizing the data elements to external memory, the storage method further includes the following steps:

[0021] The algorithm determines whether to trigger the data synchronization process.

[0022] The algorithm is specifically as follows:

[0023] When a user needs to write data, the data is not immediately synchronized to the external storage. Instead, the data is updated in the corresponding memory B+ tree. The program periodically counts the number of old data elements in the current memory B+ tree. The old data elements refer to data elements that have not been written to the external storage since the last data synchronization was completed. The number of elements is denoted as Q. A threshold P is set. When the value of Q is greater than the value of P, the data synchronization process will be triggered.

[0024] If the data synchronization process is triggered, M data elements will be synchronized to external memory.

[0025] Furthermore, in order to avoid the Q value not reaching the threshold P for too long, resulting in the data synchronization process not being triggered for too long and increasing the risk of data loss, the algorithm also includes setting a forced synchronization timer, that is, setting a maximum synchronization time T. If the synchronization process is not triggered within the maximum synchronization time T, the program will forcibly trigger the data synchronization process.

[0026] Furthermore, after synchronizing the data elements to the external memory, the storage method further includes the following step: checking whether the data synchronization monitoring software timer has been triggered;

[0027] Set up a synchronization monitoring software timer. The method for setting up the synchronization monitoring software timer is as follows: the start time of the synchronization monitoring software timer is the end time of the last data synchronization, and the timing period is shorter than the program running cycle; when the end time of the synchronization monitoring software timer arrives, count the amount of data actually written during the synchronization monitoring software timer period; if the amount of data written to external memory is less than the value M, then end the data synchronization.

[0028] Furthermore, after the step of ending data synchronization when the amount of data written to external memory is less than the value M, the process also includes recording the actual amount of data N that has been synchronized to external memory, recording whether the last data has been synchronized, and if the last data has not been synchronized, then the current data and the remaining M-N+1 data will be synchronized in the next program execution cycle; if the synchronization monitoring software timer is not triggered, then the data synchronization process continues.

[0029] Furthermore, after data synchronization is complete, the storage method also includes a step of determining whether data addition or deletion operations have occurred, as detailed below:

[0030] When data needs to be added or deleted, the sliding window of the processor memory, the free linked list data area in memory and the metadata data area in the external processor are updated.

[0031] Furthermore, after synchronizing the data elements to the external memory, the storage method also includes a data recovery step, specifically:

[0032] After the processor powers on, it needs to read data from external memory and load it into memory. This requires loading several metadata data areas from external memory.

[0033] Load the free data linked list data area in the external memory. This data area records which data elements in each metadata data area of ​​the external memory are invalid.

[0034] The data is read from each metadata data area in the external storage, and invalid data elements are removed from the metadata data area in the external storage according to the data element index recorded in the free data linked list data area in the external storage. After removal, the remaining valid data elements are organized according to the B+ tree, which means that the entire data in the external storage can be loaded into memory.

[0035] Furthermore, the memory and external storage transfer data to each other, and the data organization of the two is consistent, that is, both the memory and the external storage include free data linked list data and several metadata data areas; the memory also includes a sliding window, which is communicatively connected to several metadata data areas in the memory.

[0036] In applications where program execution cycles are critical, this invention introduces a time-sharing data synchronization mechanism. To monitor whether data synchronization is completed within a program execution cycle, a synchronization monitoring software timer is introduced. If data is not fully written, the data synchronization process is forcibly stopped, and the remaining data is synchronized in the next program execution cycle.

[0037] The data synchronization timing of this invention is based on the number of data elements in the current processor memory that have not been synchronized since the last synchronization ended. If this number exceeds a threshold, synchronization is triggered; otherwise, only the B+ tree in memory is updated. If the forced synchronization timer arrives and data synchronization is still not completed, data synchronization will also be triggered.

[0038] To improve data indexing speed, this invention introduces a sliding window. Data elements in this sliding window are dynamically updated based on access frequency and timestamp information. This method can significantly improve the hit rate and retrieval speed when searching for data.

[0039] Compared with the prior art, the beneficial effects achieved by the present invention are as follows:

[0040] (1) When a large amount of data needs to be synchronized to Flash, the present invention can store the data in time-sharing to ensure that the running cycle of a program is strictly less than 10ms. The remaining data will be synchronized in the next running cycle. In order to improve the indexing speed of the data, the data elements will be organized in memory according to the B+ tree structure and a sliding window will be opened in memory to improve the hit rate of data search. The stored data elements are classified and stored according to size. This scheme can easily locate the position of each stored data element in the external storage.

[0041] (2) This invention addresses situations where the program's execution cycle is critical when storing data. It ensures that the process of storing large amounts of data will not affect the program's running efficiency. To improve data retrieval speed, a sliding window concept is introduced. Data elements in this sliding window are dynamically updated according to a certain algorithm, which can effectively improve the probability of data hits. To determine the timing of data synchronization, a comprehensive calculation is performed by combining the amount of unsynchronized data in the B+ tree in memory and the maximum synchronization time. This can effectively balance the excessively frequent data synchronization with the prolonged lack of data synchronization.

[0042] (3) This invention proposes a time-sharing storage strategy, proposes a sliding window to improve retrieval speed, classifies the data to be stored according to the size of the data elements, and facilitates the establishment of a mapping relationship between the data in memory and the data storage location in Flash. Attached Figure Description

[0043] Figure 1 This is a schematic diagram of the low-latency storage system in Embodiment 1 of the present invention;

[0044] Figure 2 This is a flowchart illustrating the low-latency storage method in Embodiment 1 of the present invention. Detailed Implementation

[0045] The technical solution of the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the embodiments of the present invention and the specific features in the embodiments are detailed descriptions of the technical solution of the present invention, rather than limitations thereof. In the absence of conflict, the embodiments of the present invention and the technical features in the embodiments can be combined with each other.

[0046] The term "and / or" simply describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. Additionally, the character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0047] Example 1

[0048] like Figure 1As shown, the low-latency storage system for the general-purpose controller of engineering machinery in this embodiment includes: a main memory and an external memory for mutual data transfer. The data organization of the main memory and the external memory is consistent, that is, both the main memory and the external memory include a free data linked list and several metadata data areas. The metadata data area is used to store raw data information, and this data area is divided according to the size of the stored data. The free data linked list data area is used to record the index information of deleted data elements. In addition, the main memory also includes a sliding window, which is a data area used to store frequently accessed data, and its function is to improve the data retrieval speed. The sliding window is communicatively connected to the several metadata data areas in the main memory.

[0049] like Figure 2 As shown, the steps of the low-latency storage method for the general-purpose controller of engineering machinery in this embodiment are as follows:

[0050] Step S1: Calculate the appropriate amount of synchronized data M within one program execution cycle. The calculation method is as follows: Because each processor has a different processing speed, and the write speed of external flash memory (hereinafter referred to as Flash) also varies, first, calculate the time t for synchronizing M bytes of data to Flash. The calculation method can be based on the processor's timer function. Record the current system time t1 before writing M bytes, and record the system time t2 after writing all M bytes of data to Flash. The time difference between t2 and t1 is the time t for synchronizing M bytes to Flash. Compare the difference between t2 and t1 with a preset time period (e.g., 10ms). If the value of t2-t1 is much smaller than the preset time period (e.g., 10ms), continue to increase the value of M, and calculate a new value of M again using the same method until a suitable value of M is found. During the process of finding the value of M, the time consumed by other control logic of the program needs to be considered, and it is essential to ensure that the entire execution cycle of the program is less than the preset time period (e.g., 10ms). Once the ideal value of M is found, it is the amount of data that needs to be synchronized within one cycle.

[0051] Step S2: Determine the number of data elements contained in the sliding window based on the processor memory size. The function and creation direction of the sliding window are as follows. When the user reads data, since the data elements in Flash and memory are identical, the search can be performed directly in the B+ tree of memory. When the data volume is large, to further improve search efficiency and shorten the B+ tree traversal process, the concept of a sliding window is introduced. The sliding window allocates a fixed-size memory space in memory. This part of the data consists of: timestamp information + data content + data index + access count. The data index is unique. The index value starts from 0 and increases sequentially. The function of the data index is to identify the uniqueness of the data element and to calculate the storage location of the data element in external memory, i.e., the index is... The data elements are stored in Flash at the following locations: , For the first The starting address of the data area, The sliding window serves as the first-level index for the data. Data is first searched within the sliding window; if not found there, it is then searched in the subsequent in-memory B+ tree. Once found, the data is returned directly to the user. The data in the sliding window is also organized using a B+ tree. The data in the sliding window is dynamically updated based on timestamps and access counts. Timestamps record the last access time, and access counts indicate the number of times the element has been read and written. The algorithm periodically updates data with smaller timestamps, replacing data that hasn't been accessed in a long time with frequently accessed data, and updating data with fewer read / write counts with more frequently accessed data. When a data element needs to be deleted, all data elements in the sliding window must also be deleted.

[0052] Step S3: Classify data elements according to their size, and determine the number of data areas in memory based on the classification.

[0053] The data area is partitioned as follows: To facilitate the calculation of data location information in Flash, the data is first classified before processing. Data elements of the same size are organized into a metadata data area. Each metadata data area uses a B+ tree for organization, resulting in multiple B+ trees in memory. A metadata data area of ​​the same size is also allocated in Flash, corresponding one-to-one with the metadata data areas in memory. The advantage of this classification is that it facilitates the calculation of the storage location of data in Flash. When a data element needs to be deleted from Flash, it is removed from the B+ tree in memory, and its index is updated accordingly. The index of a deleted data element is recorded in a linked list within the free data area. This linked list records the index of the deleted data element. The number of linked lists corresponds to the number of metadata data areas. The location of the data element stored in the external flash memory does not need to be changed. When a data element needs to be added, the index assigned to the new data element needs to be retrieved from the free index linked list. Each time, it is only retrieved from the head of the linked list. After retrieval, the index of the data element is removed from the linked list, indicating that the index number of the data element has been used by a data element. At the same time, the data element is added to the B+ tree in the metadata data area. During data synchronization, the Flash location is calculated based on the newly assigned index number, and the data at the corresponding location is updated. The free linked list elements also need to be updated to Flash memory periodically.

[0054] Step S4: Determine whether to trigger the data synchronization process based on the corresponding algorithm. The algorithm specifically determines the timing of synchronization by combining the amount of data in the current memory area that has not been updated to Flash and the forced synchronization time. That is, when a user needs to write data, the data is not immediately synchronized to Flash; instead, it is updated to the corresponding memory B+ tree. The program periodically counts the number of old data elements in the current memory B+ tree. Old data elements refer to data elements that have not been written to Flash since the last data synchronization was completed. The number of elements is denoted as Q. This number changes dynamically; adding or deleting data by the user will affect this value. A threshold P is set. When the value of Q is greater than the value of P, the data synchronization process is triggered. Furthermore, to prevent the value of Q from failing to reach the threshold P for too long, thus increasing the risk of data loss, a forced synchronization timer (i.e., a maximum synchronization time T) is set. If the synchronization process is not triggered within the maximum synchronization time T, the program will also forcibly trigger the data synchronization process.

[0055] Step S5: If the data synchronization process was triggered in step S4, then M data elements are synchronized to the external memory Flash.

[0056] Step S6: Check if the data synchronization monitoring software timer has been triggered. The purpose of the synchronization monitoring software timer is to ensure that data synchronization does not affect the program's runtime. To solve this problem, a monitoring program is set in the program to periodically monitor the writing process. A synchronization monitoring software timer can be set as follows: the start time of the synchronization monitoring software timer is the end time of the last data synchronization, and the timing period can be slightly shorter than the program's runtime. The priority of this synchronization monitoring software timer is set to high. When the synchronization monitoring software timer ends, the actual amount of data written during the time period is counted. If the amount of data written to Flash is less than the value M, then proceed to step S7. If the synchronization monitoring software timer has not been triggered, then proceed to step S5.

[0057] Step S7: Stop data synchronization and record the actual amount of data N that has been synchronized to Flash. The last data element written to Flash may be interrupted by the synchronization monitoring software timer during the data synchronization process. Record whether the last data has been synchronized. If the last data has not been synchronized, then synchronize the current data and the remaining M-N+1 data in the next program running cycle.

[0058] Step S8: Determine if any data addition or deletion operations have occurred. When data needs to be added or deleted, the sliding window, free linked list data area in memory and Flash, and metadata data area mentioned in steps S2 and S3 need to be updated. See steps S2 and S3 for details on the update method.

[0059] Step S9, the data recovery process. After the processor powers on, the data needs to be read from Flash and loaded into memory. This requires loading several metadata data areas. First, there is the free data linked list data area, which records which data elements in each metadata data area are invalid. Next, the data in each metadata data area is read out, and invalid data elements are removed from the metadata data area according to the data element index recorded in the free data linked list data area. After removal, the remaining valid data elements are organized according to a B+ tree. In this way, all the data in the external storage can be loaded into memory.

[0060] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other modifications under the guidance of the present invention, and these modifications are all within the protection scope of the present invention.

Claims

1. A low-latency storage method for a general-purpose controller for engineering machinery, characterized in that, include: The optimal value of the amount of synchronized data M within a program execution cycle is calculated based on the program's execution cycle. The data elements are classified according to their size, and the number of metadata data areas in memory is determined based on the classification. The data elements in each metadata data area in memory are organized using a B+ tree. A metadata data area with the same amount of data as the metadata data area in memory is also allocated in external storage, and they correspond one-to-one. Synchronize data elements in the metadata data area located in memory to the metadata data area in external storage; synchronize M data elements in each program execution cycle until all data elements in memory are synchronized to external storage; When a data element needs to be added, the index assigned to the new data element needs to be obtained from the free list of indexes. Each time, it only needs to be obtained from the head of the list. After obtaining it, the index of the data element is deleted from the list, and the data element is added to the B+ tree in the metadata data area. During data synchronization, it is only necessary to calculate the location of the external storage based on the newly assigned index number and update the data at the corresponding location. The free list elements also need to be updated to the external storage periodically. Before synchronizing the data elements to external memory, the storage method further includes the following steps: The algorithm determines whether to trigger the data synchronization process. The algorithm is specifically as follows: When a user needs to write data, the data is not immediately synchronized to the external storage. Instead, the data is updated in the corresponding memory B+ tree. The program periodically counts the number of old data elements in the current memory B+ tree. The old data elements refer to data elements that have not been written to the external storage since the last data synchronization was completed. The number of elements is denoted as Q. A threshold P is set. When the value of Q is greater than the value of P, the data synchronization process will be triggered. If the data synchronization process is triggered, M data elements will be synchronized to external memory. After synchronizing the data elements to the external memory, the storage method further includes the following steps: checking whether the data synchronization monitoring software timer has been triggered; Set up a synchronization monitoring software timer. The method for setting up the synchronization monitoring software timer is as follows: the start time of the synchronization monitoring software timer is the end time of the last data synchronization, and the timing period is shorter than the program running cycle; when the end time of the synchronization monitoring software timer arrives, count the amount of data actually written during the synchronization monitoring software timer period; if the amount of data written to external memory is less than the value M, then end the data synchronization.

2. The low-latency storage method for a general-purpose controller for engineering machinery according to claim 1, characterized in that, The step of calculating the optimal amount of synchronized data M within a program execution cycle based on the program execution cycle includes: The specific method for calculating the time t of synchronizing M bytes of data to external storage is as follows: record the current time t1 before writing M bytes of data, record the time when all M bytes of data are written to external storage as t2, and the time difference between t2 and t1 is the time t of synchronizing M bytes to external storage. The difference between t2 and t1 is compared with the preset time period. If the value of t2-t1 is much smaller than the preset time period, the value of M is increased, and a new value of M is calculated again using the same method until the optimal value of M is found.

3. The low-latency storage method for a general-purpose controller for engineering machinery according to claim 1, characterized in that, The storage method further includes a step of determining the number of data elements contained in the sliding window based on the processor memory size. This step specifically involves: The concept of a sliding window is introduced, which is a fixed-size memory space allocated in memory, whose data composition includes timestamp information, data content, data index, and access count; Data indexes are unique, and index values ​​start from 0 and increase sequentially. Use the sliding window as the primary index for the data; The data in the sliding window is updated dynamically by using the timestamp information and access count in the data element composition to update the data in the sliding window. The timestamp information is used to record the time information of the last access of the data element, and the access count refers to the number of times the data element is read and written. Regularly update data with timestamp information less than a preset threshold and update data with access counts less than a preset lower limit using data with access counts greater than a preset upper limit.

4. The low-latency storage method for a general-purpose controller for engineering machinery according to claim 1, characterized in that, The data elements are classified according to their size, and the number of data areas in memory is determined according to the classification. The data elements in each metadata data area in memory are organized using a B+ tree. A metadata data area with the same amount of data as the metadata data area in memory is also opened in the external storage, and they correspond one-to-one. Synchronizing data elements from the metadata data area located in memory to the metadata data area in external storage includes: The data area is divided as follows: data elements of the same size are organized into a metadata data area. The data elements in each metadata data area are organized using a B+ tree. A metadata data area of ​​the same size is also allocated in external storage, corresponding one-to-one with the metadata data area in memory. When a data element needs to be deleted from external storage, the data element is removed from the B+ tree in memory, and the index of the data element is recorded in a linked list in the free data linked list area. This linked list is used to record the index of the deleted data element. The number of linked lists corresponds to the number of metadata data areas. The location of the data element stored in external storage does not need to be changed.

5. The low-latency storage method for a general-purpose controller for engineering machinery according to claim 1, characterized in that: After the step of ending data synchronization when the amount of data written to external memory is less than the value M, the process also includes recording the amount of data N that has actually been synchronized to external memory, recording whether the last data has been synchronized, and if the last data has not been synchronized, then the current data and the remaining M-N+1 data will be synchronized in the next program execution cycle; if the synchronization monitoring software timer is not triggered, then the data synchronization process continues.

6. The low-latency storage method for a general-purpose controller for engineering machinery according to claim 1, characterized in that, After data synchronization is complete, the storage method further includes a step of determining whether data addition or deletion operations have occurred, as detailed below: When data needs to be added or deleted, the sliding window of the processor memory, the free linked list data area in memory and the metadata data area in the external processor are updated.

7. The low-latency storage method for a general-purpose controller for engineering machinery according to claim 1, characterized in that, After synchronizing the data elements to the external memory, the storage method further includes a data recovery step, specifically: After the processor powers on, it needs to read data from external memory and load it into memory. This requires loading several metadata data areas from external memory. Load the free data linked list data area in the external memory. This data area records which data elements in each metadata data area of ​​the external memory are invalid. The data is read from each metadata data area in the external storage, and invalid data elements are removed from the metadata data area in the external storage according to the data element index recorded in the free data linked list data area in the external storage. After removal, the remaining valid data elements are organized according to the B+ tree, which means that the entire data in the external storage can be loaded into memory.

8. The low-latency storage method for a general-purpose controller for engineering machinery according to claim 1, characterized in that, The memory and external storage transfer data to each other, and the data organization of the two is consistent, that is, both the memory and the external storage include free data linked list data and several metadata data areas; the memory also includes a sliding window, which is communicatively connected to several metadata data areas in the memory.

Citation Information

Patent Citations

  • Storage space management method of Flash memory and data read-write system

    CN117194279A

  • Method and apparatus for processing data

    DE102021202021A1