Ladder program compiling method and system, electronic device and storage medium

By dividing the ladder diagram program into branch structure and single logic element structure, it is directly compiled into the target compilation file of the programmable logic controller, which solves the problem of low compilation efficiency of ladder diagram programs and improves the execution efficiency of ladder diagram programs.

CN123137665APending Publication Date: 2026-11-20SHENZHEN CITY SAMKOON TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611646283.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-23
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

In the existing technology, ladder diagram programs have low compilation efficiency, which leads to the programmable logic controller responding to control instructions in a timely manner, making it difficult to meet the real-time requirements of industrial control.

Method used

By dividing the ladder diagram program into branch structure and single logic element structure, the graphical elements and connection relationships are directly converted into compilable branch structure data and single logic element data, which are then compiled to generate target compiled files, avoiding the need to express logical relationships using an intermediate language.

Benefits of technology

It improves the compilation efficiency of ladder diagram programs, reduces the additional overhead of understanding ladder diagram logic when running target compiled files, and enhances the execution efficiency of ladder diagram programs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123137665A_ABST
    Figure CN123137665A_ABST
Patent Text Reader

Abstract

The application provides a ladder diagram program compiling method and system, an electronic device and a storage medium, and belongs to the technical field of industrial control. The method comprises the following steps: obtaining a target ladder diagram program; performing branch structure division processing according to the target ladder diagram program to obtain at least one branch structure data; performing single-logic-element structure division processing according to the at least one branch structure data to obtain at least one single-logic-element structure data; for each branch structure data, performing branch compiling processing according to the branch structure data to obtain a branch compiling program segment; performing single-logic-element compiling processing according to the at least one single-logic-element structure data to obtain at least one single-logic-element compiling program segment; and determining a target compiling file according to the at least one branch compiling program segment and the at least one single-logic-element compiling program segment. The application can improve the compiling efficiency of the ladder diagram program, thereby improving the execution efficiency of the ladder diagram program.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of industrial control technology, and in particular to a ladder diagram program compilation method and system, electronic device and storage medium. Background Technology

[0002] Ladder diagrams, as graphical programs for implementing control logic in programmable logic controllers (PLCs), represent logical relationships using series and parallel connections of contacts and coils. The execution efficiency of ladder diagrams directly affects the real-time performance of PLCs. However, when a PLC directly runs a ladder diagram program, it needs to repeatedly understand the logic before execution, incurring significant overhead and resulting in low execution efficiency. Consequently, the PLC's response to control commands is not timely enough, making it difficult to meet the real-time requirements of industrial control.

[0003] Currently, in the field of industrial control technology, some methods improve the execution efficiency of ladder diagram programs by compiling them into a high-level language text as an intermediate language, and then compiling the intermediate language into a compiled file that can be directly executed by a programmable logic controller (PLC). However, this compilation method requires conversion to intermediate language before execution, meaning the compilation is not directly applied to the ladder diagram program itself. The compilation quality is limited by the intermediate language, resulting in a limited improvement in the execution efficiency of the compiled program. Therefore, improving the compilation efficiency of ladder diagram programs, and thus improving their execution efficiency, is a pressing technical problem that needs to be solved in the industry. Summary of the Invention

[0004] The main objective of this application is to provide a ladder diagram program compilation method and system, electronic device and storage medium, which aims to improve the compilation efficiency of ladder diagram programs, thereby improving the execution efficiency of ladder diagram programs.

[0005] To achieve the above objectives, a first aspect of this application proposes a ladder diagram program compilation method, the method comprising: Program to obtain the target ladder diagram; The target ladder diagram program is used to perform branch structure division processing to obtain at least one branch structure data; Based on at least one of the branch structure data, perform single logical element structure partitioning to obtain at least one single logical element structure data. For each branch structure data, perform branch compilation processing based on the branch structure data to obtain a branch compilation program segment; Based on at least one of the single logical element structure data, perform single logical element compilation processing to obtain at least one single logical element compiler segment; The target compiled file is determined based on at least one of the branch compiler segments and at least one of the single logic element compiler segments.

[0006] In some embodiments, the branch structure data includes a conditional substructure and a branch output substructure. The step of performing branch compilation processing based on the branch structure data for each branch structure data to obtain a branch compilation program segment includes: For each branch structure data, conditional compilation processing is performed according to the conditional substructure to obtain a conditional compilation subroutine segment; Execution verification is performed based on the branch output substructure to obtain the execution verification result; In response to the executable verification result not meeting the preset executable segment verification conditions, a total jump compilation process is performed based on the branch output substructure to obtain a total jump compilation subroutine segment; The branch compiler segment is determined based on the conditional compiler subroutine segment and the global jump compiler subroutine segment.

[0007] In some embodiments, the step of performing branch compilation processing based on the branch structure data for each branch structure data to obtain a branch compilation program segment further includes: In response to the executability verification result satisfying the preset executable segment verification conditions, the skip sequence and execution sequence are determined from the branch structure data; Perform local jump compilation processing based on the skip sequence to obtain a local jump compilation subroutine segment; The execution sequence is used to perform compilation processing to obtain the compiled subroutine segment. The branch compiler segment is determined based on the conditional compiler subroutine segment, the local jump compiler subroutine segment, and the execution compiler subroutine segment.

[0008] In some embodiments, at least one of the single logic element structure data includes translated single logic elements and edge-type single logic elements. The single logic element compilation process based on at least one of the single logic element structure data to obtain at least one single logic element compiler segment includes: Based on the single logical element of the translation class, a translation and compilation process is performed to obtain the translation and compilation program segment; Based on the edge-type single logic element, the on / off state change analysis is performed to obtain the on / off state change analysis results; Based on the analysis results of the on / off state changes and the edge-type single logic element, edge compilation processing is performed to obtain the edge-compiled program segment; The literal translation compiler segment and the edge-translation compiler segment are determined to be at least one single-logic-element compiler segment.

[0009] In some embodiments, at least one of the single logical element structure data further includes a comparison-type single logical element, and determining the translated compiler segment and the edge-triggered compiler segment as at least one single logical element compiler segment includes: Based on the single logical element of the comparison class, a comparison logical adaptation is performed to obtain the comparison logical adaptation result; Based on the comparison logic adaptation result, a comparison compilation process is performed to obtain a comparison compilation program segment; The direct translation compiler segment, the edge compiler segment, and the comparison compiler segment are determined to be at least one single-logic-element compiler segment.

[0010] In some embodiments, determining the target compiled file based on at least one of the branch compiler segments and at least one of the single logic element compiler segments includes: The container structure is divided according to the target ladder diagram program to obtain at least one container structure data. The target ladder diagram program is used to perform logical structure partitioning to obtain at least one OR logical structure data and at least one AND logical structure data. For each of the container structure data, container compilation processing is performed based on the container structure data to obtain a container compilation program segment; For each of the OR logic structure data, OR logic compilation processing is performed based on the OR logic structure data to obtain an OR logic compiler segment; For each of the aforementioned AND logic structure data, AND logic compilation processing is performed based on the aforementioned AND logic structure data to obtain an AND logic compiler segment; The target compiled file is determined based on at least one of the branch compiler segments, at least one of the single logic element compiler segments, at least one of the container compiler segments, at least one of the OR logic compiler segments, and at least one of the AND logic compiler segments.

[0011] In some embodiments, determining the target compiled file based on at least one branch compiler segment, at least one single logic element compiler segment, at least one container compiler segment, at least one OR logic compiler segment, and at least one AND logic compiler segment includes: Based on at least one branch compiler segment, at least one single logic element compiler segment, at least one container compiler segment, at least one OR logic compiler segment, and at least one AND logic compiler segment, duplicate program segment analysis is performed to obtain duplicate program segment analysis results; Common segment analysis is performed based on at least one of the branch compiler segments, at least one of the single logic element compiler segments, at least one of the container compiler segments, at least one of the OR logic compiler segments, and at least one of the AND logic compiler segments to obtain common segment analysis results; The initial target compiled file is determined based on at least one of the branch compiler segments, at least one of the single logic element compiler segments, at least one of the container compiler segments, at least one of the OR logic compiler segments, and at least one of the AND logic compiler segments. Based on the analysis results of the repeated program segments and the analysis results of the common program segments, the initial target compilation file is optimized to obtain the target compilation file.

[0012] To achieve the above objectives, a second aspect of this application provides a ladder diagram program compilation system, the system comprising: The acquisition unit is used to acquire the target ladder diagram program; A branching unit is used to perform branch structure division processing according to the target ladder diagram program to obtain at least one branch structure data. An element partitioning unit is used to perform single logical element structure partitioning processing based on at least one of the branch structure data to obtain at least one single logical element structure data. A branch compilation unit is used to perform branch compilation processing on each branch structure data to obtain a branch compilation program segment. An element compilation unit is used to perform single logical element compilation processing based on at least one of the single logical element structure data to obtain at least one single logical element compiler segment. A determining unit is used to determine a target compiled file based on at least one said branch compiler segment and at least one said single logic element compiler segment.

[0013] To achieve the above objectives, a third aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described in the first aspect.

