Breakpoint setting method and breakpoint debugging method and device based on ladder diagram

By converting ladder diagrams into structured text code in PLC programming and establishing the correspondence between logical elements and logical rows, the problem of inflexible breakpoint settings in ladder diagrams is solved, enabling flexible breakpoint settings and efficient debugging.

CN120972753APending Publication Date: 2025-11-18HANGZHOU HIKROBOT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511114218.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-08
Publication Date
2025-11-18

AI Technical Summary

Technical Problem

Existing PLC programming software has limited support for breakpoint functionality in ladder diagrams, making it difficult to flexibly set breakpoints and thus hindering the rapid location of logic errors.

Method used

By converting ladder diagrams into structured text code, a correspondence between logical elements and logical rows is established, allowing users to flexibly set breakpoints and add breakpoints before logical rows.

Benefits of technology

It enables flexible setting of breakpoints in ladder diagrams, improves the accuracy and efficiency of breakpoint debugging, reduces debugging time, and enhances the convenience of program error location.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120972753A_ABST
    Figure CN120972753A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a breakpoint setting method and device and a breakpoint debugging method and device based on a ladder diagram, and relates to the technical field of programmable logic controllers. The method comprises the steps of displaying a first ladder diagram, obtaining a first structured text code, and determining logic elements capable of setting breakpoints in the displayed first ladder diagram as first logic elements; in response to a breakpoint adding instruction aiming at any first logic element, determining a logic line corresponding to the first logic element aiming at the breakpoint adding instruction as a first logic line based on a preset corresponding relationship between the logic line in the first structured text code and the logic element in the first ladder diagram; a breakpoint is added before the first logic row. According to the embodiment of the invention, a user can add the breakpoint in front of the logic row corresponding to the first logic element needing to add the breakpoint according to own requirements, and flexible setting of the breakpoint of the ladder diagram is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of programmable logic controller technology, and in particular to a method and apparatus for setting and debugging breakpoints based on ladder diagrams. Background Technology

[0002] Ladder diagrams (LD) are a widely used graphical programming language in PLC (Programmable Logic Controller) programming. They use electrical graphical symbols to represent control logic. Programs programmed using ladder diagrams may exhibit logical errors and other abnormal behaviors during execution. Therefore, breakpoints are necessary. Developers can pause program execution at specific points to examine variable values, the call stack, memory status, and other information to quickly locate errors. However, most current PLC programming software offers limited support for ladder diagram breakpoint functionality, preventing flexible breakpoint settings. Summary of the Invention

[0003] The purpose of this application is to provide a method and apparatus for setting and debugging breakpoints based on ladder diagrams, so as to achieve flexible setting of breakpoints in ladder diagrams. The specific technical solution is as follows:

[0004] A first aspect of this application provides a breakpoint setting method based on a ladder diagram, the method comprising:

[0005] Display a first trapezoidal diagram and obtain a first structured text code, wherein the first structured text code is obtained by converting the first trapezoidal diagram into structured text code;

[0006] Determine the logic elements in the first ladder diagram that can be set with breakpoints, and use them as the first logic elements;

[0007] In response to a breakpoint addition instruction for any of the first logical elements, based on a pre-set correspondence between logical lines in the first structured text code and logical elements in the first ladder diagram, the logical line corresponding to the first logical element targeted by the breakpoint addition instruction is determined as the first logical line.

[0008] Add a breakpoint before the first line of logic.

[0009] In one possible implementation, the logic elements in the first ladder diagram that can be set with breakpoints, as the first logic elements, include:

[0010] In the first structured text, identify the logical lines where breakpoints can be set, and use them as the second logical lines;

[0011] Based on the pre-set correspondence between the logical lines in the first structured text code and the logical elements in the first ladder diagram, the logical element corresponding to the second logical line is determined as the first logical element.

[0012] In one possible implementation, the method further includes:

[0013] In response to a selection instruction for a second logical element in the first ladder diagram, if the second logical element is the first logical element, then the first control is displayed in the first display interface in a first form.

[0014] The response to a breakpoint addition instruction for any of the first logical elements, based on a pre-set correspondence between logical lines in the first structured text code and logical elements in the first ladder diagram, determines the logical line corresponding to the first logical element targeted by the breakpoint addition instruction as the first logical line, including:

[0015] In response to an interaction instruction for the first control of the first form, based on the pre-set correspondence between the logical lines in the first structured text code and the logical elements in the first ladder diagram, the logical line corresponding to the second logical element is determined as the first logical line.

[0016] In one possible implementation, the method further includes:

[0017] In response to a selection instruction for a second logical element in the first ladder diagram, if the second logical element is not the first logical element, the first control is displayed in a second form in the first display interface, wherein the first control in the second form is in a non-interactive state.

[0018] In one possible implementation, the method further includes:

[0019] Identify the logical lines in the first structured text that already have breakpoints set as the third logical lines;

[0020] Based on the pre-set correspondence between the logical lines in the first structured text code and the logical elements in the first ladder diagram, the logical element corresponding to the third logical line is determined as the third logical element.

[0021] In response to a selection instruction for a second logical element in the first ladder diagram, if the second logical element is the third logical element, the first control is displayed in a third form in the first display interface.

[0022] In response to the interaction instruction for the first control of the third form, based on the pre-set correspondence between the logical lines in the first structured text code and the logical elements in the first ladder diagram, the logical line corresponding to the second logical element is determined as the fourth logical line;

[0023] Delete the breakpoint set on the fourth logical line in the first structured text code.

[0024] In one possible implementation, after adding a breakpoint before the first logical line, the method further includes:

[0025] Each of the breakpoints is identified in the first ladder diagram shown.

[0026] A second aspect of this application provides a breakpoint debugging method based on ladder diagrams, the method comprising:

[0027] Obtain the first structured text code with breakpoints added based on any of the ladder diagram breakpoint setting methods described in the first aspect above;

[0028] The program executes each logical line in the first structured text sequentially until it reaches a breakpoint that meets the preset interruption condition, at which point it will be interrupted.

[0029] In one possible implementation, the interruption until a breakpoint satisfying a preset interruption condition is reached includes:

[0030] The program will terminate when it reaches a breakpoint of the first preset type; or,

[0031] The program will terminate when it reaches a breakpoint of the second preset type and the conditions set for the breakpoint of the second preset type are met.

[0032] In one possible implementation, the method further includes:

[0033] Determine the logical element to which the program was executed when the interruption occurred, and designate it as the fourth logical element;

[0034] The first ladder diagram is displayed, and each of the fourth logic elements in the displayed first ladder diagram is identified in a first style.

[0035] In one possible implementation, the method further includes:

[0036] Identify the logical element that was already running at the time of the interruption and designate it as the fifth logical element;

[0037] In the second display interface, each of the fifth logical elements is identified in a second style.

[0038] In one possible implementation, the method further includes:

[0039] The next running path is predicted based on the values ​​of each variable at the time of interruption, and the logical elements on the next running path are taken as the sixth logical element.

[0040] In the second display interface, each of the sixth logical elements is identified using a third style.

[0041] In one possible implementation, the method further includes:

[0042] The values ​​of each variable at the time of the interruption are displayed in the second display interface.

[0043] A third aspect of this application provides a breakpoint setting device based on a ladder diagram, the device comprising:

[0044] A ladder diagram display module is used to display a first ladder diagram and obtain a first structured text code, wherein the first structured text code is obtained by converting the first ladder diagram into structured text code;

[0045] The logic element determination module is used to determine each logic element in the first ladder diagram that can be set with breakpoints, and to use it as the first logic element.

[0046] The logic line determination module is used to respond to a breakpoint addition instruction for any of the first logic elements, and determine the logic line corresponding to the first logic element targeted by the breakpoint addition instruction as the first logic line based on the pre-set correspondence between the logic lines in the first structured text code and the logic elements in the first ladder diagram.

[0047] The breakpoint addition module is used to add a breakpoint before the first logical line.

[0048] In one possible implementation, the device includes an editor and a compiler, the editor including a ladder diagram display module and a breakpoint addition module, and the compiler including a logic element determination module and a logic row determination module.

[0049] In one possible implementation, the logical element determination module is specifically used for:

[0050] In the first structured text, identify the logical lines where breakpoints can be set, and use them as the second logical lines;

[0051] Based on the pre-set correspondence between the logical lines in the first structured text code and the logical elements in the first ladder diagram, the logical element corresponding to the second logical line is determined as the first logical element.

[0052] In one possible implementation, the device further includes:

[0053] The first display module is configured to respond to a selection instruction for a second logical element in the first ladder diagram. If the second logical element is the first logical element, the first control is displayed in a first form in the first display interface, wherein the first display interface is an interface for displaying the first ladder diagram.

[0054] The logic row determination module is specifically used to respond to the interaction instruction for the first control of the first form, and determine the logic row corresponding to the second logic element as the first logic row based on the pre-set correspondence between the logic rows in the first structured text code and the logic elements in the first ladder diagram.

[0055] In one possible implementation, the device further includes:

[0056] The second display module is used to respond to a selection instruction for a second logical element in the first ladder diagram. If the second logical element is not the first logical element, the first control is displayed in the first display interface in a second form, wherein the first control in the second form is in a non-interactive state.

[0057] In one possible implementation, the device further includes:

[0058] The first determining module is used to determine the logical lines in the first structured text that have already been set with breakpoints, and use them as the third logical lines;

[0059] The second determining module is used to determine the logical element corresponding to the third logical line as the third logical element based on the pre-set correspondence between the logical lines in the first structured text code and the logical elements in the first ladder diagram.

[0060] The third display module is used to respond to the selection instruction for the second logical element in the first ladder diagram. If the second logical element is the third logical element, the first control is displayed in the first display interface in a third form.

[0061] The third determining module is used to respond to the interaction instruction of the first control in the third form, and determine the logical row corresponding to the second logical element as the fourth logical row based on the pre-set correspondence between the logical rows in the first structured text code and the logical elements in the first ladder diagram;

[0062] The breakpoint deletion module is used to delete the breakpoint set on the fourth logical line in the first structured text code.

[0063] In one possible implementation, the device further includes:

[0064] The breakpoint identification module is used to identify each breakpoint in the displayed first ladder diagram after adding a breakpoint before the first logic line.

[0065] A fourth aspect of this application provides a breakpoint debugging device based on a ladder diagram, the device comprising:

[0066] The acquisition module is used to acquire the first structured text code with breakpoints added based on the ladder diagram breakpoint setting method described in the first aspect;

[0067] The execution module is used to sequentially run each logical line in the first structured text until it reaches a breakpoint that meets the preset interruption conditions and then interrupts.

[0068] In one possible implementation, the interruption until a breakpoint satisfying a preset interruption condition is reached includes:

[0069] The program will terminate when it reaches a breakpoint of the first preset type; or,

[0070] The program will terminate when it reaches a breakpoint of the second preset type and the conditions set for the breakpoint of the second preset type are met.

[0071] In one possible implementation, the device further includes:

[0072] The fourth determining module is used to determine the logical element that was executed when the interruption occurred, and it serves as the fourth logical element.

[0073] The display module is used to display the first ladder diagram and identify each of the fourth logical elements in the displayed first ladder diagram using a first style.

[0074] In one possible implementation, the device further includes:

[0075] The fifth determination module is used to determine the logical element that has already been running at the time of the interruption, and to designate it as the fifth logical element.

[0076] The first identification module is used to identify each of the fifth logical elements in the first ladder diagram shown in a second style.

[0077] In one possible implementation, the device further includes:

[0078] The path prediction module is used to predict the next running path based on the values ​​of each variable when the interruption occurs, and to use the logical elements on the next running path as the sixth logical element.

[0079] The second identification module is used to identify each of the sixth logical elements in the first ladder diagram shown in a third style.

[0080] In one possible implementation, the device further includes:

[0081] The variable value display module is used to display the variable values ​​of each variable when the first ladder diagram is interrupted.

[0082] This application also provides an electronic device, including:

[0083] Memory, used to store computer programs;

[0084] When a processor executes a program stored in memory, it implements any of the ladder diagram breakpoint setting methods or ladder diagram-based breakpoint debugging methods described above.

[0085] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements any of the ladder diagram breakpoint setting methods or ladder diagram-based breakpoint debugging methods described above.

[0086] This application also provides a computer program product containing instructions that, when run on a computer, cause the computer to execute any of the ladder diagram breakpoint setting methods or ladder diagram-based breakpoint debugging methods described above.

[0087] Beneficial effects of the embodiments in this application:

[0088] This application provides a method and apparatus for setting and debugging breakpoints based on ladder diagrams. Since a pre-defined correspondence between logical lines in a first structured text code and logical elements in a first ladder diagram is established, after determining each first logical element in the first ladder diagram that can be used to set breakpoints, in response to a breakpoint addition instruction for any first logical element, the first logical line corresponding to the first logical element targeted by the breakpoint addition instruction can be determined according to this correspondence, and a breakpoint can be added before the first logical line. Because the first logical element in this application is a breakpoint-configurable logical element, and the correspondence between logical elements and logical lines is pre-defined, users can add breakpoints before the logical line corresponding to the first logical element to which breakpoints need to be added, thus achieving flexible setting of breakpoints in the ladder diagram.

