Multi-script execution method for a virtual controller

By designing script structure, graph model structure and graph node structure in the virtual controller, converting script data into directed acyclic graphs, and using FIFO algorithm and ignition rules to schedule and interpret script objects, the problem of execution of multiple virtual controllers in the virtual production line is solved, and efficient and reliable multi-script execution is achieved.

CN119356817BActive Publication Date: 2025-06-10GUANGDONG UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411459142.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-18
Publication Date
2025-06-10
Estimated Expiration
2044-10-18

AI Technical Summary

Technical Problem

The prior art is difficult to effectively support the execution of multiple virtual controllers in the virtual production line, resulting in increased development workload and inconsistent script management.

Method used

A multi-script execution method for virtual controllers is proposed. By setting script structure, graph model structure and graph node structure, script data is converted into directed acyclic graph, and FIFO algorithm and ignition rules are used to schedule and interpret script objects.

Benefits of technology

It improves the reliability of the virtual production line, reduces the cost of using the platform, supports programming languages ​​for multiple device controllers, adapts to multiple control script types, and improves execution efficiency and resource usage optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119356817B_ABST
    Figure CN119356817B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of script execution, and proposes a multi-script execution method for a virtual controller. The multi-script execution method includes: setting a script structure, a graph model structure, and a graph node structure; performing syntax and semantic checks on the script data to be executed, converting the script data into a script object according to the script structure, converting the script data into a directed acyclic graph according to the graph model structure, and traversing the directed acyclic graph to obtain the execution sequence of the graph in each level of the directed acyclic graph; scheduling the script objects according to the FIFO algorithm, and traversing the directed acyclic graph during scheduling to obtain the graph nodes in each execution sequence, and interpreting and executing the script objects according to the firing rules and the graph nodes in each execution sequence. The purpose of the present invention is to parse and execute multiple scripts, further improve the reliability of the virtual production line and reduce the usage cost of the platform.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of script execution, in particular to a multi-script execution method for a virtual controller. Background Art

[0002] Control scripts can be written in two ways: text and graphical. The programming languages ​​used are diverse, including general high-level languages ​​such as Java, C++, and C#, as well as languages ​​dedicated to physical device controllers and custom languages ​​for simulation platforms. Language diversity brings two challenges: first, users need to master different programming languages, which increases learning costs; second, the selected language must meet the specific requirements of the model because different languages ​​differ in function and applicability.

[0003] For production line simulation platforms, it is particularly important to speed up the process of building virtual production lines while simulating real production lines as much as possible. This is especially important for companies that frequently change production lines. However, there are multiple controllers in real production lines that need to execute different control programs. If the simulation platform also needs to support multiple virtual controllers, it will inevitably increase the development workload and is not conducive to the unified management of scripts.

[0004] Therefore, it is particularly necessary to study general virtual controller technology and design a unified intermediate execution structure of scripts and a unified interactive environment of models in virtual controllers. Summary of the invention

[0005] In view of the above-mentioned defects, the purpose of the present invention is to propose a multi-script execution method for a virtual controller, aiming to parse and execute multiple scripts, further improve the reliability of the virtual production line and reduce the cost of using the platform.

[0006] To achieve this object, the present invention adopts the following technical solutions:

[0007] A multi-script execution method for a virtual controller, the multi-script execution method comprising:

[0008] Set the script structure, graph model structure and graph node structure, where the graph model structure includes a main graph and several levels of sub-graphs, the main graph and sub-graphs include multiple graph nodes, each graph node structure includes information required for storing the corresponding script instruction interpretation and execution and the ignition rule for determining whether the graph node can be executed, and the script structure includes graph model structure information;

[0009] Performing a syntax and semantic check on the script data to be executed, converting the script data into a script object according to the script structure, converting the script data into a directed acyclic graph according to the graph model structure, and traversing the directed acyclic graph to obtain an execution sequence of the graph at each level of the directed acyclic graph;

[0010] Schedule the script object according to the FIFO algorithm. When scheduling, traverse the directed acyclic graph to obtain the graph nodes in each execution sequence, and interpret and execute the script object according to the ignition rule and the graph nodes in each execution sequence.

[0011] Preferably, the directed acyclic graph is stored by the cross linked list method, and any level of the directed acyclic graph satisfies the relational expression:

[0012] g = <id, N, E, ES, ptr>;

[0013] Wherein, g represents any level of the directed acyclic graph, id represents the graph identifier, N represents the graph node set, E represents the connection edge set, ES represents the execution sequence of the graph, and ptr represents the execution pointer;

[0014] A basic node N' in the graph node set N satisfies the relational expression:

[0015] N' = <id', e fi , e fo , iv, ir, d, eb, init, res>;

[0016] Wherein, id' represents the graph node identifier, e fi represents the first incoming edge, e fo represents the first outgoing edge, iv represents the ignition variable, ir represents the ignition rule, d represents the execution data, eb represents the execution behavior, init represents the initialization behavior, res represents the reset behavior, and the first incoming edge e fi and the first outgoing edge e fo are the definition methods of the graph nodes in the cross linked list method;

[0017] A connection edge E' in the connection edge set E satisfies the relational expression:

[0018] E' = <n t , n h , e nt , e nh , bti>;

[0019] Wherein, n t represents the graph node at the tail end connected by the edge, n h represents the graph node at the head end connected by the edge, e nt represents the next connection edge with the same tail node of the edge, e nj represents the next connection edge with the same head node of the edge, and bti represents the breadth time sequence information;

[0020] The graph node set N also includes a control node N'';

[0021] The control node N'' is extended from the basic node N' and includes:

[0022] The execution data d in the control node N″ consists of the control condition set CS and the graph set G cn (G cn ∈ G), and the execution behavior eb in the control node N" is set to the control rule cr of the node.

[0023] Furthermore, the sequential execution order relationships of the directed acyclic graph in different dimensions include the breadth time sequence relationship and the depth time sequence relationship;

[0024] The breadth time sequence relationship between the subgraphs is represented by the order in the graph set Gc n The control conditions in the control condition set CS correspond to the subgraphs in G cn ;

[0025] The ignition rule is configured such that if the ignition variables iv of the predecessor nodes are all true, then the ignition variable iv of the current node is set to true, and the processing function of the current node is activated to process the data of the current node. If the ignition variables iv of the predecessor nodes are not all true, then the ignition variable iv of the current node is set to false, and the processing function of the current node is not activated and cannot process the data of the current node.

[0026] Preferably, the script structure is represented by a five-tuple and satisfies the relational expression:

[0027] Script = <sn, SI, EB, VAR, G>;

[0028] where Script represents the script object, sn represents the script name, SI represents the set of script interpretation execution status identifiers, EB represents the set of executions before and after the script execution, VAR represents the set of all variables with the scope of the script, and G represents all the graphs that control the graph model after the script conversion;

[0029] The set of script interpretation execution status identifiers SI is represented by a four-tuple and satisfies the relational expression:

[0030] SI = <st, df, ce, db>;

[0031] where st represents the script status, df represents whether it is executed by default when the script execution engine starts, ce represents single execution or loop execution, and db represents whether the script is in the debugging state;

[0032] The set of executions before and after the script execution EB is represented by a four-tuple and satisfies the relational expression:

[0033] EB = <init, res′, br, ar>;

[0034] Among them, init represents the initialization behavior for factors including the configuration of the script, the graph, and variables, res′ represents the reset behavior for factors including the configuration of the script, the graph, and variables, br represents the pre-execution behavior, and ar represents the post-execution behavior.

[0035] Furthermore, a basic queue Q and a buffer queue BQ are set. The basic queue Q is used to store all script objects to be scheduled, and the buffer queue BQ is used to record all script objects to be scheduled in the next cycle.

[0036] Scheduling the script objects according to the FIFO algorithm includes:

[0037] Step A: Insert the script objects with the script state st being READY to the end of the basic queue Q, and take out the script object from the head of the basic queue Q as the current script object.