[0014] To achieve the above objectives, a fourth aspect of the present application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in the first aspect.

[0015] This application embodiment obtains a target ladder diagram program; then, it performs branch structure division processing on the target ladder diagram program to obtain at least one branch structure data, and performs single logic element structure division processing on the at least one branch structure data to obtain at least one single logic element structure data; next, it performs branch compilation processing on each branch structure data to obtain a branch compilation program segment, and performs single logic element compilation processing on the at least one single logic element structure data to obtain at least one single logic element compilation program segment; finally, it determines the target compiled file based on the at least one branch compilation program segment and the at least one single logic element compilation program segment. Thus, this embodiment of the application, through branch structure partitioning and single logic element structure partitioning, transforms the logical relationships represented by graphical elements and their connections in a ladder diagram program into branch structure data and single logic element structure data that can be directly used by the compiler. The compiler processes directly based on the structure data, without needing to use an intermediate language to express the logic of the ladder diagram program, reducing the limitations of the intermediate language on compilation quality. The generated target compiled file corresponds one-to-one with the logic of the ladder diagram program, reducing the additional overhead of repeatedly understanding the ladder diagram logic when running the target compiled file. In other words, this embodiment of the application can improve the compilation efficiency of ladder diagram programs, thereby improving the execution efficiency of ladder diagram programs. Attached Figure Description

[0016] Figure 1 This is a flowchart of a ladder diagram program compilation method provided in an embodiment of this application; Figure 2 yes Figure 1 A flowchart of step S104 in the process; Figure 3 yes Figure 1 Another flowchart of step S104 in the process; Figure 4 yes Figure 1 A flowchart of step S105 in the process; Figure 5 yes Figure 4 A flowchart of step S404 in the process; Figure 6 yes Figure 1 A flowchart of step S106 in the process; Figure 7 yes Figure 6 A flowchart of step S606 in the process; Figure 8 This is a schematic diagram of the ladder diagram program compilation system provided in the embodiments of this application; Figure 9 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0017] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0018] It should be noted that although functional modules are divided in the system diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the system or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0019] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0020] A Programmable Logic Controller (PLC) is a digital electronic system designed for industrial applications, used for automation control. It stores instructions for performing logical operations, sequential control, timing, counting, and arithmetic operations in programmable memory, and controls various types of machinery or production processes through digital or analog input / output interfaces. It is a core control unit in industrial control. When designing control logic for a PLC, a programming approach supporting multiple programming languages ​​is typically used to translate the control logic into executable code for the PLC, ultimately achieving automated operation of industrial equipment.

[0021] Among various programming languages, ladder diagrams are programs written in graphical programming languages. Their syntax and symbol system borrow from relay circuit diagrams in traditional electrical control systems. Logical relationships are represented by graphical elements such as normally open contacts, normally closed contacts, coils, and function blocks. These graphical elements are connected by horizontal wires to form ladder levels. Each level starts from the left busbar and connects to the output elements on the right. The logic is expressed in a top-down, left-to-right execution order. AND, OR, and NOT logical operations are achieved through the series and parallel combinations of contacts. It is suitable for describing on / off control scenarios such as motor start / stop and valve interlocking, offering intuitiveness and engineering practicality. In automation control, programmable logic controllers (PLCs) execute control logic by running ladder diagram programs. Before execution, the ladder diagram program needs to be converted into executable instructions. However, when a PLC directly runs a ladder diagram program, it needs to repeatedly understand the logic before execution, incurring significant overhead and resulting in low execution efficiency. Consequently, the PLC's response to control commands is not timely enough, making it difficult to meet the real-time requirements of industrial control.

[0022] Currently, in the field of industrial control technology, some methods improve the execution efficiency of ladder diagram programs by compiling them into high-level language text as an intermediate language, and then compiling the intermediate language into a compiled file that can be directly executed by a programmable logic controller (PLC). For example, the ladder diagram program is converted into a high-level language text such as C / C++ as an intermediate language, and then compiled into a compiled file that can be directly executed by the PLC. However, this compilation method requires conversion into an intermediate language before execution, and the compilation is not directly applied to the ladder diagram program itself. The compilation quality is limited by the intermediate language, resulting in a limited improvement in the execution efficiency of the compiled program. Therefore, this application provides a ladder diagram program compilation method and system, electronic device, and storage medium to improve the compilation efficiency of ladder diagram programs, thereby improving their execution efficiency.

[0023] The ladder diagram program compilation method provided in this application relates to the field of industrial control technology. This method can be applied to a terminal, a server, or software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, etc.; the server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application implementing the ladder diagram program compilation method, but is not limited to the above forms.

[0024] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0025] Figure 1 This is an optional flowchart of the ladder diagram program compilation method provided in the embodiments of this application. Figure 1 The method may include, but is not limited to, steps S101 to S106: Step S101: Obtain the target ladder diagram program; Step S102: Perform branch structure division processing according to the target ladder diagram program to obtain at least one branch structure data; Step S103: Perform single logical element structure partitioning processing based on at least one branch structure data to obtain at least one single logical element structure data. Step S104: For each branch structure data, perform branch compilation processing based on the branch structure data to obtain the branch compilation program segment; Step S105: Perform single logic element compilation processing based on at least one single logic element structure data to obtain at least one single logic element compiled program segment. Step S106: Determine the target compilation file based on at least one branch compiler segment and at least one single logic element compiler segment.

[0026] Steps S101 to S106 as shown in the embodiments of this application involve: obtaining a target ladder diagram program; then performing branch structure partitioning processing on the target ladder diagram program to obtain at least one branch structure data, and performing single logic element structure partitioning processing on the at least one branch structure data to obtain at least one single logic element structure data; next, performing branch compilation processing on each branch structure data to obtain a branch compilation program segment, and performing single logic element compilation processing on the at least one single logic element structure data to obtain at least one single logic element compilation program segment; finally, determining the target compiled file based on the at least one branch compilation program segment and the at least one single logic element compilation program segment. Thus, this embodiment of the application, through branch structure partitioning and single logic element structure partitioning, transforms the logical relationships represented by graphical elements and their connections in a ladder diagram program into branch structure data and single logic element structure data that can be directly used by the compiler. The compiler processes directly based on the structure data, without needing to use an intermediate language to express the logic of the ladder diagram program, reducing the limitations of the intermediate language on compilation quality. The generated target compiled file corresponds one-to-one with the logic of the ladder diagram program, reducing the additional overhead of repeatedly understanding the ladder diagram logic when running the target compiled file. In other words, this embodiment of the application can improve the compilation efficiency of ladder diagram programs, thereby improving the execution efficiency of ladder diagram programs.

[0027] In step S101 of some embodiments, the target ladder diagram program may refer to program data that needs to be compiled and uses graphical elements to represent logical relationships. For example, the target ladder diagram program may be program data that uses graphical elements, including normally open contacts and coils, to represent logical relationships; or, the target ladder diagram program may also be program data that uses graphical elements, including normally open contacts, normally closed contacts, coils, and function blocks, to represent logical relationships. It is understood that the number of graphical elements included in the target ladder diagram program can be adjusted according to actual control requirements.

[0028] It should be noted that a normally open contact can refer to a graphical element that closes when a condition is met. For example, a normally open contact can be a graphical element that closes when a start-up condition is met; or, a normally open contact can be a graphical element that closes when a valve opens. A normally closed contact can refer to a graphical element that opens when a condition is met. For example, a normally closed contact can be a graphical element that opens when a stop condition is met; or, a normally closed contact can be a graphical element that opens when a valve closes. It is understood that the use of normally open and normally closed contacts can be adjusted according to actual control requirements. A coil can refer to a graphical element representing the output state of a logical operation. For example, a coil can be a graphical element representing the running state of a motor; or, a coil can be a graphical element representing the running state of a valve. It is understood that the number of coils used can be adjusted according to actual control requirements. A function block can refer to a graphical element that performs an operation or control function. For example, a function block can be a graphical element performing data displacement operations; or, a function block can be a graphical element performing timing operations. It is understood that the type of operation performed by a function block can be selected according to actual control requirements.

[0029] In step S102 of some embodiments, the branch structure partitioning process can refer to the process of partitioning the portion of the target ladder diagram program that drives at least one output based on the logical relationship represented by the graphical elements in the target ladder diagram program. Branch structure data can refer to data reflecting the driving relationship of a condition on at least one output. For example, if the target ladder diagram program uses graphical elements including normally open contacts and coils to represent logical relationships, where the condition represented by the normally open contact determines the output state of the coil, then the branch structure partitioning process could be to identify the coil as an output element, and divide the normally open contact and the coil into one branch structure, thus obtaining one branch structure data. Alternatively, if the target ladder diagram program uses graphical elements including normally open contacts, normally closed contacts, coils, and function blocks to represent logical relationships, where the condition represented by the normally open contact determines the output state of the coil, and the condition represented by the normally closed contact determines the output state of the function block, and these two are not connected, then the branch structure partitioning process could be to identify the coil and the function block as output elements, and divide the normally open contact and the coil, and the normally closed contact and the function block into separate branch structures, thus obtaining two branch structure data. It is understood that the number of branch structure data is determined based on the actual content of the target ladder diagram program.