[0089] Of course, implementing any product or method of this application does not necessarily require achieving all of the advantages described above at the same time. Attached Figure Description

[0090] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other embodiments can be obtained based on these drawings.

[0091] Figure 1 A first schematic diagram of a ladder diagram-based breakpoint setting method provided in an embodiment of this application;

[0092] Figure 2 An example diagram of the first ladder diagram provided in the embodiments of this application;

[0093] Figure 3 Example diagram of a first ladder diagram with added breakpoints provided for embodiments of this application;

[0094] Figure 4 To be Figure 3 An example diagram of the first structured text obtained by transforming the first trapezoidal diagram in the image;

[0095] Figure 5 A second schematic diagram of the breakpoint setting method based on ladder diagram provided in the embodiments of this application;

[0096] Figure 6 A third schematic diagram of the breakpoint setting method based on ladder diagram provided in the embodiments of this application;

[0097] Figure 7 A fourth schematic diagram of the breakpoint setting method based on ladder diagram provided in the embodiments of this application;

[0098] Figure 8 A fifth schematic diagram of the breakpoint setting method based on ladder diagram provided in the embodiments of this application;

[0099] Figure 9 A schematic diagram of a ladder diagram-based breakpoint debugging method provided in an embodiment of this application;

[0100] Figure 10 Example diagram of LD code in debug state provided in the embodiments of this application;

[0101] Figure 11 The figure shown is an example diagram of breakpoint debugging provided in an embodiment of this application;

[0102] Figure 12 An interaction diagram illustrating the ladder diagram-based breakpoint setting method provided in this application embodiment;

[0103] Figure 13 A schematic diagram of the structure of the ladder diagram-based breakpoint setting device provided in the embodiments of this application;

[0104] Figure 14 A schematic diagram of the breakpoint debugging device based on a ladder diagram provided in an embodiment of this application;

[0105] Figure 15 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0106] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art based on this application are within the scope of protection of this application.

[0107] First, the technical terms used in the embodiments of this application will be explained:

[0108] PLC (Programmable Logic Controller): A digital computing controller with a microprocessor for automation control, capable of loading control instructions into memory for storage and execution at any time.

[0109] LD (Ladder Diagram): A graphical symbol-based programming language that uses electrical graphical symbols to represent control logic.

[0110] ST (Structured Text): A high-level text-based programming language for PLCs, which can be used for complex algorithms and data operations to achieve complex computational control.

[0111] Logic elements: The main elements of an LD include power rails, contacts (normally open, normally closed, rising edge, falling edge), coils (output, hold, reset), function blocks (timing, comparison, counting, arithmetic, etc.), variables, or values. While contacts, coils, and function blocks have different functions and locations within an LD, they are all units that execute logic. Therefore, in this application, contacts, coils, and function blocks are collectively referred to as logic elements.

[0112] In LD programming, energy flow is typically used to visualize current flow, showing which contacts and coils are active, helping users understand the program's execution flow. While users can see these states using an LD compiler, they cannot set breakpoints for line-by-line debugging like in high-level programming languages.

[0113] To enable flexible setting of breakpoints in ladder diagrams, a first aspect of this application provides a method for setting breakpoints based on ladder diagrams, applicable to electronic devices. For example... Figure 1 The diagram shown is a first embodiment of the breakpoint setting method based on ladder diagrams provided in this application. The method includes the following steps:

[0114] Step S10: Display the first trapezoidal diagram and obtain the first structured text code;

[0115] The first structured text code is obtained by converting the first trapezoidal diagram into structured text code;

[0116] Step S20: Determine each logical element in the first ladder diagram that can be set with breakpoints, and use it as the first logical element;

[0117] Step S30: In response to a breakpoint addition instruction for any first logical element, based on the pre-set correspondence between logical lines in the first structured text code and logical elements in the first ladder diagram, determine the logical line corresponding to the first logical element targeted by the breakpoint addition instruction, and use it as the first logical line.

[0118] Step S40: Add a breakpoint before the first logical line.

[0119] In this embodiment, since a pre-defined correspondence exists between logical lines in the first structured text code and logical elements in the first ladder diagram, after determining each first logical element in the first ladder diagram that can be set with breakpoints, in response to a breakpoint addition instruction for any first logical element, the first logical line corresponding to the first logical element targeted by the breakpoint addition instruction can be determined based on this correspondence, and a breakpoint can be added before the first logical line. Because the first logical element in this application is a breakpoint-settable logical element, and the pre-defined correspondence between logical elements and logical lines exists, users can add breakpoints before the logical line corresponding to the first logical element to which breakpoints need to be added, thus achieving flexible setting of breakpoints in the ladder diagram.

[0120] The following is a detailed explanation of steps S10 to S40:

[0121] In step S10 above, the first ladder diagram refers to the code obtained using LD encoding, such as... Figure 2 The diagram shown is an example of a first ladder diagram provided in an embodiment of this application. For ease of description, the ladder diagram will be referred to as LD code, and the first ladder diagram will be referred to as the first LD code. Figure 2 The logic elements in dashed boxes 1, 2, 4, 6, and 8 are logic contacts; the logic elements in dashed boxes 3, 7, and 9 are logic coils; and the logic element in dashed box 5 is a logic operation block. The logic operation block displays the values ​​of each variable.

[0122] The first structured text is obtained by converting the first ladder diagram. For ease of description, the structured text will be referred to as ST code, and the first structured text will be referred to as the first ST code. The first ST code can be manually written based on the first LD code, or it can be obtained by using the automatic conversion function of an automated tool to convert the LD code into ST code, or it can be obtained in other ways. This application does not limit this.

[0123] like Figure 2 As shown, there are multiple logical elements in the LD code. It is understandable that not every logical element can be set as a breakpoint.

[0124] In step S20 above, the logic elements for which breakpoints can be set are determined based on the type of each logic element and user requirements. For example, normally open contacts, normally closed contacts, output coils, timers, and other logic elements cannot be set as breakpoints.

[0125] When determining the logical elements for which breakpoints can be set, they can be directly determined based on the type of each logical element in the displayed first LD code. For example, if the user identifies the type of each logical element during the writing of the first LD code, the element identifier of the logical element for which breakpoints can be set can be directly output based on the type of each logical element in the first LD code. Alternatively, the logical elements for which breakpoints can be set can be determined by combining the first LD code and the first ST code. In this embodiment, the specific process of determining the logical elements for which breakpoints can be set is detailed below and will not be repeated here.

[0126] The logic elements in the first ladder diagram that can be set with breakpoints can be identified either by directly marking the logic elements that can be set with breakpoints in the first ladder diagram or by identifying the element identifiers of the logic elements that can be set with breakpoints. Both are acceptable.