[0038] Step B: If the script state st of the current script object is READY, then execute the preset pre-execution behavior br, otherwise give up executing the preset pre-execution behavior br.

[0039] Step C: Interpret and execute the script object, and execute the preset post-execution behavior ar.

[0040] Step D: If the ce value of the script object is for loop execution, then the script state st of the current script object becomes READY, and the current script object is inserted into the buffer queue BQ. If the ce value of the script object is for single execution, then take the next script object as the current script object.

[0041] Loop and execute steps A - D. If there are no script objects in the basic queue Q, then stop looping steps A - D, and swap the basic queue Q and the buffer queue BQ. If the total time consumed for scheduling the script objects is greater than the preset execution cycle, then directly enter the scheduling of script objects in the next cycle. Otherwise, enter the sleep state. When the total time consumed plus the sleep time is equal to the preset execution cycle, enter the scheduling of script objects in the next cycle.

[0042] Furthermore, a stack S′ is set. Traversing the directed acyclic graph to obtain the execution sequence of the graph at each level of the directed acyclic graph includes:

[0043] Obtain the graph at the first level in the directed acyclic graph as the current level graph g′.

[0044] Step K: Obtain the graph node n with an in-degree of 0 in the current level graph g′ start , and insert it into the stack S′.

[0045] Step L: Loop and take out the graph node at the top of the stack S′, and inversely traverse all the direct successor nodes n of the graph node according to the breadth time sequence relationship btih , insert n into the top of stack S'. h , until stack S' is empty;

[0046] Step M: Obtain the graph of the next level in the directed acyclic graph as the current level graph g'.

[0047] Loop steps K - M until all graph nodes in the directed acyclic graph are traversed to obtain the execution sequences of the graphs in each level of the directed acyclic graph.

[0048] Preferably, set stack S and store the main graph of the directed acyclic graph into stack S.

[0049] The interpretive execution of the script object according to the ignition rule and the graph nodes in each execution sequence includes:

[0050] Step E: Set the top element of stack S as the graph to be executed cg, and sequentially obtain the corresponding graph node n in the execution sequence of the graph to be executed cg according to the execution pointer ptr.

[0051] Step F: Judge whether graph node n is executed through the ignition rule. When graph node n needs to be executed and is a control node, after executing the execution behavior eb of graph node n, insert the sub - graph of graph node n into stack S to execute the execution behavior eb of the sub - graph.

[0052] Step G: If the execution pointer ptr is empty, then the graph to be executed cg has been executed, the execution pointer ptr returns to its original position and the top element of stack S is popped.

[0053] Loop steps E, F and G until stack S is empty.

[0054] Further, with the top element of the current stack S as the head of the queue and the target graph node of the jump as the tail of the queue, a form in which several graph nodes and several levels of graphs are arranged at intervals is used as the jump path queue PQ.

[0055] The execution behavior eb includes the jump of graph node n, including:

[0056] Step X: Take out the element A' from the head of the jump path queue PQ.

[0057] Step Y: If the element A' is a graph node, then point the execution pointer ptr to the element A', and when the element A' is a control node, then execute the reset behavior res of the element A', and then read the element B' from the head of the jump path queue PQ. If the element A' is a control node connecting the element B', then take out the element B' from the jump path queue PQ and insert it into the top of stack S.

[0058] If the element A' is the graph cg to be executed in the stack S, read the element C' from the head of the jump path queue PQ. If the element C' is the control node connecting the element A', execute the reset behavior res of the element A', and jump the graph cg to be executed in the stack S to the upper level;

[0059] Repeat steps X and Y until all elements in the jump path queue PQ are taken out.

[0060] Preferably, set the instruction tree tn to satisfy the relational expression: tn = <id, t, Data, TN>;

[0061] Wherein, id represents the unique identifier of the node, t is used to determine the instruction type, Data represents the execution data according to the individual design of each instruction, and TN is used to store all the direct child nodes tn of this node in the instruction tree;

[0062] Converting the script data into a directed acyclic graph according to the graph model structure includes:

[0063] Store the script data in the root node tn of the instruction tree tn root Insert the root node tn root into the instruction tree node stack S tn Create the main graph of the directed acyclic graph and insert it into the graph stack S g where S tn and S g correspond to the elements;

[0064] Obtain the top element tn tn of S 1 and the top element g g of S 1 For all child nodes tn 1 of tn cur execute steps H-I:

[0065] Step H: Create the corresponding graph node n 1 according to the information of each child node tn cur of tn new and add n new to g 1 ;

[0066] Step I: Establish the connection edge between the penultimate graph node in g 1 and n new ;

[0067] Step J: If the graph node n new is of the While type, convert the graph node n new into a control node, create a new subgraph g 2 and insert it into the graph set G. If the graph node nnew It is of the If type. Convert the graph node n new into a control node, create new subgraphs for all its child nodes and insert them into the graph set G;

[0068] When S tn is empty, the conversion ends, and the graph set G is the converted directed acyclic graph.

[0069] Preferably, when interpreting and executing the script object, it also includes the script debugger debugging the script object:

[0070] When the debug flag of the script is true, the script debugger obtains the script object;

[0071] The script debugger executes the graph nodes in the directed acyclic graph step by step;

[0072] When the debug flag of the script is false, resume interpreting and executing the script object, and the script debugger stops executing the graph nodes in the directed acyclic graph.

[0073] One of the above technical solutions has the following advantages or beneficial effects:

[0074] By setting the script structure, graph model structure, and graph node structure, the present invention determines the existence form after script conversion, provides the basic implementation of the script, graph, and graph node; by performing syntax and semantic checks on the script data to be executed, it ensures that the input script conforms to the lexical and grammatical rules of the script language, and converts the script data into a directed acyclic graph, which can clearly represent the dependency relationships and execution order in the script, making it intuitive and easy to understand to handle complex control logics, being able to support the programming languages of multiple device controllers, adapting to multiple control script types, improving the compatibility and scalability of the platform, traversing the directed acyclic graph to obtain the execution sequence at each level, which can conveniently obtain the order of script execution, thereby improving the execution efficiency; the FIFO scheduling algorithm can ensure that script objects are processed in the order of first come, first served, avoiding resource competition and conflicts caused by concurrent execution; by using the firing rule during the scheduling process to interpret and execute the graph nodes in each execution sequence, it can effectively improve the execution efficiency. When executing the script, it can ensure that all dependent nodes have been executed before being called, avoiding errors caused by missing dependencies. The firing rule can ensure that the execution of nodes is triggered only when the conditions are met, thereby optimizing the use of resources. Description of the Drawings

[0075] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on the provided drawings.

[0076] Figure 1 It is a flowchart of the multi-script execution method of the virtual controller provided by the embodiment of the present invention;

[0077] Figure 2 It is the first example diagram of the breadth timing relationship of the multi-script execution method of the virtual controller provided by the embodiment of the present invention;

[0078] Figure 3 It is a schematic diagram of the timing multi-level directed acyclic graph structure of the multi-script execution method of the virtual controller provided by the embodiment of the present invention;

[0079] Figure 4 It is the second example diagram of the breadth timing relationship of the multi-script execution method of the virtual controller provided by the embodiment of the present invention;

[0080] Figure 5 It is an example diagram of the depth timing relationship of the multi-script execution method of the virtual controller provided by the embodiment of the present invention;

[0081] Figure 6 It is an example diagram of the timing relationship conflict under different dimensions of the multi-script execution method of the virtual controller provided by the embodiment of the present invention;

[0082] Figure 7 It is a flowchart of the data stream ignition judgment of the multi-script execution method of the virtual controller provided by the embodiment of the present invention;

[0083] Figure 8 It is the script scheduling process of the multi-script execution method of the virtual controller provided by the embodiment of the present invention;

[0084] Figure 9 It is the first example diagram of the depth-first topological sorting algorithm based on timing of the multi-script execution method of the virtual controller provided by the embodiment of the present invention;

[0085] Figure 10 It is the second example diagram of the depth-first topological sorting algorithm based on timing of the multi-script execution method of the virtual controller provided by the embodiment of the present invention;