[0030] In step S103 of some embodiments, the single logic element structure partitioning process can refer to the process of partitioning the graphical elements included in at least one branch structure data according to the logical relationship represented by the graphical elements in at least one branch structure data. Single logic element structure data can refer to data reflecting the logical relationship represented by a single graphical element. For example, if the branch structure data reflects the driving relationship of a condition on at least one output, where the condition represented by a normally open contact determines the output state of a coil, then the single logic element structure partitioning process can be to determine that all graphical elements included in the branch structure data are single, and to identify the normally open contact and the coil as single logic elements respectively, thereby obtaining two single logic element structure data; or, if there are two branch structure data, one branch structure data reflecting the relationship that the condition represented by a normally open contact determines the output state of a coil, and the other branch structure data reflecting the relationship that the condition represented by a normally closed contact determines the output state of a functional block, then the single logic element structure partitioning process can be to determine that all graphical elements included in the two branch structure data are single, and to identify the normally open contact, the coil, the normally closed contact, and the functional block as single logic elements respectively, thereby obtaining four single logic element structure data. It is understandable that the number of single logical element structure data is determined based on the actual content of the branch structure data.

[0031] In step S104 of some embodiments, the branch compilation process can refer to the process of converting the driving relationship represented by the branch structure data into a program segment form for each branch structure data. The branch compilation program segment can refer to a program segment that reflects the driving relationship represented by the branch structure data. For example, the branch compilation program segment can be a program segment including load instructions corresponding to normally open contacts and output instructions corresponding to coils; or, the branch compilation program segment can be a program segment including load instructions corresponding to normally closed contacts and function call instructions corresponding to function blocks. It is understood that the form of the branch compilation program segment is determined according to the actual content of the branch structure data.

[0032] In step S105 of some embodiments, the single logic element compilation process can refer to the process of converting the logical relationship represented by at least one single logic element structure data into a program segment form based on at least one single logic element structure data. The single logic element compiled program segment can refer to a program segment reflecting the logical relationship represented by a single graphical element. For example, if the single logic element structure data reflects the logical relationship represented by a normally open contact, then the single logic element compiled program segment can be a program segment corresponding to the normally open contact that includes load-type instructions; or, if the single logic element structure data reflects the logical relationship represented by a coil, then the single logic element compiled program segment can be a program segment corresponding to the coil that includes output-type instructions. It is understood that each single logic element structure data corresponds to one single logic element compiled program segment; the representation of the single logic element compiled program segment is determined according to the actual content of the single logic element structure data.

[0033] In step S106 of some embodiments, the target compiled file may refer to a file that can be directly executed by a programmable logic controller (PLC) by merging at least one branch compiled program segment and at least one single logic element compiled program segment. For example, the target compiled file may be a compiled file that merges a branch compiled program segment containing load class instructions corresponding to normally open contacts and output class instructions corresponding to coils, and a single logic element compiled program segment containing load class instructions corresponding to normally open contacts; or, the target compiled file may be a compiled file that merges a branch compiled program segment containing load class instructions corresponding to normally closed contacts and function call class instructions corresponding to function blocks, and a single logic element compiled program segment containing output class instructions corresponding to coils.

[0034] Please see Figure 2 In some embodiments, the branch structure data includes a conditional substructure and a branch output substructure, and step S104 may include, but is not limited to, steps S201 to S204: Step S201: For each branch structure data, perform conditional compilation processing according to the conditional substructure to obtain the conditional compilation subroutine segment; Step S202: Perform executability verification based on the branch output substructure to obtain the executability verification result; Step S203: In response to the executable verification result not meeting the preset executable segment verification conditions, perform overall jump compilation processing based on the branch output substructure to obtain the overall jump compilation subroutine segment; Step S204: Determine the branch compiler segment based on the conditional compiler subroutine segment and the global jump compiler subroutine segment.

[0035] In step S201 of some embodiments, the branch structure data may refer to data that includes a condition substructure and a branch output substructure, reflecting the driving relationship of a condition on at least one output. The condition substructure may refer to data reflecting a condition. For example, the condition substructure may be data reflecting a condition represented by a normally open contact; or, the condition substructure may be data reflecting a condition represented by a normally closed contact. The branch output substructure may refer to data reflecting the output state. For example, the branch output substructure may be data reflecting the output state of a coil; or, the branch output substructure may be data reflecting the output state of a functional block.

[0036] Conditional compilation refers to the process of compiling graphical elements of conditional substructures within each branch structure data according to a serial-parallel relationship. A conditional compilation subroutine segment refers to a program segment obtained after conditional compilation that reflects the conditional result. For example, if the conditional substructure reflects data representing conditions indicated by normally open contacts, the conditional compilation subroutine segment can be a RISC-V32 instruction segment, including the load instruction LB corresponding to the normally open contact, representing the conditional result; or, if the conditional substructure reflects data representing conditions represented by normally open and normally closed contacts in series, the conditional compilation subroutine segment can be a RISC-V32 instruction segment, including the load instruction LB corresponding to the normally open contact, the load instruction LB corresponding to the normally closed contact, and the XOR instruction, representing the conditional result in a serial relationship. It is understandable that the representation of the conditional compilation subroutine segment is determined by the graphical elements included in the conditional substructure.

[0037] In step S202 of some embodiments, executability verification may refer to the process of verifying whether there are any mandatory instructions among the instructions included in the branch output substructure. The executability verification result may refer to whether the executability verification passes or fails. Passing the executability verification means that there are mandatory instructions among the instructions included in the branch output substructure; failing the executability verification means that there are no mandatory instructions among the instructions included in the branch output substructure. For example, if the branch output substructure is data reflecting the output state of a coil, and the branch output substructure includes an output instruction SB corresponding to the coil, and the output instruction SB is not a mandatory instruction, then the executability verification result is a failure; or, if the branch output substructure includes a negation instruction XOR, and the negation instruction XOR is a mandatory instruction, then the executability verification result is a pass.

[0038] In step S203 of some embodiments, the preset executable segment verification condition may refer to the condition that there are instructions in the branch output substructure that must be executed. If the executable verification result does not meet the preset executable segment verification condition, it means that the branch output substructure can be skipped entirely when the condition is not met. In this case, a total jump compilation process can be performed based on the branch output substructure to obtain a total jump compilation subroutine segment. The total jump compilation process may refer to the process of generating conditional jump instructions based on the branch output substructure, setting the jump target of the conditional jump instructions after the branch output substructure, and then sequentially compiling the branch output substructures. The total jump compilation subroutine segment may refer to the program segment obtained after the total jump compilation process, which includes the compilation result of the conditional jump instructions and the branch output substructure. For example, if the branch output substructure reflects the output state of the coil, and includes the output instruction SB corresponding to the coil, then the overall jump compilation subroutine segment can be a RISC-V32 instruction segment, including the conditional jump instruction BEQ and the output instruction SB corresponding to the coil, with the jump target of the conditional jump instruction BEQ located after the output instruction SB; or, if the branch output substructure reflects the output state of the function block, and includes the function call instruction JAL corresponding to the function block, then the overall jump compilation subroutine segment can be a RISC-V32 instruction segment, including the conditional jump instruction BEQ and the function call instruction JAL corresponding to the function block, with the jump target of the conditional jump instruction BEQ located after the function call instruction JAL.

[0039] In step S204 of some embodiments, the branch compiler segment may refer to a program segment obtained by combining a conditional compiler subroutine segment and a global jump compiler subroutine segment. For example, the branch compiler segment may be a program segment of RISC-V32 instructions including a load instruction LB representing the conditional result, a conditional jump instruction BEQ, and an output instruction SB corresponding to the coil; or, the branch compiler segment may be a program segment of RISC-V32 instructions including two load instructions LB representing the conditional result, an XOR instruction, a BEQ instruction, and a function call instruction JAL corresponding to the function block.

[0040] It is understood that, in this embodiment, conditional compilation is performed based on the conditional substructure to obtain a conditional compilation subroutine segment; then, executability verification is performed based on the branch output substructure to obtain an executability verification result; then, in response to the executability verification result not meeting the preset executable segment verification conditions, overall jump compilation is performed based on the branch output substructure to obtain an overall jump compilation subroutine segment; finally, the branch compilation program segment is determined based on the conditional compilation subroutine segment and the overall jump compilation subroutine segment. Thus, in this embodiment, the parts of the branch output substructure that do not need to be executed when the condition is not met can be uniformly covered by a conditional jump instruction, and the parts of the branch output substructure that do not need to be executed when the condition is not met are skipped entirely without execution, reducing the execution of useless output code when the condition is not met, improving the conciseness of the branch compilation program segment, and thereby further improving the compilation efficiency of ladder diagram programs.

