Online Update Method and Device for Controller Program

By quickly interrupting the task thread before the controller program is updated, and after the update, the unfinished program organization unit is completed based on the operation information, the problems of excessive waiting time and data consistency caused by online updates in the existing technology are solved, and efficient and secure online update of controller programs is achieved.

CN116360822BActive Publication Date: 2025-06-27NR ELECTRIC CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310316588.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-24
Publication Date
2025-06-27
Estimated Expiration
2043-03-24

AI Technical Summary

Technical Problem

When existing controller programs are updated online incrementally, the running cycle of low-priority tasks is long, resulting in multiple cycles of waiting time and the interference-free switching cannot be achieved; after incremental update, the task is restarted and executed sequentially from beginning to end, resulting in data consistency problems.

Method used

By quickly realizing interrupt execution of task threads with program organization units as granularity, after the controller program updates, determine the interrupt position of the task before the update based on the running information, and supplement the program organization units that are not run in the interrupt task.

Benefits of technology

It realizes the rapid exit and accurate operation of tasks before and after online update of controller programs, ensures the consistency of data sections and program logic, and improves the efficiency, security and reliability of updates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116360822B_ABST
    Figure CN116360822B_ABST
Patent Text Reader

Abstract

A method and device for online update of a controller program. The controller program includes one or more tasks, and each task includes one or more program organization units. The method includes: interrupting the currently executing task in response to an update signal; in the case of the update being completed, determining the task in the execution interruption state according to the running information of the controller program; determining the unrun program organization units in the task in the execution interruption state; and supplementarily running the unrun program organization units. The solution proposed in this application quickly realizes the interrupted execution of task threads at the granularity of program organization units before the update of the controller program. When the controller program runs again after the update, it can determine the interruption position of the task before the update of the controller program and supplementarily run it, improving the efficiency of the online update of the controller program and ensuring the security and reliability of the update.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of controller programs, and in particular, to a method and device for online updating of controller programs. Background Art

[0002] A programmable controller is an electronic system for digital operation, which is specially designed for application in industrial environments. It is used to execute instructions for operations such as storage logic operations, sequential control, timing, counting, and arithmetic operations, and controls various types of mechanical equipment or production processes through digital or analog input / output interfaces. Programmable controllers have been widely used in the automatic control of various production machinery and production processes, and have become one of the most important, most popular, and most widely used industrial control devices.

[0003] When performing online incremental updates on existing controller programs, it is usually switched in units of tasks. The common practice is to wait for the currently running task to complete before canceling or stopping. The main problems with the current method include: if the running cycle of a low-priority task is long, it will cause the waiting time to occupy multiple cycles during incremental updates, and seamless switching cannot be achieved; after incremental updates, the tasks are restarted and executed sequentially from beginning to end, which will cause different tasks to run under different sections, resulting in data consistency problems. Therefore, a method is needed that can quickly exit the tasks before incremental updates and accurately determine the tasks interrupted before the update and resume the execution of the tasks after the update. Summary of the Invention

[0004] In view of the problems existing in the prior art, the present application provides a method and device for online updating of controller programs. The method proposed in the present application quickly realizes the interrupted execution of task threads in units of program organization units before the controller program is updated, and when the controller program runs again after the update, it can determine the interruption position of the task before the controller program is updated and resume the execution of the interrupted tasks.

[0005] According to a first aspect of the present application, a method for online updating of a controller program is proposed. The controller program includes one or more tasks, and each task includes one or more program organization units. The method includes:

[0006] Responding to an update signal to interrupt the currently executing task;

[0007] In the case where the update is completed, determining the tasks in the execution interruption state according to the running information of the controller program;

[0008] Determining the unexecuted program organization units in the tasks in the execution interruption state;

[0009] Resuming the execution of the unexecuted program organization units.

[0010] According to some embodiments, the operation information includes name information and count information. The name information includes a task name, and the count information includes the number of times the task starts to execute and the number of times the task ends to execute corresponding to the task name.

[0011] According to some embodiments, determining a task in an execution interruption state based on the operation information of the controller program includes:

[0012] In the case where the number of times any task starts to execute is greater than the number of times the corresponding task ends to execute, it is determined that the task is in an execution interruption state.

[0013] According to some embodiments, determining a task in an execution interruption state based on the operation information of the controller program includes:

[0014] In the case where the number of times any task starts to execute is zero and the number of times the corresponding task ends to execute is greater than zero, it is determined that the task is in an execution interruption state.

[0015] According to some embodiments, the name information further includes a program organization unit name, and the count information further includes the number of times the program organization unit executes.

[0016] According to some embodiments, determining an unexecuted program organization unit in the task in an execution interruption state includes:

[0017] In the case where the number of times the program organization unit executes is less than the number of times the task in an execution interruption state starts to execute, it is determined that the program organization unit has not been executed.

[0018] According to some embodiments, determining an unexecuted program organization unit in the task in an execution interruption state further includes:

[0019] In the case where the number of times the task in an execution interruption state starts to execute is zero and the number of times the program organization unit executes is greater than zero, it is determined that the program organization unit has not been executed.

[0020] According to a second aspect of the present application, a controller program online update device is proposed, including an interruption module, an interruption screening module, an unexecuted screening module, and a supplementary execution module, where:

[0021] The interruption module is configured to interrupt the currently executing task in response to an update signal;

[0022] The interruption screening module is configured to determine a task in an execution interruption state according to the operation information of the controller program when the update ends;

[0023] The unexecuted screening module is used to determine the unexecuted program organization units in the tasks in the execution interruption state;

[0024] The supplementary execution module is used to supplement the execution of the unexecuted program organization units.

[0025] According to the third aspect of the present application, an electronic device is provided, which is characterized by including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the method described in the first aspect of the present application is implemented.

[0026] According to the fourth aspect of the present application, a computer-readable storage medium is provided, which is characterized by storing a computer program for electronic data exchange, wherein the computer program enables a computer to execute the method described in the first aspect of the present application.

[0027] A method and device for online update of a controller program proposed in the present application record operation information in units of program organization units before the controller program is updated, and quickly interrupt the execution of task threads according to the operation information. When the controller program runs again after being updated, it can judge the interruption position of the task before the controller program is updated, and supplement the execution of the unexecuted program organization units in the interrupted tasks. The solution proposed in the present application improves the efficiency of the online update of the controller program, ensures the consistency of the data section and program logic before and after the update, and improves the security and reliability of the update. Description of the Drawings

[0028] 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, other drawings can also be obtained according to these drawings without exceeding the scope required to be protected by the present application.

[0029] Figure 1 It is a schematic diagram of the steps of the method for online update of the controller program of the present application;

[0030] Figure 2 It is a schematic diagram of the structure of the device for online update of the controller program of the present application;

[0031] Figure 3 It is a flowchart when the controller program of the present application runs for the first time after being updated;

[0032] Figure 4 It is a structural diagram of an electronic device of the present application. Detailed Embodiments

[0033] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.

[0034] Figure 1 It is a schematic diagram of the steps of the method for online updating of the controller program of the present application.

[0035] Step S101, in response to an update signal, interrupt the currently executing task.

[0036] In some specific embodiments, the controller program includes one or more tasks. In some specific embodiments, any task includes one or more program organization units. In some specific embodiments, each program organization unit includes a corresponding program organization unit running function. In some specific embodiments, the currently executing task can be one or multiple.

[0037] In some specific embodiments, the task execution process includes executing the program organization unit running function in a task thread. In some specific embodiments, in response to an update signal for the controller program, interrupt the currently executing task. In some specific embodiments, when an update signal is received, end the currently called program organization unit running function, exit the task thread, and interrupt the task.

[0038] Step S102, when the update is completed, determine the task in the execution interruption state according to the running information of the controller program.

[0039] In some specific embodiments, the controller program records its own running information. In some specific embodiments, the running information includes name information and count information. In some specific embodiments, the name information includes task name and program organization unit name. In some specific embodiments, the count information includes the number of times the task starts to execute, the number of times the task ends to execute, and the number of times the program organization unit executes. In some specific embodiments, when the update is completed, determine the task in the execution interruption state according to the running information. In some specific embodiments, obtain the corresponding number of times the task starts to execute and the number of times the task ends to execute according to the task name.

