Data power failure keeping method and system, storage medium, electronic equipment and computer program product

By defining the mapping table and configuration file, and using instrumentation code to synchronize data area variables to the retention area and store them on non-volatile media, the problem of inflexible power-down retention schemes in existing technologies is solved, and fast data synchronization of structure and array sub-members is achieved.

CN120407281APending Publication Date: 2025-08-01NR ELECTRIC CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510386386.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-28
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

Existing controller power-down retention schemes do not support setting individual structure and array sub-members as power-down retention variables, resulting in insufficient flexibility and wasted resources.

Method used

By obtaining the flags of the variables retained after power failure, the mapping table and configuration file are determined. The variables in the data area are synchronized to the retention area using instrumentation code, and the running values ​​of these variables are stored in non-volatile storage media. When power is restored, they are filled back into the data area.

Benefits of technology

It achieves flexible power-loss retention of structure and array sub-members, improving resource utilization efficiency and data synchronization speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407281A_ABST
    Figure CN120407281A_ABST
Patent Text Reader

Abstract

The invention discloses a data power failure keeping method and system, a storage medium, electronic equipment and a computer program product. The data power-down holding method comprises the steps that a mapping table and a configuration file are determined according to a power-down holding mark of an obtained power-down holding variable, and the power-down holding variable at least comprises a structural body or an array sub-member; determining a target file according to the instrumentation code of the target running program; according to the configuration file, the target file and the instrumentation code, synchronizing the operation value of the power-down retention variable in the data area to a retention area; storing the operation value of the power-down holding variable of the holding area in a nonvolatile storage medium; under the condition that the controller is powered on again, the operation value of the power-down holding variable in the nonvolatile storage medium is read to a holding area; and according to the mapping table, backfilling the operation value of the power-down hold variable from the hold area to the data area.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of programmable controllers. Specifically, it relates to a data power-off retention method, system, storage medium, electronic device, and computer program product. Background Art

[0002] Power-off retention is a way for the system to store relevant data after power-off. The data collected or generated during system operation often requires not to be lost when the power is off, and the system can resume its original working state after power-on.

[0003] The inventors of this application found that the existing controller power-off retention scheme does not support setting the structure and array sub-members separately as power-off retention variables. It only supports allocating the top-level basic variables or the top-level structure and array as a whole to the power-off retention area, which is not flexible enough and wastes resources.

[0004] The content of the background art part is only the technology known to the applicant and does not necessarily represent the prior art in this field. Summary of the Invention

[0005] According to one aspect of this application, this application also provides a data power-off retention method. The data power-off retention method includes: determining a mapping table and a configuration file according to the power-off retention flag of the obtained power-off retention variable, where the power-off retention variable includes at least a structure or an array sub-member; determining a target file according to the instrumentation code of the target running program; synchronizing the running value of the power-off retention variable in the data area to the retention area according to the configuration file, the target file, and the instrumentation code; storing the running value of the power-off retention variable in the retention area in a non-volatile storage medium; when the controller is powered on again, reading the running value of the power-off retention variable in the non-volatile storage medium to the retention area; and backfilling the running value of the power-off retention variable from the retention area to the data area according to the mapping table.

[0006] According to some exemplary embodiments, after the step of determining the mapping table and the configuration file according to the power-off retention flag of the obtained power-off retention variable, the data power-off retention method further includes: determining the power-off retention information according to the power-off retention flag of the power-off retention variable; storing the power-off retention information in the configuration file.

[0007] According to some exemplary embodiments, the step of determining the target file according to the instrumentation code of the program includes: when the variable in the program organization unit of the target running program meets the preset instrumentation condition, embedding the instrumentation code at the end of the program organization unit running function to determine the target file; and the step of synchronizing the running value of the power-off retention variable in the data area to the retention area includes: calling the interface when the controller is running to synchronize the running value of the power-off retention variable in the data area to the retention area.

[0008] According to some example embodiments, the non-volatile storage medium includes a first memory and a second memory; the step of storing the running value of the power-down hold variable in the hold area in the non-volatile storage medium includes: determining whether the length of the hold area is less than a preset length threshold; if so, storing the running value of the power-down hold variable in the second memory; if not, storing the running value of the power-down hold variable in the first memory; wherein, the first memory is a memory-mapped file memory, and the second memory is a static random access memory or a non-volatile random access memory.