[0041] Please see Figure 3 In some embodiments, step S104 may also include, but is not limited to, steps S301 to S304: Step S301: In response to the executability verification result satisfying the preset executable segment verification conditions, determine the skip sequence and execution sequence from the branch structure data; Step S302: Perform local jump compilation processing based on the skip sequence to obtain the local jump compilation subroutine segment; Step S303: Perform execution compilation processing according to the execution sequence to obtain the execution compilation subroutine segment; Step S304: Determine the branch compiler segment based on the conditional compiler segment, the local jump compiler segment, and the execution compiler segment.

[0042] In step S301 of some embodiments, in response to the executability verification result satisfying the preset executable segment verification conditions, it indicates that there is a part in the branch output substructure that still needs to be executed even if the conditions are not met. At this time, the branch output substructure cannot be skipped entirely; it is necessary to distinguish between the skippable part and the part that must be executed, and to determine the skip sequence and execution sequence from the branch structure data. The skip sequence can refer to a sequence composed of consecutively arranged output elements included in the branch output substructure that do not need to be executed when the conditions are not met. For example, the skip sequence can be a sequence composed of consecutively arranged coils and function blocks included in the branch output substructure; or, if the branch output substructure includes only one output element that does not need to be executed when the conditions are not met, then the skip sequence can be a sequence composed of that output element. The execution sequence can refer to a sequence composed of consecutively arranged output elements included in the branch output substructure that still need to be executed when the conditions are not met. For example, the execution sequence can be a sequence composed of consecutively arranged output elements included in the branch output substructure that all include the XOR instruction; or, if the branch output substructure includes only one output element that still needs to be executed when the conditions are not met, then the execution sequence can be a sequence composed of that output element. Understandably, skip sequences and execution sequences alternate, and the number of skip sequences and execution sequences is determined by the distribution of output elements within the branch output substructure that still need to be executed and those that do not. Output elements can refer to graphical elements representing the output state of logical operations. For example, an output element can be a coil; or, an output element can be a function block.

[0043] In step S302 of some embodiments, the local jump compilation process may refer to the process of generating a conditional jump instruction for each skip sequence, setting the jump target of the conditional jump instruction after the skip sequence, and then compiling the output elements included in the skip sequence in sequence. The local jump compilation subroutine segment may refer to the program segment obtained after the local jump compilation process, which includes the compilation result of the conditional jump instruction and the output elements included in the skip sequence. For example, if the skip sequence is a sequence of coils and function blocks arranged consecutively within a branch output substructure, the local jump compiler subroutine segment can be a RISC-V32 instruction segment, including the conditional jump instruction BEQ, the output instruction SB corresponding to the coil, and the function call instruction JAL corresponding to the function block. The jump target of the conditional jump instruction BEQ is located after the output instruction SB and the function call instruction JAL. Alternatively, if the skip sequence is a sequence of coils included in a branch output substructure, the local jump compiler subroutine segment can be a RISC-V32 instruction segment, including the conditional jump instruction BEQ and the output instruction SB corresponding to the coil. The jump target of the conditional jump instruction BEQ is located after the output instruction SB.

[0044] In step S303 of some embodiments, performing compilation processing can refer to the process of sequentially compiling the output elements included in each execution sequence without generating conditional jump instructions. The execution compilation subroutine segment can refer to the program segment obtained after performing compilation processing, which is composed of the sequentially compiled results of the output elements included in the execution sequence. For example, if the execution sequence is a sequence of consecutively arranged output elements included in a branch output substructure, all of which include the XOR instruction, then the execution compilation subroutine segment can be a RISC-V32 instruction program segment, including the sequentially arranged XOR instructions, but excluding conditional jump instructions; or, if the execution sequence is a sequence of output elements including the XOR instruction included in a branch output substructure, then the execution compilation subroutine segment can be a RISC-V32 instruction program segment, including the XOR instruction, but excluding conditional jump instructions.

[0045] In step S304 of some embodiments, the branch compiler segment may refer to a program segment obtained by combining a conditional compiler subroutine segment, a local jump compiler subroutine segment, and an execution compiler subroutine segment. For example, the branch compiler segment may be a program segment including a load instruction LB representing the condition result, a conditional jump instruction BEQ, an output instruction SB corresponding to the coil, a function call instruction JAL corresponding to the function block, and a negation instruction XOR; or, the branch compiler segment may be a program segment including two load instructions LB representing the condition result, a negation instruction XOR, a conditional jump instruction BEQ, an output instruction SB corresponding to the coil, and a negation instruction XOR, all of which are RISC-V32 instructions.

[0046] It is understood that, in response to the executable verification result meeting the preset executable segment verification conditions, this embodiment of the application determines the skip sequence and execution sequence from the branch structure data; then, it performs local jump compilation processing based on the skip sequence to obtain the local jump compilation subroutine segment; then, it performs execution compilation processing based on the execution sequence to obtain the execution compilation subroutine segment; finally, it determines the branch compilation program segment based on the conditional compilation subroutine segment, the local jump compilation subroutine segment, and the execution compilation subroutine segment. Thus, this embodiment of the application allows the parts of the branch output substructure that do not need to be executed when the condition is not met to be grouped in the form of a skip sequence, while the parts that still need to be executed when the condition is not met are retained in the form of an execution sequence. This ensures that the conditional jump instruction only applies to the parts that can be skipped and does not cover the parts that must be executed, reducing the situation where useless output code is executed when the condition is not met, improving the conciseness of the branch compilation program segment, and thereby further improving the compilation efficiency of the ladder diagram program.

[0047] Please see Figure 4In some embodiments, at least one single logic element structure data includes a literal single logic element and an edge-type single logic element, and step S105 may include, but is not limited to, steps S401 to S404: Step S401: Perform direct translation and compilation processing based on the single logical element of the direct translation class to obtain the direct translation and compilation program segment; Step S402: Perform on / off state change analysis based on edge-type single logic elements to obtain on / off state change analysis results; Step S403: Based on the analysis results of the on / off state changes and the edge-type single logic element, perform edge compilation processing to obtain the edge-compiled program segment; Step S404: Determine the direct translation compiler segment and the edge compiler segment as at least one single-logic-element compiler segment.

[0048] In step S401 of some embodiments, at least one single logic element structure data can refer to data including translated single logic elements and edge-triggered single logic elements. For example, at least one single logic element structure data can be two single logic element structure data, one of which is a translated single logic element and the other is an edge-triggered single logic element. The translated single logic element can refer to a single logic element that can be directly compiled into instructions. For example, a translated single logic element can be a normally open contact, a normally closed contact, or an inverted instruction; or, a translated single logic element can be a coil or a function block. The edge-triggered single logic element can refer to a single logic element that requires analysis of changes in on / off states. For example, an edge-triggered single logic element can be a rising-edge single logic element; or, an edge-triggered single logic element can be a falling-edge single logic element. It is understood that the types of translated single logic elements and edge-triggered single logic elements can be adjusted according to actual control requirements.

[0049] Interpretive compilation refers to the process of determining the corresponding instructions for each interpreted single logic element and compiling them sequentially. An interpreted compiler segment refers to a program segment obtained after interpretive compilation, consisting of instructions corresponding to the interpreted single logic elements. For example, if the interpreted single logic element is a negation instruction, the interpreted compiler segment can be a RISC-V32 instruction segment, including the negation instruction XOR; or, if the interpreted single logic element is a normally closed contact, the interpreted compiler segment can be a RISC-V32 instruction segment, including the load instruction LB and the negation instruction XOR corresponding to the normally closed contact. It is understood that the form of the interpreted compiler segment is determined by the type of interpreted single logic element.

[0050] In step S402 of some embodiments, the on / off state change analysis can refer to the process of obtaining the current state and the previous state of the on / off state represented by the edge-type single logic element and comparing them. The on / off state change analysis result can refer to the result obtained after the on / off state change analysis, reflecting the change in the on / off state. For example, if the edge-type single logic element is a rising edge single logic element, the current state of the on / off state is closed, and the previous state is open, then the on / off state change analysis result is that the on / off state changes from open to closed; or, if the edge-type single logic element is a falling edge single logic element, the current state of the on / off state is open, and the previous state is closed, then the on / off state change analysis result is that the on / off state changes from closed to open.

[0051] It should be noted that the current state can be the on / off state of the edge-type single logic element obtained this time, and the previous state can be the on / off state saved after the previous acquisition. The current state is saved after being compared with the previous state, and serves as the previous state for the next comparison.

[0052] In step S403 of some embodiments, edge compilation processing can refer to the process of generating edge judgment instructions for judging on / off state changes based on the on / off state change analysis results for edge-type single logic elements. The edge-compiled program segment can refer to the program segment obtained after edge compilation processing, including the edge judgment instructions. For example, if the edge-type single logic element is a rising-edge single logic element, and the on / off state change analysis result is that the on / off state changes from open to closed, then the edge-compiled program segment can be a RISC-V32 instruction program segment, including the load instruction LB and the edge judgment instruction SLT; or, if the edge-type single logic element is a falling-edge single logic element, and the on / off state change analysis result is that the on / off state changes from closed to open, then the edge-compiled program segment can be a RISC-V32 instruction program segment, including the load instruction LB and the edge judgment instruction SLT with the operands in reverse order. It is understood that the form of the edge-compiled program segment is determined according to the type of edge-type single logic element and the on / off state change analysis results.

