Simulation method and system, device and nonvolatile storage medium of control logic

By receiving and converting control logic program datasets, generating high-level programming language data structure text, the problem of low troubleshooting efficiency caused by the inability to simulate specific program segments in existing technologies is solved, and more efficient control logic program problem localization is achieved.

CN116224826BActive Publication Date: 2026-06-19SUPCON TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SUPCON TECH CO LTD
Filing Date
2022-12-14
Publication Date
2026-06-19

Smart Images

  • Figure CN116224826B_ABST
    Figure CN116224826B_ABST
Patent Text Reader

Abstract

This application discloses a simulation method, system, device, and non-volatile storage medium for control logic. The method includes: receiving a control logic program dataset, wherein the control logic program dataset includes a tag table and a control logic program assembly, the control logic program assembly including project block information and connection relationships between project blocks, and project blocks including tag numbers and function blocks; determining the high-level programming language data structure text corresponding to the control logic program assembly; converting the high-level programming language data structure text corresponding to the control logic program assembly into a target program; and determining the simulation result of the control logic to be simulated based on the target program. This application solves the technical problem of low efficiency in troubleshooting control logic programs due to the inability to simulate specific program segments within the control logic program.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of industrial automatic control, and more specifically, to a simulation method and system for control logic, an apparatus, and a non-volatile storage medium. Background Technology

[0002] With the expansion of factory scale and the rapid development of microprocessor and computer technology, automatic control has gradually permeated almost all process industry production fields. Against this backdrop, in order to ensure that the operation of logic control programs can be monitored in real time and the rationality and stability of the programs can be verified, logic control program simulation systems have emerged.

[0003] Currently, there are several types of control logic simulation systems. One type is based on electrical schematics, where the simulation module simulates the potential and flow of various electronic components according to their characteristics, providing real-time feedback of voltage and current data to simulate the circuit control logic from an electronic and electrical perspective. Another type converts the visualized schematic into a configuration file that the industrial control device can recognize and run. This file is then transmitted from a host computer to the industrial control device via Ethernet, where it simulates the operation and returns real-time data to the designer.

[0004] Both of the aforementioned control logic simulation methods heavily rely on the basic parameters and characteristics of the implementing hardware (industrial control devices), and cannot operate independently of hardware or electronic component information. Furthermore, hardware-based simulation methods can only employ whole-machine simulation debugging. In this method, debuggers cannot test specific program segments, which may harbor more hidden problems. When problems are discovered during debugging, the whole-machine debugging method cannot quickly pinpoint the problem; repeated debugging is required to locate the issue, significantly reducing troubleshooting efficiency.

[0005] There is currently no effective solution to the above problems. Summary of the Invention

[0006] This application provides a simulation method, system, device, and non-volatile storage medium for control logic, to at least solve the technical problem of low efficiency in troubleshooting control logic programs due to the inability to simulate specific program segments within the control logic program.

[0007] According to one aspect of the embodiments of this application, a simulation method for control logic is provided, comprising: receiving a control logic program dataset, wherein the control logic program dataset includes: a tag table and a control logic program set, the control logic program set includes: engineering block information and connection relationships between engineering blocks, and the engineering block includes: tag number and function block; determining the high-level programming language data structure text corresponding to the control logic program set; converting the high-level programming language data structure text corresponding to the control logic program set into a target program, and determining the simulation result of the control logic to be simulated based on the target program.

[0008] Optionally, determining the high-level programming language data structure text corresponding to the control logic program assembly includes: determining the high-level programming language data structure text corresponding to the tag number table; determining the target control logic program in the control logic program assembly, and determining the execution order of the project blocks in the target control logic program, as well as the high-level programming language data structure text corresponding to the function blocks; determining the high-level programming language data structure text corresponding to the target control logic program based on the execution order, the high-level programming language data structure text corresponding to the tag number table, and the high-level programming language data structure text corresponding to the function blocks; and determining the high-level programming language data structure text corresponding to the control logic program assembly based on the high-level programming language data structure text corresponding to the target control logic program.

[0009] Optionally, determining the high-level programming language data structure text corresponding to the tag number table includes: determining the type of the target data storage method corresponding to the tag number table, wherein the target data storage method is a high-level programming language data storage method; determining the tag number in the tag number table as the target variable in the target data storage method according to the type of the target data storage method corresponding to the tag number table; and determining the high-level programming language data structure text corresponding to the tag number table according to the type of the target data storage method and the target variable.