[0009] According to some example embodiments, after filling back the data of the power-down hold variable from the hold area to the data area according to the mapping table, the data power-down hold method further includes: in the case of an update of the target running program, updating the mapping table and the valid flag hold variable according to a preset variable rule, wherein the valid flag hold variable is a valid power-down hold variable; according to the updated mapping table and the valid flag hold variable, updating the data of the valid flag hold variable from the hold area to the data area.

[0010] According to some example embodiments, the step of updating the mapping table and the valid flag hold variable according to a preset variable rule in the case of a program update includes: determining a first hash table according to the power-down hold information in the read configuration file; determining a second hash table according to the hold variable file, wherein the hold variable file is formed according to the valid power-down hold information; updating the mapping table and the valid flag hold variable according to the first hash table and the second hash table.

[0011] According to some example embodiments, after determining the target file according to the instrumentation code of the program and before the step of synchronizing the running value of the power-down hold variable in the data area to the hold area according to the configuration file, the target file, and the instrumentation code, the data power-down hold method further includes: in the case where the power-down hold becomes a global variable of the program organization unit, determining a global hold file; the step of synchronizing the running value of the power-down hold variable in the data area to the hold area includes: synchronizing the running value of the global variable from the data area to the hold area.

[0012] According to one aspect of the present application, the present application further provides a data power-off retention system. The data power-off retention system executes the data power-off retention method as described above. The data power-off retention system includes a processing unit. The processing unit determines a mapping table and a configuration file according to the power-off retention flag of the acquired power-off retention variable, where the power-off retention variable at least includes a structure or array sub-member; the processing unit determines a target file according to the instrumentation code of the target running program; the processing unit synchronizes the running value of the power-off retention variable in the data area to the retention area according to the configuration file, the target file, and the instrumentation code; the processing unit stores the running value of the power-off retention variable in the retention area in a non-volatile storage medium; the processing unit reads the running value of the power-off retention variable in the non-volatile storage medium to the retention area when the controller is powered on again; the processing unit backfills the running value of the power-off retention variable from the retention area to the data area according to the mapping table.

[0013] According to one aspect of the present application, the present application further provides a non-volatile computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it can implement the data power-off retention method as described above.

[0014] According to one aspect of the present application, the present application further provides an electronic device, including: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors can implement the data power-off retention method as described above.

[0015] According to one aspect of the present application, the present application further provides a computer program product, including: a computer program stored on a computer-readable storage medium; the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes the data power-off retention method as described above.

[0016] The data power-off retention method provided by the present application can support marking structure sub-members and array sub-members as power-off retention variables, and the allocation of power-off retention variables in the data area remains unchanged. By adding a retention area to achieve fast synchronization during the operation of the target running program, the problem of inflexible power-off retention selection is solved. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0018] Figure 1A schematic flowchart of a data power-off retention method 1000 according to an embodiment of the present application is shown;

[0019] Figure 2 Another schematic flowchart of a data power-off retention method 1000 according to an embodiment of the present application is shown;

[0020] Figure 3 A schematic flowchart of step S140 according to an embodiment of the present application is shown;

[0021] Figure 4 Another schematic flowchart of a data power-off retention method 1000 according to an embodiment of the present application is shown;

[0022] Figure 5 A schematic flowchart of step S170 according to an embodiment of the present application is shown;

[0023] Figure 6 Another schematic flowchart of a data power-off retention method 1000 according to an embodiment of the present application is shown;

[0024] Figure 7 A schematic structural diagram of a data power-off retention system according to an embodiment of the present application is shown.

[0025] Reference numerals

[0026] Data power-off retention system 200; Processing unit 210. Detailed implementation manners

[0027] Example embodiments will now be described more fully with reference to the accompanying drawings. However, the example embodiments can be implemented in various forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this application will be thorough and complete, and will fully convey the concept of the example embodiments to those skilled in the art. Identical reference numerals in the figures denote identical or similar parts, and thus their repeated description will be omitted.

[0028] The features, structures, or characteristics described may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of the embodiments of the present disclosure. However, those skilled in the art will realize that the technical solutions of the present disclosure can be practiced without one or more of these specific details, or can be implemented in other ways, components, materials, devices, etc. In these cases, well-known structures, methods, devices, implementations, materials, or operations will not be shown or described in detail.

[0029] In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that comprises a series of steps or units is not limited to the listed steps or units, but optionally further comprises steps or units not listed, or optionally further comprises other steps or units inherent to these processes, methods, products, or apparatuses.