[0053] In step S404 of some embodiments, at least one single-logic element compiler segment may refer to a program segment that includes an interpreted compiler segment and an edge-checking compiler segment. For example, at least one single-logic element compiler segment may be two single-logic element compiler segments, one of which is an interpreted compiler segment that includes a negation instruction XOR, and the other is an edge-checking compiler segment that includes a load instruction LB and an edge-checking instruction SLT; or, at least one single-logic element compiler segment may be two single-logic element compiler segments, one of which is an interpreted compiler segment that includes a load instruction LB corresponding to a normally closed contact and a negation instruction XOR, and the other is an edge-checking compiler segment that includes a load instruction LB and an edge-checking instruction SLT with the operands in reverse order.

[0054] It should be noted that if there are multiple translated single logic elements and / or multiple edge-type single logic elements, then each translated single logic element is translated and compiled separately, and each edge-type single logic element is analyzed for on / off state changes and processed by edge compilation. The translated and edge-type compiled program segments obtained are determined as single logic element compiled program segments, thereby obtaining at least one single logic element compiled program segment.

[0055] It is understood that, in this embodiment, the translated single logic element is directly translated and compiled to obtain a translated compiler segment; then, the on / off state change analysis is performed on the edge-type single logic element to obtain the on / off state change analysis result; then, edge-compilation is performed based on the on / off state change analysis result and the edge-type single logic element to obtain an edge-compiled program segment; finally, the translated compiler segment and the edge-compiled program segment are determined as at least one single logic element compiler segment. Thus, this embodiment allows translated single logic elements to be directly mapped to corresponding instructions according to their type, and the edge judgment of edge-type single logic elements is based on the on / off state change analysis result. This ensures that the compilation rules of single logic elements match the element properties, reduces the lack of basis for deriving correspondences and edge judgments during compilation, improves the accuracy of single logic element compiler segments, and further improves the compilation efficiency of ladder diagram programs.

[0056] Please see Figure 5 In some embodiments, at least one single logic element structure data further includes a comparison-type single logic element, and step S404 may also include, but is not limited to, steps S501 to S503: Step S501: Compare logic adaptation based on the single logic element of the comparison class to obtain the comparison logic adaptation result; Step S502: Perform comparison and compilation processing based on the comparison logic adaptation results to obtain the comparison compilation program segment; Step S503: The direct translation compiler segment, the edge compiler segment, and the comparison compiler segment are determined as at least one single-logic-element compiler segment.

[0057] In step S501 of some embodiments, at least one single logic element structure data further includes a comparison-type single logic element. A comparison-type single logic element can refer to a single logic element representing a comparison relationship. For example, a comparison-type single logic element can be a single-word comparison instruction; or, a comparison-type single logic element can be a floating-point comparison instruction. It is understood that the type of comparison-type single logic element can be adjusted according to actual control requirements. Comparison logic adaptation can refer to the process of determining the corresponding combination of comparison instructions based on the comparison relationship represented by the comparison-type single logic element. The comparison logic adaptation result can refer to the result reflecting the determined combination of comparison instructions. For example, if a single logic element of the comparison class represents an equal or unequal comparison relation, the comparison logic adaptation result is an instruction combination including the XOR instruction and the unsigned size comparison instruction SLTU; or, if a single logic element of the comparison class represents a less than or greater than comparison relation, the comparison logic adaptation result is an instruction combination including the size comparison instruction SLT; or, if a single logic element of the comparison class represents a less than or equal to comparison relation or a greater than or equal to comparison relation, the comparison logic adaptation result is an instruction combination including the size comparison instruction SLT and the XOR instruction.

[0058] In step S502 of some embodiments, the comparison compilation process can refer to the process of generating corresponding instructions for each comparison-class single logic element according to the comparison instruction combination determined by the comparison logic adaptation result, and determining the operand loading method based on whether the comparison number is a constant. The comparison compilation program segment can refer to the program segment obtained after the comparison compilation process that reflects the comparison instructions and operand loading situation generated according to the comparison logic adaptation result. For example, if the comparison logic adaptation result is an instruction combination including the XOR instruction and the unsigned size comparison instruction SLTU, and one of the comparison numbers is a constant, then the comparison compilation program segment can be a RISC-V32 instruction program segment, including the XOR instruction and the unsigned size comparison instruction SLTU; or, if the comparison logic adaptation result is an instruction combination including the size comparison instruction SLT, and neither of the comparison numbers is a constant, then the comparison compilation program segment can be a RISC-V32 instruction program segment, including the load instruction LB and the size comparison instruction SLT. It is understandable that loading can refer to the process of reading out the value of data, and the data is used as an operand of the instruction to participate in the operation after being read out; the value of the constant comparison number is determined and is directly used as an operand of the instruction, while the comparison number that is not constant needs to be loaded before participating in the comparison.

[0059] In step S503 of some embodiments, at least one single-logic element compiler segment may refer to a program segment including an interpreted compiler segment, an edge-checked compiler segment, and a comparison compiler segment. For example, at least one single-logic element compiler segment may be three single-logic element compiler segments, one of which is an interpreted compiler segment including a negation instruction XOR, another is an edge-checked compiler segment including a load instruction LB and an edge-checking instruction SLT, and the third is a comparison compiler segment including an XOR instruction XOR and an unsigned size check instruction SLTU; or, at least one single-logic element compiler segment may be three single-logic element compiler segments, one of which is an interpreted compiler segment including a load instruction LB corresponding to a normally closed contact and a negation instruction XOR, another is an edge-checked compiler segment including a load instruction LB and an edge-checking instruction SLT with the operands in reverse order, and the third is a comparison compiler segment including a load instruction LB and a size check instruction SLT.

[0060] It should be noted that if there are multiple translated single logic elements and / or multiple edge-type single logic elements and / or multiple comparison-type single logic elements, then each translated single logic element is subjected to translated compilation, each edge-type single logic element is subjected to on / off state change analysis and edge compilation, and each comparison-type single logic element is subjected to comparison logic adaptation and comparison compilation. The resulting translated compilation segment, edge compilation segment, and comparison compilation segment are all determined as single logic element compilation segments, thereby obtaining at least one single logic element compilation segment.

[0061] It is understood that, in this embodiment, comparison logic adaptation is performed based on the comparison-type single logic element to obtain the comparison logic adaptation result; then, comparison compilation processing is performed based on the comparison logic adaptation result to obtain the comparison compiler segment; finally, the direct translation compiler segment, the edge-triggered compiler segment, and the comparison compiler segment are determined as at least one single logic element compiler segment. Thus, in this embodiment, each comparison relationship represented by the comparison-type single logic element has a matching combination of comparison instructions. The comparison is implemented as instructions according to the determined combination, and the constant comparison number is directly used as the operand of the instruction, eliminating the need for loading. This reduces the generation of operand loading instructions in the comparison instructions, reduces redundant instructions caused by mismatch between comparison cases and instruction combinations, improves the simplification of the single logic element compiler segment, and further improves the compilation efficiency of ladder diagram programs.

[0062] Please see Figure 6 In some embodiments, step S106 may include, but is not limited to, steps S601 to S606: Step S601: Perform container structure partitioning processing according to the target ladder diagram program to obtain at least one container structure data; Step S602: Perform logical structure partitioning processing according to the target ladder diagram program to obtain at least one OR logical structure data and at least one AND logical structure data. Step S603: For each container structure data, perform container compilation processing based on the container structure data to obtain the container compilation program segment; Step S604: For each OR logic structure data, perform OR logic compilation processing based on the OR logic structure data to obtain an OR logic compiler segment; Step S605: For each AND logic structure data, perform AND logic compilation processing based on the AND logic structure data to obtain the AND logic compiled program segment; Step S606: Determine the target compiled file based on at least one branch compiler segment, at least one single logic element compiler segment, at least one container compiler segment, at least one OR logic compiler segment, and at least one AND logic compiler segment.

[0063] In step S601 of some embodiments, the container structure partitioning process can refer to the process of partitioning unconnected parts of the target ladder diagram program into container structures based on the connection relationships between the parts in the target ladder diagram program. At least one container structure data can refer to data obtained after the container structure partitioning process, reflecting that the same container structure includes unconnected parts. For example, at least one container structure data can be a single container structure data, reflecting that two unconnected parts are partitioned into the same container structure, where one part includes normally open contacts and a coil, and the other part includes normally open contacts and a function block; or, at least one container structure data can be two container structure data, where the target ladder diagram program has two unconnected parts, one part including normally open contacts and a coil, and the other part including two unconnected sub-parts, where the two sub-parts respectively include normally open contacts and a function block, and normally closed contacts and a coil. One container structure data reflects that the two parts are partitioned into one container structure, and the other container structure data reflects that the two sub-parts are partitioned into another container structure. It is understood that the number of container structure data is determined based on the distribution of unconnected parts in the target ladder diagram program.