[0010] Optionally, determining the execution order of engineering blocks in the target control logic program includes: determining a first connection relationship between engineering blocks according to the target control logic program; step S1, determining a first engineering block according to the first connection relationship, wherein the first engineering block is an engineering block that has no input source in the first connection relationship, and determining the execution order of the first engineering block as a first sub-execution order; step S2, removing the first engineering block and the connection relationship between the first engineering block and other engineering blocks to obtain a second connection relationship between engineering blocks; step S3, determining a second engineering block according to the second connection relationship, wherein the second engineering block is an engineering block that has no input source in the second connection relationship, and determining the execution order of the second engineering block as a second sub-execution order; repeating steps S1 to S3 until all n engineering blocks in the target control logic program are removed to obtain n sub-execution orders, wherein n is a positive integer; determining the execution order of engineering blocks in the target control logic program according to the n sub-execution orders.

[0011] Optionally, before determining the high-level programming language data structure text corresponding to the function block, the method further includes: determining the pin information of the function block in the target control logic program; determining the symbol table of the target logic control standard corresponding to the pin information; and determining the correctness of the control logic program corresponding to the function block based on the symbol table.

[0012] Optionally, after determining the simulation results of the control logic to be simulated based on the target program, the method further includes: sending the simulation results of the control logic to be simulated to the client.

[0013] According to another aspect of the embodiments of this application, a simulation system for control logic is also provided, comprising: a client and a server, wherein the client is communicatively connected to the server and is used to determine a tag table and a control logic program set as a control logic program dataset, and send the control logic program dataset to the server via a network hypertext transfer protocol, wherein the control logic program set includes: project block information and connection relationships between project blocks, and the project block includes: tag number and function block; the server is used to execute the above simulation method for control logic.

[0014] According to another aspect of the embodiments of this application, a non-volatile storage medium is also provided, the storage medium including a stored program, wherein the program, when running, controls the device where the storage medium is located to execute the above control logic in a simulation method.

[0015] According to another aspect of the embodiments of this application, an electronic device is also provided, including: a memory and a processor, wherein the processor is configured to run a program stored in the memory, wherein the program executes the simulation method of the control logic described above during runtime.

[0016] In this embodiment, a control logic program dataset is received, comprising a tag table and a control logic program set. The control logic program set includes engineering block information and connection relationships between engineering blocks. Each engineering block includes a tag number and a function block. The high-level programming language data structure text corresponding to the control logic program set is determined. This high-level programming language data structure text is converted into a target program, and the simulation result of the control logic to be simulated is determined based on the target program. By determining the high-level programming language data structure text corresponding to the obtained control logic program dataset and converting it into a target program, the purpose of simulating specific program segments in the control logic program is achieved. This improves the efficiency of troubleshooting problems in the control logic program and solves the problem of low efficiency in troubleshooting control logic programs caused by the inability to simulate specific program segments. Attached Figure Description

[0017] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0018] Figure 1 This is a flowchart of a simulation method for control logic according to an embodiment of this application;

[0019] Figure 2 This is a flowchart of another simulation method for control logic according to an embodiment of this application;

[0020] Figure 3 This is a control logic program diagram according to an embodiment of this application;

[0021] Figure 4 This is a flowchart illustrating how to determine the execution order of project blocks according to an embodiment of this application;

[0022] Figure 5 This is a flowchart illustrating how to determine the high-level programming language data structure text corresponding to a function block according to an embodiment of this application;

[0023] Figure 6 This is a flowchart illustrating how to determine the high-level programming language data structure text corresponding to a control logic program set according to an embodiment of this application;

[0024] Figure 7 This is a schematic diagram illustrating the interaction between a client and a server according to an embodiment of this application;

[0025] Figure 8 This is a schematic diagram of the generation principle of a control logic simulator according to an embodiment of this application;

[0026] Figure 9 This is a structural diagram of a simulation system for control logic according to an embodiment of this application;

[0027] Figure 10 This is a structural diagram of a simulation device for control logic according to an embodiment of this application;

[0028] Figure 11 This is a hardware structure block diagram of a computer terminal (or electronic device) according to an embodiment of the present application, which provides a simulation method for control logic. Detailed Implementation

[0029] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0030] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0031] To better understand the embodiments of this application, the technical terms involved in the embodiments of this application are explained below:

[0032] Function block: An abstract representation of computer code with a specific function on the user interface.

[0033] ST Code: High-level language text written in accordance with the IEC 61131-3 programming system standard syntax.

[0034] A compiler is a program that translates one language into another. Developers write high-level computer languages, and the compiler translates them into machine code that computers can understand.