[0086] Figure 11 It is a schematic diagram of the connection edge elements of the multi-script execution method of the virtual controller provided by the embodiment of the present invention;

[0087] Figure 12 It is the flowchart of the interpretation and execution of the script of the multi-script execution method of the virtual controller provided by the embodiment of the present invention;

[0088] Figure 13 It is the hierarchical relationship diagram of the script data structure of the multi-script execution method of the virtual controller provided by the embodiment of the present invention;

[0089] Figure 14 It is the flowchart of the jump mechanism of the directed acyclic graph of the multi-script execution method of the virtual controller provided by the embodiment of the present invention;

[0090] Figure 15 It is the schematic diagram of the pseudo code of the jump path search algorithm based on the post-order traversal of the multi-way tree of the multi-script execution method of the virtual controller provided by the embodiment of the present invention;

[0091] Figure 16 It is the flowchart of constructing a PDAG based on an instruction tree for the multi-script execution method of the virtual controller provided by the embodiment of the present invention;

[0092] Figure 17 It is the schematic diagram of the process of converting a robot script to a PDAG for the multi-script execution method of the virtual controller provided by the embodiment of the present invention;

[0093] Figure 18 It is the schematic diagram of the observer pattern of the multi-script execution method of the virtual controller provided by the embodiment of the present invention. Detailed implementation manners

[0094] The embodiments of the present invention will be described in detail below. Examples of the embodiments are shown in the accompanying drawings, where the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary only for explaining the present invention and should not be construed as limiting the present invention.

[0095] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "transverse", "length", "width", "thickness", "upper", "lower", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", "axial", "radial", "circumferential", etc. indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus should not be construed as limiting the present invention.

[0096] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, "plurality" means two or more.

[0097] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a direct connection, or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0098] Control scripts can be written in two ways: text and graphical. The programming languages ​​used are diverse, including general high-level languages ​​such as Java, C++, and C#, as well as languages ​​dedicated to physical device controllers and custom languages ​​for simulation platforms. Language diversity brings two challenges: first, users need to master different programming languages, which increases learning costs; second, the selected language must meet the specific requirements of the model because different languages ​​differ in function and applicability.

[0099] For production line simulation platforms, it is particularly important to speed up the process of building virtual production lines while simulating real production lines as much as possible. This is especially important for companies that frequently change production lines. However, there are multiple controllers in real production lines that need to execute different control programs. If the simulation platform also needs to support multiple virtual controllers, it will inevitably increase the development workload and is not conducive to the unified management of scripts.

[0100] The present invention provides a multi-script execution method for a virtual controller, the multi-script execution method comprising the steps of:

[0101] S1: Set the script structure, graph model structure and graph node structure, wherein the graph model structure includes a main graph and several levels of subgraphs, the main graph and the subgraphs include multiple graph nodes, each graph node structure includes the data and behavior required for storing the corresponding script instructions when interpreting and executing, and the ignition rules for judging whether the graph node can be executed, and the script structure includes graph model structure information;

[0102] S2: Performing a syntax and semantic check on the script data to be executed, converting the script data into a script object according to the script structure, converting the script data into a directed acyclic graph according to the graph model structure, and traversing the directed acyclic graph to obtain an execution sequence of the graph in each level of the directed acyclic graph;

[0103] S3: Schedule the script objects according to the FIFO algorithm. When scheduling, traverse the directed acyclic graph to obtain the graph nodes in each execution sequence, and interpret and execute the script objects according to the firing rules and the graph nodes in each execution sequence.

[0104] Among them, the virtual controller is generally a system composed of multiple modules. The virtual controller system is both a script execution engine that supports script parsing and execution and a device controller that can interact with the digital twin model. In addition, it also needs to support the writing of control scripts. In the production line of an actual factory, it is often necessary to use multiple languages to write device control programs, and the simulation platform should also be able to support the writing and execution of multiple control scripts. To achieve this goal, the virtual controller needs to be able to parse and execute multiple scripts. The multi-script execution method of a virtual controller proposed by the present invention can solve the above problems.

[0105] Specifically, in step S1, the script structure includes basic syntax elements, such as data types (such as integers, strings), control flows (such as conditional statements, loops), function calls, etc. Setting the script structure provides a standardized format, making all scripts follow the same rules, which helps to reduce errors caused by inconsistent formats during writing and execution. The definitions of the graph model structure and the graph node structure make the organization of scripts and data clearer. The graph model structure visualizes complex execution logic in the form of a graph (especially a directed acyclic graph, DAG), making different execution paths and logical relationships clearer, which helps to quickly search and manage during subsequent operations. The graph model structure can clearly show the dependency relationships between each node. Based on the set graph structure, scheduling algorithms (such as FIFO or priority scheduling) can more effectively manage the execution of scripts, ensuring reasonable allocation of resources; the graph node is the basic unit during the execution process, including the specific implementation of instructions, data storage, and execution conditions. Each node not only stores script instructions but also contains the firing rules for judging whether the instruction can be executed. The firing rules are usually some logical conditions or status checks, such as whether a variable is initialized, whether the preconditions are met, etc., which enables flexible control of the execution process and avoids incorrect execution. The relationships among the script structure, the graph model structure, and the graph node structure designed in step S1 are as Figure 13 shown.

[0106] It should be noted that when the script to be executed is input into the virtual controller, the script editor ensures that the script conforms to the lexical and partial syntax of the script language by restricting user input. However, for some syntax and semantics, it is still necessary to check the entire script data to make a judgment. Therefore, in step S2, it is necessary to perform syntax and semantics checks on the script data to be executed. The syntax check ensures that the script conforms to the predefined syntax rules. For example, if an undefined variable or a syntax error (such as missing a semicolon or mismatched parentheses) appears in the script, the parser will prompt an error and prevent further execution. The semantics check ensures the logical rationality of the script, including type checking (ensuring that variables are used in accordance with their types), scope checking (ensuring that variables are available within the appropriate scope), etc. The script data to be executed is converted into a script object according to the script structure set in step S1, that is, there is a one-to-one relationship between the script structure and the script data. The script structure set in step S1 manages both all the graphs formed after the script conversion and the state of the script, and converts the script logic into a directed acyclic graph (PDAG), which helps to represent the dependency relationships between execution nodes. Each node represents an execution unit, and the edges represent the execution order and dependency relationships to simultaneously adapt to the representation of data flow and control flow scripts. The converted directed acyclic graph (PDAG) is as Figure 3 shown.

[0107] The FIFO (First In First Out) algorithm is a simple and efficient scheduling strategy. Script objects are put into the queue in the order they arrive and are executed in sequence. The FIFO algorithm helps to ensure the fairness of tasks and is simple and easy to implement. When a script is requested to be executed, the corresponding script object is put into a FIFO queue, and the scheduler takes out the script objects in the queue in order for processing, ensuring that all script objects are scheduled in the order they are requested. The traversal starts from the starting node of the directed acyclic graph and tracks all reachable nodes in the graph. The depth-first search (DFS) or breadth-first search (BFS) algorithm can be used to traverse the directed acyclic graph to obtain all the graph nodes. During the traversal, the execution order of the nodes is recorded, and a legal execution sequence is constructed based on the dependency relationships of each graph node to ensure that each node is executed only after all the nodes it depends on have been executed. The script objects are executed according to the execution sequence. When executing a graph node, if the firing rule of the graph node is satisfied, it means that the graph node is allowed to be executed. When all graph nodes have been executed, it means that the script object has been executed.

