A non-real-time function block execution boundary evaluation method and system
By converting non-real-time function blocks into intermediate programs and constructing a control flow graph, the parameterized evaluation formula for execution boundaries is derived. This solves the problem of difficult evaluation of execution boundaries of non-real-time function blocks in industrial control systems, and achieves reasonable allocation and deterministic guarantee of system resources.
Patent Information
- Application Number
- CN202510089021.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-21
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2045-01-21
AI Technical Summary
Existing technologies make it difficult to quickly and accurately evaluate the execution boundaries of non-real-time function blocks in industrial control systems, resulting in uneven system resource usage and affecting control accuracy and determinism.
Convert non-real-time function blocks into intermediate programs, build control flow graphs, derive parameterized evaluation formulas for execution boundaries, and systematically evaluate execution boundaries through the modules of the development and operation platform to ensure that the scan cycle is set reasonably.
It achieves accurate evaluation of the execution boundaries of non-real-time function blocks, ensures the determinism and reasonable allocation of resources of industrial control systems, and avoids confusion caused by execution timeouts.
Smart Images

Figure CN119937517B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of industrial control technology, and in particular to a method and system for evaluating the execution boundary of a non-real-time function block. Background Art
[0002] Industrial control systems execute cyclically according to fixed scan cycles, offering high determinism and widespread adoption in discrete manufacturing. With the development of intelligent manufacturing, advanced information technologies such as image processing and artificial intelligence are increasingly being incorporated into control systems in the form of function blocks, which can adaptively adjust control parameters based on dynamic environments. However, these function blocks have long execution times, experience significant fluctuations, and exhibit non-real-time performance. When a system needs to simultaneously process both real-time and non-real-time function blocks, balancing their execution time and system resources presents a challenge. If a non-real-time function block consumes excessive system resources, it can impact the execution of other function blocks. If the execution time exceeds the set scan cycle, the determinism of the industrial control system will be compromised, affecting control accuracy and even damaging the object being processed. Therefore, it is necessary to assess the execution boundaries of these non-real-time function blocks and set a reasonable scan cycle based on their upper bounds.
[0003] However, due to the complexity and diversity of advanced information technologies such as image processing and artificial intelligence, their execution time is often affected by multiple factors, such as the scale of input data, algorithm efficiency, and hardware performance, making it difficult to accurately predict. In particular, when these technologies are integrated into industrial control systems in the form of functional blocks, they need to be quickly evaluated based on the system execution status. However, existing evaluation methods for IT programming languages do not support rapid analysis of OT programming languages, especially graphical programming languages. Summary of the Invention
[0004] The object of the present invention is to provide a method and system for evaluating the execution boundary of a non-real-time function block to solve the problems raised in the above background technology.
[0005] The present invention provides the following technical solution: a method for evaluating the execution boundary of a non-real-time function block, comprising the following steps:
[0006] Step S1: converting the non-real-time function block into an intermediate program;
[0007] Preferably, the conversion route includes direct conversion and indirect conversion, wherein ST, SFC and LD can be directly converted to IL, while FBD needs to be converted to LD first and then to IL.
[0008] Step S2: construct a control flow graph based on the intermediate program;
[0009] Preferably, constructing a control flow graph according to the intermediate program includes:
[0010] S201: Divide the intermediate program into several basic execution units;
[0011] The basic execution unit of the intermediate program is a maximum continuous instruction sequence that meets the division rule;
[0012] The division rules at least include:
[0013] Rule R1: The basic execution unit does not contain jump instructions;
[0014] Rule R2: The target of the jump instruction is the starting instruction of the basic execution unit;
[0015] Rule R3: The subsequent instruction of the jump instruction is the starting instruction of the basic execution unit;
[0016] Rule R4: Merge two consecutive basic execution units without violating Rule R2.
[0017] S202: Generate a control flow graph with basic execution units as nodes and control flows as edges.
[0018] Step S3: deriving the execution boundary parameterization evaluation formula;
[0019] Preferably, the derivation and execution boundary parameterization evaluation formula comprises the following steps:
[0020] S301: Analyze the execution time ω required by the basic execution unit in combination with the processor information of the operating platform;
[0021] S302: Convert the control flow graph into a control flow tree;
[0022] S303: recursively analyzing all nodes of the control flow tree, and obtaining a non-real-time function block execution boundary evaluation formula through calculation of the operation operator of the node execution boundary.
[0023] Step S4: Substitute the input pin value of the non-real-time function block into the evaluation formula to obtain the evaluation result.
[0024] Preferably, it includes repeated execution in the development platform and the operation platform. In the development platform, step S4 is executed multiple times to obtain the maximum execution boundary under common input pin values as the set scan cycle. In the operation platform, step S4 is executed each time before executing the non-real-time function block to evaluate the execution boundary.
[0025] The present invention provides a non-real-time function block execution boundary assessment system, comprising the following functional modules: an import module, an analysis module, an export module, a download module of a development platform, and an assessment module and an execution module of an operation platform;
[0026] The import module is responsible for importing various non-real-time function blocks;
[0027] The analysis module is used to analyze the internal control flow and operation platform of the imported non-real-time function block and provide an execution boundary evaluation formula;
[0028] The export module is used to further simplify the evaluation formula and generate the corresponding evaluation program segment;
[0029] The download module is used to package and download the non-real-time function blocks and evaluation program segments to the operation platform;
[0030] The evaluation module is used to obtain the input pin value of the non-real-time function block during execution and run the evaluation program segment to obtain the execution boundary of the function block;
[0031] The execution module is used to respond according to the evaluation result and execute the non-real-time function block only when the given scan cycle is not exceeded.
[0032] Compared with the prior art, the beneficial effects achieved by the present invention are as follows: the present invention converts non-real-time function blocks into intermediate programs, constructs a control flow graph based on the intermediate programs; derives an execution boundary parameterized evaluation formula; and brings the input pin values of the non-real-time function blocks into the evaluation formula to obtain an evaluation result. Based on this method, a system is designed that includes an import module, an analysis module, an export module, and a download module on the development platform side, and an evaluation module and an execution module on the operation platform side. By adopting the technical solution of the present invention, the execution boundary of the non-real-time function block can be evaluated, thereby providing a basis for setting the scan cycle and ensuring the certainty of the execution of the industrial control system. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention and do not constitute a limitation of the present invention.
[0034] In the attached figure:
[0035] Figure 1 A schematic diagram illustrating the effect of a non-real-time function block execution boundary assessment method provided by an embodiment of the present invention;
[0036] Figure 2 A flowchart of a method for evaluating execution boundaries of non-real-time function blocks provided by an embodiment of the present invention;
[0037] Figure 3 A schematic diagram of a conversion route for converting a non-real-time function block into an intermediate program according to an embodiment of the present invention;
[0038] Figure 4 An example of converting a non-real-time function block provided in an embodiment of the present invention into an intermediate program;
[0039] Figure 5 An example of derivation of a parameterized evaluation formula for execution boundaries provided in an embodiment of the present invention;
[0040] Figure 6 A schematic diagram of the module composition of a system for implementing a non-real-time function block execution boundary assessment method provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0041] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0042] This embodiment combines Figure 1 , Figure 1 This is a schematic diagram of the effect of implementing a non-real-time function block execution boundary evaluation method provided by an embodiment of the present invention. For example, the execution object of this embodiment is any non-real-time function block developed in a programming language that complies with the IEC 61131-3 standard specification. The evaluation method provided by this embodiment can automatically generate an execution boundary evaluation program segment for it under a given platform. The program segment returns the upper bound of the execution time required for different input pin values of the non-real-time function block.
[0043] This embodiment further combines Figure 2 , Figure 2 The flowchart of the method for evaluating the execution boundary of a non-real-time function block provided by an embodiment of the present invention includes the following steps:
[0044] Step S1: converting the non-real-time function block into an intermediate program;
[0045] For example, IL is an assembly-like language that can better reflect the execution logic of the underlying hardware of the industrial control system program and is supported by most industrial control system manufacturers. Considering the versatility and accuracy of the evaluation method, it is preferred that the intermediate program used to evaluate the execution boundary use IL language;
[0046] Preferably, in a specific implementation, Figure 3 , Figure 3 A schematic diagram of a conversion route for converting a non-real-time function block into an intermediate program provided in an embodiment of the present invention. The conversion route includes direct conversion and indirect conversion. ST, SFC, and LD can be directly converted to IL, while FBD needs to be converted to LD first and then to IL.
[0047] Specifically, ST is a text language and can be directly converted to IL by referring to the compiler of existing text languages; SFC, LD and FBD are all graphical languages, and conversion strategies need to be formulated according to the graphical logic. Among them, the graphical logic of SFC includes steps, transfers and jumps, which can be directly converted through rule mapping; the graphical logic of LD includes contacts, coils, functions and connections, and the series and parallel relationships between elements are intertwined. The program needs to be abstracted into a series-parallel unilateral directed graph first, and then the series-parallel unilateral directed graph is converted into a binary decomposition tree through the series reduction and parallel reduction operations, and finally the conversion is completed according to the reduction rules; the graphical logic of FBD is similar to LD, and the AOV diagram corresponding to FBD can be adjusted and converted into an AOV diagram with LD characteristics, and finally converted to IL.
[0048] Step S2: construct a control flow graph based on the intermediate program;
[0049] Exemplarily, the method further comprises the following steps:
[0050] S201: Divide the intermediate program into several basic execution units;
[0051] In this embodiment, the basic execution unit of the intermediate program is a maximum continuous instruction sequence that meets the division rules, where the division rules include at least:
[0052] Rule R1: The basic execution unit does not contain jump instructions;
[0053] Rule R2: The target of the jump instruction is the starting instruction of the basic execution unit;
[0054] Rule R3: The subsequent instruction of the jump instruction is the starting instruction of the basic execution unit;
[0055] Rule R4: Merge two consecutive basic execution units without violating Rule R2.
[0056] S202: Generate a control flow graph with basic execution units as nodes and control flows as edges;
[0057] In this embodiment, the program logic and feasible paths within the non-real-time function block can be intuitively displayed through the control flow graph.
[0058] Step S3: deriving the execution boundary parameterization evaluation formula;
[0059] In this embodiment, the following steps are also included:
[0060] S301: Analyze the execution time ω required for a basic execution unit based on processor information of the operating platform; the processor information includes at least performance indicators such as instruction set architecture, main frequency, number of instructions per clock cycle, number of floating-point operations per second, and cache hit, pipeline, branch prediction, etc.; in particular, the execution time ω is a sorted non-increasing sequence, representing the time required to continuously execute the same basic execution unit;
[0061] For example, before deriving the evaluation formula, it is necessary to model the processor of the operating platform, where the processor instruction set architecture determines the mapping relationship of IL instructions, the processor performance index determines the time required to execute a single instruction, and the processor behavior affects the time required to execute multiple consecutive instructions;
[0062] Furthermore, the execution time ω=[5,5,3,1] means that the first execution of the basic execution unit requires ω[1]=5 units of time, and the second execution still requires ω[2]=5 units of time, which is reduced to ω[3]=3 units of time when executed for the third time, and only ω[≥4]=1 unit of time each time when executed for the fourth time or more times.
[0063] S302: Convert the control flow graph into a control flow tree; wherein the control flow tree includes four types of nodes: leaf, sequence, branch and loop, wherein the leaf node has no child nodes and corresponds to a basic execution unit; all subtrees of the sequence node Sep(T1, T2...) are executed from left to right in sequence; of all subtrees of the branch node Alt(C1→T1, C2→T2...), only one is executed according to the execution condition; the left subtree L of the loop node Loop(L,M,R) is executed cyclically, at most m times, and the right subtree R is executed once before exiting the loop.
[0064] S303: Recursively analyze all nodes of the control flow tree, and obtain a non-real-time function block execution boundary evaluation formula through calculation of the node execution boundary operation operator, wherein the operation operator includes at least:
[0065] Accumulation: ω=ω1+ω2, ω[i]=ω1[i]+ω2[i];
[0066] For example, ω1 = [1, 2, 3], ω2 = [4, 5, 6], then ω = ω1 + ω2 = [5, 7, 9];
[0067] condition: Where c is the condition in the branch node Alt (C1→T1, C2→T2…);
[0068] Cycle: ω n =∑ω[i],
[0069] In this embodiment, combined with Figure 4 and Figure 5 , Figure 4 The example of converting a non-real-time function block into an intermediate program provided in the embodiment of the present invention is taken as an example. A simple internal program segment of a non-real-time function block is used as an example. The code segment is developed in ST language and includes a conditional branch and a loop. After being converted into an IL instruction sequence, it is divided into five basic execution units B1, B2, B3, B4 and B5 according to the division rule. Then, as shown in FIG. Figure 5 As shown, Figure 5 An example of derivation of the execution boundary parameterized evaluation formula provided for an embodiment of the present invention is provided. A control flow graph is constructed with these basic execution units as nodes and control flows as edges. The control flow graph is then converted into a control flow tree with 2 sequential nodes, 1 branch node, 1 loop node and 6 leaf nodes, where the maximum number of loops of the loop node is the input pin n. Finally, the control flow tree is iterated to obtain the execution boundary evaluation formula of the non-real-time function block based on the mapping relationship between the node type and the operation operator.
[0070] Step S4: Substitute the input pin value of the non-real-time function block into the evaluation formula to obtain the evaluation result;
[0071] In this embodiment, for a given operating platform, steps S1-S3 only need to be executed once in the development platform, while step S4 can be repeatedly executed in both the development platform and the operating platform. For example, in the development platform, step S4 is executed multiple times to obtain the maximum execution boundary under common input pin values as the set scan cycle; in the operating platform, step S4 is executed each time before executing a non-real-time function block to evaluate the execution boundary to avoid execution timeout causing execution chaos in the industrial control system.
[0072] The embodiment of the present invention is combined with Figure 6 , Figure 6A schematic diagram of the module composition of a system for implementing a method for evaluating the execution boundary of a non-real-time function block provided in an embodiment of the present invention is provided, that is, this embodiment provides the following technical solutions: a non-real-time function block execution boundary evaluation system, comprising an import module 201, an analysis module 202, an export module 203, and a download module 204 of a development platform, and an evaluation module 205 and an execution module 206 of an operation platform; wherein the import module 201 is responsible for importing various types of non-real-time function blocks, which are saved in the form of XML files; the analysis module 202 analyzes the internal control flow and the operation platform of the imported non-real-time function blocks and provides an execution boundary evaluation formula; the export module 203 further simplifies the evaluation formula and generates a corresponding evaluation program segment; the download module 204 is responsible for packaging and downloading the non-real-time function block and its evaluation program segment to the operation platform; the evaluation module 205 obtains the input pin value of the non-real-time function block during execution and runs the evaluation program segment to obtain the execution boundary of the function block; the execution module 206 responds according to the evaluation result and executes the non-real-time function block only when it does not exceed a given scan cycle.
[0073] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus.
[0074] Finally, it should be noted that the above descriptions are merely preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art will be able to modify the technical solutions described in the aforementioned embodiments or substitute equivalents for some of the technical features. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention.
Claims
1. A method for evaluating execution boundaries of non-real-time function blocks, characterized by: The following steps are involved: Step S1: converting the non-real-time function block into an intermediate program; Step S2: construct a control flow graph based on the intermediate program; The constructing of a control flow graph based on the intermediate program includes: dividing the intermediate program into a plurality of basic execution units; the basic execution unit of the intermediate program is a maximum continuous instruction sequence that satisfies a division rule; generating a control flow graph with the basic execution units as nodes and the control flows as edges; Step S3: deriving the execution boundary parameterization evaluation formula; The derivation of the execution boundary parameterized evaluation formula includes the following steps: S301: Analyze the execution time required by the basic execution unit based on the processor information of the operating platform ; S302: Convert the control flow graph into a control flow tree; S303: recursively analyzing all nodes of the control flow tree, and obtaining a non-real-time function block execution boundary evaluation formula through calculation of the operation operator of the node execution boundary; Step S4: Substitute the value of the input pin of the non-real-time function block into the evaluation formula to obtain the evaluation result; respond according to the evaluation result, and execute the non-real-time function block only when it does not exceed the given scan cycle.
2. The method for evaluating the execution boundary of a non-real-time function block according to claim 1, wherein: The conversion route for converting the non-real-time function block includes direct conversion and indirect conversion.
3. The method for evaluating the execution boundary of a non-real-time function block according to claim 2, wherein: The division rules at least include: Rule R1: The basic execution unit does not contain jump instructions; Rule R2: The target of the jump instruction is the starting instruction of the basic execution unit; Rule R3: The subsequent instruction of the jump instruction is the starting instruction of the basic execution unit; Rule R4: Merge two consecutive basic execution units without violating Rule R2.
4. The method for evaluating the execution boundary of a non-real-time function block according to claim 3, wherein: The processor information in S301 includes at least the instruction set architecture, main frequency, number of instructions per clock cycle, performance indicators of floating-point operations per second, cache hit, pipeline, and branch prediction behavior. The processor of the operating platform is modeled before deriving the evaluation formula; The execution time It is a sorted non-increasing sequence that represents the time required to execute the same basic execution unit continuously.
5. The method for evaluating the execution boundary of a non-real-time function block according to claim 4, wherein: In S302, the control flow tree includes four types of nodes: leaf, sequence, branch and loop, wherein the leaf node has no child nodes and corresponds to a basic execution unit; the sequence node All subtrees of are executed from left to right; branch nodes ) of all subtrees according to the execution condition, only one is executed; loop node The left subtree L is executed in a loop at most M times, and the right subtree R is executed once before exiting the loop.
6. The method for evaluating the execution boundary of a non-real-time function block according to claim 5, wherein: The step S4 includes repeated execution in the development platform and the operation platform. In the development platform, step S4 is executed multiple times to obtain the maximum execution boundary under common input pin values as the set scan cycle. In the operation platform, it is evaluated whether the execution boundary exceeds the set scan cycle.
7. The method for evaluating the execution boundary of a non-real-time function block according to claim 1, wherein: The method is applied to a non-real-time function block execution boundary assessment system, which includes the following functional modules: an import module, an analysis module, an export module, a download module of a development platform, and an assessment module and an execution module of a running platform; The import module is responsible for importing various non-real-time function blocks; The analysis module is used to analyze the internal control flow and operation platform of the imported non-real-time function block and provide an execution boundary evaluation formula; The export module is used to further simplify the evaluation formula and generate the corresponding evaluation program segment; The download module is used to package and download the non-real-time function blocks and evaluation program segments to the operation platform; The evaluation module is used to obtain the input pin value of the non-real-time function block during execution and run the evaluation program segment to obtain the execution boundary of the function block; The execution module is used to respond according to the evaluation result and execute the non-real-time function block only when the given scan cycle is not exceeded.
Citation Information
Patent Citations
Circulation boundary inward direction analysis method of real-time system
CN104317572A
System, method and device for automatically generating program according to function block diagram
CN110147226A