[0030] The terms "first", "second", etc. in the description and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order.

[0031] The technical solutions of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, rather than all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments in this application without creative efforts fall within the scope of protection of this application.

[0032] According to one aspect of this application, this application provides a data power-off retention method. The data power-off retention method 1000 can be executed by a data power-off retention system. Exemplarily, the data power-off retention system can be a host (or server) with data processing capabilities.

[0033] See Figure 1 , the method 1000 may include step S110 - step S160.

[0034] In step S110, the data power-off retention system determines a mapping table and a configuration file according to the power-off retention flag of the acquired power-off retention variable. The power-off retention variable at least includes structural or array sub-members.

[0035] According to an exemplary embodiment, the power-off retention flag can be a flag that identifies the characteristic that certain data or states can still remain unchanged after a power interruption. The power-off retention variable can be a variable with a power-off retention flag. For example, the power-off retention variable can include one of a structure, an array sub-member, and a single variable, etc.

[0036] According to an exemplary embodiment, the data power-off retention system can obtain the power-off retention flag of the variable through configuration software. The data power-off retention system can allocate the relative position of the power-off retention variable in the data area and the relative position of the power-off retention variable in the retention area to form a mapping table. The data power-off retention system can store the power-off retention information into a configuration file (PLC.cfg).

[0037] In step S120, the data power-off retention system determines a target file according to the instrumentation code of the target running program.

[0038] According to an exemplary embodiment, the target running program can be a program running on a configuration software. For example, the target running program can be a program for calculating the cumulative power generation of a generator set and the cumulative running time of a system. The instrumentation code can be an additional code segment inserted into the source code or object code of the target running program, used to collect information during the running of the target running program or change the behavior of the target running program.

[0039] In the case where the configuration software generates the code of the target running program, the data power failure retention system can embed instrumentation code at the end of the running function of the program organization unit of each target running program, and compile the program to form a target file (PLC.lib).

[0040] In step S130, the data power failure retention system synchronizes the running values of the power failure retention variables in the data area to the retention area according to the configuration file, the target file, and the instrumentation code.

[0041] According to an exemplary embodiment, the data area can be a memory area allocated during the running of the target running program. The retention area can be a long-term storage part.

[0042] According to an exemplary embodiment, the data power failure retention system can download the target file and the configuration file to the controller through the configuration software. The data power failure retention system can start the target running program through the controller. During the running of the target running program, the instrumentation code is executed, and the data power failure retention system can synchronize the running values of the power failure retention variables from the data area to the retention area through the controller.

[0043] In step S140, the data power failure retention system stores the running values of the power failure retention variables in the retention area in a non-volatile storage medium.

[0044] According to an exemplary embodiment, the non-volatile storage medium can be a physical device or technology for long-term or large-scale data storage. The data power failure retention system can store the running values of the power failure retention variables in the retention area in a non-volatile medium during the periodic task stage of the background running of the target running program.

[0045] In step S150, when the controller is powered on again, the data power failure retention system reads the running values of the power failure retention variables in the storage medium into the retention area.

[0046] According to an exemplary embodiment, the controller power-on again can select the warm start mode. In the case of selecting the warm start mode after the controller is powered off, the data power failure retention system can, through the controller, when the controller is powered on again, read the running values of the power failure retention variables from the non-volatile medium and synchronize the running values of the power failure retention variables to the retention area.

[0047] In step S160, the data power-off retention system backfills the running value of the power-off retention variable from the retention area to the data area according to the mapping table.

[0048] After the controller selects the warm start mode, when powered on, it reads data from the non-volatile medium and synchronizes it to the retention area.

[0049] According to the exemplary embodiment, the data power-off retention system can backfill the running value of the valid power-off retention variable from the retention area to the corresponding data area according to the mapping table.

[0050] Through the above embodiments, the data power-off retention method 1000 provided by the present application determines the mapping table and the configuration file through the power-off retention flag of the obtained power-off retention variable. The present application determines the target file through the instrumentation code of the target running program. The present application synchronizes the running value of the power-off retention variable in the data area to the retention area through the configuration file, the target file, and the instrumentation code. The present application stores the running value of the power-off retention variable in the retention area in the non-volatile storage medium. The present application reads the running value of the power-off retention variable in the non-volatile storage medium to the retention area when the controller is powered on again. The present application backfills the running value of the power-off retention variable from the retention area to the data area according to the mapping table.