[0108] The present invention determines the existence form after script conversion by setting the script structure, graph model structure, and graph node structure, and provides the basic implementation of scripts, graphs, and graph nodes. By performing syntax and semantic checks on the script data to be executed, it ensures that the input script conforms to the lexical and grammatical rules of the script language, and converts the script data into a directed acyclic graph, which can clearly represent the dependency relationships and execution order in the script, making it intuitive and easy to understand to handle complex control logics, being able to support the programming languages of multiple device controllers, adapting to multiple types of control scripts, improving the compatibility and scalability of the platform. By traversing the directed acyclic graph to obtain the execution sequence at each level, the execution order of the script can be conveniently obtained, thereby improving the execution efficiency. The FIFO scheduling algorithm can ensure that script objects are processed in the order of first come, first served, avoiding resource competition and conflicts caused by concurrent execution. By using the firing rule during the scheduling process to interpret and execute the graph nodes in each execution sequence, the execution efficiency can be effectively improved. When executing the script, it can ensure that all dependent nodes have been executed before being called, avoiding errors caused by missing dependencies. The firing rule can ensure that the execution of nodes is triggered only when the conditions are met, thereby optimizing the use of resources.

[0109] Preferably, the directed acyclic graph is stored by the cross linked list method, and for any level of the graph in the directed acyclic graph, the following relationship is satisfied:

[0110] g = <id, N, E, ES, ptr>;

[0111] where, g represents any level of the graph in the directed acyclic graph, id represents the graph identifier, N represents the set of graph nodes, E represents the set of connection edges, ES represents the execution sequence of the graph, and ptr represents the execution pointer;

[0112] A basic node N' in the set of graph nodes N satisfies the following relationship:

[0113] N' = <id', e fi , e fo , iv, ir, d, eb, init, res>;

[0114] where, id' represents the graph node identifier, e fi represents the first incoming edge, e fo represents the first outgoing edge, iv represents the firing variable, ir represents the firing rule, d represents the execution data, eb represents the execution behavior, init represents the initialization behavior, res represents the reset behavior, and the first incoming edge e fi and the first outgoing edge e fo are the definition methods of graph nodes in the cross linked list method;

[0115] A connection edge E' in the set of connection edges E satisfies the following relationship:

[0116] E′ = <n t , n h , e nt , e nh , bti>;

[0117] Among them, n t represents the graph node at the tail connected by the edge, n h represents the graph node at the head connected by the edge, e nt represents the next connecting edge with the same tail node of the edge, e nh represents the next connecting edge with the same head node of the edge, and bti represents the breadth timing information;

[0118] The graph node set N also includes a control node N″;

[0119] The control node N″ is expanded from the basic node N′ and includes:

[0120] The execution data d in the control node N″ is composed of the control condition set CS and the graph set G cn (G cn ∈ G), and the execution behavior eb in the control node N″ is set to the control rule cr of the node.

[0121] Specifically, the cross-linked list method is a way to store a graph. By using two pointer sets to separately maintain the connections of incoming edges and outgoing edges, it supports fast traversal. For any level of a directed acyclic graph, it can be described as a graph. The id is used to distinguish different levels of graphs to ensure that operations between different graphs will not be confused; N represents the set of all nodes in the graph at this level. Each node represents a state or an operation. The set of nodes is the core part of the graph, responsible for storing all the data and logical structures of the graph. The connecting edge set E defines the connection relationships between nodes, determines the data flow direction and operation sequence. Each edge connects two nodes, indicating that one node can transfer information or execute an operation to another node; the execution sequence ES of the graph can ensure that nodes are activated and processed in a specific order. Importantly, it can control the logical flow of task execution; the introduction of the execution pointer ptr enables the execution process of the graph to proceed efficiently and sequentially, and the movement of the pointer can guide the state change of the graph during execution.

[0122] In addition, the first incoming edge in the graph node points to the predecessor node of the node, and the first outgoing edge points to the successor node of the node. The ignition variable iv is a boolean value. When it is true, it indicates that the node is ready to be executed. The ignition rule ir can be a conditional expression that controls when the node is triggered in the execution flow to ensure that the node is processed only when specific conditions are met. The execution data d stores the core data that the graph node needs to process, which can be input parameters, status information, or intermediate results, ensuring that the node has sufficient information for processing when it is executed. The execution behavior eb describes the operations or logic that the graph node needs to execute when it is activated, which can include specific tasks such as calculations, data transmission, graph node jumps, or status updates, and is a direct manifestation of the node's function.

[0123] The graph node n at the tail connected by the connecting edge E′ t is the starting point of information transfer, indicating from which node the data starts. The graph node at the head connected by the connecting edge E′ is the node that receives the information and determines the final destination of the data, e nt points to the next edge with the same tail node as the current edge for traversal. In this way, all the edges connected to the same tail node in the graph can be easily traversed; e nh points to the next edge with the same head node as the current edge to support traversal starting from the head node. By combining the use of e nt and e nh , all the edges in the graph can be comprehensively traversed; bti records the chronological information about node execution. The breadth chronological information can help determine the execution dependency relationships between nodes to ensure that the graph follows the correct order during execution. The schematic diagram of each part element of the connecting edge is as Figure 11 shown.

[0124] The control node N″ is developed and transformed from the basic node N′. Among them, the execution data d consists of the control condition set CS and the graph set G cn (G cn ∈G). The control condition set CS contains multiple condition sets that trigger execution behaviors and is used to control the activation of the node to ensure that the execution behavior of the node can be triggered under specific circumstances. The graph set G cn can be a graph at any level of a directed acyclic graph. Through the graph set G cn , cross-graph control and information flow can be achieved; the execution behavior eb is set to the control rule cr of the node. The control rule cr describes the rule for how the control node processes the execution flow according to the input conditions. The control rule determines the operations that the node will take when it receives specific inputs to enhance the decision-making ability and flexibility of the node.

[0125] The sequential execution order relationships of the directed acyclic graph in different dimensions include breadth chronological relationships and depth chronological relationships;

[0126] The breadth-time sequence relationship between the subgraphs is represented by the order of the subgraphs in the graph set G cn and the control conditions in the control condition set CS correspond to the subgraphs in G cn ;

[0127] The ignition rule is configured such that if the ignition variables iv of the predecessor nodes are all true, then the ignition variable iv of the current node is set to true, and the processing function of the current node is activated to process the data of the current node. If the ignition variables iv of the predecessor nodes are not all true, then the ignition variable iv of the current node is set to false, and the processing function of the current node is not activated and cannot process the data of the current node.