[0035] Schematic diagram: A diagram illustrating the connection principles between various components on a circuit board.

[0036] Host computer: The computer that issues control commands.

[0037] Industrial control devices: actuators used to control processes in industrial production.

[0038] Tag number: The data source or output source in the control system. The data of the instrument hardware in the control system is connected to the controller through hardware connections. The tag number represents the input data of the instrument or the data to be output to the instrument.

[0039] Tag Table: A list of tag numbers in the database.

[0040] Pin: The element in a function block or tag that is responsible for connection, representing the channel through which data flows in or out.

[0041] Web client: i.e., browser.

[0042] Web technologies: a general term for technologies used to develop internet applications.

[0043] HTTP request: A request message from the web client to the server.

[0044] Database: A carrier used to store control logic and related information.

[0045] Class: A data storage and interaction method in high-level programming languages.

[0046] In related technologies, control logic simulation systems cannot utilize the interconnectivity of the internet and can only be performed by installing dedicated simulation software on a single computer. Therefore, there are problems such as the inability to share or collaboratively edit the simulated system, program, or circuit with others, the inability to reuse systems with the same or similar applications from others through online marketplaces, and difficulty in interacting with third parties such as equipment suppliers. To address these issues, this application provides relevant solutions, which are detailed below.

[0047] According to an embodiment of this application, a method embodiment for simulating control logic is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although the logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0048] Figure 1 This is a flowchart of a simulation method for control logic according to an embodiment of this application, such as... Figure 1 As shown, the method includes the following steps:

[0049] Step S102: Receive control logic program dataset, wherein the control logic program dataset includes: a tag number table and a control logic program set, the control logic program set includes: project block information and connection relationships between project blocks, and the project block includes: tag number and function block.

[0050] According to an optional embodiment of this application, a control logic program dataset corresponding to a control logic program diagram is received, wherein the control logic program diagram is as follows: Figure 3As shown. For example, the control logic program consists of two input pins, AOR14020001 and AOR14020002, an addition function block ADD, and an output pin, AOR14020003. The relationships between the program blocks are as follows: the output pin of pin AOR14020001 is connected to the input pin IN1 of ADD; the output pin of pin AOR14020002 is connected to the input pin IN2 of ADD; and the output pin OUT of function block ADD is connected to the input pin of output pin AOR14020003.

[0051] Step S104: Determine the high-level programming language data structure text corresponding to the control logic program set.

[0052] According to another optional embodiment of this application, the control logic assembly includes a list of relationships between project blocks. Each relationship in the list is traversed. When the connection relationship is a tag output connected to a function block input, the value of the tag is obtained by calling the value acquisition method in the tag table, and then the value setting method of the corresponding function block is called to input the obtained value into the function block. Similarly, when the connection relationship is a function block output connected to a function block input and / or a function block output connected to a tag input, the value acquisition operation method of the corresponding input source block is called first, and then the value setting operation method of the output source block is called to realize the value transfer between project blocks.

[0053] Optionally, the high-level programming language data structure text corresponding to the control logic program assembly can be stored as a high-level programming language text file.

[0054] Step S106: Convert the high-level programming language data structure text corresponding to the control logic program set into a target program, and determine the simulation result of the control logic to be simulated based on the target program.

[0055] The server sends the simulation results of the control logic to be simulated, determined by the target program, to the web client, i.e., the browser. The user can directly observe the simulation results of the control logic to be simulated through the browser and perform the next related work based on the simulation results.

[0056] Based on the above steps, by determining the high-level programming language data structure text corresponding to the obtained control logic program dataset and converting the high-level programming language data structure text into a target program, the purpose of simulating a specific program segment in the control logic program is achieved, thereby realizing the technical effect of improving the efficiency of troubleshooting problems in the control logic program.

[0057] According to an optional embodiment of this application, the high-level programming language data structure text corresponding to the control logic program assembly can be determined by the following method: determining the high-level programming language data structure text corresponding to the tag table; determining the target control logic program in the control logic program assembly, and determining the execution order of the project blocks in the target control logic program, as well as the high-level programming language data structure text corresponding to the function blocks; determining the high-level programming language data structure text corresponding to the target control logic program based on the execution order, the high-level programming language data structure text corresponding to the tag table, and the high-level programming language data structure text corresponding to the function blocks; and determining the high-level programming language data structure text corresponding to the control logic program assembly based on the high-level programming language data structure text corresponding to the target control logic program.

[0058] Optionally, the generated high-level programming language data structure text can be stored as a high-level programming language text file.