[0127] The breakpoint addition command in step S30 above can be issued by the user by clicking a control in the interface that displays the first ladder diagram, or it can be issued by the user via a shortcut key; the breakpoint addition command can be used to indicate the first logical element to which the user wants to set a breakpoint, or it can be used to indicate to display all the first logical elements to which breakpoints can be set.

[0128] In the case where step S20 above directly identifies each logical element for which breakpoints can be set in the first ladder diagram, the user can select a first logical element and then issue a breakpoint addition command by clicking a control in the interface displaying the first ladder diagram or by using a shortcut key. At this time, the breakpoint addition command is used to indicate the first logical element for which the user wants to set a breakpoint.

[0129] In the case where step S20 above determines the element identifier of each logical element for which breakpoints can be set, the user can click on a control in the interface displaying the first ladder diagram or issue a breakpoint addition command via a shortcut key, so that each first logical element can be displayed in the first ladder diagram.

[0130] Understandably, when a breakpoint addition instruction is used to instruct the user to view all first logical elements for which breakpoints can be set, the user can select the first logical element for which a breakpoint is to be set from all the first logical elements for which breakpoints can be set, and use it as the first logical element targeted by the breakpoint addition instruction.

[0131] During the process of converting LD code to ST code, a correspondence between each logical element in the LD code and each logical line in the ST code can be established. Therefore, in step S30 above, after determining the first logical element targeted by the breakpoint addition instruction, the first logical line corresponding to the first logical element can be determined based on this correspondence.

[0132] Understandably, in LD code, breakpoints are set before the logical element to which breakpoints can be set. Correspondingly, in ST code, breakpoints are also set before the logical line corresponding to the first logical element to which breakpoints can be set.

[0133] For example, such as Figure 3 The image shown is an example diagram of a first ladder diagram with added breakpoints provided in an embodiment of this application. Figure 4 The image shows the... Figure 3 Example diagram of the first structured text obtained by transforming the first trapezoidal diagram in the image. If the user is in Figure 3 Set a breakpoint before the first logical element in the dashed box 1 above, that is, the first logical element in step S30 above is Figure 3 The logical element in the dashed box 3 determines the logical behavior of the first logical element in the first ST code. Figure 4 Line 13, i.e. Figure 4 The line of logic indicated by the dashed box is the first line of logic in step S30 above. Therefore, a breakpoint is set before line 13 of the first ST code. This is understandable. Figure 4 Codes 1-16 in the code represent a logical row.

[0134] To avoid missing breakpoints at critical locations and improve breakpoint debugging efficiency, in one possible implementation, after step S40 above, each breakpoint that has been set can also be identified in the first LD code. This allows users to quickly locate the set breakpoints, avoid duplicate setting or omission of breakpoints at critical locations, and allow users to clearly understand the breakpoint distribution, optimize breakpoint debugging strategies, and thus improve breakpoint debugging efficiency.

[0135] In step S40 above, when adding breakpoints before the first logical line, the breakpoint types set before different first logical lines can be the same or different. Breakpoint types include, but are not limited to, ordinary breakpoints, conditional breakpoints, data breakpoints, function breakpoints, etc. Users can set breakpoints reasonably before the first logical line according to their own needs and code logic.

[0136] The process of determining the logical elements for which breakpoints can be set by combining the first LD code and the first ST code is explained below:

[0137] As can be seen from the above, in the process of converting the first LD code into the first ST code, a correspondence is established between each logical element in the LD code and each logical line in the ST code. Therefore, in one possible implementation, the logical elements for which breakpoints can be set can be determined based on this correspondence.

[0138] like Figure 5 The diagram shown is a second illustration of a breakpoint setting method based on a ladder diagram provided in this application. Step S20 includes the following steps:

[0139] Step S201: Determine the logical lines in the first structured text where breakpoints can be set, and use them as the second logical lines;

[0140] In ST code, the logic lines for which breakpoints can be set are determined by the type of each logic line. For example, variable assignment lines, conditional statements, loop control lines, critical algorithm lines, and error handling lines are logic lines for which breakpoints can be set.

[0141] Step S202: Based on the pre-set correspondence between logical lines in the first structured text code and logical elements in the first ladder diagram, determine the logical element corresponding to the second logical line as the first logical element.

[0142] After identifying the logic lines in the first ST code where breakpoints can be set, the logic elements corresponding to the second logic line can be determined based on the pre-set correspondence between the logic lines in the first structured text code and the logic elements in the first ladder diagram.

[0143] In the embodiments of this application, the logical lines for which breakpoints can be set are first determined based on the first structured text, and then the first logical elements for which breakpoints can be set in the first ladder diagram are determined based on the correspondence between the logical elements of the first ladder diagram and the logical lines of the first structured text. Since the first ladder diagram cannot set conditional breakpoints, while the first structured text supports conditional breakpoints, this makes up for the shortcomings of the first ladder diagram in complex logic.

[0144] In one possible implementation, the first ladder diagram may not display the first logic elements. In this case, the user is unaware of which logic element in the first ladder diagram is a breakpoint-configurable logic element. Therefore, in another possible implementation, the user may first select a logic element in the first ladder diagram, and then determine whether the selected logic element is a breakpoint-configurable logic element based on the element identifier of the determined first logic element. If so, the user may then click on a control in the interface displaying the first ladder diagram or issue a breakpoint addition command via a shortcut key.

[0145] To allow users to intuitively understand whether the selected logic element in the first ladder diagram is the first logic element, in addition to directly marking the logic elements with settable breakpoints in the first ladder diagram as mentioned above, the following methods can also be used:

[0146] When the user selects the first logical element as the second logical element, a control is displayed on the first display interface used to show the first ladder diagram. The user can mark the second logical element as a breakpoint by clicking the control. Based on this, in one possible implementation, such as Figure 6 The diagram shown is a third schematic of the ladder diagram-based breakpoint setting method provided in this application. After step S20 and before step S30, the ladder diagram-based breakpoint setting method of this application further includes:

[0147] Step S200: In response to the selection instruction for the second logical element in the first ladder diagram, if the second logical element is the first logical element, the first control is displayed in the first display interface in a first form.

[0148] Specifically, when determining whether a second logical element is a first logical element, it is determined whether the element identifier of the second logical element is the same as the identifier of any of the first logical elements determined in the aforementioned step S20. If they are the same, then the second logical element is a first logical element for which breakpoints can be set.

[0149] For example, suppose we determine that we have three logical element identifiers, namely a, b, and c. If the user selects the second logical element with identifier d in the first ladder diagram, then the second logical element is considered to be unbreakable. If the second logical element has identifier a, b, or c, then the logical element is considered to be breakable.