[0128] Specifically, in a complex graph structure, a subgraph (or component) can represent a logical set of specific functions or tasks. G cn is a graph set containing multiple subgraphs. By arranging the order of the subgraphs in G cn , the control conditions in the control condition set CS correspond to these subgraphs, and the execution flow of the overall graph can be effectively managed and controlled. Figure 3 is a PDAG structure diagram with a total of four layers and three levels of subgraphs. In the figure, the subgraphs of the next level are linked by control nodes to form multiple levels, and then the depth-time sequence relationship between the front and back nodes is formed by means of node connection edges. And a breadth-time sequence relationship is formed between all the out-edges of the nodes. In addition, the directed acyclic graph converted according to the graph model structure follows the following specifications: 1. Whether it is the main graph or the subgraph, there can only be one graph node with an in-degree of zero, that is, the script represented by the graph can only have one starting point, and this node is called the starting node n start . Among them, the in-degree refers to the number of in-edges of the graph node. If there is no in-edge, the in-degree is zero, such as Figure 3 A in; 2. Whether it is the main graph or the subgraph, there can be multiple graph nodes with an out-degree of zero, that is, the script represented by the graph can have multiple end points, such as Figure 3 the I and J nodes in, and these end nodes are collectively called n end ; 3. The breadth-time sequence relationship represents the sequential execution order relationship between the direct successor nodes of a certain node. As shown in Figure 2 , nodes B, C, and D are all direct successor nodes of node A, so there is a breadth-time sequence relationship among the three. Since the sorting of node B is 1, node B is executed first among the three during the interpretation execution, and so on. As shown in Figure 4 is another case. Node E has three direct predecessor nodes, then node E participates in three segments of breadth-time sequence relationships at the same time; 4. The depth-time sequence relationship represents the sequential execution order relationship between a certain node and its direct predecessor and successor nodes. As shown in Figure 5As shown, node B is the successor node of node A, so node B should be executed after node A, and so on; 5. When there are conflicts in the temporal relationships of different dimensions, the depth temporal relationship shall prevail. For example, Figure 6 As shown, there are both breadth and depth temporal relationships between node C and node B. If node C has a higher sorting in the breadth temporal relationship, it will conflict with the depth temporal relationship. In this case, the depth temporal relationship shall prevail. It can be known that node C should be executed after nodes A and B; 6. The multi-levels of the PDAG are implemented by controlling node-linked subgraphs. If a control node links multiple subgraphs simultaneously, there will also be a breadth temporal relationship between the subgraphs. Different from the breadth temporal relationship between ordinary nodes, the breadth temporal relationship between subgraphs is only for reference. The execution order and whether to execute of the subgraphs are determined by the control conditions and control rules of the control node; 7. The PDAG is based on the data flow and is compatible with the control flow. Therefore, there is an ignition link common in the data flow during the execution of the graph nodes. For example, Figure 7 As shown is a common data flow ignition process. There is a processing function for processing data in node B. The processing function only takes effect when the activation condition is satisfied, and the activation condition needs to be comprehensively judged by combining the data passed in from the predecessor nodes A and C. Since the activation condition directly determines whether the processing function is executed, the activation condition is also called the ignition rule ir. For the sake of generality, it is decided to set a boolean-type ignition variable iv in the graph node. When iv is True, the ignition is successful and the node is executed. At the same time, the data passed between nodes is also set to iv. Therefore, what the ignition rule needs to do is to judge its own iv value according to the iv passed in from the predecessor nodes. The ignition rule ensures that only when the ignition variables of all predecessor nodes are true, the ignition variable of the current node will be set to true, which means that the processing logic of the current node depends on the completion status of all its predecessor nodes, thus establishing a strict dependency relationship. Once the ignition variable of the current node is set to true, the corresponding processing function will be called. If the ignition variable of any predecessor node is false, the ignition variable of the current node will be set to false, and the processing function of this node will not be activated, ensuring that the node is only processed under appropriate conditions, thereby maintaining the correctness and consistency of data processing.

[0129] The script structure is represented by a five-tuple and satisfies the relationship:

[0130] Script = <sn, SI, EB, VAR, G>;

[0131] Among them, Script represents the script object, sn represents the script name, SI represents the set of script interpretation execution status identifiers, EB represents the set of operations performed before and after the script execution, VAR represents the set of all variables with the scope of the script, and G represents all the graphs that control the graph model after the script transformation;

[0132] The set SI of script interpretation execution status identifiers is represented by a quadruple and satisfies the relation:

[0133] SI = <st, df, ce, db>;

[0134] Where st represents the script status, df represents whether the script is executed by default when the execution engine starts, ce represents whether it is executed once or in a loop, and db represents whether the script is in the debugging state;

[0135] The set EB of script execution before and after execution is represented by a quadruple and satisfies the relation:

[0136] EB = <init, res′, br, ar>;

[0137] Where init represents the initialization behavior for factors including the configuration, graph, and variables of the script, res′ represents the reset behavior for factors including the configuration, graph, and variables of the script, br represents the pre-execution behavior, and ar represents the post-execution behavior.

[0138] Specifically, the script status st in the set SI of script interpretation execution status identifiers can include states such as READY and Running, which can determine whether to implement the pre-execution behavior br and the post-execution behavior ar. ce can be a boolean value that determines whether the script is executed only once or in a loop. Looping execution is suitable for handling persistent tasks, such as real-time data monitoring. eb can also be a boolean value indicating whether the script is running in debug mode, so that developers can track errors and check the execution process. The set EB of script execution before and after execution includes the initialization behavior init for factors such as the configuration, graph, and variables of the script, which is executed before the script execution and is responsible for configuring the environment, initializing variables, and preparing the required resources. For example, reading the configuration file, setting up the database connection, etc.; res′ is used to reset the status and variables of the script after the script execution is completed to ensure that the next execution is not affected by the previous state; br represents specific operations that need to be performed before the script execution, such as logging, allocating resources, etc., which helps monitor and manage the running of the script; ar represents operations that need to be performed after the script execution is completed, such as releasing resources, updating the status, recording the results, etc., to ensure the stability and consistency of the system.

[0139] A basic queue Q and a buffer queue BQ are set. The basic queue Q is used to store all script objects to be scheduled, and the buffer queue BQ is used to record all script objects to be scheduled in the next cycle;

[0140] The scheduling of script objects according to the FIFO algorithm includes:

[0141] Step A: Insert the script object with the script status st being READY into the tail of the basic queue Q, and take the script object from the head of the basic queue Q as the current script object;

[0142] Step B: If the script status st of the current script object is READY, then execute the preset pre-execution behavior br, otherwise give up executing the preset pre-execution behavior br;

[0143] Step C: Interpret and execute the script object, and execute the preset post-execution behavior ar;

[0144] Step D: If the ce value of the script object is for loop execution, then the script status st of the current script object becomes READY, and insert the current script object into the buffer queue BQ. If the ce value of the script object is for single execution, then take the next script object as the current script object;

[0145] Loop and execute Steps A - D. If there is no script object in the basic queue Q, then stop looping Steps A - D, and swap the basic queue Q and the buffer queue BQ. If the total time taken for scheduling the script object is greater than the preset execution period, then directly enter the script object scheduling for the next cycle. Otherwise, enter the sleep state. When the total time taken plus the sleep time is equal to the preset execution period, enter the script object scheduling for the next cycle.

[0146] Specifically, as Figure 8 shown, it is the process of script scheduling. The setting of the buffer queue BQ is based on the need for periodic loop execution. At the beginning of the scheduling process, all Scripts in the READY state will be inserted into the tail of the Q queue according to the script status st, and then the script object Script will be taken out from the head in sequence for processing. Before processing, it is still necessary to judge st, st CsFor the st of the current script, the Script in the READY state is executed for the first time, indicating that the script is scheduled for the first time. Therefore, the preset pre-execution behavior (br) needs to be executed to ensure that each script can complete the necessary initialization operations during the first execution. The Script in the RUNNING state is resumed, indicating that the script has been executed in the previous cycle and can directly skip the pre-execution behavior to improve the execution efficiency. Then, the common part is the interpretive execution of the Script. After the execution is completed, the preset post-execution behavior ar needs to be executed, and it is determined whether the Script continues to execute or sleeps according to the loop execution identifier ce. After there are no elements in Q, it indicates the end of this round of execution. By setting a fixed execution period (such as 20 ms), the scheduling and execution of the script are managed. The difference between the calculated execution total time and the 20-ms execution period is used as the thread sleep time. If the execution total time has exceeded 20 ms, there is no need to sleep and directly enter the next round of execution. It should be added that during the scheduling process, there may be Scripts in the sleep state that are activated. At this time, the Script should be inserted into the end of the Q queue and the st should be modified to READY. By calculating the execution total time and comparing it with the preset period, it is determined whether to sleep to optimize the use of system resources. During the scheduling process, there may be scripts in the sleep state that are activated by external events. In this case, it is allowed to insert them at the end of the queue and update their status to READY, increasing the flexibility of the system and enabling the virtual controller to adapt to the dynamically changing environment.

[0147] Preferably, a stack S′ is set. The process of traversing the directed acyclic graph to obtain the execution sequence of the graphs in each level of the directed acyclic graph includes:

[0148] Obtain the graph in the first level of the directed acyclic graph as the current level graph g′;

[0149] Step K: Obtain the graph node n with an in-degree of 0 in the current level graph g′ start , and insert it into the stack S′;

[0150] Step L: Loop to take out the graph node at the top of the stack S′, and reverse-traverse all the direct successor nodes n of the graph node according to the breadth time sequence relationship bti h , insert n into the top of the stack S′ h , until the stack S′ is empty;

[0151] Step M: Obtain the graph in the next level of the directed acyclic graph as the current level graph g′;

[0152] Loop steps K - M until all the graph nodes in the directed acyclic graph are traversed to obtain the execution sequence of the graphs in each level of the directed acyclic graph.