[0064] In step S602 of some embodiments, the logic structure partitioning process can refer to the process of partitioning parallel graphical elements into OR logic structures and serially arranged graphical elements into AND logic structures based on the serial and parallel arrangement of graphical elements in the target ladder diagram program. At least one OR logic structure data can refer to data obtained after the logic structure partitioning process, reflecting the parallel arrangement of graphical elements. For example, at least one OR logic structure data can be a single OR logic structure data reflecting two normally open contacts in parallel; or, at least one OR logic structure data can be two OR logic structure data, one of which reflects the parallel arrangement of two normally open contacts, and the other reflects the parallel arrangement of normally open and normally closed contacts. At least one AND logic structure data can refer to data reflecting the serial arrangement of graphical elements. For example, at least one AND logic structure data can be a single AND logic structure data reflecting the serial arrangement of normally open and normally closed contacts; or, at least one AND logic structure data can be two AND logic structure data, one of which reflects the serial arrangement of normally open and normally closed contacts, and the other reflects the serial arrangement of two normally closed contacts. It is understandable that the amount of logical structure data and the amount of logical structure data are determined based on the distribution of the serial and parallel arrangement of graphical elements in the target ladder diagram program.

[0065] In step S603 of some embodiments, the container compilation process can refer to the process of compiling and sequentially combining each part of the container structure data for each container structure data. The container compilation program segment can refer to the program segment obtained after container compilation, which is composed of the compilation results of each part in sequence. For example, if the container structure data includes two parts, namely normally open contact and coil, and normally open contact and function block, then the container compilation program segment can be a RISC-V32 instruction program segment, sequentially including the load instruction LB corresponding to the normally open contact, the output instruction SB corresponding to the coil, the load instruction LB corresponding to the normally open contact, and the function call instruction JAL corresponding to the function block; or, if there are two container structure data, one of which includes two parts, namely normally open contact and coil and another part including two unconnected sub-parts, and the other container structure data includes two sub-parts, namely normally open contact and function block, and normally closed contact and coil, then the container compilation program... There can be two segments. One is a RISC-V32 instruction segment, which includes, in sequence, the load instruction LB corresponding to the normally open contact, the output instruction SB corresponding to the coil, the load instruction LB again corresponding to the normally open contact, the function call instruction JAL corresponding to the function block, the load instruction LB corresponding to the normally closed contact, the XOR instruction, and the output instruction SB again corresponding to the coil. The other is also a RISC-V32 instruction segment, which includes, in sequence, the load instruction LB corresponding to the normally open contact, the function call instruction JAL corresponding to the function block, the load instruction LB again corresponding to the normally closed contact, the XOR instruction, and the output instruction SB again corresponding to the coil. It is understandable that the format of the container compiler segment is determined by the actual content of each part of the container structure data.

[0066] In step S604 of some embodiments, the OR logic compilation process can refer to the process of sequentially compiling each parallel part for each OR logic structure data and generating a conditional jump instruction that skips subsequent parallel parts when any parallel part is true. The OR logic compiler segment can refer to the program segment obtained after OR logic compilation, which sequentially includes each parallel part and jumps to the end when any parallel part is true. For example, if the OR logic structure data reflects two normally open contacts arranged in parallel, the OR logic compiler segment can be a RISC-V32 instruction segment, including the load instruction LB and the conditional jump instruction BNE corresponding to the normally open contacts. The load instruction LB and the conditional jump instruction BNE jump to the end when the previous parallel part is true. Alternatively, if there are two OR logic structure data, one reflecting two normally open contacts arranged in parallel and the other reflecting a normally open contact and a normally closed contact arranged in parallel, then there can be two OR logic compiler segments, one of which is a RISC-V32 instruction. The OR logic compiler segment is a RISC-V32 instruction segment, including the load instruction LB and the conditional jump instruction BNE corresponding to the normally open contact. The load instruction LB and the conditional jump instruction BNE jump to the end when the preceding parallel part is true. The other OR logic compiler segment is also a RISC-V32 instruction segment, including the load instruction LB and the conditional jump instruction BNE corresponding to the normally open contact, and the load instruction LB and the XOR instruction corresponding to the normally closed contact. The conditional jump instruction BNE jumps to the end when the preceding parallel part is true. It can be understood that the form of the OR logic compiler segment is determined by the actual content of the parallel parts included in the OR logic structure data.

[0067] In step S605 of some embodiments, the AND logic compilation process can refer to the process of sequentially compiling each concatenated part for each AND logic structure data, and generating a conditional jump instruction that jumps to the end when any concatenated part is false. The AND logic compilation program segment can refer to the program segment obtained after the AND logic compilation process, which sequentially includes each concatenated part, and jumps to the end when any concatenated part is false. For example, if the AND logic structure data reflects a series arrangement of normally open and normally closed contacts, the AND logic compilation program segment can be a RISC-V32 instruction program segment, including the load instruction LB and the conditional jump instruction BEQ corresponding to the normally open contacts, the load instruction LB and the invert instruction XOR corresponding to the normally closed contacts, and the conditional jump instruction BEQ jumps to the end when any concatenated part is false; or, if there are two AND logic structure data, one reflecting a series arrangement of normally open and normally closed contacts, and the other reflecting a series arrangement of two normally closed contacts, then there can be two AND logic compilation program segments, one of which is a RISC-V32 instruction segment. The program segment uses RISC-V32 instructions, including the load instruction LB and the conditional jump instruction BEQ corresponding to normally open contacts, and the load instruction LB and the invert instruction XOR corresponding to normally closed contacts. The conditional jump instruction BEQ jumps to the end when any concatenated part is false. Another logic compiler segment also uses RISC-V32 instructions, including the load instruction LB, the invert instruction XOR, and the conditional jump instruction BEQ corresponding to normally closed contacts, and the load instruction LB and the invert instruction XOR corresponding to normally closed contacts. The conditional jump instruction BEQ jumps to the end when any concatenated part is false. It can be understood that the form of the logic compiler segment is determined by the actual content of the concatenated parts included in the logic structure data.

[0068] In step S606 of some embodiments, the target compiled file may refer to a file that can be directly executed by a programmable logic controller, which is assembled hierarchically from at least one branch compiler segment, at least one single logic element compiler segment, at least one container compiler segment, at least one OR logic compiler segment, and at least one AND logic compiler segment. It should be noted that the assembly is performed according to the hierarchical structure of the target ladder diagram program. The container compiler segment includes the compilers corresponding to each part of the container structure; the branch compiler segment includes the compilers corresponding to its conditional substructure and branch output substructure; the OR logic compiler segment and the AND logic compiler segment are the compilers corresponding to the parallel and series parts in the conditional substructure; and the single logic element compiler segment is the compiler corresponding to the single logic element constituting each structure. For example, the target compiled file can be a compiled file in which the container compiled program segments sequentially include branch compiled program segments and container compiled program segments. The branch compiled program segments include a load instruction LB representing the conditional result, a conditional jump instruction BEQ, and an output instruction SB corresponding to the coil. The container compiled program segments sequentially include two branch compiled program segments. One branch compiled program segment includes two load instructions LB representing the conditional result, a negation instruction XOR, a conditional jump instruction BEQ, and a function call instruction JAL corresponding to the function block. The other branch compiled program segment includes a load instruction LB representing the conditional result, a conditional jump instruction BEQ, a function call instruction JAL, and a negation instruction XOR. Alternatively, the target compiled file can be a compiled file in which the container compiled program segments sequentially include two branch compiled program segments. One branch compiled program segment includes two load instructions LB representing the conditional result, a negation instruction XOR, a conditional jump instruction BEQ, an output instruction SB corresponding to the coil, and a negation instruction XOR. The other branch compiled program segment includes two load instructions LB representing the conditional result, a negation instruction XOR, a conditional jump instruction BEQ, and a function call instruction JAL corresponding to the function block.

[0069] It is understood that, in this embodiment of the application, container structure partitioning is performed based on the target ladder diagram program to obtain at least one container structure data; logical structure partitioning is performed based on the target ladder diagram program to obtain at least one OR logic structure data and at least one AND logic structure data; container compilation is performed on each container structure data to obtain a container compiler segment; OR logic compilation is performed on each OR logic structure data to obtain an OR logic compiler segment; AND logic compilation is performed on each AND logic structure data to obtain an AND logic compiler segment; and finally, the target compiled file is determined based on at least one branch compiler segment, at least one single logic element compiler segment, at least one container compiler segment, at least one OR logic compiler segment, and at least one AND logic compiler segment. Thus, the embodiments of this application can compile the unconnected parts, parallel parts, and series parts of the target ladder diagram program separately. The unconnected parts are compiled in sequence, the parallel parts skip the subsequent parts when any parallel part is true, and the series parts jump to the end when any series part is false. This reduces the number of invalid parts in the target ladder diagram program being executed, improves the integrity and conciseness of the target compiled file, and further improves the compilation efficiency of the ladder diagram program.