[0051] The data power-off retention method 1000 provided by the present application can support marking structure sub-members and array sub-members as power-off retention variables. The allocation of power-off retention variables in the data area remains unchanged, and the target running program can be quickly synchronized during operation by adding a retention area, solving the problem that the selection of power-off retention is not flexible enough.

[0052] Optionally, referring to Figure 2 , after step S110, method 1000 may further include step S111 and step S112.

[0053] In step S111, the data power-off retention system determines the power-off retention information according to the power-off retention flag of the power-off retention variable.

[0054] According to the exemplary embodiment, when the configuration software generates the code of the target running program, the data power-off retention system can sequentially allocate the relative positions of variables (including power-off retention variables) in the data area, and allocate the relative positions of power-off retention variables in the retention area according to the task priority, the call order of the program organization unit, and the principle of large boundary alignment according to the variable type. The data power-off retention system forms a hierarchical variable name according to "program organization unit name.structure instance.sub-member variable name". The data power-off retention system can use the hierarchical variable name as the power-off retention information.

[0055] In step S112, the data power-off retention system stores the power-off retention information in the configuration file.

[0056] According to the exemplary embodiment, the power failure retention system may store the power failure retention information into the [RETAIN] field of the configuration file (PLC.cfg).

[0057] Exemplarily, the format of the [RETAIN] field of the configuration file (PLC.cfg) is as follows:

[0058] [RETAIN num=3total_len=4crc=12345678]

[0059] na=GLBVAR2 area=0src=2dst=0len=1 / / Global variable na=POU1.Var1 area=1src=10dst=1len=2 / / Program organization unit variable na=POU2.TRIG_1.M area=1src=20dst=3len=1 / Member variable of function block

[0060] Wherein, num is the number of signals; total_len is the total length; na is the variable name; area is the variable area type, 0 is the global variable area, and 1 is the POU memory area; src is the offset address of the variable in the data area; dst is the offset address of the variable in the retention area; len is the byte length of the variable type.

[0061] Optionally, step S120 may be specifically: when the variables of the program organization unit of the target running program meet the preset instrumentation conditions, the power failure retention system embeds instrumentation code at the end of the program organization unit running function to determine the target file.

[0062] According to the exemplary embodiment, the preset instrumentation condition may be a preset condition for inserting instrumentation code into the target running program. The preset instrumentation condition may be that there are power failure retention variables declared in the program organization unit of the target running program.

[0063] For example, when the configuration software generates the code of the target running program, if the power failure retention system determines that there are power failure retention variables declared in the program organization unit of the target running program, it embeds instrumentation code at the end of the program organization unit running function of each target running program, and compiles the program to form the target file (PLC.lib).

[0064] Step S130 may be specifically: the power failure retention system calls the interface when the controller is running, and synchronizes the running values of the power failure retention variables in the data area to the retention area.

[0065] According to an exemplary embodiment, the interface in the case of the controller running can be a function interface. The data power-down retention system can call the function interface to synchronize the running values of the power-down retention variables in the data area to the retention area.

[0066] The data power-down retention system can synchronize the running values of the power-down retention variables in the data area to the retention area by calling the interface provided in the case of the controller running. The controller creates the data area and the retention area as a continuous memory during the initialization phase.

[0067] For example, the continuous memory can be:

[0068] RTE_API.fpSyncDataToRetainArea(AREA_M,10,1,12).

[0069] The interface for the data power-down retention system to write a certain offset address in the data area to the retention area is as follows:

[0070] void(*fpSyncDataToRetainArea)(IecDataAreaType areatp,int src_offset,

[0071] int data_len,int dst_offset).

[0072] Optionally, the non-volatile storage medium includes a first memory and a second memory. The first memory can be a memory-mapped file memory, and the second memory can be a static random access memory (SRAM) or a non-volatile random access memory (NVRAM).

[0073] See Figure 3 , step S140 may include steps S141 - S143.

[0074] In step S141, the data power-down retention system determines whether the length of the retention area is less than a preset length threshold.

[0075] According to an exemplary embodiment, the length of the retention area can be the size of the retention area capacity. For example, the length of the retention area can be 512KB. The preset length threshold can be a critical value of the preset retention area length. The data power-down retention system determines whether the length of the retention area is less than the preset length threshold.

[0076] In step S141, if the data power-down retention system determines that the length of the retention area is less than the preset length threshold, step S142 is executed. In step S142, the data power-down retention system stores the running value of the power-down retention variable in the second memory.