[0150] In this case, step S30 specifically includes the following steps:

[0151] Step S301: In response to the interaction instruction for the first control of the first form, based on the pre-set correspondence between the logical lines in the first structured text code and the logical elements in the first ladder diagram, determine the logical line corresponding to the second logical element as the first logical line.

[0152] In this embodiment, the breakpoint addition instruction in step S30 is an interactive instruction for the first control in the first form. It is understood that the first control may be displayed in the first display interface in the first form when the second logical element selected by the user is the first logical element, and may not be displayed in the first display interface when the second logical element is not the first logical element.

[0153] Using the embodiments of this application, the selected second logical element is determined to be a logical element for which breakpoints can be set based on whether a first control of the first form appears, which facilitates users to set breakpoints accurately and improves the accuracy of breakpoint setting based on ladder diagrams.

[0154] In another possible implementation, different forms of first controls can be used to indicate whether the second logical element selected by the user is a logical element with settable breakpoints. Based on this, in one possible implementation, such as... Figure 7 The diagram shown is a fourth schematic of the breakpoint setting method based on ladder diagrams provided in this application embodiment. After step S200 above, it further includes:

[0155] In step S300, in response to the selection instruction for the second logical element in the first ladder diagram, if the second logical element is not the first logical element, the first control is displayed in the first display interface in a second form.

[0156] In this scenario, the first control in the second form is in a non-interactive state, while the first control in the first form is in an interactive state. The first and second forms differ in color, style, or both. For example, if the first control is a circular button, it is dark gray in the first display interface when in the first form, and light gray when in the second form. Alternatively, if the first control is a circular button, it is dark gray in the first display interface when in the first form, and has a "+" symbol in the upper right corner indicating that a breakpoint can be added to the selected second logical element, it is light gray in the second form.

[0157] Using the embodiments of this application, users can determine whether the selected second logical element is a logical element that can be set with breakpoints through the form of a first control, which makes it easier for users to set breakpoints accurately and improves the accuracy of breakpoint setting based on ladder diagrams.

[0158] During the process of setting breakpoints, if there are redundant, invalid, or unnecessary breakpoints among the existing breakpoints, some of them can be deleted. Based on this, in one possible implementation, such as... Figure 8 The diagram shown is a fifth illustration of the breakpoint setting method based on ladder diagrams provided in this application. The method further includes the following steps:

[0159] Step S50: Determine the logical line in the first structured text that has already been set with breakpoints, and use it as the third logical line;

[0160] Step S60: Based on the pre-set correspondence between the logical lines in the first structured text code and the logical elements in the first ladder diagram, determine the logical element corresponding to the third logical line, and use it as the third logical element.

[0161] Step S70: In response to the selection instruction for the second logical element in the first ladder diagram, if the second logical element is a third logical element, the first control is displayed in a third form in the first display interface.

[0162] The third form differs from both the first and second forms. This difference can be in color, style, or both. For example, if the first control is a circular button, in the first form it is black; in the second form it is light gray; and in the third form it is dark gray. Alternatively, if the first control is a circular button, in the first form it is black and has a "+" symbol in the upper right corner indicating that a breakpoint can be added to the selected second logical element; in the second form it is light gray; and in the third form it is dark gray and has a "-" symbol in the upper right corner indicating that the breakpoint set at the selected second logical element can be deleted.

[0163] Step S80: In response to the interaction instruction for the first control in the third form, based on the pre-set correspondence between the logical lines in the first structured text code and the logical elements in the first ladder diagram, determine the logical line corresponding to the second logical element as the fourth logical line;

[0164] Step S90: Delete the breakpoint set on the fourth logical line in the first structured text code.

[0165] As mentioned above, a correspondence has been established between the logical lines in the first structured text code and the logical elements in the first ladder diagram. Therefore, if the user issues an interactive command for the first control in the third form, that is, a command to delete the breakpoint set before the second logical element, the logical line corresponding to the second logical element can be determined according to the correspondence, and the breakpoint before the logical line can be deleted.

[0166] By using the embodiments of this application, redundant, invalid, and unnecessary breakpoints in the already set breakpoints can be deleted, reducing the number of program pauses during subsequent debugging, speeding up debugging, thereby improving subsequent debugging efficiency, and enabling dynamic debugging.

[0167] After setting breakpoints in the first LD code according to the aforementioned first aspect, it is necessary to perform breakpoint debugging on the first LD code based on each breakpoint.

[0168] It is understandable that breakpoint setting and breakpoint debugging in this application are actually implemented in the program development environment, and therefore the compiled code is actually run by the underlying layer. After the user sets a breakpoint, the underlying layer will obtain the location of the set breakpoint and record it. Similarly, if the user deletes the set breakpoint, the underlying layer will also delete the recorded breakpoint accordingly.

[0169] Corresponding to the first aspect mentioned above, the second aspect of this application provides a breakpoint debugging method based on ladder diagrams. For example... Figure 9 The diagram shown is a schematic representation of a ladder diagram-based breakpoint debugging method provided in an embodiment of this application. The method includes the following steps:

[0170] Step S100: Obtain the first structured text code with breakpoints added based on the ladder diagram breakpoint setting method described above.

[0171] Step S200: Run each logical line in the first structured text sequentially until the run reaches a breakpoint that meets the preset interruption condition and then stops.

[0172] In the embodiments of this application, each breakpoint in the first structured text code is set according to user requirements. By running the first structured text code, when there is an exception or error in the first structured text code, the location of the error can be located according to the breakpoint position, and the program state at the time of the error can be checked. Since the correspondence between the logical lines in the first structured text code and the logical elements in the first ladder diagram is pre-set, the first logical element in the first ladder diagram where the error occurred can be located according to the location relationship, which reduces the breakpoint debugging time and thus improves the breakpoint debugging efficiency.

[0173] The above step S100 is detailed in the first aspect mentioned above, and will not be repeated here.

[0174] Since the CPU (Central Processing Unit) of the PLC is responsible for executing program instructions and data processing, and cannot directly understand structured text, in the above step S200, running each logical line in the first structured text means converting the first structured text into compiled code and then running the compiled code at the lower level.

[0175] Preset breakpoint conditions are set by users based on their own needs and practical experience. Whether the program breaks when it reaches a breakpoint depends on the breakpoint type, breakpoint state, execution path, etc. For example, the program usually breaks when it reaches a normal breakpoint, which makes it convenient for users to check variables, single-step execution, etc. However, if the breakpoint is a conditional breakpoint, the program will only break when a specific condition is met when it reaches the breakpoint. For example, if it is set to break when "error > 10", if "error" is always less than 10 when the program runs at the line of logic where the breakpoint is located, the program will not break.