[0070] Please see Figure 7 In some embodiments, step S606 may include, but is not limited to, steps S701 to S704: Step S701: Perform duplicate segment analysis based on at least one branch compiler segment, at least one single logic element compiler segment, at least one container compiler segment, at least one OR logic compiler segment, and at least one AND logic compiler segment to obtain duplicate segment analysis results. Step S702: Perform common program segment analysis based on at least one branch compiler segment, at least one single logic element compiler segment, at least one container compiler segment, at least one OR logic compiler segment, and at least one AND logic compiler segment to obtain the common program segment analysis result. Step S703: Determine the initial target compilation file based on at least one branch compiler segment, at least one single logic element compiler segment, at least one container compiler segment, at least one OR logic compiler segment, and at least one AND logic compiler segment; Step S704: Optimize the initial target compilation file based on the analysis results of repeated program segments and common program segments to obtain the target compilation file.

[0071] In step S701 of some embodiments, duplicate program segment analysis can refer to the process of identifying duplicate program segments in at least one branch compiler segment, at least one single logic element compiler segment, at least one container compiler segment, at least one OR logic compiler segment, and at least one AND logic compiler segment. The result of duplicate program segment analysis can refer to a result reflecting the situation of duplicate program segments. For example, if two container compiler segments are compared, one container compiler segment sequentially includes a load instruction LB corresponding to a normally open contact, an output instruction SB corresponding to a coil, a load instruction LB corresponding to a normally open contact, and a function call instruction JAL corresponding to a function block; the other container compiler segment sequentially includes a load instruction LB corresponding to a normally open contact, a function call instruction JAL corresponding to a function block, a load instruction LB corresponding to a normally closed contact, an XOR instruction, and an output instruction SB corresponding to a coil. Then the result of duplicate program segment analysis is that the load instruction LB corresponding to the normally open contact appears in both container compiler segments. The duplicate program segment analysis result is that the load instruction LB corresponding to the normally open contact appears repeatedly in both the container compiler segment and the logic compiler segment. Alternatively, if we compare the container compiler segment and the logic compiler segment, and the container compiler segment includes, in sequence, the load instruction LB corresponding to the normally open contact, the output instruction SB corresponding to the coil, the load instruction LB corresponding to the normally open contact, and the function call instruction JAL corresponding to the function block, while the logic compiler segment includes the load instruction LB corresponding to the normally open contact and the conditional jump instruction BEQ, and the load instruction LB corresponding to the normally closed contact and the invert instruction XOR, then the duplicate program segment analysis result is that the load instruction LB corresponding to the normally open contact appears repeatedly in both the container compiler segment and the logic compiler segment. It is understandable that the duplicate program segment analysis result includes both cases where duplicate program segments exist and cases where duplicate program segments do not exist.

[0072] In step S702 of some embodiments, common segment analysis can refer to the process of identifying segments that can be shared by multiple compiler segments among at least one branch compiler segment, at least one single logic element compiler segment, at least one container compiler segment, at least one OR logic compiler segment, and at least one AND logic compiler segment. The result of the common segment analysis can refer to a result reflecting the situation of the shareable segments. For example, if two container compiler segments are compared, one segment includes, in sequence, a load instruction LB corresponding to a normally open contact, an output instruction SB corresponding to a coil, another load instruction LB corresponding to a normally open contact, and a function call instruction JAL corresponding to a function block; the other segment includes, in sequence, a load instruction LB corresponding to a normally open contact, a function call instruction JAL corresponding to a function block, a load instruction LB corresponding to a normally closed contact, an XOR instruction, and an output instruction SB corresponding to a coil. If there is an overlap in the load instruction segment corresponding to the normally open contact, then the common segment analysis result is that the load instruction segment corresponding to the normally open contact can be shared by both container compiler segments. Alternatively, if the two container compiler segments are compared and there is an overlap in the function call instruction segment corresponding to the function block, then the common segment analysis result is that the function call instruction segment corresponding to the function block can be shared by both container compiler segments. It is understandable that the common segment analysis result includes both cases where it can be shared and cases where it cannot be shared.

[0073] In step S703 of some embodiments, the initial target compilation file may refer to at least one branch compiler segment, at least one single logic element compiler segment, at least one container compiler segment, at least one OR logic compiler segment, and at least one file assembled with logic compiler segments according to structural hierarchy. For example, the initial target compilation file can be a file containing container compilation segments in sequence, including branch compilation segments and container compilation segments. The branch compilation segments include a load instruction LB representing a conditional result, a conditional jump instruction BEQ, and an output instruction SB corresponding to a coil. The container compilation segments in sequence include two branch compilation segments. One branch compilation segment includes two load instructions LB representing a conditional result, a negation instruction XOR, a conditional jump instruction BEQ, and a function call instruction JAL corresponding to a function block. The other branch compilation segment includes a load instruction LB representing a conditional result, a conditional jump instruction BEQ, a function call instruction JAL, and a negation instruction XOR. Alternatively, the initial target compilation file can be a file containing container compilation segments in sequence, including two branch compilation segments. One branch compilation segment includes two load instructions LB representing a conditional result, a negation instruction XOR, a conditional jump instruction BEQ, an output instruction SB corresponding to a coil, and a negation instruction XOR. The other branch compilation segment includes two load instructions LB representing a conditional result, a negation instruction XOR, a conditional jump instruction BEQ, and a function call instruction JAL corresponding to a function block.

[0074] In step S704 of some embodiments, program optimization can refer to the process of replacing repetitive and publicly available program segments in the initial target compiled file with publicly available program segments based on the results of repetitive program segment analysis and public program segment analysis. The target compiled file can refer to the file obtained after program optimization, which can be directly executed by the programmable logic controller. For example, if the repetitive program segment analysis result shows that the load instruction segment corresponding to the normally open contact appears repeatedly in the container compiled program segment of the initial target compiled file, and the public program segment analysis result shows that the load instruction segment corresponding to the normally open contact can be publicly available, then program optimization replaces two repetitive load instruction segments with one publicly available load instruction segment. The resulting target compiled file includes, in sequence, a load instruction LB corresponding to the normally open contact, an output instruction SB corresponding to the coil, a function call instruction JAL corresponding to the function block, a load instruction LB corresponding to the normally closed contact, an XOR instruction, and a AND instruction. The output instruction SB corresponds to the coil; or, if the analysis result of the repeated program segment is that the function call instruction segment corresponding to the function block appears repeatedly in the container compiler segment of the initial target compiled file, and the analysis result of the common program segment is that the function call instruction segment corresponding to the function block can be shared, then the program optimization replaces the two repeated function call instruction segments with one common function call instruction segment. The container compiler segment included in the resulting target compiled file includes, in order, the load instruction LB corresponding to the normally open contact, the load instruction LB corresponding to the normally closed contact, the invert instruction XOR, and the output instruction SB corresponding to the coil. It can be understood that the program optimization replaces repeated program segments that can be shared with a common program segment, and retains the original program segments that are not repeated or repeated but cannot be shared.

[0075] It is understood that, in this embodiment of the application, duplicate program segment analysis is performed based on at least one branch compiler segment, at least one single logical element compiler segment, at least one container compiler segment, at least one OR logic compiler segment, and at least one AND logic compiler segment to obtain duplicate program segment analysis results; common program segment analysis is performed based on at least one branch compiler segment, at least one single logical element compiler segment, at least one container compiler segment, at least one OR logic compiler segment, and at least one AND logic compiler segment to obtain common program segment analysis results; an initial target compiled file is determined based on at least one branch compiler segment, at least one single logical element compiler segment, at least one container compiler segment, at least one OR logic compiler segment, and at least one AND logic compiler segment; and the initial target compiled file is optimized based on the duplicate program segment analysis results and the common program segment analysis results to obtain the target compiled file. Thus, the embodiments of this application can first identify recurring program segments in various types of compiled program segments through repeated program segment analysis, and then confirm the common parts in the repeated program segments through common program segment analysis. In this way, the program can be optimized to replace the repeated program segments with common program segments, reduce the size of the repeated code in the target compiled file, reduce the overhead of executing the repeated code, improve the conciseness of the target compiled file, and further improve the compilation efficiency of ladder diagram programs.

[0076] It should be noted that if the compiled program segments obtained from the above compilation process include not only true instructions but also pseudo instructions, the pseudo instructions can be converted into true instructions first and then assembled to obtain the initial target compiled file. Then, based on the analysis results of repeated program segments and common program segments, the initial target compiled file is optimized to obtain a target compiled file that can be directly run by the programmable logic controller. Here, true instructions can refer to instructions whose operands have been mapped to their final form, while pseudo instructions can refer to instructions whose operands have not yet been mapped to their final form.

[0077] Please see Figure 8 This application also provides a ladder diagram program compilation system that can implement the above-described ladder diagram program compilation method. The system includes: Acquisition unit 801 is used to acquire the target ladder diagram program; Branching unit 802 is used to perform branch structure partitioning processing according to the target ladder diagram program to obtain at least one branch structure data. The element partitioning unit 803 is used to perform single logical element structure partitioning processing based on at least one branch structure data to obtain at least one single logical element structure data. Branch compilation unit 804 is used to perform branch compilation processing on each branch structure data to obtain the branch compilation program segment. The element compilation unit 805 is used to perform single logic element compilation processing based on at least one single logic element structure data to obtain at least one single logic element compiler segment. Determining unit 806 is used to determine the target compiled file based on at least one branch compiler segment and at least one single logic element compiler segment.