[0040] In some specific embodiments, the numerical values of the task start execution count and the task end execution count are compared. When the task start execution count is greater than the task end execution count, it is determined that the task is in an execution interrupted state. In some specific embodiments, the numerical values of the task start execution count and the task end execution count are compared. The task start execution count is 0. When the current task was executed last time, the task start execution count flipped after reaching the maximum value allowed for counting. When the task start execution count is less than the task end execution count, it is determined that the task is in an execution interrupted state. In some specific embodiments, for a task in an execution interrupted state, the task thread is re - called to start task execution.

[0041] Step S103: Determine the un - run program organization units in the task in the execution interrupted state.

[0042] In some specific embodiments, any task includes one or more program organization units. In some specific embodiments, each program organization unit includes a corresponding program organization unit running function. In some specific embodiments, the running information includes name information and count information. In some specific embodiments, the name information includes the task name and the program organization unit name. In some specific embodiments, the count information includes the task start execution count, the task end execution count, and the program organization unit execution count.

[0043] In some specific embodiments, one or more un - run program organization units in the task in the execution interrupted state are determined according to the running information. In some specific embodiments, when the program organization unit execution count is less than the task start execution count, it is determined that the current program organization unit has not been run. In some specific embodiments, the task start execution count is zero. When the current task was executed last time, the task start execution count flipped after reaching the maximum value allowed for counting. When the program organization unit execution count is greater than zero, it is determined that the current program organization unit has not been run.

[0044] Step S104: Supplementarily run the un - run program organization units.

[0045] In some specific embodiments, when it is determined that a program organization unit has not been run, the current program organization unit is supplementarily run. In some specific embodiments, the program organization unit is supplementarily run by re - calling the program organization unit running function.

[0046] According to the controller program online update method proposed in this application, before the controller program is updated, the running information is recorded in units of program organization units, and the interruption of the task thread is quickly realized according to the running information. When the controller program runs again after the update, it can judge the interruption position of the task before the controller program is updated, and supplement and run the unexecuted program organization units in the interrupted task. The solution proposed in this application improves the efficiency of the online update of the controller program, ensures the consistency of the data section and program logic before and after the update, and improves the safety and reliability of the update.

[0047] Figure 2 It is a schematic structural diagram of the controller program online update device of this application.

[0048] The interruption module is used to interrupt the currently executing task in response to the update signal.

[0049] In some specific embodiments, the controller program includes one or more tasks. In some specific embodiments, any task includes one or more program organization units. In some specific embodiments, each program organization unit includes a corresponding program organization unit running function. In some specific embodiments, the currently executing task can be one or multiple.

[0050] In some specific embodiments, the task execution process includes executing the program organization unit running function in the task thread. In some specific embodiments, in response to the update signal of the controller program, the currently executing task is interrupted. In some specific embodiments, when the update signal is received, the currently called program organization unit running function is ended, the task thread is exited, and the task is interrupted.

[0051] The interruption screening module is used to determine the task in the execution interruption state according to the running information of the controller program when the update ends.

[0052] In some specific embodiments, the controller program records its own running information. In some specific embodiments, the running information includes name information and count information. In some specific embodiments, the name information includes task name and program organization unit name. In some specific embodiments, the count information includes the task start execution times, the task end execution times, and the program organization unit execution times. In some specific embodiments, when the update ends, the task in the execution interruption state is determined according to the running information. In some specific embodiments, the corresponding task start execution times and task end execution times are obtained according to the task name.

[0053] In some specific embodiments, the numerical magnitudes of the task start execution count and the task end execution count are compared. When the task start execution count is greater than the task end execution count, it is determined that the task is in an interrupted execution state. In some specific embodiments, the numerical magnitudes of the task start execution count and the task end execution count are compared. The task start execution count is 0. When the current task was last executed, the task start execution count flipped after reaching the maximum value allowed for counting. When the task start execution count is less than the task end execution count, it is determined that the task is in an interrupted execution state. In some specific embodiments, for a task in an interrupted execution state, the task thread is re - called to start task execution.

[0054] A non - running screening module is used to determine the non - running program organization units in the task in the interrupted execution state.

[0055] In some specific embodiments, any task includes one or more program organization units. In some specific embodiments, each program organization unit includes a corresponding program organization unit running function. In some specific embodiments, the running information includes name information and count information. In some specific embodiments, the name information includes the task name and the program organization unit name. In some specific embodiments, the count information includes the task start execution count, the task end execution count, and the program organization unit execution count.