[0059] In some optional embodiments of this application, the high-level programming language data structure text corresponding to the tag number table is determined by the following method: determining the type of the target data storage method corresponding to the tag number table, wherein the target data storage method is a high-level programming language data storage method; determining the tag number in the tag number table as the target variable in the target data storage method according to the type of the target data storage method corresponding to the tag number table; and determining the high-level programming language data structure text corresponding to the tag number table according to the type of the target data storage method and the target variable.

[0060] As an optional embodiment of this application, a class name for the tag table is defined, and each tag in the tag table is defined as a member variable in the class. The type of the tag is converted and defined according to the actual system definition, into a data storage type in a high-level programming language. The tag data type is REAL. In engineering, the REAL type is defined to occupy 4 bytes in the computer. Therefore, it is converted and defined into a data type that also occupies 4 bytes in the high-level programming language. When converting it to the high-level programming language C++, the type is converted to float. And according to the design requirements, the tag operation methods (such as setting value, getting value) required for accessing the tag in the system are added.

[0061] In some optional embodiments of this application, determining the execution order of engineering blocks in the target control logic program includes the following steps: determining a first connection relationship between engineering blocks according to the target control logic program; step S1, determining a first engineering block according to the first connection relationship, wherein the first engineering block is an engineering block that has no input source in the first connection relationship, and determining the execution order of the first engineering block as a first sub-execution order; step S2, removing the first engineering block and the connection relationship between the first engineering block and other engineering blocks to obtain a second connection relationship between engineering blocks; step S3, determining a second engineering block according to the second connection relationship, wherein the second engineering block is an engineering block that has no input source in the second connection relationship, and determining the execution order of the second engineering block as a second sub-execution order; repeating steps S1 to S3 until all n engineering blocks in the target control logic program are removed to obtain n sub-execution orders, wherein n is a positive integer; determining the execution order of engineering blocks in the target control logic program according to the n sub-execution orders.

[0062] As another optional embodiment of this application, the execution of each project block has an abstract order. When the connection relationship of project blocks is from the output of A to the input of B, then the execution of block A must precede that of B, so that the calculation result of A can be correctly transmitted to block B. According to the topological sorting algorithm, the sequence number of the bit numbers of the left input part of the control logic drawing interface is set to 1, and the sequence number of the block without an input source in the logical relationship is also set to 1. The above blocks and their output connection relationships are deleted. In this way, a new batch of blocks without an input source will appear. The sequence number of the new batch of blocks is set to 2, and so on, until all blocks disappear. At this time, the execution order of all project blocks can be obtained.

[0063] In an optional embodiment, before determining the high-level programming language data structure text corresponding to the function block, it is also necessary to: determine the pin information of the function block in the target control logic program; determine the symbol table of the target logic control standard corresponding to the pin information; and determine the correctness of the control logic program corresponding to the function block based on the symbol table.

[0064] According to an optional embodiment of this application, in accordance with the requirements of the IEC61131-3 compiler, a symbol table is generated from the pin list of the function block, the symbol table data and the industrial programming code in the function block are input into the IEC61131-3 compiler, the correctness of the industrial programming code is checked, and the compilation result and the compiled text of the high-level programming language are output.

[0065] According to a preferred embodiment of this application, after determining the simulation result of the control logic to be simulated according to the target program, it is also necessary to: send the simulation result of the control logic to be simulated to the client.

[0066] Figure 2 This is a flowchart of another simulation method for control logic according to an embodiment of this application, such as... Figure 2 As shown, the method includes the following steps:

[0067] Step S202: After receiving the control logic program dataset, the simulator generation module checks whether there are any errors in the control logic program dataset. If errors are found, a prompt message is generated and sent to the client; if no errors are found, a tag table data structure is created.

[0068] The control logic program consists of two input pins, AOR14020001 and AOR14020002, an adder function block ADD, and an output pin, AOR14020003. The relationships between the program blocks are as follows: the output pin of pin AOR14020001 is connected to the input pin IN1 of ADD; the output pin of pin AOR14020002 is connected to the input pin IN2 of ADD; and the output pin OUT of function block ADD is connected to the input pin of output pin AOR14020003.

[0069] As an optional embodiment of this application, a tag table data structure is created, which contains three member variables: floating-point type AOR14020001, floating-point type AOR14020002 and floating-point type AOR14020003; and three methods for setting values ​​and three methods for getting values, respectively corresponding to the three tag value setting methods.