[0077] According to the exemplary embodiment, when the data power-down retention system determines that the length of the retention area is less than the preset length threshold, the running value of the power-down retention variable is stored in the second memory (i.e., SRAM or NVRAM).

[0078] In step S141, if the data power-down retention system determines that the length of the retention area is greater than or equal to the preset length threshold, step S143 is executed. In step S143, the data power-down retention system stores the running value of the power-down retention variable in the first memory.

[0079] According to the exemplary embodiment, when the data power-down retention system determines that the length of the retention area is greater than or equal to the preset length threshold, the running value of the power-down retention variable is stored in the first memory (i.e., the memory-mapped file memory). When the controller is powered on again, the data power-down retention system can also, through the controller, use the Cyclic Redundancy Check (CRC) method to pass the verification, and modify the file with the most recent time as the valid data of the running value of the data retention variable, and synchronize the valid data from the data area to the retention area.

[0080] The data power-down retention method 1000 provided by the present application can select a suitable non-volatile storage medium according to the size of the retention area, and store the data in the storage area in the background non-real-time thread task to the non-volatile storage medium, solving the problems of limited storage space and insufficient supported retention area capacity.

[0081] Optionally, referring to Figure 4 , after step S160, method 1000 may further include step S170 and step S180.

[0082] In step S170, when the target running program is updated, the data power-down retention system updates the mapping table and the valid flag retention variable according to the preset variable rule. The valid flag retention variable is a valid power-down retention variable.

[0083] According to the exemplary embodiment, the update of the target running program may be an online update. The preset variable rule may be a preset rule for updating the mapping table and the valid flag retention variable.

[0084] For example, the preset variable rule may be: determine the first hash table according to the power-down retention information in the read configuration file; determine the second hash table according to the retention variable file; update the mapping table and the valid flag retention variable according to the first hash table and the second hash table.

[0085] Optionally, referring to Figure 5 , step S170 may include steps S171 - S173.

[0086] In step S171, the data power - down retention system determines a first hash table according to the power - down retention information in the read configuration file.

[0087] According to the exemplary embodiment, the data power - down retention system may read the power - down retention information [RETAIN] field of the configuration file (PLC.cfg) through the controller. The data power - down retention system may use a first hash table (hash table hash1) to record information such as the variable name of the power - down retention variable, the relative position of the power - down retention variable in the data area, the relative position of the power - down retention variable in the retention area, and the data length information of the running value of the power - down retention variable.

[0088] In step S172, the data power - down retention system determines a second hash table according to the retention variable file.

[0089] According to the exemplary embodiment, the retention variable file may be a file formed by the power - down retention information segment [RETAIN] field of the configuration file (PLC.cfg).

[0090] In the case where there is a retention variable file (retain.cfg file), the data power - down retention system may read the retention variable file (retain.cfg file) through the controller and use a second hash table (hash table hash2) to record the power - down retention information before the controller is updated.

[0091] In step S173, the data power - down retention system updates the mapping table and the valid flag retention variable according to the first hash table and the second hash table.

[0092] According to the exemplary embodiment, the data power - down retention system may sequentially traverse the variables in the first hash table (hash table hash1). The data power - down retention system may search for variables with the same variable name and variable type as those in the first hash table (hash table hash1) in the second hash table (hash table hash2). The data power - down retention system may match the found variables through the first hash table (hash table hash1) and the second hash table (hash table hash2).

[0093] In the case of successful matching (for example, the variable names of a certain power - down retention variable in the first hash table and the second hash table are the same, and the variable types are the same), the data power - down retention system uses the retention value of the power - down retention variable and marks the power - down retention variable as a valid retention flag to form a valid flag retention variable.

[0094] In the case of unsuccessful matching, it indicates that the variable is a newly added power-off retention variable, and the variable is marked as an invalid retention flag.

[0095] The power-off retention system can update the mapping table and the valid flag retention variable according to the matching result after matching the first hash table (hash table hash1) and the second hash table (hash table hash2).

[0096] The power-off retention system can store the power-off retention information segment [RETAIN] of the newly downloaded configuration file (PLC.cfg) as a retention variable file (retain.cfg file) through the controller for the next comparison. Re-initialize the data in the retention area to 0.

[0097] In step S180, the power-off retention system updates the data of the valid flag retention variable from the retention area to the data area according to the updated mapping table and the valid flag retention variable.