[0153] Specifically, in order to completely obtain the execution sequence of the graphs at each level of the directed acyclic graph, the present invention uses a time-based depth-first topological sorting algorithm. First, it is necessary to traverse the levels of the directed acyclic graph and generate the execution sequence of the graphs at each level. Specifically, among the nodes at the same level of the execution sequence, all dependency relationships have been satisfied, and the nodes can be executed in parallel. The dependencies between levels are ordered, that is, the nodes in the upper level are executed first, and then the nodes in the lower level. First, we obtain the first level of the directed acyclic graph. The nodes in the first level are all graph nodes n with an in-degree of 0 start , an in-degree of 0 means that these nodes have no prior dependencies and can start execution directly. In step K, in the current level graph g′, find all nodes with an in-degree of 0. These nodes have no prior tasks and are the first nodes to be executed, so put them into the stack S′. In step L, the stack S′ is a last-in-first-out data structure, which means that the node at the top of the stack is the last node to be accessed. Each time a graph node is popped from the top of the stack and its successor nodes are processed. Therefore, when traversing the successor nodes in reverse order, the execution of the successor nodes depends on the completion of the current node. Therefore, the direct successor nodes of the node at the top of the stack can only be processed after the graph node at the top of S′ is processed. The purpose of traversing the successor nodes in reverse order is to ensure that the execution order of the successor nodes n h conforms to the topological order and satisfies the dependency relationship. Whenever a graph node is traversed, we record it in the execution sequence and continue to push its successor nodes (in reverse order) onto the stack in turn to ensure that they will be processed at the correct time sequence. Subsequently, in step M, continue to obtain the graph of the next level as the current level graph g′. By repeating steps K-M until all nodes at all levels are processed, ensure that the nodes at each level of the graph are executed in topological order. In this algorithm, the topological order guarantees the dependency relationship. All predecessor nodes (nodes that depend on it) of each node will be executed first before its successor nodes can be processed. The stack S′ ensures that the node we process each time is the topmost node of the current level, and all its dependency relationships (predecessor nodes) have been processed. The execution sequence obtained according to this idea is correct. Therefore, the executed steps K-M are the time-based depth-first topological sorting algorithm, and its implementation process is as Figure 9 and Figure 10 shown. Using the stack structure and the reverse traversal mechanism, it realizes the hierarchical traversal of the directed acyclic graph and can output the execution sequence of each level, following the basic principle of topological sorting to ensure that the execution order of tasks conforms to the dependency relationship. This algorithm can be applied to practical scenarios such as task scheduling and course arrangement to ensure that each task is executed in a reasonable order

[0154] Preferably, set the stack S and deposit the main graph of the directed acyclic graph into the stack S

[0155] Interpretively executing the script object according to the ignition rule and the graph nodes in each execution sequence includes:

[0156] Step E: Set the top element of the stack S as the graph cg to be executed, and sequentially obtain the corresponding graph node n in the execution sequence of the graph cg to be executed according to the execution pointer ptr;

[0157] Step F: Determine whether the graph node n is to be executed through the ignition rule. When the graph node n needs to be executed and is a control node, after executing the execution behavior eb of the graph node n, insert the sub-graph of the graph node n into the stack S to execute the execution behavior eb of the sub-graph;

[0158] Step G: If the execution pointer ptr is empty, the graph cg to be executed is completed, the execution pointer ptr returns to its original position and the top element of the stack S is popped;

[0159] Loop through steps E, F, and G until the stack S is empty.

[0160] Specifically, as Figure 13 shown, first create a stack S, deposit the main graph of the directed acyclic graph into the stack S, pop the top element from the stack S, and regard it as the graph cg to be executed, that is, the graph cg to be executed for the first time is the main graph of the directed acyclic graph. The execution sequence of the directed acyclic graph has been obtained in the previous steps. The execution pointer ptr of the graph cg to be executed points to the first node in the graph to be executed. The execution pointer ptr sequentially obtains the graph node n of the execution sequence corresponding to the graph cg to be executed. First execute the ignition rule ir of n, and then determine whether n is to be executed according to the ignition variable iv. When the graph node n needs to be executed, the execution behavior eb of the graph node n is implemented. At the same time, when the graph node n is a control node, the sub-graph of the graph node n is inserted into the stack S to execute the execution behavior eb of the sub-graph. After executing the current graph node n, move the execution pointer ptr to the top of the stack S and pop the graph that has been executed. Repeat steps E, F, and G until the stack is empty. Combining Figure 8 it can be seen that the interpretive execution of the script object is carried out during script scheduling to ensure the accurate execution of the script.

[0161] Preferably, with the top element of the current stack S as the queue head and the target graph node of the jump as the queue tail, the form of arranging several graph nodes and several levels of graphs at intervals is used as the jump path queue PQ;

[0162] The execution behavior eb includes the jump of the graph node n, including:

[0163] Step X: Take out the element A′ from the head of the jump path queue PQ;

[0164] Step Y: If the element A′ is a graph node, then set the execution pointer ptr to point to the element A′. And when the element A′ is a control node, then execute the reset behavior res of the element A′, and then read the element B′ from the head of the jump path queue PQ. If the element A′ is a control node connecting the element B′, then remove the element B′ from the jump path queue PQ and insert it at the top of the stack S.

[0165] If the element A′ is an executable graph cg in the stack S, read the element C′ from the head of the jump path queue PQ. If the element C′ is a control node connecting the element A′, then execute the reset behavior res of the element A′, and jump the executable graph cg in the stack S to the upper level.

[0166] Repeat steps X and Y until all elements in the jump path queue PQ are taken out.

[0167] During the execution of the graph node, the execution behavior eb may include the jump of the graph node. An example of the jump is as Figure 14 shown. Specifically, in step X, take out the element A′ from the head of the jump path queue PQ, and extract that A′ can obtain the currently executed graph node or control node for subsequent processing to ensure that the elements in the queue are accessed and operated in a predetermined order. Determine whether A is a graph node or the graph cg at the top of the stack S. If A is a graph node, then set the pointer ptr to point to A. If A is still a control node cn, then the reset behavior function res needs to be called to eliminate the influence caused by the non-callback of cn. At the same time, when the PQ element is not zero, read the element B. At this time, if A is a cn connecting B, it means that a jump to the sub-graph of cn is required. If A is the current graph cg, then take out the element C from the PQ. At this time, if C is a cn connecting A, it means that a jump to the upper-level graph of the graph cg is required. When the PQ element is zero, it means that the jump is over, and the script can be continued according to S.

[0168] In addition, the present invention also designs a jump path search algorithm based on the post-order traversal of a multi-way tree to obtain PQ, as Figure 15 shown. Figure 15Pseudocode implementation in recursive form for the algorithm. The input of the algorithm is the current node cur, the starting node start, the ending node end, and the result queue RQ as a global variable. The output, i.e., the return value, is the queue TQ. Queues AQ and BQ are defined as temporary variables. According to the idea of post-order traversal, the algorithm will first classify and process all child nodes under the cur node, and then process the cur node according to the situation where AQ and BQ are not empty. Among them, when both AQ and BQ are not empty, it means that a path is found. In addition, the custom function forN is used to traverse the graph node set N, and during the process, recur(n, start, end) is recursively called, and then the non-empty return value is assigned to the empty AQ or BQ; the function equal is used to determine whether cur is equal to start or end. If so, a queue is created and cur is inserted, and then the queue is returned; the function forG is similar to the function forN, but traverses the graph set G; the function merge is used to merge AQ and BQ, and the elements of the queue without start are taken from the end and inserted into the other queue in turn. If cur is not in the original queue, it needs to be inserted first; the function insert is used to determine whether there is a non-empty one in AQ or BQ. If both are empty, null is returned. If there is one, it is determined whether it contains cur. If not, cur is inserted, and then the queue TQ is returned.

[0169] Preferably, an instruction tree tn is set, satisfying the relational expression: tn = <id, t, Data, TN>;