[0070] In step S204, the simulator generation module determines the target control logic program in the control logic program assembly, that is, there is only one currently defined program in the program listing of the program assembly, and names it Program 1.

[0071] Step S206: Calculate the execution order of the project blocks in Program 1 according to the topological sorting algorithm.

[0072] Figure 4 This is a flowchart illustrating how to determine the execution order of project blocks according to an embodiment of this application, such as... Figure 4 As shown, the method includes the following steps:

[0073] Step S2061: Define the execution order of input bit number AOR14020001 and input bit number AOR14020002 as 1;

[0074] Step S2062: Find all blocks in the current graph that do not have input. The current cases found are: tag number AOR14020001 and tag number AOR14020002.

[0075] Step S2063: Define the execution order of the blocks found in step S2062 as 1;

[0076] Step S2064: Remove the tag number AOR1402001 and the tag number AOR14020002;

[0077] Step S2065: Remove all output connections from tag numbers AOR1402001 and AOR14020002. At this point, the remaining block consists of the addition function block ADD and one output tag number AOR14020003. Regarding the relationship between blocks, the output pin OUT of the remaining function block ADD is connected to the input pin of the output tag number AOR14020003.

[0078] Step S2066, repeat step S2062, find the block in the current figure that does not have input, the current situation is: function block ADD;

[0079] Step S2067: Repeat step S2063 and define the execution order of the block (functional block ADD) found in the previous step as 2;

[0080] Step S2068, repeat step S2064, remove function block ADD;

[0081] Step S2069: Repeat step S2065 to remove all output connections from function block ADD. At this point, the block retains output bit number AOR14020003.

[0082] Step S20610, repeat step S2062, find the block in the current figure that does not have input, the current case is output bit number AOR14020003;

[0083] Step S20611, repeat step S2063, and define the execution order of the current block output bit number AOR14020003 as 3;

[0084] Step S20612: Remove the output bit number AOR14020003 and remove all outputs of the output bit number AOR14020003.

[0085] Step S20613: At this point, there are no block-connection relationships, so the calculation ends.

[0086] Based on the above steps, the first step is to execute the input bit number AOR14020001 and input bit number AOR14020002. The second step is to execute the function block ADD. The third step is to execute the output bit number AOR14020003.

[0087] Step S208: Determine the high-level programming language data structure text corresponding to the function block.

[0088] Figure 5 This is a flowchart illustrating how to determine the high-level programming language data structure text corresponding to a function block according to an embodiment of this application, such as... Figure 5 As shown: Organize the pins of function block ADD, including the input floating-point pins IN1 and IN2; and the output floating-point pin OUT; organize them into symbol table data. Transmit the symbol table information and function block ADD information (internal IEC61131-3 executes "OUT:=IN1+IN2;") to the IEC61131-3 compiler. The compiler compiles the high-level programming language data structure text corresponding to the function block and writes this high-level programming language data structure text to a file.

[0089] Step S210: Generate the high-level programming language data structure text of Program 1.

[0090] Step S2101: Execute the input bit number AOR14020001 and input bit number AOR14020002, and obtain the values ​​of bit number AOR14020001 and bit number AOR14020002 from the bit number table structure generated in step S204.

[0091] In step S2102, based on the connection relationship between the engineering blocks, the values ​​of AOR1402001 and AOR14020002 are input into the high-level programming language data structure class of the function block generated in step S208.

[0092] Step S2103: Execute the run method in function block ADD.

[0093] Step S2104: Based on the connection relationship between the engineering blocks, obtain the output value OUT of the function block ADD and set the value into the output tag AOR14020003.

[0094] Step S2105: Execute the output bit number AOR14020003.

[0095] Step S212: Based on steps S202 to S210, determine the high-level programming language data structure text corresponding to the control logic program assembly, wherein the process is as follows: Figure 6 As shown.

[0096] Step S214: Use CMake to generate the above manifest file, tag table file, and function block file into a project.

[0097] Step S216: Use Mingw32 to generate the above project into an executable program.

[0098] This application combines the characteristics of traditional industrial control systems with the convenience of the internet. It abandons the hardware-dependent nature of traditional industrial control systems and incorporates the open and collaborative nature of the internet, integrating control logic design with simulation to form a complete upper-level control logic design solution for engineering implementation. This application can solve the following problems in control logic simulation systems: reliance on hardware parameters and characteristics or direct hardware operation; inability to run individual specific program segments; and inability to enable team collaboration or application sharing and interoperability via network.

[0099] Figure 9 This is a structural diagram of a simulation system for control logic according to an embodiment of this application, such as... Figure 9 As shown, the system includes: client 902 and server 904, wherein,