[0098] According to the exemplary embodiment, after the power-off retention system completes the task initialization function call through the controller, it can update the running value data of the corresponding retention area of the valid flag retention variable to the data area according to the updated mapping table and the valid flag retention variable.

[0099] According to the exemplary embodiment, after the power-off retention system downloads the target running program in the online update mode through the controller, it can analyze the addition, deletion, and position change of the power-off retention variables based on the retention variable files (retain.cfg files) before and after the update. The power-off retention system can optionally copy the data of the retention area before the update to the newly created retention area, and then synchronize the data of the retention area to the data area according to the mapping table for the first run after the update, realizing the maximum retention and use of the running values of the power-off retention variables, thus solving the problem that when the target running program has new variables added, deleted, or modified, when downloading the target running program in the online update mode, due to the change of the address of the power-off retention variables in the data area, the retained data becomes unavailable, and it is necessary to retain the power-off retention values of the available power-off retention variables as much as possible.

[0100] See Figure 6 , after step S120, method 1000 further includes step S121.

[0101] In step S121, the power-off retention system determines the global retention file when the power-off retention becomes a global variable of the program organization unit.

[0102] According to an exemplary embodiment, a global variable can be a variable globally declared for a program organization unit of a target running program. When the power-down retention system makes a global variable of a program organization unit become a power-down retention variable, during the stage of generating the code of the target running program by the configuration software, a global retention file (global_retain.c file) is output, thereby adding a global variable data synchronization function.

[0103] Step S130 can be specifically: the power-down retention system synchronizes the running value of the global variable from the data area to the retention area.

[0104] According to an exemplary embodiment, the power-down retention system can, through the global variable data synchronization function, call the global variable data synchronization function in the task with the highest controller priority, and synchronize the running value of the global variable in the data area to the retention area by calling the interface provided under the condition of the controller running.

[0105] Through the above embodiments, the power-down retention method 1000 provided by the present application can support global variables and program organization unit variables to select the power-down retention attribute with the smallest granularity. The present application can be applied to the development of multiple application directions of programmable controllers, improving the usability, convenience, and robustness of the power-down retention method.

[0106] According to an aspect of the present application, the present application further provides a power-down retention system 200. The power-down retention system 200 executes the power-down retention method 1000 as described above. Refer to Figure 7 the power-down retention system 200 includes a processing unit 210.

[0107] According to an exemplary embodiment, the processing unit 210 determines a mapping table and a configuration file according to the power-down retention flag of the power-down retention variable obtained, where the power-down retention variable at least includes a structure or array sub-member.

[0108] The processing unit 210 determines a target file according to the instrumentation code of the target running program.

[0109] The processing unit 210 synchronizes the running value of the power-down retention variable in the data area to the retention area according to the configuration file, the target file, and the instrumentation code.

[0110] The processing unit 210 stores the running value of the power-down retention variable in the retention area in a non-volatile storage medium.

[0111] When the controller is powered on again, the processing unit 210 reads the running value of the power-down retention variable in the non-volatile storage medium into the retention area.

[0112] The processing unit 210 backfills the running value of the power-down retention variable from the retention area to the data area according to the mapping table.

[0113] According to the exemplary embodiment, power-off retention variables, power-off retention flags, configuration files, target files, data areas, retention areas, and non-volatile storage media have been described in the power-off data retention method 1000, and thus will not be elaborated herein.

[0114] This application can support marking structure sub-members and array sub-members as power-off retention variables. The allocation of power-off retention variables in the data area remains unchanged, and the rapid synchronization during the operation of the target running program is achieved by adding a retention area, solving the problem of inflexible power-off retention selection.

[0115] According to one aspect of the present application, the present application further provides a non-volatile computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it can implement the power-off data retention method as described above.

[0116] According to one aspect of the present application, the present application further provides an electronic device, including: one or more processors; a storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors can implement the power-off data retention method as described above.

[0117] According to one aspect of the present application, the present application further provides a computer program product, including: a computer program stored on a computer-readable storage medium; the computer program includes program instructions. When the program instructions are executed by a computer, the computer is caused to execute the power-off data retention method as described above.