[0056] In some specific embodiments, one or more non - running program organization units in the task in the interrupted execution state are determined according to the running information. In some specific embodiments, when the program organization unit execution count is less than the task start execution count, it is determined that the current program organization unit has not run. In some specific embodiments, the task start execution count is zero. When the current task was last executed, the task start execution count flipped after reaching the maximum value allowed for counting. When the program organization unit execution count is greater than zero, it is determined that the current program organization unit has not run.

[0057] A supplementary execution module is used to supplementarily execute the non - running program organization units.

[0058] In some specific embodiments, when it is determined that a program organization unit has not run, the current program organization unit is supplementarily executed. In some specific embodiments, the program organization unit is supplementarily executed by re - calling the program organization unit running function.

[0059] Figure 3 This is the flowchart when the controller program of this application runs for the first time after being updated.

[0060] In some specific embodiments, the controller program includes one or more tasks. In some specific embodiments, it is first determined whether it is the first run after the controller program is updated. If the current controller program is the first run after the update, the execution of the online update method of the controller program is started. In some specific embodiments, it is first determined whether it is the first run after the controller program is updated. If the current controller program is not the first run after the update, the execution of the online update method of the controller program is ended. In some specific embodiments, the task serial number is initialized to n = 1, and the total task count s = p. In some specific embodiments, it is determined whether n is less than or equal to p. If n is less than or equal to p, the nth task in the task list is executed. In some specific embodiments, it is determined whether n is less than or equal to p. If n is greater than p, all tasks of the controller program have been determined, and the execution of the online update method of the controller program is ended.

[0061] In some specific embodiments, it is determined whether the task start execution count of the nth task is zero. If the task start execution count is not 0, and the task start execution count is greater than the task end execution count, it is determined that the task is in an execution interruption state. In some specific embodiments, it is determined whether the task start execution count of the nth task is zero. If the task start execution count is not 0, and the task start execution count is less than the task end execution count, the task is not in an execution interruption state. After the value of n is incremented by 1, it is again determined whether n is less than or equal to p.

[0062] In some specific embodiments, it is determined whether the task start execution count of the nth task is zero. If the task start execution count is 0, and in the previous execution of the current task, the task start execution count flipped after reaching the maximum value allowed by the count, and the task start execution count is less than the task end execution count, it is determined that the task is in an execution interruption state. In some specific embodiments, it is determined whether the task start execution count of the nth task is zero. If the task start execution count is 0, and in the previous execution of the current task, the task start execution count flipped after reaching the maximum value allowed by the count, and the task start execution count is greater than the task end execution count, the task is not in an execution interruption state. After the value of n is incremented by 1, it is again determined whether n is less than or equal to p. In some specific embodiments, for a task in an execution interruption state, the task thread is re - called to start the task execution.

[0063] In some specific embodiments, the serial number of the initialization program organization unit is m = 1, and the number of program organization units is q. In some specific embodiments, it is determined whether m is less than or equal to q. If m is less than or equal to q, it is determined whether the m-th program organization unit has not been run. In some specific embodiments, it is determined whether m is less than or equal to q. If m is greater than q, all the program organization units of the current task have been determined, and the execution of the controller program online update method ends.

[0064] In some specific embodiments, it is determined whether the m-th program organization unit has not been run. If the execution count of the program organization unit is less than the task start execution count, it is determined that the current program organization unit has not been run. In some specific embodiments, it is determined whether the m-th program organization unit has not been run. The task start execution count is zero. When the current task was executed last time, the task start execution count flipped after reaching the maximum value allowed by the count. If the execution count of the program organization unit is greater than zero, it is determined that the current program organization unit has not been run. In some specific embodiments, if the m-th program organization unit is not unrun, after the value of m is incremented by 1, it is again determined whether m is less than or equal to q.

[0065] In some specific embodiments, when it is determined that the program organization unit has not been run, the current program organization unit is run additionally. In some specific embodiments, the program organization unit is run additionally by re-calling the program organization unit running function.

[0066] Figure 4 The structural diagram of an electronic device provided by this application includes a processor and a memory. The memory stores computer instructions. When the computer instructions are executed by the processor, the processor executes the computer instructions to implement the method and refinement scheme as Figure 1 shown.

[0067] It should be understood that the above device embodiments are illustrative only, and the devices disclosed in the present invention can also be implemented in other ways. For example, the division of the above-mentioned units / modules is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.