[0100] Client 902 communicates with server 904 to determine the tag table and control logic program set as control logic program dataset, and sends the control logic program dataset to server 904 via network hypertext transfer protocol. The control logic program set includes: project block information and connection relationship between project blocks. The project block includes: tag number and function block.

[0101] Server-side 904, a simulation method used to execute control logic.

[0102] Figure 7 This is a schematic diagram illustrating the interaction between a client and a server according to an embodiment of this application, such as... Figure 7 As shown, after accessing the system through the browser on client 902, the user creates custom function blocks according to the different requirements of the project. On the system interface, the user creates the pins required for external connections of the custom function block and enters industrial programming code in the code editor to implement the function block's intended functionality using the created pins. The user creates the tag number by entering the tag type and initial value in the tag number table in the system. After completion, client 902 uses JavaScript to save the data into the database of server 904 via a network HTTP request. The control logic drawing interface is divided into three areas: the leftmost input area and the rightmost output area display the user-selected tag numbers in a table format; the middle logic function area displays the control logic of the current logic page; and the right side of the control logic drawing interface shows a list of system-built-in function blocks and user-defined function blocks.

[0103] According to an optional embodiment of this application, when a user selects a tag number using the tag number selection tool in the toolbar above the control logic drawing interface, the client 902 requests a tag number list from the server 904 via JavaScript. Upon receiving the request, the server 904 returns the tag number list information from the tag number table in the database to the client 902. After receiving the tag number list information, the client 902 uses a visualization tool to draw the tag number style on the interface. Each tag number placed in the input area has a pin on its right side that can be used to connect to an output. Each tag number placed in the output area has a pin on its left side that can be used to connect to an input. When the user selects a function block from the function block list, the client 902 obtains the function block data from the server 904 and draws the function block on the interface. When the user's mouse is positioned on a tag number or a function block's output pin, they can drag to select a pin and connect it to the corresponding input pin of another block. This continues until the user has finished drawing the control logic diagram. The client 902 saves the connection relationship between the function blocks and the tag numbers, as well as the information about the function blocks and tag numbers, as a program in the server 904's database via a network HTTP request.

[0104] When a user triggers a simulation, client 902 sends a simulation request to server 904. Server 904 generates a simulation task ID to notify client 90 of the simulation task. Server 904 then retrieves the dataset to be simulated from the database. The simulation dataset contains information from the tag table and program assemblies. Each program assembly contains multiple programs, and each program contains multiple function blocks, tag numbers, and a list of relationships between the function block tag numbers in the program.

[0105] The principle of generating the server-side 904 control logic simulator is as follows: Figure 8 As shown, the simulator generation module in server 904 will obtain the tag table data and generate a high-level programming language data structure text according to the tag type: Define the class name of the tag table, define each tag in the tag table as a member variable in the class, and convert the tag type to a data storage type in the high-level programming language based on the actual system definition (e.g., if the tag data type is REAL, and in engineering, REAL occupies 4 bytes in the computer, the converted data type in the high-level programming language must also be 4 bytes long, for example, converting it to C++, i.e., converting the type to float). It will also add the tag operation methods (e.g., setting and getting values) required by the system according to design requirements. Finally, the generated high-level programming language data structure text will be stored as a high-level programming language text file on the computer.

[0106] The simulator generation module iterates through the acquired program assemblies, processing each program within them. Each program then sequentially traverses each function block and tag number using a topological sorting algorithm. Following the requirements of the IEC 61131-3 compiler, it generates a symbol table from the pin lists of the function blocks. The symbol table data and the industrial programming code from the function blocks are input into IEC 61131-3 to check the correctness of the industrial programming code, and outputs the compilation results and the compiled text of the high-level programming language. Similar to the tag number table conversion, the names of the function blocks are converted into class names in the high-level programming language, the pins of the function blocks are converted into member variables in the high-level programming language, and the industrial programming code of the function blocks is defined as the execution operation methods in the class.

[0107] The program is parsed to generate a list of function blocks and tag relationships, and then a high-level programming language text describing how the program runs.

[0108] The simulator generation module finally converts the assembly runtime manifest into high-level programming language text.

[0109] The simulator generation module uses the CMAKE tool to combine the generated files with a predefined network communication module into a high-level programming language project. Then, the MINGW32 tool is used to compile this project into a corresponding executable program, thus obtaining the simulator assembly.