[0118] Finally, it should be noted that the above are only the preferred embodiments of the present application and are not used to limit the present application. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions of the foregoing embodiments, or perform equivalent replacements for some of the technical features. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A data power-off retention method, characterized in that, The data power-off retention method includes: Determine a mapping table and a configuration file according to the power-off retention flag of the obtained power-off retention variable, where the power-off retention variable includes at least structure or array sub-members; Determine a target file according to the instrumentation code of the target running program; Synchronize the running values of the power-off retention variables in the data area to the retention area according to the configuration file, the target file, and the instrumentation code; Store the running values of the power-off retention variables in the retention area in a non-volatile storage medium; In the case of the controller being powered on again, read the running values of the power-off retention variables in the non-volatile storage medium into the retention area; Backfill the running values of the power-off retention variables from the retention area to the data area according to the mapping table.

2. The data power-down retention method according to claim 1, wherein After determining the mapping table and the configuration file according to the power-off retention flag of the obtained power-off retention variable, the data power-off retention further includes: Determine power-off retention information according to the power-off retention flag of the power-off retention variable; Store the power-off retention information in the configuration file.

3. The data power-off retention method according to claim 1, wherein The determining the target file according to the instrumentation code of the program includes: When the variables in the program organization unit of the target running program meet the preset instrumentation conditions, embed the instrumentation code at the end of the program organization unit running function to determine the target file; The synchronizing the running values of the power-off retention variables in the data area to the retention area includes: Call the interface in the case of the controller running to synchronize the running values of the power-off retention variables in the data area to the retention area.

4. The data power-off retention method according to claim 1, characterized in that The non-volatile storage medium includes a first memory and a second memory; The storing the running values of the power-off retention variables in the retention area in a non-volatile storage medium includes: Judge whether the length of the retention area is less than a preset length threshold; If so, store the running values of the power-off retention variables in the second memory; If not, store the running values of the power-off retention variables in the first memory; Wherein, the first memory is a memory-mapped file memory, and the second memory is a static random access memory or a non-volatile random access memory.

5. The data power-off retention method according to claim 2, wherein After backfilling the data of the power-off retention variables from the retention area to the data area according to the mapping table, the data power-off retention method further includes: In the case of the target running program being updated, update the mapping table and the valid flag retention variables according to the preset variable rules, where the valid flag retention variables are valid power-off retention variables; Update the data of the valid flag retention variables from the retention area to the data area according to the updated mapping table and the valid flag retention variables.

6. The data power-off retention method according to claim 5, characterized in that The updating the mapping table and the valid flag retention variables according to the preset variable rules in the case of the program being updated includes: Determine a first hash table according to the power-off retention information in the read configuration file; Determine a second hash table according to the retention variable file, where the retention variable file is formed according to the valid power-off retention information; Update the mapping table and the valid flag holding variable according to the first hash table and the second hash table.

7. The data power-off retention method according to claim 3, wherein After determining the target file according to the instrumented code of the program, and before synchronizing the running value of the power-down holding variable in the data area to the holding area according to the configuration file, the target file, and the instrumented code, the data power-down holding method further includes: When the power-down holding becomes a global variable of the program organization unit, determine the global holding file; The synchronizing the running value of the power-down holding variable in the data area to the holding area includes: Synchronize the running value of the global variable from the data area to the holding area.

8. A data power-off retention system, characterized in that, The data power-down holding system executes the data power-down holding method according to any one of claims 1-7. The data power-down holding system includes: A processing unit that determines a mapping table and a configuration file according to the power-down holding flag of the acquired power-down holding variable, where the power-down holding variable at least includes a structure or an array sub-member; The processing unit determines the target file according to the instrumented code of the target running program; The processing unit synchronizes the running value of the power-down holding variable in the data area to the holding area according to the configuration file, the target file, and the instrumented code; The processing unit stores the running value of the power-down holding variable in the holding area in a non-volatile storage medium; When the controller is powered on again, the processing unit reads the running value of the power-down holding variable in the non-volatile storage medium into the holding area; The processing unit backfills the running value of the power-down holding variable from the holding area to the data area according to the mapping table.

9. A non-volatile computer-readable storage medium having a computer program stored thereon, characterized in that, The computer program, when executed by a processor, implements the data power-down holding method according to any one of claims 1-7.

10. An electronic device, characterized in that, Comprising: One or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the data power-down holding method according to any one of claims 1-7.

11. A computer program product, characterized in that, Comprising a computer program stored on a computer-readable storage medium. The computer program includes program instructions that, when executed by a computer, cause the computer to execute the data power-down holding method according to any one of claims 1-7.