[0176] As mentioned above, when a user sets a breakpoint before the first logical line, they can set the breakpoint type. Therefore, in one possible implementation, the breakpoint type includes a first preset type and a second preset type. In step S200, after sequentially running each logical line in the first structured text, if the execution reaches a breakpoint of the first preset type, it will interrupt; if it reaches a breakpoint of the second preset type, it will only interrupt when the conditions pre-set for the second preset type of breakpoint are met.

[0177] For example, assuming the first preset breakpoint is a normal breakpoint and the second preset breakpoint is a conditional breakpoint, after running each logical line in the first structured text in sequence, if the run reaches the line before the normal breakpoint, it needs to be interrupted. If the run reaches the line before the conditional breakpoint, it needs to be determined whether the condition corresponding to the conditional breakpoint is met. If it is met, the run is interrupted; if it is not met, the run continues.

[0178] In other embodiments, the second preset type can also be other types, such as hit count breakpoint, event breakpoint, data breakpoint, etc. The conditions set for the second preset type of breakpoint are set according to the breakpoint type and user needs, and this application embodiment does not limit this.

[0179] By using the embodiments of this application, the program only interrupts when it reaches a breakpoint of the first preset type or when it reaches a breakpoint of the second preset type and the conditions set for the breakpoint of the second preset type are met. This can avoid frequent interruptions, reduce interference caused by frequent interruptions, reduce debugging time, and thus improve debugging efficiency.

[0180] like Figure 11 The diagram shown is an example of breakpoint debugging provided in this application embodiment. LD code and ST code are upper-level languages. Users add breakpoints through LD code and convert the LD code into ST code. Then, the ST code is converted into binary code that can be recognized by the computer's low-level hardware (hereinafter referred to as the low-level). Since the binary code is generated after compilation, it is referred to as compiled code below. By setting breakpoints in the LD code, the low-level will record the position of each breakpoint in the compiled code. Therefore, when the low-level runs the compiled code, if it reaches a breakpoint, it will pause execution and throw breakpoint interruption messages, variable value change messages, etc., to the upper level. LD code and ST code can receive the message simultaneously and determine the variable value and breakpoint by parsing the message.

[0181] Therefore, in order to make it easier for users to intuitively understand the current running position and interruption position in the LD code, when the variable value of a logical element changes, the logical element, logical line that caused the interruption, as well as the logical element and logical line that have already been run, can be directly determined.

[0182] Based on this, in one possible implementation, after an interruption occurs, the logic element that was executed at the time of the interruption can be determined as the fourth logic element, and each fourth logic element can be identified in a first style in the first ladder diagram shown.

[0183] The first style is used to identify the fourth logical element. This can be done by adding a dashed box to each fourth logical element, displaying each fourth logical element in another color, or in other ways. This application does not limit this method.

[0184] Understandably, since breakpoints are added before logical lines and logical elements, after an interruption occurs, the logical element or logical behavior following the breakpoint that has not yet been executed, or the logical line or logical element whose behavior has not yet been executed, will be affected. For example, ... Figure 10 The figure shown is an example diagram of LD code in debug mode provided in the embodiment of this application. The logical elements in the dashed box are logical elements that have not yet been executed. The current execution stops at the breakpoint at position A. There is a dashed box around the logical element to the right of the breakpoint, indicating that the logical element in the dashed box has not yet been executed.

[0185] Furthermore, it is also possible to identify the logic element that was already running at the time of the interruption as the fifth logic element, and to identify each fifth logic element in the second style in the first ladder diagram shown.

[0186] The second style used to identify the fifth logical element can be achieved by adding a dashed border to each fifth logical element, displaying each fifth logical element in a different color, or using other methods; this embodiment does not limit this. It is understood that the second style differs from the first style in the previous embodiment. For example, as shown... Figure 10 As shown in the figure, solid lines are set around logic elements that are already running.

[0187] To help users better understand the execution logic of the code, in one possible implementation, after an interruption, the next possible execution path can be predicted based on the energy flow state, the current value of variables, etc., that is, the line of logic that will be run after the interruption is resumed.

[0188] Then, based on the aforementioned correspondence, the logical element corresponding to the logical row is determined, and each of the sixth logical elements is identified in the third style in the first ladder diagram shown.

[0189] The sixth logical element is identified using the third style. This could involve adding a dashed border to the sixth logical element, displaying it in a different color, or using other methods; this embodiment does not limit this approach. It is understood that the third style is different from both the first and second styles. For example, such as... Figure 10 As shown in the figure, the logical elements corresponding to the logical lines that will be executed after the interruption are set with double dashed boxes.

[0190] Since the current value of a variable can reflect whether an error has occurred during the execution process, i.e., if an error occurs during the execution process, the value of the current variable will be abnormal, therefore, in one possible implementation, the values ​​of each variable at the time of interruption can also be displayed in the first ladder diagram shown, so that users can quickly locate the abnormality based on the changes in the values ​​of the variables.

[0191] When the breakpoint is interrupted, the operation can be resumed by using a shortcut key or a second control, which will continue to run the remaining logical lines in the first structured text.

[0192] It is understandable that breakpoints can also be set using the breakpoint setting method described in the first aspect during debugging. For example, breakpoints can be deleted from program segments that have already run without exceptions, or breakpoints can be added to code that has not yet been run.

[0193] The breakpoint setting method and breakpoint debugging method based on ladder diagrams provided in this application are described below with reference to specific embodiments:

[0194] It is understandable that, since the breakpoint settings in this application are actually implemented in the program development environment, in one possible implementation, the above-mentioned electronic device is equipped with an IDE (Integrated Development Environment), which includes tools such as an editor, compiler, debugger and graphical user interface.

[0195] In this case, such as Figure 12 The diagram shown is an interactive diagram of the ladder diagram-based breakpoint setting method provided in this application embodiment. After the user adds, deletes, and modifies logical elements in the document through the editor, an LD document (corresponding to the first ladder diagram) is obtained. Then, a syntax check is triggered, and the LD serialization document (i.e., the ladder diagram document in the diagram) is sent to the compiler. The compiler parses the LD document and converts it into ST code (corresponding to the aforementioned step S10). Based on the logical lines in the ST code, the compiler derives the LD logical elements for which breakpoints can be set (corresponding to the aforementioned step S20), and then returns the identifier of the LD logical element for which breakpoints can be set to the editor. When a user selects a logical element for which breakpoints can be set via the editor, the breakpoint setting button (corresponding to the first control) is enabled as "True" (corresponding to the first form); otherwise, it is enabled as "False" (corresponding to the second form). The user can then set a breakpoint before the logical element by clicking the breakpoint setting button. After the user sets a breakpoint before the logical element, the editor sends the identifier of the logical element with the breakpoint to the compiler. The compiler can add the breakpoint before the logical line corresponding to the logical element with the breakpoint (corresponding to steps S30 and S40) based on the correspondence between logical lines and logical elements, and return the setting result to the editor. The editor then renders the effect so that the breakpoint appears on the horizontal link element before the logical element in the first ladder diagram.