[0110] Server 904 runs the generated simulator, which sends real-time data to server 904 via the network module. Client 902 subscribes to real-time data from server 904 based on the simulation task ID received from the simulator. Finally, the received real-time data is displayed on the interface and presented to the user.

[0111] When a user needs to set the value of a block to see the effect of the new value on the current control logic, the client 902 sets the pin value for the tag number or function block, and the client 902 sends a network HTTP request to the server 904.

[0112] Figure 10 This is a structural diagram of a simulation device for control logic according to an embodiment of this application, such as... Figure 10 As shown, the device includes:

[0113] The 1002 receiving module is used to receive the control logic program dataset, which includes: a tag number table and a control logic program set. The control logic program set includes: project block information and the connection relationship between project blocks. The project block includes: tag number and function block.

[0114] 1004 First Determination Module, used to determine the high-level programming language data structure text corresponding to the control logic program set;

[0115] The second determination module 1006 is used to convert the high-level programming language data structure text corresponding to the control logic program set into a target program, and determine the simulation result of the control logic to be simulated based on the target program.

[0116] It should be noted that the above Figure 10 The modules in the above can be program modules (e.g., a set of program instructions that implement a specific function) or hardware modules. For the latter, they can be represented in the following forms, but are not limited to these: each of the above modules is represented by a processor, or the functions of each of the above modules are implemented by a processor.

[0117] Figure 11 A hardware block diagram of a computer terminal (or mobile device) for implementing a simulation method of control logic is shown. Figure 11 As shown, the computer terminal 110 (or mobile device 110) may include one or more processors 1102 (shown as 1102a, 1102b, ..., 1102n in the figure) (processor 1102 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 1104 for storing data, and a transmission module 1106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 11 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, the computer terminal 110 may also include... Figure 11 The more or fewer components shown, or having the same Figure 11 The different configurations shown.

[0118] It should be noted that the aforementioned one or more processors 1102 and / or other data processing circuitry are generally referred to herein as "data processing circuitry". This data processing circuitry may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuitry may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 110 (or mobile device). As involved in the embodiments of this application, this data processing circuitry serves as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).

[0119] The memory 1104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the control logic simulation method in this embodiment. The processor 1102 executes various functional applications and data processing by running the software programs and modules stored in the memory 1104, thereby realizing the above-mentioned control logic simulation method. The memory 1104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1104 may further include memory remotely located relative to the processor 1102, and these remote memories can be connected to the computer terminal 110 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0120] The transmission module 1106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 110. In one example, the transmission module 1106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission module 1106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.

[0121] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 110 (or mobile device).

[0122] It should be noted here that, in some optional embodiments, the above... Figure 11 The computer device (or electronic device) shown may include hardware elements (including circuitry), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware and software elements. It should be noted that... Figure 11 This is only one instance of a particular specific instance, and is intended to illustrate the types of components that may exist in the aforementioned computer equipment (or electronic equipment).

[0123] It should be noted that, Figure 11 The electronic device shown is used to perform Figure 1 The simulation method of the control logic shown above is also applicable to this electronic device, and will not be repeated here.

[0124] This application also provides a non-volatile storage medium, which includes a stored program, wherein the program, when running, controls the device where the storage medium is located to execute the above control logic in a simulation method.

[0125] A non-volatile storage medium performs the following functions: receiving a control logic program dataset, wherein the control logic program dataset includes: a tag table and a control logic program assembly, the control logic program assembly includes: project block information and the connection relationship between project blocks, and the project block includes: tag number and function block; determining the high-level programming language data structure text corresponding to the control logic program assembly; converting the high-level programming language data structure text corresponding to the control logic program assembly into a target program, and determining the simulation result of the control logic to be simulated based on the target program.

[0126] This application also provides an electronic device, including: a memory and a processor, wherein the processor is used to run a program stored in the memory, wherein the program executes the simulation method of the above control logic during runtime.

[0127] The processor is used to run a program that performs the following functions: receiving a control logic program dataset, wherein the control logic program dataset includes: a tag table and a control logic program set, the control logic program set includes: project block information and the connection relationship between project blocks, and the project block includes: tag number and function block; determining the high-level programming language data structure text corresponding to the control logic program set; converting the high-level programming language data structure text corresponding to the control logic program set into a target program, and determining the simulation result of the control logic to be simulated based on the target program.

[0128] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0129] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0130] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.