[0170] Among them, id represents the unique identifier of the node, t is used to determine the instruction type, Data represents the execution data designed separately according to each instruction, and TN is used to store all direct child nodes tn of this node in the instruction tree;

[0171] Converting the script data into a directed acyclic graph according to the graph model structure includes:

[0172] Storing the script data into the root node tn of the instruction tree tn root in, and inserting the root node tn root into the instruction tree node stack S tn in, creating the main graph of the directed acyclic graph and inserting it into the graph stack S g in, where S tn and S g correspond to the elements in;

[0173] Obtain the top element tn tn of S 1 and the top element g g of S 1 , and perform steps H-I on all child nodes tn 1 of tn cur :

[0174] Step H: According to tn1 each child node tn cur create a corresponding graph node n according to the information of new and add n new to g 1 ;

[0175] Step I: Establish the connection edge between the penultimate graph node in g 1 and n new ;

[0176] Step J: If the graph node n new is of the While type, convert the graph node n new into a control node, create a new sub - graph g 2 and insert it into the graph set G. If the graph node n new is of the If type, convert the graph node n new into a control node, create new sub - graphs for all its child nodes and insert them into the graph set G;

[0177] When S tn is empty, the conversion ends, and the graph set G is the converted directed acyclic graph.

[0178] Specifically, taking a robot as an example, the program data of the robot script is stored through the root node tn root of the instruction tree. The conversion of the script data to PDAG requires processing the instruction tree tn. The strategy for converting the instruction tree tn to PDAG is to perform a breadth - first traversal of the instruction tree tn, placing sibling nodes in the same graph and child nodes in sub - graphs. Its specific conversion process is as Figure 16 shown. At the beginning of the process, insert tn root into the instruction tree node stack S tn , and create the main graph g of PDAG and insert it into the graph stack S g , where the elements in S tn and S g correspond to each other. Then, obtain the top elements tn tn and g g of S 1 and S 1 , and traverse and process all child nodes under tn 1 . Taking tn cur as an example, at the beginning of the processing, create a corresponding graph node n new according to its information and add it to the graph g 1 where the node is located. Subsequently, establish the connection edge between the penultimate graph node recorded in g 1 and n new . Secondly, classify and process by judging the type of the current instruction tree node element tn cur . The key point in this process is to determine the insertion into S tnand S g For the elements of g , when the type is While, first convert the graph node into a control node and create a new subgraph g 2 Add it to the graph set. Finally, when S tn is empty, it indicates the end of the conversion, and return the graph set G representing the PDAG.

[0179] Take Figure 17 as an example. When tn is popped from S tn and tn root is tn 1 and TN 1 is 5, enter the process. Connect PTP1 and WaitSignal in the graph g. If tn cur is for sequential execution, the process ends directly. When taking if as tn cur , connect if and PTP1 in the graph g. Judge that tn cur is of If type, convert the if node into a control node, traverse the child nodes Then and Else of if, create a new subgraph for each, add it to the graph set G and the control conditions of the control node, insert Then and Else into the top of S tn , insert the new subgraph into the graph stack S g , the process ends, continue to traverse the child nodes under the root node. When taking Delay2 as tn cur , connect Delay2 and if in the graph g. Judge that the type is other and the process ends. Continue to traverse the child nodes under the root node. When taking SetSignal as tn cur , connect SetSignal and Delay2 in the graph g. Judge that the type is other and the process ends;

[0180] Pop Else from S tn and assign it to tn 1 . Traverse the child nodes of tn 1 . Connect SetTool and PTP2 according to the above in the graph level where Else is located. When taking While as tn cur , connect While and SetTool. Judge that tn cur is of While type, convert the current graph node into a control node, and create a new subgraph, add it to the graph set G and the control conditions of the control node, insert While into the top of S tn , insert the new subgraph into the graph stack S g .

[0181] Pop While from S tn and assign it to tn 1 . Traverse the child nodes of tn 1 . Judge its child nodes and tn curWhen it is of other types, at the graph level where While is located, connect Assign to Setbase to PTP3.

[0182] From S tn Pop Then and assign it to tn 1 , for the child nodes of tn 1 Traverse the child nodes of tn, and its child nodes determine tn cur When it is of other types, at the graph level where Then is located, connect Delay1 to LIN, S tn When the element is empty, the conversion ends, and return the graph set G representing the PDAG.

[0183] Preferably, when interpreting and executing the script object, it also includes the script debugger debugging the script object:

[0184] When the debug flag of the script is true, the script debugger obtains the script object;

[0185] The script debugger step - by - step executes the graph nodes in the directed acyclic graph;

[0186] When the debug flag of the script is false, resume interpreting and executing the script object, and the script debugger stops executing the graph nodes in the directed acyclic graph.

[0187] Specifically, the debug function of the script enables the script writer to clearly understand the script execution process and effects, so as to optimize and modify the script content. The script debugger is the specific carrier providing the debug function, and its core is the script debug mechanism. Since this article uses PDAG graphs to represent scripts, it is relatively easy to implement script debugging. In the debug mechanism, when the scheduling execution thread determines that the debug flag db of the script is true, it will pass the script to the script debugger, and the script debugger will only step - by - step execute the script after receiving the execution instruction. Among them, the core of step - by - step execution is to step - by - step execute the graph node n according to the stack S. When db is false, the debugger will return the script back to the execution thread to continue executing the subsequent content. At the same time, the interpretation and execution of the script object can be regarded as an event source. Therefore, the observer pattern is designed to be divided into three parts: event source, event, and event listener. When the event source changes, one or more types of events will be generated, and the event listener responds by registering and listening for a specific type of event of the event source. After establishing the listening mechanism, external programs can monitor and respond to the state through the event listener, as specifically shown in Figure 18 as follows.

[0188] In the description of this specification, the descriptions referring to terms such as "one embodiment", "some embodiments", "schematic embodiments", "examples", "specific examples", or "some examples", etc., mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples.

[0189] Although the embodiments of the present invention have been shown and described, those of ordinary skill in the art can understand that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention, and the scope of the present invention is defined by the claims and their equivalents.

Claims

1. A multi-script execution method for a virtual controller, characterized in that: The multi-script execution method comprises: Set the script structure, graph model structure and graph node structure, where the graph model structure includes a main graph and several levels of sub-graphs, the main graph and sub-graphs include multiple graph nodes, each graph node structure includes information required for storing the corresponding script instruction interpretation and execution and the ignition rule for determining whether the graph node can be executed, and the script structure includes graph model structure information; Performing a syntax and semantic check on the script data to be executed, converting the script data into a script object according to the script structure, converting the script data into a directed acyclic graph according to the graph model structure, and traversing the directed acyclic graph to obtain an execution sequence of the graph at each level of the directed acyclic graph; The script objects are scheduled according to the FIFO algorithm. During scheduling, the directed acyclic graph is traversed to obtain the graph nodes in each execution sequence. The script objects are interpreted and executed according to the ignition rules and the graph nodes in each execution sequence. The script structure is represented by a five-tuple and satisfies the relationship: Script=<sn,SI,EB,VAR,G> ; Among them, Script represents the script object, sn represents the script name, SI represents the script interpretation and execution status identification set, EB represents the script execution set before and after execution, VAR represents the set of all variables with the script scope, and G represents all graphs of the graph model after the control script conversion.