[0196] When running the ST code obtained above, if the execution reaches a line of logic with a breakpoint, the execution will be interrupted, and the debugger will then perform debugging.

[0197] After debugging the current interruption, you can actively trigger the continuation operation using a shortcut key or button. The program will continue to execute until it encounters the next breakpoint or the program terminates.

[0198] Corresponding to the first aspect mentioned above, a third aspect of the embodiments of this application provides a breakpoint setting device based on a ladder diagram, such as... Figure 13 This is a schematic diagram of the structure of the ladder diagram-based breakpoint setting device provided in the embodiments of this application. The device includes:

[0199] The ladder diagram display module 1301 is used to display a first ladder diagram and obtain a first structured text code, wherein the first structured text code is obtained by converting the first ladder diagram into structured text code;

[0200] The logic element determination module 1302 is used to determine each logic element in the first ladder diagram that can be set with breakpoints, and to use it as the first logic element.

[0201] The logic line determination module 1303 is used to respond to a breakpoint addition instruction for any of the first logic elements, and determine the logic line corresponding to the first logic element targeted by the breakpoint addition instruction as the first logic line based on the pre-set correspondence between the logic lines in the first structured text code and the logic elements in the first ladder diagram.

[0202] The breakpoint addition module 1304 is used to add a breakpoint before the first logical line.

[0203] In this embodiment, since a pre-defined correspondence exists between logical lines in the first structured text code and logical elements in the first ladder diagram, after determining each first logical element in the first ladder diagram that can be set with breakpoints, in response to a breakpoint addition instruction for any first logical element, the first logical line corresponding to the first logical element targeted by the breakpoint addition instruction can be determined based on this correspondence, and a breakpoint can be added before the first logical line. Because the first logical element in this application is a breakpoint-settable logical element, and the pre-defined correspondence between logical elements and logical lines exists, users can add breakpoints before the logical line corresponding to the first logical element to which breakpoints need to be added, thus achieving flexible setting of breakpoints in the ladder diagram.

[0204] In one possible implementation, the device includes an editor and a compiler, the editor including a ladder diagram display module and a breakpoint addition module, and the compiler including a logic element determination module and a logic row determination module.

[0205] In one possible implementation, the logical element determination module is specifically used for:

[0206] In the first structured text, identify the logical lines where breakpoints can be set, and use them as the second logical lines;

[0207] Based on the pre-set correspondence between the logical lines in the first structured text code and the logical elements in the first ladder diagram, the logical element corresponding to the second logical line is determined as the first logical element.

[0208] In one possible implementation, the device further includes:

[0209] The first display module is configured to respond to a selection instruction for a second logical element in the first ladder diagram. If the second logical element is the first logical element, the first control is displayed in a first form in the first display interface, wherein the first display interface is an interface for displaying the first ladder diagram.

[0210] The logic row determination module is specifically used to respond to the interaction instruction for the first control of the first form, and determine the logic row corresponding to the second logic element as the first logic row based on the pre-set correspondence between the logic rows in the first structured text code and the logic elements in the first ladder diagram.

[0211] In one possible implementation, the device further includes:

[0212] The second display module is used to respond to a selection instruction for a second logical element in the first ladder diagram. If the second logical element is not the first logical element, the first control is displayed in the first display interface in a second form, wherein the first control in the second form is in a non-interactive state.

[0213] In one possible implementation, the device further includes:

[0214] The first determining module is used to determine the logical lines in the first structured text that have already been set with breakpoints, and use them as the third logical lines;

[0215] The second determining module is used to determine the logical element corresponding to the third logical line as the third logical element based on the pre-set correspondence between the logical lines in the first structured text code and the logical elements in the first ladder diagram.

[0216] The third display module is used to respond to the selection instruction for the second logical element in the first ladder diagram. If the second logical element is the third logical element, the first control is displayed in the first display interface in a third form.

[0217] The third determining module is used to respond to the interaction instruction of the first control in the third form, and determine the logical row corresponding to the second logical element as the fourth logical row based on the pre-set correspondence between the logical rows in the first structured text code and the logical elements in the first ladder diagram;

[0218] The breakpoint deletion module is used to delete the breakpoint set on the fourth logical line in the first structured text code.

[0219] In one possible implementation, the device further includes:

[0220] The breakpoint identification module is used to identify each breakpoint in the displayed first ladder diagram after adding a breakpoint before the first logic line.

[0221] A fourth aspect of this application provides a breakpoint debugging device based on a ladder diagram, such as... Figure 14 This is a schematic diagram of the structure of a ladder diagram-based breakpoint debugging device provided in an embodiment of this application. The device includes:

[0222] The acquisition module 1401 is used to acquire the first structured text code with breakpoints added based on the ladder diagram breakpoint setting method described in the first aspect above;

[0223] The running module 1402 is used to run each logical line in the first structured text sequentially until it reaches a breakpoint that meets the preset interruption conditions and then interrupts.

[0224] In one possible implementation, the interruption until a breakpoint satisfying a preset interruption condition is reached includes:

[0225] The program will terminate when it reaches a breakpoint of the first preset type; or,

[0226] The program will terminate when it reaches a breakpoint of the second preset type and the conditions set for the breakpoint of the second preset type are met.

[0227] In one possible implementation, the device further includes:

[0228] The fourth determining module is used to determine the logical element that was executed when the interruption occurred, and it serves as the fourth logical element.

[0229] The display module is used to display the first ladder diagram and identify each of the fourth logical elements in the displayed first ladder diagram using a first style.

[0230] In one possible implementation, the device further includes:

[0231] The fifth determination module is used to determine the logical element that has already been running at the time of the interruption, and to designate it as the fifth logical element.

[0232] The first identification module is used to identify each of the fifth logical elements in the first ladder diagram shown in a second style.

[0233] In one possible implementation, the device further includes:

[0234] The path prediction module is used to predict the next running path based on the values ​​of each variable when the interruption occurs, and to use the logical elements on the next running path as the sixth logical element.

[0235] The second identification module is used to identify each of the sixth logical elements in the first ladder diagram shown in a third style.

[0236] In one possible implementation, the device further includes:

[0237] The variable value display module is used to display the variable values ​​of each variable when the first ladder diagram is interrupted.

[0238] This application also provides an electronic device, such as... Figure 15 As shown, it includes:

[0239] Memory 1501 is used to store computer programs;

[0240] The processor 1502, when executing the program stored in the memory 1501, implements any of the ladder diagram-based breakpoint setting methods or ladder diagram-based breakpoint debugging methods described above.

[0241] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements any of the ladder diagram breakpoint setting methods or ladder diagram-based breakpoint debugging methods described above.

[0242] This application also provides a computer program product containing instructions that, when run on a computer, cause the computer to execute any of the ladder diagram breakpoint setting methods or ladder diagram-based breakpoint debugging methods described above.

[0243] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0244] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0245] In another embodiment provided in this application, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements the steps of any of the ladder diagram-based breakpoint setting methods or ladder diagram-based breakpoint debugging methods described above.

[0246] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the ladder diagram-based breakpoint setting method or the ladder diagram-based breakpoint debugging method described above.

[0247] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a solid-state drive (SSD), etc.

[0248] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0249] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the apparatus embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0250] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.

Claims

1. A method for setting breakpoints based on ladder diagrams, characterized in that, The method includes: Display a first trapezoidal diagram and obtain a first structured text code, wherein the first structured text code is obtained by converting the first trapezoidal diagram into structured text code; Determine the logic elements in the first ladder diagram that can be set with breakpoints, and use them as the first logic elements; In response to a breakpoint addition instruction for any of the first logical elements, based on a pre-set correspondence between logical lines in the first structured text code and logical elements in the first ladder diagram, the logical line corresponding to the first logical element targeted by the breakpoint addition instruction is determined as the first logical line. Add a breakpoint before the first line of logic.

2. The method according to claim 1, characterized in that, The logic elements in the first ladder diagram that can be set with breakpoints, as the first logic elements, include: In the first structured text, identify the logical lines where breakpoints can be set, and use them as the second logical lines; Based on the pre-set correspondence between the logical lines in the first structured text code and the logical elements in the first ladder diagram, the logical element corresponding to the second logical line is determined as the first logical element.

3. The method according to claim 1, characterized in that, The method further includes: In response to a selection instruction for a second logical element in the first ladder diagram, if the second logical element is the first logical element, a first control is displayed in a first form in a first display interface, wherein the first display interface is an interface that displays the first ladder diagram. The step of responding to a breakpoint addition instruction for any of the first logical elements, based on a pre-set correspondence between logical lines in the first structured text code and logical elements in the first ladder diagram, determines the logical line corresponding to the first logical element targeted by the breakpoint addition instruction as the first logical line, including: In response to an interaction instruction for the first control of the first form, based on the pre-set correspondence between the logical lines in the first structured text code and the logical elements in the first ladder diagram, the logical line corresponding to the second logical element is determined as the first logical line.

4. The method according to claim 3, characterized in that, The method further includes: In response to a selection instruction for a second logical element in the first ladder diagram, if the second logical element is not the first logical element, the first control is displayed in a second form in the first display interface, wherein the first control in the second form is in a non-interactive state.

5. The method according to claim 3 or 4, characterized in that, The method further includes: Identify the logical lines in the first structured text that already have breakpoints set as the third logical lines; Based on the pre-set correspondence between the logical lines in the first structured text code and the logical elements in the first ladder diagram, the logical element corresponding to the third logical line is determined as the third logical element. In response to a selection instruction for a second logical element in the first ladder diagram, if the second logical element is the third logical element, the first control is displayed in a third form in the first display interface. In response to the interaction instruction for the first control of the third form, based on the pre-set correspondence between the logical lines in the first structured text code and the logical elements in the first ladder diagram, the logical line corresponding to the second logical element is determined as the fourth logical line; Delete the breakpoint set on the fourth logical line in the first structured text code.

6. The method according to claim 1, characterized in that, After adding a breakpoint before the first logical line, the method further includes: Each of the breakpoints is identified in the first ladder diagram shown.

7. A breakpoint debugging method based on ladder diagrams, characterized in that, The method includes: Obtain the first structured text code with breakpoints added based on the ladder diagram breakpoint setting method according to any one of claims 1-6; The program executes each logical line in the first structured text sequentially until it reaches a breakpoint that meets the preset interruption condition, at which point it will be interrupted.

8. The method according to claim 7, characterized in that, The interruption until a breakpoint meeting the preset interruption conditions is reached includes: The program will terminate when it reaches a breakpoint of the first preset type; or, The program will terminate when it reaches a breakpoint of the second preset type and the conditions set for the breakpoint of the second preset type are met.

9. The method according to claim 7, characterized in that, The method further includes: Determine the logical element to which the program was executed when the interruption occurred, and designate it as the fourth logical element; The first ladder diagram is displayed, and each of the fourth logic elements is identified in the first ladder diagram using a first style.

10. The method according to claim 9, characterized in that, The method further includes: Identify the logical element that was already running at the time of the interruption and designate it as the fifth logical element; In the first ladder diagram shown, each of the fifth logic elements is identified in a second style.

11. The method according to claim 9 or 10, characterized in that, The method further includes: The next running path is predicted based on the values ​​of each variable at the time of interruption, and the logical elements on the next running path are taken as the sixth logical element. In the first ladder diagram shown, each of the sixth logic elements is identified in a third style.

12. The method according to claim 7, characterized in that, The method further includes: The first ladder diagram shown displays the variable values ​​when the interruption occurs.

13. A breakpoint setting device based on a ladder diagram, characterized in that, The device includes: A ladder diagram display module is used to display a first ladder diagram and obtain a first structured text code, wherein the first structured text code is obtained by converting the first ladder diagram into structured text code; The logic element determination module is used to determine each logic element in the first ladder diagram that can be set with breakpoints, and to use it as the first logic element. The logic line determination module is used to respond to a breakpoint addition instruction for any of the first logic elements, and determine the logic line corresponding to the first logic element targeted by the breakpoint addition instruction as the first logic line based on the pre-set correspondence between the logic lines in the first structured text code and the logic elements in the first ladder diagram. The breakpoint addition module is used to add a breakpoint before the first logical line.

14. The apparatus according to claim 13, characterized in that, The device includes an editor and a compiler. The editor includes a ladder diagram display module and a breakpoint addition module. The compiler includes a logic element determination module and a logic row determination module.

15. A breakpoint debugging device based on a ladder diagram, characterized in that, The device includes: The acquisition module is used to acquire the first structured text code with breakpoints added based on the ladder diagram breakpoint setting method according to any one of claims 1-6; The execution module is used to sequentially run each logical line in the first structured text until it reaches a breakpoint that meets the preset interruption conditions and then interrupts.

16. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the method of any one of claims 1-6 or 7-12.

17. 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 method described in any one of claims 1-6 or 7-12.