[0078] The specific implementation of this ladder diagram program compilation system is basically the same as the specific implementation of the ladder diagram program compilation method described above, and will not be repeated here.

[0079] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the ladder diagram program compilation method described above. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.

[0080] Please see Figure 9 , Figure 9 The hardware structure of an electronic device according to another embodiment is illustrated. The electronic device includes: The processor 901 can be implemented using a general-purpose central processing unit (CPU), microprocessor, application specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application. The memory 902 can be implemented as a read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 902 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 902 and is called and executed by the processor 901 using the ladder diagram program compilation method of the embodiments of this application. The 903 input / output interface is used to implement information input and output. The communication interface 904 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.). Bus 905 transmits information between various components of the device (e.g., processor 901, memory 902, input / output interface 903, and communication interface 904); The processor 901, memory 902, input / output interface 903, and communication interface 904 are connected to each other within the device via bus 905.

[0081] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described ladder diagram program compilation method.

[0082] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0083] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.

[0084] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.

[0085] The system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0086] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.

[0087] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification 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.

[0088] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

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

[0090] The units described above 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 network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0091] 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.

[0092] 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 the prior art, 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 multiple 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 of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0093] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.

Claims

1. A ladder diagram program compilation method, characterized in that, The method includes: Program to obtain the target ladder diagram; The target ladder diagram program is subjected to branch structure partitioning to obtain at least one branch structure data; the branch structure partitioning process refers to the process of dividing the part of the target ladder diagram program that drives at least one output with a condition according to the logical relationship represented by the graphical elements in the target ladder diagram program; the branch structure data refers to data that reflects the driving relationship of a condition on at least one output. Based on at least one of the branch structure data, a single logical element structure partitioning process is performed to obtain at least one single logical element structure data; the single logical element structure partitioning process refers to the process of dividing the graphic elements included in at least one of the branch structure data according to the logical relationship represented by the graphic elements in at least one of the branch structure data; the single logical element structure data refers to data that reflects the logical relationship represented by a single graphic element. For each branch structure data, branch compilation processing is performed based on the branch structure data to obtain a branch compilation program segment; the branch compilation processing refers to the process of converting the driving relationship represented by the branch structure data into a program segment form for each branch structure data; the branch compilation program segment refers to a program segment that reflects the driving relationship represented by the branch structure data. Based on at least one of the single logical element structure data, single logical element compilation processing is performed to obtain at least one single logical element compiled program segment; the single logical element compilation processing refers to the process of converting the logical relationship represented by at least one of the single logical element structure data into the form of a program segment based on at least one of the single logical element structure data; the single logical element compiled program segment refers to a program segment that reflects the logical relationship represented by a single graphical element; The target compiled file is determined based on at least one of the branch compiler segments and at least one of the single logic element compiler segments.

2. The method according to claim 1, characterized in that, The branch structure data includes a conditional substructure and a branch output substructure. For each branch structure data, branch compilation processing is performed based on the branch structure data to obtain a branch compilation program segment, including: For each branch structure data, conditional compilation processing is performed according to the conditional substructure to obtain a conditional compilation subroutine segment; Execution verification is performed based on the branch output substructure to obtain the execution verification result; In response to the executable verification result not meeting the preset executable segment verification conditions, a total jump compilation process is performed based on the branch output substructure to obtain a total jump compilation subroutine segment; The branch compiler segment is determined based on the conditional compiler subroutine segment and the global jump compiler subroutine segment.

3. The method according to claim 2, characterized in that, The step of performing branch compilation processing based on the branch structure data for each of the branch structure data to obtain a branch compilation program segment further includes: In response to the executability verification result satisfying the preset executable segment verification conditions, the skip sequence and execution sequence are determined from the branch structure data; Perform local jump compilation processing based on the skip sequence to obtain a local jump compilation subroutine segment; The execution sequence is used to perform compilation processing to obtain the executable compilation subroutine segment; The branch compiler segment is determined based on the conditional compiler subroutine segment, the local jump compiler subroutine segment, and the execution compiler subroutine segment.

4. The method according to claim 1, characterized in that, At least one of the single logic element structure data includes translated single logic elements and edge-type single logic elements. The step of performing single logic element compilation processing based on at least one of the single logic element structure data to obtain at least one single logic element compiler segment includes: Based on the single logical element of the translation class, a translation and compilation process is performed to obtain the translation and compilation program segment; Based on the edge-type single logic element, the on / off state change analysis is performed to obtain the on / off state change analysis results; Based on the analysis results of the on / off state changes and the edge-type single logic element, edge compilation processing is performed to obtain the edge-compiled program segment; The literal translation compiler segment and the edge-translated compiler segment are determined to be at least one single-logic-element compiler segment.

5. The method according to claim 4, characterized in that, At least one of the single-logic element structure data further includes a comparison-type single-logic element, and determining the translated compiler segment and the edge-triggered compiler segment as at least one single-logic element compiler segment includes: Based on the single logical element of the comparison class, a comparison logical adaptation is performed to obtain the comparison logical adaptation result; Based on the comparison logic adaptation result, a comparison compilation process is performed to obtain a comparison compilation program segment; The direct translation compiler segment, the edge compiler segment, and the comparison compiler segment are determined to be at least one single-logic-element compiler segment.

6. The method according to claim 1, characterized in that, Determining the target compiled file based on at least one of the branch compiler segments and at least one of the single logical element compiler segments includes: The container structure is divided according to the target ladder diagram program to obtain at least one container structure data. The target ladder diagram program is used to perform logical structure partitioning to obtain at least one OR logical structure data and at least one AND logical structure data. For each of the container structure data, container compilation processing is performed based on the container structure data to obtain a container compilation program segment; For each of the OR logic structure data, OR logic compilation processing is performed based on the OR logic structure data to obtain an OR logic compiler segment; For each of the AND logic structure data, AND logic compilation processing is performed based on the AND logic structure data to obtain an AND logic compiler segment; The target compiled file is determined based on at least one of the branch compiler segments, at least one of the single logic element compiler segments, at least one of the container compiler segments, at least one of the OR logic compiler segments, and at least one of the AND logic compiler segments.

7. The method according to claim 6, characterized in that, The step of determining the target compiled file based on at least one of the branch compiler segments, at least one of the single logic element compiler segments, at least one of the container compiler segments, at least one of the OR logic compiler segments, and at least one of the AND logic compiler segments includes: Based on at least one branch compiler segment, at least one single logic element compiler segment, at least one container compiler segment, at least one OR logic compiler segment, and at least one AND logic compiler segment, duplicate program segment analysis is performed to obtain duplicate program segment analysis results; Common segment analysis is performed based on at least one of the branch compiler segments, at least one of the single logic element compiler segments, at least one of the container compiler segments, at least one of the OR logic compiler segments, and at least one of the AND logic compiler segments to obtain common segment analysis results; The initial target compiled file is determined based on at least one of the branch compiler segments, at least one of the single logic element compiler segments, at least one of the container compiler segments, at least one of the OR logic compiler segments, and at least one of the AND logic compiler segments. Based on the analysis results of the repeated program segments and the analysis results of the common program segments, the initial target compilation file is optimized to obtain the target compilation file.

8. A ladder diagram program compilation system, characterized in that, The system includes: The acquisition unit is used to acquire the target ladder diagram program; A branching unit is used to perform branch structure division processing according to the target ladder diagram program to obtain at least one branch structure data; the branch structure division processing refers to the process of dividing the part of the target ladder diagram program that drives at least one output with a condition according to the logical relationship represented by the graphical elements in the target ladder diagram program; the branch structure data refers to data reflecting the driving relationship of a condition on at least one output; An element partitioning unit is used to perform single logical element structure partitioning processing based on at least one branch structure data to obtain at least one single logical element structure data; the single logical element structure partitioning processing refers to the process of partitioning the graphic elements included in at least one branch structure data according to the logical relationship represented by the graphic elements in at least one branch structure data; the single logical element structure data refers to data reflecting the logical relationship represented by a single graphic element. A branch compilation unit is used to perform branch compilation processing on each branch structure data to obtain a branch compilation program segment; the branch compilation processing refers to the process of converting the driving relationship represented by the branch structure data into a program segment form for each branch structure data; the branch compilation program segment refers to a program segment that reflects the driving relationship represented by the branch structure data. An element compilation unit is used to perform single-logical element compilation processing based on at least one single-logical element structure data to obtain at least one single-logical element compiled program segment; the single-logical element compilation processing refers to the process of converting the logical relationship represented by at least one single-logical element structure data into a program segment form based on at least one single-logical element structure data; the single-logical element compiled program segment refers to a program segment that reflects the logical relationship represented by a single graphic element. A determining unit is used to determine a target compiled file based on at least one said branch compiler segment and at least one said single logic element compiler segment.

9. An electronic device, characterized in that, The electronic device includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the ladder diagram program compilation method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the ladder diagram program compilation method according to any one of claims 1 to 7.