2. The multi-script execution method according to claim 1, characterized in that: The directed acyclic graph is stored in a cross-linked list method, and the graphs at any level in the directed acyclic graph satisfy the relationship: g=<id,N,E,ES,ptr> ; Where g represents a graph of any level in a directed acyclic graph, id represents a graph identifier, N represents a graph node set, E represents a connection edge set, ES represents an execution sequence of the graph, and ptr represents an execution pointer; A basic node N' in the graph node set N satisfies the relationship: N′= <id′,e fi ,and fo ,iv,ir,d,eb,init,res>; Among them, id′ represents the graph node identifier, e fi represents the first incoming edge, e fo represents the first outgoing edge, iv represents the ignition variable, ir represents the ignition rule, d represents the execution data, eb represents the execution behavior, init represents the initialization behavior, res represents the reset behavior, and the first incoming edge e fi and the first outgoing edge e fo It is the way to define graph nodes in the cross-linked list method; A connecting edge E′ in the connecting edge set E satisfies the relationship: E′= <n t ,n h ,e nt ,e nh ,bti>; Among them, n t Represents the graph node at the end of the edge, n h The graph node representing the head to which the edge connects, e nt Indicates the next connecting edge with the same tail node, e nh Indicates the next connecting edge with the same head node, bti indicates breadth timing information; The graph node set N also includes control nodes N″; The control node N″ is extended from the basic node N′ and includes: The execution data d in the control node N″ is composed of the control condition set CS and the graph set G cn (G cn ∈G), the execution behavior eb in the control node N″ is set as the control rule cr of the node.

3. The multi-script execution method according to claim 2, characterized in that: The execution order relationship of the directed acyclic graph in different dimensions includes a breadth time sequence relationship and a depth time sequence relationship; The breadth-time relationship between the subgraphs is represented by the subgraphs in the graph set G cn The order in which the control conditions in the control condition set CS are related to G cn The subgraph in corresponds to; The ignition rule is configured such that if the ignition variables iv of the predecessor nodes are all true, the ignition variable iv of the current node is set to true, the processing function of the current node is activated, and the data of the current node is processed; if the ignition variables iv of the predecessor nodes are not all true, the ignition variable iv of the current node is set to false, the processing function of the current node is not activated, and the data of the current node cannot be processed.

4. The multi-script execution method according to claim 2, characterized in that: The script interpretation execution state identification set SI is represented by a four-tuple and satisfies the relationship: SI=<st,df,ce,db> ; Among them, st indicates the script status, df indicates whether the script is executed by default when the execution engine is started, ce indicates single execution or loop execution, and db indicates whether the script is in debugging state; The script is executed as a set EB before and after execution, which is represented by a four-tuple and satisfies the relationship: EB=<init,res′,br,ar> ; Among them, init represents the initialization behavior of factors including the script configuration, graphs and variables, res′ represents the reset behavior of factors including the script configuration, graphs and variables, br represents the pre-execution behavior, and ar represents the post-execution behavior.

5. The multi-script execution method according to claim 4, characterized in that: Set a basic queue Q and a buffer queue BQ, wherein the basic queue Q is used to store all script objects to be scheduled, and the buffer queue BQ is used to record all script objects that need to be scheduled in the next cycle; The scheduling of script objects according to the FIFO algorithm includes: Step A: insert the script object whose script status st is READY to the end of the basic queue Q, and take the script object from the head of the basic queue Q as the current script object; Step B: If the script state st of the current script object is READY, then the preset pre-execution behavior br is executed; otherwise, the preset pre-execution behavior br is abandoned; Step C: interpret and execute the script object, and execute the preset post-execution behavior ar; Step D: If the ce value of the script object is loop execution, the script state st of the current script object becomes READY, and the current script object is inserted into the buffer queue BQ. If the ce value of the script object is single execution, the next script object is used as the current script object. Loop through steps AD. If there is no script object in the basic queue Q, stop looping through steps AD and swap the basic queue Q with the buffer queue BQ. If the total time consumed to schedule the script object is greater than the preset execution cycle, directly proceed to the script object scheduling for the next cycle. Otherwise, enter a dormant state. When the total time consumed plus the dormant time equals the preset execution cycle, proceed to the script object scheduling for the next cycle.

6. The multi-script execution method according to claim 5, characterized in that: A stack S′ is set, and the execution sequence of traversing the directed acyclic graph to obtain a graph in each level of the directed acyclic graph includes: Get the first level graph in the directed acyclic graph as the current level graph g′; Step K: Get the graph node n with in-degree 0 in the current level graph g′ start , and insert it into the stack S′; Step L: Loop out the graph node at the top of the stack S′ and traverse all the direct successor nodes n of the graph node in reverse order according to the breadth-time relationship bti h , insert n to the top of stack S′ h , until the stack S′ is empty; Step M: Obtain the next level graph in the directed acyclic graph as the current level graph g′; Step KM is repeated until all graph nodes in the directed acyclic graph are traversed to obtain the execution sequence of the graph in each level of the directed acyclic graph.

7. The multi-script execution method according to claim 6, characterized in that: Set a stack S, and store the main graph of the directed acyclic graph into the stack S; The interpreting and executing the script object according to the ignition rules and the graph nodes in each execution sequence includes: Step E: Set the top element of the stack S as the to-be-executed graph cg, and obtain the corresponding graph node n in the execution sequence of the to-be-executed graph cg in sequence according to the execution pointer ptr; Step F: Determine whether the graph node n is executed by the ignition rule. When the graph node n needs to be executed and is a control node, after executing the execution behavior eb of the graph node n, insert the subgraph of the graph node n into the stack S to execute the execution behavior eb of the subgraph; Step G: If the execution pointer ptr is empty, the execution graph cg is executed, the execution pointer ptr is reset and the top element of the stack S is popped out; Repeat steps E, F, and G until stack S is empty.

8. The multi-script execution method according to claim 7, characterized in that: The top element of the current stack S is used as the head of the queue and the target graph node of the jump is used as the tail of the queue. Several graph nodes and several levels of graphs are arranged in intervals as the jump path queue PQ. The execution behavior eb includes the jump of graph node n, including: Step X: Take element A′ from the head of the jump path queue PQ; Step Y: If element A′ is a graph node, point the execution pointer ptr to element A′, and when element A′ is a control node, execute the reset behavior res of element A′, and then read element B′ from the head of jump path queue PQ. If element A′ is a control node connected to element B′, take element B′ out of jump path queue PQ and insert it into the top of stack S. If element A′ is the to-be-executed graph cg in the stack S, read element C′ from the head of the jump path queue PQ. If element C′ is a control node connected to element A′, execute the reset behavior res of element A′ and jump the to-be-executed graph cg in the stack S to the upper level. Repeat steps X and Y until all elements of the jump path queue PQ are taken out.

9. The multi-script execution method according to claim 1, characterized in that: Set the instruction tree tn to satisfy the relationship: tn =<id,t,Data,TN> ; Wherein, id represents the unique identifier of the node, t is used to determine the instruction type, Data represents the execution data according to the individual design of each instruction, and TN is used to store all direct child nodes tn of the node in the instruction tree; Converting script data into a directed acyclic graph according to the graph model structure includes: Store the script data in the root node tn of the instruction tree tn root In the example, the root node tn root Insert into instruction tree node stack S tn In the example above, create the main graph of the directed acyclic graph and insert it into the graph stack S g Among them, S tn and S g The elements in the table correspond to each other; Get S tn The top elements of the stack tn1 and S g The top element g1 of the stack, for all child nodes tn1 cur Execute step HI: Step H: According to each child node tn of tn1 cur Create the corresponding graph node n new , n new Add to g1; Step I: Establish the penultimate graph node in g1 and n new The connecting edges between Step J: If graph node n new For While type, graph node n new Convert to a control node, create a new subgraph g2 and insert it into the graph set G. If the graph node n new If type, the graph node n new Transform into a control node, create a new subgraph for all its child nodes and insert it into the graph set G; When S tn When it is empty, the conversion is completed, and the graph set G is the converted directed acyclic graph.

10. The multi-script execution method according to claim 1, characterized in that: When interpreting and executing a script object, the script debugger is also used to debug the script object: When the script's debug flag is true, the script debugger gets the script object; Script debugger steps through graph nodes in a directed acyclic graph; When the debugging flag of the script is false, the script object is restored to be interpreted and executed, and the script debugger stops executing the graph nodes in the directed acyclic graph.

Citation Information

Patent Citations

  • Script generation method and device, equipment and storage medium

    CN118519630A

  • Script conversion program for model inspection, model inspection program, script conversion device for model inspection and model inspection device

    JP2020030490A