[0131] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0132] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0133] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to related technologies, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0134] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A method of simulating control logic, characterized by, include: Receive control logic program dataset, wherein the control logic program dataset includes: a tag table and a control logic program set, the control logic program set includes: project block information and the connection relationship between the project blocks, and the project block includes: tag number and function block; The process involves: determining the high-level programming language data structure text corresponding to the control logic program set, including determining the high-level programming language data structure text corresponding to the tag table; determining the target control logic program in the control logic program set, and determining the execution order of the project blocks in the target control logic program, as well as the high-level programming language data structure text corresponding to the function blocks; determining the high-level programming language data structure text corresponding to the target control logic program based on the execution order, the high-level programming language data structure text corresponding to the tag table, and the high-level programming language data structure text corresponding to the function blocks; and determining the high-level programming language data structure text corresponding to the control logic program set based on the high-level programming language data structure text corresponding to the target control logic program. The high-level programming language data structure text corresponding to the control logic program set is converted into a target program, and the simulation result of the control logic to be simulated is determined based on the target program.

2. The method of claim 1, wherein, Determining the high-level programming language data structure text corresponding to the tag table includes: Determine the type of the target data storage method corresponding to the tag table, wherein the target data storage method is a data storage method of a high-level programming language; Based on the type of the target data storage method corresponding to the tag number table, the tag number in the tag number table is determined as the target variable in the target data storage method; Based on the type of the target data storage method corresponding to the tag table and the target variable, determine the high-level programming language data structure text corresponding to the tag table.

3. The method according to claim 1, characterized in that, Determining the execution order of the project blocks in the target control logic program includes: The first connection relationship between the engineering blocks is determined according to the target control logic program; Step S1: Determine the first project block according to the first connection relationship, wherein the first project block is the project block that does not have an input source in the first connection relationship, and determine the execution order of the first project block as the first sub-execution order; Step S2: Remove the first engineering block and the connection relationships between the first engineering block and other engineering blocks to obtain the second connection relationships between the engineering blocks; Step S3: Determine the second project block according to the second connection relationship, wherein the second project block is the project block that does not have an input source in the second connection relationship, and determine the execution order of the second project block as the second sub-execution order; Repeat steps S1 to S3 until all n project blocks in the target control logic program are removed, resulting in n sub-execution sequences, where n is a positive integer; The execution order of the engineering blocks in the target control logic program is determined based on the n sub-execution orders.

4. The method according to claim 1, characterized in that, Before determining the high-level programming language data structure text corresponding to the function block, the method further includes: Determine the pin information of the functional block in the target control logic program; Determine the symbol table of the target logic control standard corresponding to the pin information; The correctness of the control logic program corresponding to the function block is determined based on the symbol table.

5. The method according to claim 1, characterized in that, After determining the simulation result of the control logic to be simulated based on the target program, the method further includes: sending the simulation result of the control logic to be simulated to the client.

6. A simulation system for control logic, characterized in that, include: Client and server, among which, The client communicates with the server to determine the tag table and control logic program set as a control logic program dataset, and sends the control logic program dataset to the server via the Hypertext Transfer Protocol. The control logic program set includes: project block information and the connection relationship between the project blocks. The project block includes: tag number and function block. The server is used to execute the simulation method of the control logic according to any one of claims 1 to 5.

7. A simulation apparatus of control logic, characterized by, include: A receiving module is used to receive a control logic program dataset, wherein the control logic program dataset includes: a tag table and a control logic program set, the control logic program set includes: project block information and the connection relationship between the project blocks, and the project block includes: tag number and function block; The first determining module is configured to determine the high-level programming language data structure text corresponding to the control logic program set, wherein: it determines the high-level programming language data structure text corresponding to the tag table; it determines the target control logic program in the control logic program set, and determines the execution order of the project blocks in the target control logic program, as well as the high-level programming language data structure text corresponding to the function blocks; it determines the high-level programming language data structure text corresponding to the target control logic program based on the execution order, the high-level programming language data structure text corresponding to the tag table, and the high-level programming language data structure text corresponding to the function blocks; and it determines the high-level programming language data structure text corresponding to the control logic program set based on the high-level programming language data structure text corresponding to the target control logic program. The second determining module is used to convert the high-level programming language data structure text corresponding to the control logic program set into a target program, and determine the simulation result of the control logic to be simulated based on the target program.

8. A non-volatile storage medium, comprising: The non-volatile storage medium includes a stored program, wherein, when the program is executed, a simulation method is used to control the device containing the non-volatile storage medium to execute the control logic as described in any one of claims 1 to 5.

9. An electronic device, characterized in that, include: A memory and a processor, the processor being configured to run a program stored in the memory, wherein the program, when running, executes a simulation method of the control logic according to any one of claims 1 to 5.