[0068] In addition, unless otherwise specified, in each embodiment of the present invention, the functional units / modules can be integrated in one unit / module, or each unit / module can exist physically alone, or two or more units / modules can be integrated together. The above integrated unit / module can be implemented in the form of hardware or in the form of a software program module.

[0069] When the integrated unit / module is implemented in the form of hardware, the hardware can be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. Unless otherwise specified, the processor or chip can be any suitable hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, the on-chip cache, off-chip memory, and memory can be any suitable magnetic storage medium or magneto-optical storage medium, such as resistive random access memory (RRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (EDRAM), high-bandwidth memory (HBM), hybrid memory cube (HMC), etc.

[0070] When the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a memory and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned memory includes: USB flash drives, read-only memory (ROM), random access memory (RAM), external hard drives, magnetic disks, or optical discs, etc., which are various media that can store program codes.

[0071] The embodiments of this application also provide a non-transitory computer storage medium storing a computer program. When the computer program is executed by multiple processors, the processors are caused to execute the method and refinement scheme as Figure 1 shown.

[0072] The above has introduced the embodiments of the present application in detail. Specific examples are used in this text to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application. At the same time, any changes or deformations made by those skilled in the art based on the idea of the present application, within the specific implementation manner and application scope of the present application, fall within the scope of protection of the present application. In summary, the content of this specification should not be construed as a limitation to the present application.

Claims

1. A method for online updating of a controller program, where the controller program includes one or more tasks, and each task includes one or more program organization units. The method includes: Interrupting the currently executing task in response to an update signal; In the case where the update ends, determining the task in an execution interrupted state according to the running information of the controller program; Determining the unexecuted program organization units in the task in the execution interrupted state; Supplementarily executing the unexecuted program organization units; The running information includes name information and count information. The name information includes task names, and the count information includes the task start execution times and task end execution times corresponding to the task names; The determining the task in the execution interrupted state according to the running information of the controller program includes: In the case where the start execution times of any task are greater than the corresponding task end execution times, determining that the task is in the execution interrupted state; The name information further includes program organization unit names, and the count information further includes program organization unit execution times; The determining the unexecuted program organization units in the task in the execution interrupted state includes: In the case where the program organization unit execution times are less than the start execution times of the task in the execution interrupted state, determining that the program organization unit is unexecuted.

2. The method according to claim 1, characterized in that, The determining the task in the execution interrupted state according to the running information of the controller program further includes: In the case where the start execution times of any task are zero and the corresponding task end execution times are greater than zero, determining that the task is in the execution interrupted state.

3. The method according to claim 1, characterized in that The determining the unexecuted program organization units in the task in the execution interrupted state further includes: In the case where the start execution times of the task in the execution interrupted state are zero and the program organization unit execution times are greater than zero, determining that the program organization unit is unexecuted.

4. An apparatus for online updating of a controller program, including an interruption module, an interruption screening module, an unexecuted screening module, and a supplementary execution module, where: The interruption module is configured to interrupt the currently executing task in response to an update signal; The interruption screening module is configured to determine the task in the execution interrupted state according to the running information of the controller program in the case where the update ends; The unexecuted screening module is configured to determine the unexecuted program organization units in the task in the execution interrupted state; The supplementary execution module is configured to supplementarily execute the unexecuted program organization units; The running information includes name information and count information. The name information includes task names, and the count information includes the task start execution times and task end execution times corresponding to the task names; The determining the task in the execution interrupted state according to the running information of the controller program includes: In the case where the start execution times of any task are greater than the corresponding task end execution times, determining that the task is in the execution interrupted state; The name information further includes program organization unit names, and the count information further includes program organization unit execution times; The determining the unexecuted program organization units in the task in the execution interrupted state includes: In the case where the number of executions of the program organization unit is less than the number of executions at which the task in the execution interruption state starts to execute, it is determined that the program organization unit has not run.

5. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the method described in any one of claims 1-3 is implemented.

6. A computer-readable storage medium, characterized in that, It stores a computer program for electronic data exchange, wherein the computer program causes a computer to execute the method described in any one of claims 1-3.

Citation Information

Patent Citations

  • Remote dynamic upgrading method and method for embedded software of power system

    CN108196873A

  • Code update in system management mode

    CN113826072A