Interface layout method of sequential function diagram and terminal
Through the automated layout method of element numbering and element type, the problem of high complexity in manual layout of sequential function diagrams is solved, and efficient element layout is achieved, ensuring the rationality and integrity of the layout.
Patent Information
- Application Number
- CN202411529216.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-30
- Publication Date
- 2024-11-29
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing sequential functional diagram layout method requires users to manually place the elements, which increases the layout complexity and workload and reduces the layout efficiency.
Use primitive numbers to layout among primitives, traverse primitives to layout element types, calculate the initial length and height, and finally determine the final length and height, and complete the reasonable layout through automated means.
Reduces layout complexity, improves layout efficiency, and ensures a complete display of element content.
Smart Images

Figure CN119045709A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of graphic layout technology, and in particular to an interface layout method and a terminal for a sequential function diagram. Background Art
[0002] A PLC (Programmable Logic Controller) control program written in SFC (Sequential Function Chart) mainly consists of the following two parts: variable definition and graphic element area. The graphic element area is mainly used to write business logic and consists of several graphic elements. A graphic element mainly consists of the following elements: 1. Element connection line: a vertical line; 2. Starting step: used as the starting point of the graphic element from top to bottom; 3. Step: There are input and output; 4. Transfer: With the step as the transfer target, it is divided into serial transfer, selective transfer, and parallel transfer; 5. Branch: It is divided into selective branch and parallel branch, which correspond to selective transfer and parallel transfer in transfer respectively; 6. Element annotation: used to add annotation information to the element; 7. Action: used for specific operations performed by the step; 8. Ending step: as the end point of the element from top to bottom; 9. Jump: the end position of the program, jump to other programs, divided into conditional jump and unconditional jump; 10. Macro: It is composed of a series of steps / transfers.
[0003] The existing method of laying out a sequential function chart requires the user to manually place the positions of the graphic elements one by one, which increases the complexity of the layout and the workload of the user. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide an interface layout method and terminal for a sequential function diagram, which can reduce layout complexity and improve layout efficiency.
[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is: A method for layout of an interface of a sequential function chart comprises the steps of: Perform inter-element layout on all the elements according to the element numbers to obtain all the elements after preliminary layout; Traversing all the primitives after the preliminary layout according to the primitive numbers, for the traversed primitives, laying out all elements in the primitives according to the element types, and after the primitive layout is completed, calculating the initial length and initial height of the primitives; The final length and final height of each of the graphic elements are determined according to the initial length and initial height of each of the graphic elements to complete the layout.
[0006] In order to solve the above technical problems, another technical solution adopted by the present invention is: A sequential function chart interface layout terminal includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented: Perform inter-element layout on all the elements according to the element numbers to obtain all the elements after preliminary layout; Traversing all the primitives after the preliminary layout according to the primitive numbers, for the traversed primitives, laying out all elements in the primitives according to the element types, and after the primitive layout is completed, calculating the initial length and initial height of the primitives; The final length and final height of each of the graphic elements are determined according to the initial length and initial height of each of the graphic elements to complete the layout.
[0007] The beneficial effects of the present invention are as follows: firstly, all primitives are laid out among themselves according to their primitive numbers, then all primitives after the preliminary layout are traversed according to their primitive numbers, all elements within the traversed primitives are laid out according to their element types, and after the primitive layout is completed, the initial length and initial height of the primitives are calculated, and the final length and final height of each primitive are determined according to the initial length and initial height of each primitive, thereby automatically completing the reasonable layout of the sequential function diagram based on the primitive numbers and element types by first laying out among primitives and then laying out within primitives, thereby reducing the layout complexity and improving the layout efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] Figure 1 A flowchart of the steps of a method for layout of an interface of a sequential function diagram according to an embodiment of the present invention; Figure 2 A schematic diagram of the structure of an interface layout terminal of a sequential function diagram according to an embodiment of the present invention; Figure 3 The present invention is a schematic diagram of a graphic element that has completed layout in the interface layout method of a sequential function chart according to an embodiment of the present invention. DETAILED DESCRIPTION
[0009] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.
[0010] Please refer to Figure 1 , a method for layout of interface of sequential function chart, comprising the steps of: Perform inter-element layout on all the elements according to the element numbers to obtain all the elements after preliminary layout; Traversing all the primitives after the preliminary layout according to the primitive numbers, for the traversed primitives, laying out all elements in the primitives according to the element types, and after the primitive layout is completed, calculating the initial length and initial height of the primitives; The final length and final height of each of the graphic elements are determined according to the initial length and initial height of each of the graphic elements to complete the layout.
[0011] From the above description, it can be seen that the beneficial effects of the present invention are: first, all primitives are laid out between primitives according to the primitive numbers, then all primitives after the preliminary layout are traversed according to the primitive numbers, all elements within the traversed primitives are laid out according to the element types, and after the primitive layout is completed, the initial length and initial height of the primitives are calculated, and the final length and final height of each primitive are determined according to the initial length and initial height of each primitive, thereby automatically completing the reasonable layout of the sequential function diagram based on the primitive numbers and element types by first laying out between primitives and then laying out within primitives, thereby reducing the layout complexity and improving the layout efficiency.
[0012] Furthermore, the laying out of all elements in the primitive according to element type includes: Determine a starting step element from all elements in the primitive, and determine the name coordinates of the primitive, the annotation coordinates of the primitive, and the coordinates of the starting step element; Determine the first element connected to the bottom of the starting step element, determine the coordinates of the first element, and determine the coordinates of the connection point between the starting step element and the first element; If the first element is an end step element or a jump element, it is determined that the primitive layout is ended; If the first element is a transfer element or a macro element, then determining a second element connected to the lower portion of the first element, determining the coordinates of the second element, and determining the coordinates of the connection point between the first element and the second element; If the second element is an end step element or a jump element, it is determined that the primitive layout is ended; If the second element is a step element, a selection branch element, a parallel branch element or a macro element, determine whether there is a connected third element below the second element. If not, determine that the primitive layout is completed. If so, return the third element as the first element to execute the step of determining the coordinates of the first element.
[0013] From the above description, it can be seen that the starting step element is determined first, and the name coordinates of the graphic element, the annotation coordinates of the graphic element and the coordinates of the starting step element are determined. Starting from the starting step element, the connected elements are determined in sequence to avoid missing elements. The element coordinates and connection point coordinates are determined according to the element type, which is simpler and more efficient.
[0014] Further, the determining the coordinates of the name of the graphic element, the annotation coordinates of the graphic element and the coordinates of the starting step element includes: Determine that the horizontal coordinate of the start step element is the distance between the preset start step and the left side of the interface, and the vertical coordinate is the distance between the preset start step and the top of the interface; Determine the abscissa of the name coordinates of the graphic element according to the abscissa of the starting step element and the distance between the sequential function diagram after layout is completed and the left side of the interface, and determine the ordinate of the name coordinates of the graphic element according to the ordinate of the starting step element and the distance between the sequential function diagram after layout is completed and the top of the interface; The horizontal coordinate of the annotation coordinate of the graphic element is determined according to the horizontal coordinate of the graphic element, the width of the graphic element and the distance between the default sequential function diagram and the left side of the interface, and the vertical coordinate of the annotation coordinate of the graphic element is determined according to the vertical coordinate of the graphic element.
[0015] From the above description, it can be seen that it is only necessary to determine the horizontal coordinate and the vertical coordinate of the starting step element. Subsequently, the name coordinate and the annotation coordinate of the primitive can be determined according to the horizontal coordinate and the vertical coordinate of the starting step element, which is faster and more reliable.
[0016] Further, determining the coordinates of the first element includes: If the first element is the end step element, the abscissa of the end step element is determined according to the abscissa of the start step element; Calculate the product of the number of actions in the step element and the preset height of the action; Determine a maximum value from the product and the vertical distance between the preset primitives, and use the maximum value as the height of the primitive connection line; The vertical coordinate of the ending step element is calculated according to the vertical coordinate of the starting step element, the default height of the step element and the height of the primitive connection line.
[0017] From the above description, it can be seen that if the first element is the end step element, the horizontal coordinate of the end step element is determined according to the horizontal coordinate of the start step element, and the vertical coordinate of the end step element is calculated according to the vertical coordinate of the start step element, the default height of the step element and the height of the graphic element connection line, so as to accurately determine the position of the end step element in the interface.
[0018] Further, determining the coordinates of the first element includes: If the first element is the jump element, the abscissa of the jump element is calculated according to the abscissa of the start step element and the preset distance between the jump element and the left side of the interface; Calculate the product of the number of actions in the step element and the preset height of the action; Determine a maximum value from the product and the vertical distance between the preset primitives, and use the maximum value as the height of the primitive connection line; The vertical coordinate of the jump element is calculated according to the vertical coordinate of the start step element, the default height of the step element and the height of the primitive connection line.
[0019] From the above description, it can be seen that if the first element is a jump element, the horizontal coordinate of the jump element is calculated according to the horizontal coordinate of the starting step element and the preset distance between the jump element and the left side of the interface, and the vertical coordinate of the jump element is calculated according to the vertical coordinate of the starting step element, the default height of the step element and the height of the graphic element connection line. In this way, the coordinates of the jump element are determined according to the properties of the jump element, which is efficient and reasonable.
[0020] Further, determining the coordinates of the first element includes: If the first element is the transition element, the abscissa of the transition element is calculated according to the abscissa of the starting step element and the preset distance between the transition element and the left side of the interface; Calculate the product of the number of actions in the step element and the preset height of the action; Determine a maximum value from the product and the vertical distance between the preset primitives, and use the maximum value as the height of the primitive connection line; The ordinate of the transfer element is calculated according to the ordinate of the start step element, the default height of the step element and the height of the primitive connection line.
[0021] From the above description, it can be seen that if the first element is a transfer element, the horizontal coordinate of the transfer element is calculated according to the horizontal coordinate of the starting step element and the preset distance between the transfer element and the left side of the interface, and the vertical coordinate of the transfer element is calculated according to the vertical coordinate of the starting step element, the default height of the step element and the height of the primitive connection line. The coordinates of the transfer element can be determined quickly and accurately, thereby improving layout efficiency.
[0022] Further, determining the coordinates of the first element includes: If the first element is the macro element, determining the abscissa of the macro element according to the abscissa of the start step element; Calculate the product of the number of actions in the step element and the preset height of the action; Determine a maximum value from the product and the vertical distance between the preset primitives, and use the maximum value as the height of the primitive connection line; The vertical coordinate of the macro element is calculated according to the vertical coordinate of the starting step element, the default height of the step element and the height of the primitive connection line.
[0023] From the above description, it can be seen that if the first element is a macro element, the horizontal coordinate of the macro element is determined according to the horizontal coordinate of the starting step element, the product of the number of actions in the step element and the preset height of the action is calculated, and the maximum value is determined from the product and the vertical distance between the preset graphic elements. The maximum value is used as the height of the graphic element connecting line, and the height of the graphic element connecting line is taken into account in the calculation of the vertical coordinate of the macro element, thereby ensuring the accuracy of the macro element coordinate calculation.
[0024] Further, the determining the coordinates of the connection point between the starting step element and the first element includes: If the first element is the end step element, the abscissa of the bottom connection point of the start step element is calculated according to the abscissa of the start step element and the default width of the step element, and the ordinate of the bottom connection point of the start step element is calculated according to the ordinate of the start step element and the default height of the step element; The horizontal coordinate of the upper connection point of the first element is determined according to the horizontal coordinate of the lower connection point of the starting step element, and the vertical coordinate of the upper connection point of the first element is calculated according to the vertical coordinate of the lower connection point of the starting step element and the height of the primitive connection line.
[0025] From the above description, it can be seen that if the first element is the end step element, the horizontal coordinate of the bottom connection point of the starting step element is calculated according to the horizontal coordinate of the starting step element and the default width of the step element, and the vertical coordinate of the bottom connection point of the starting step element is calculated according to the vertical coordinate of the starting step element and the default height of the step element. Then, the horizontal coordinate of the top connection point of the first element is determined according to the horizontal coordinate of the bottom connection point of the starting step element, and the vertical coordinate of the top connection point of the first element is calculated according to the vertical coordinate of the bottom connection point of the starting step element and the height of the graphic element connection line. In this way, the connection point between the starting step element and the first element can be automatically confirmed, thereby improving layout efficiency.
[0026] Further, the determining the final length and final height of each of the graphic elements according to the initial length and initial height of each of the graphic elements comprises: Determine the maximum initial length and initial height according to the initial length and initial height of each of the graphic elements; The maximum initial length and initial height are used as the final length and final height of each of the primitives.
[0027] From the above description, it can be seen that the maximum initial length and initial height are used as the final length and final height of each primitive, ensuring that the content in each primitive can be fully displayed, thereby ensuring the layout effect.
[0028] Please refer to Figure 2 Another embodiment of the present invention provides an interface layout terminal for a sequential function chart, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, each step in the above-mentioned sequential function chart interface layout method is implemented.
[0029] The interface layout method and terminal of the sequential function diagram described above in the present invention can be applied to the interface layout scenario of the sequential function diagram, which is described below through specific implementation methods: Please refer to Figure 1 and Figure 3 , Embodiment 1 of the present invention is: A method for layout of an interface of a sequential function chart comprises the steps of: S1. Perform inter-element layout on all the elements according to the element numbers to obtain all the elements after preliminary layout.
[0030] Specifically, the connection relationship between the primitives is bound using the primitive number to obtain all the primitives after the preliminary layout. The primitive number is a unique number of the primitive.
[0031] S2, traversing all the primitives after the preliminary layout according to the primitive numbers, for the traversed primitives, laying out all elements in the primitives according to the element types, and after the primitive layout is completed, calculating the initial length and initial height of the primitive, specifically including S21-S27: S21. Traverse all the primitives after the preliminary layout according to the primitive numbers, and for the traversed primitives, determine the starting step element from all the elements in the primitive, and determine the name coordinates of the primitive, the annotation coordinates of the primitive, and the coordinates of the starting step element.
[0032] The step of determining the coordinates of the name of the graphic element, the annotation coordinates of the graphic element, and the coordinates of the starting step element includes: Determine that the horizontal coordinate of the starting step element is the preset distance GRAPH_MARGIN_LEFT between the starting step and the left side of the interface, and the vertical coordinate is the preset distance INIT_MARGIN_TOP between the starting step and the top of the interface; determine the horizontal coordinate in the name coordinate of the graphic element according to the horizontal coordinate of the starting step element and the distance MARGIN_LEFT between the sequential function chart after layout is completed and the left side of the interface, and determine the vertical coordinate in the name coordinate of the graphic element according to the vertical coordinate of the starting step element and the distance MARGIN_TOP between the sequential function chart after layout is completed and the top of the interface; determine the horizontal coordinate in the annotation coordinate of the graphic element according to the horizontal coordinate x of the graphic element, the width GRAPG_WIDTH of the graphic element and the default distance MARGIN_LEFT_DEF between the sequential function chart and the left side of the interface, and determine the vertical coordinate in the annotation coordinate of the graphic element according to the vertical coordinate y of the graphic element.
[0033] Specifically, the horizontal coordinate NAME_X in the name coordinate of the graphic element is GRAPH_MARGIN_LEFT+MARGIN_LEFT, the vertical coordinate NAME_Y in the name coordinate of the graphic element is INIT_MARGIN_TOP+MARGIN_TOP, the horizontal coordinate CM_X in the annotation coordinate of the graphic element is x+GRAPG_WIDTH+MARGIN_LEFT_DEF, and the vertical coordinate CM_Y in the annotation coordinate of the graphic element is y.
[0034] S22. Determine the first element connected to the bottom of the starting step element, determine the coordinates of the first element, and determine the coordinates of the connection point between the starting step element and the first element.
[0035] Wherein, determining the coordinates of the first element includes: If the first element is the end step element, the abscissa of the end step element is determined according to the abscissa of the start step element; the product of the number of actions in the step element ACTION_NUM and the preset height of the action ACTION_HEIGHT_DEF is calculated; the maximum value is determined from the product and the preset vertical distance between the primitives GRAPH_DISTANCE_V, and the maximum value is used as the height of the primitive connection line DISTANCE_CONN; the ordinate of the end step element is calculated according to the ordinate of the start step element, the default height of the step element STEP_HEIGHT_DEF and the height of the primitive connection line. Specifically, the abscissa of the end step element = GRAPH_MARGIN_LEFT, and the ordinate of the end step element = INIT_MARGIN_TOP+STEP_HEIGHT_DEF+DISTANCE_CONN.
[0036] Alternatively, if the first element is the jump element, the horizontal coordinate of the jump element is calculated according to the horizontal coordinate of the starting step element and the preset distance JUMP_MARGIN_LEFT between the jump element and the left side of the interface; the product of the number of actions in the step element and the preset height of the action is calculated; the maximum value is determined from the product and the vertical distance between the preset primitives, and the maximum value is used as the height of the primitive connection line; the vertical coordinate of the jump element is calculated according to the vertical coordinate of the starting step element, the default height of the step element and the height of the primitive connection line. Specifically, the horizontal coordinate of the jump element = GRAPH_MARGIN_LEFT + JUMP_MARGIN_LEFT, and the vertical coordinate of the jump element = INIT_MARGIN_TOP + STEP_HEIGHT_DEF + DISTANCE_CONN.
[0037] Alternatively, if the first element is the transition element, the abscissa of the transition element is calculated according to the abscissa of the starting step element and the preset distance TRANS_MARGIN_LEFT between the transition element and the left side of the interface; the product of the number of actions in the step element and the preset height of the action is calculated; the maximum value is determined from the product and the preset vertical distance between the primitives, and the maximum value is used as the height of the primitive connection line; the ordinate of the transition element is calculated according to the ordinate of the starting step element, the default height of the step element and the height of the primitive connection line. Specifically, the abscissa of the transition element = GRAPH_MARGIN_LEFT + TRANS_MARGIN_LEFT, and the ordinate of the transition element = INIT_MARGIN_TOP + STEP_HEIGHT_DEF + DISTANCE_CONN.
[0038] Alternatively, if the first element is the macro element, the abscissa of the macro element is determined according to the abscissa of the starting step element; the product of the number of actions in the step element and the preset height of the action is calculated; the maximum value is determined from the product and the vertical distance between the preset primitives, and the maximum value is used as the height of the primitive connection line; the ordinate of the macro element is calculated according to the ordinate of the starting step element, the default height of the step element and the height of the primitive connection line. Specifically, the abscissa of the macro element = GRAPH_MARGIN_LEFT, and the ordinate of the macro element = INIT_MARGIN_TOP + STEP_HEIGHT_DEF + DISTANCE_CONN.
[0039] Determining the coordinates of the connection point between the starting step element and the first element comprises: If the first element is the ending step element, the horizontal coordinate of the lower connection point of the starting step element is calculated according to the horizontal coordinate of the starting step element and the default width STEP_WIDTH_DEF of the step element, and the vertical coordinate of the lower connection point of the starting step element is calculated according to the vertical coordinate of the starting step element and the default height of the step element; the horizontal coordinate of the upper connection point of the first element is determined according to the horizontal coordinate of the lower connection point of the starting step element, and the vertical coordinate of the upper connection point of the first element is calculated according to the vertical coordinate of the lower connection point of the starting step element and the height of the primitive connection line. Specifically, the horizontal coordinate of the lower connection point of the starting step element = GRAPH_MARGIN_LEFT + STEP_WIDTH_DEF / 2, the vertical coordinate of the lower connection point of the starting step element = INIT_MARGIN_TOP + STEP_HEIGHT_DEF, the horizontal coordinate of the upper connection point of the ending step element = the horizontal coordinate of the lower connection point of the starting step element, and the vertical coordinate of the upper connection point of the ending step element = the vertical coordinate of the lower connection point of the starting step element + DISTANCE_CONN.
[0040] Alternatively, if the first element is the jump element, the horizontal coordinate of the lower connection point of the starting step element is calculated according to the horizontal coordinate of the starting step element and the default width STEP_WIDTH_DEF of the step element, and the vertical coordinate of the lower connection point of the starting step element is calculated according to the vertical coordinate of the starting step element and the default height of the step element; the horizontal coordinate of the upper connection point of the first element is determined according to the horizontal coordinate of the lower connection point of the starting step element, and the vertical coordinate of the upper connection point of the first element is calculated according to the vertical coordinate of the lower connection point of the starting step element and the height of the graphic element connection line. Specifically, the horizontal coordinate of the lower connection point of the starting step element = GRAPH_MARGIN_LEFT + STEP_WIDTH_DEF / 2, the vertical coordinate of the lower connection point of the starting step element = INIT_MARGIN_TOP + STEP_HEIGHT_DEF, the horizontal coordinate of the upper connection point of the jump element = the horizontal coordinate of the lower connection point of the starting step element, and the vertical coordinate of the upper connection point of the jump element = the vertical coordinate of the lower connection point of the starting step element + DISTANCE_CONN.
[0041] Alternatively, if the first element is the transition element, the abscissa of the lower connection point of the starting step element is calculated according to the abscissa of the starting step element and the default width of the step element STEP_WIDTH_DEF, and the ordinate of the lower connection point of the starting step element is calculated according to the ordinate of the starting step element and the default height of the step element; the abscissa of the upper connection point of the first element is determined according to the abscissa of the lower connection point of the starting step element, and the ordinate of the upper connection point of the first element is calculated according to the ordinate of the lower connection point of the starting step element and the height of the primitive connection line. Specifically, the abscissa of the lower connection point of the starting step element = GRAPH_MARGIN_LEFT + STEP_WIDTH_DEF / 2, the ordinate of the lower connection point of the starting step element = INIT_MARGIN_TOP + STEP_HEIGHT_DEF, the abscissa of the upper connection point of the transition element = the abscissa of the lower connection point of the starting step element, and the ordinate of the upper connection point of the transition element = the ordinate of the lower connection point of the starting step element + DISTANCE_CONN.
[0042] Alternatively, if the first element is the macro element, the abscissa of the lower connection point of the starting step element is calculated according to the abscissa of the starting step element and the default width of the step element STEP_WIDTH_DEF, and the ordinate of the lower connection point of the starting step element is calculated according to the ordinate of the starting step element and the default height of the step element; the abscissa of the upper connection point of the first element is determined according to the abscissa of the lower connection point of the starting step element, and the ordinate of the upper connection point of the first element is calculated according to the ordinate of the lower connection point of the starting step element and the height of the primitive connection line. Specifically, the abscissa of the lower connection point of the starting step element = GRAPH_MARGIN_LEFT + STEP_WIDTH_DEF / 2, the ordinate of the lower connection point of the starting step element = INIT_MARGIN_TOP + STEP_HEIGHT_DEF, the abscissa of the upper connection point of the macro element = the abscissa of the lower connection point of the starting step element, and the ordinate of the upper connection point of the macro element = the ordinate of the lower connection point of the starting step element + DISTANCE_CONN.
[0043] S23. If the first element is an end step element or a jump element, it is determined that the primitive layout is ended.
[0044] S24. If the first element is a transfer element or a macro element, determine a second element connected to the lower portion of the first element, determine the coordinates of the second element, and determine the coordinates of the connection point between the first element and the second element.
[0045] Wherein, determining the coordinates of the second element includes: If the second element is an end step element, the abscissa of the end step element is determined according to the abscissa of the start step element; the height of the primitive connection line DISTANCE_CONN is determined according to the preset vertical distance between primitives GRAPH_DISTANCE_V; the ordinate of the end step element is calculated according to the ordinate of the upper connection point of the first element, the default height of the transfer element, the default height of the macro element and the height of the primitive connection line. Specifically, DISTANCE_CONN=GRAPH_DISTANCE_V, the abscissa of the end step element=GRAPH_MARGIN_LEFT, if the first element is a transfer element, the ordinate of the end step element=the ordinate of the upper connection point of the transfer element+(TRANSITION_HEIGHT_DEF||MACRO_HEIGHT_DEF)+DISTANCE_CONN, if the first element is a macro element, the ordinate of the end step element=the ordinate of the upper connection point of the macro element+(TRANSITION_HEIGHT_DEF||MACRO_HEIGHT_DEF)+DISTANCE_CONN.
[0046] Alternatively, if the second element is a jump element, the horizontal coordinate of the jump element is calculated according to the horizontal coordinate of the starting step element and the preset distance between the jump element and the left side of the interface; the height of the primitive connection line DISTANCE_CONN is determined according to the preset vertical distance between primitives GRAPH_DISTANCE_V; the vertical coordinate of the jump element is calculated according to the vertical coordinate of the starting step element, the default height of the transfer element, the default height of the macro element and the height of the primitive connection line. Specifically, DISTANCE_CONN=GRAPH_DISTANCE_V, the horizontal coordinate of the jump element=GRAPH_MARGIN_LEFT+JUMP_MARGIN_LEFT, and the vertical coordinate of the jump element= INIT_MARGIN_TOP+(TRANSITION_HEIGHT_DEF||MACRO_HEIGHT_DEF)+DISTANCE_CONN.
[0047] Alternatively, if the second element is a step element or a macro element, the horizontal coordinate of the step element or macro element is calculated according to the horizontal coordinate of the starting step element; the height of the graphic element connection line DISTANCE_CONN is determined according to the preset vertical distance between graphic elements GRAPH_DISTANCE_V; the vertical coordinate of the step element or macro element is calculated according to the vertical coordinate of the starting step element, the default height of the transfer element, the default height of the macro element and the height of the graphic element connection line. Specifically, DISTANCE_CONN=GRAPH_DISTANCE_V, the horizontal coordinate of the step element or macro element=GRAPH_MARGIN_LEFT+JUMP_MARGIN_LEFT, and the vertical coordinate of the step element or macro element=INIT_MARGIN_TOP+(TRANSITION_HEIGHT_DEF||MACRO_HEIGHT_DEF)+DISTANCE_CONN.
[0048] Alternatively, if the second element is a branch element, the horizontal coordinate of the branch element is calculated according to the horizontal coordinate of the starting step element and the preset distance BRANCH_MARGIN_LEFT between the branch and the left side of the interface; the height DISTANCE_CONN of the graphic element connection line is determined according to the preset vertical distance between the graphic elements GRAPH_DISTANCE_V; the vertical coordinate of the branch element is calculated according to the vertical coordinate of the starting step element, the default height of the transfer element, the default height of the macro element and the height of the graphic element connection line. Specifically, DISTANCE_CONN=GRAPH_DISTANCE_V, the horizontal coordinate of the branch element=GRAPH_MARGIN_LEFT+BRANCH_MARGIN_LEFT, and the vertical coordinate of the branch element= INIT_MARGIN_TOP+(TRANSITION_HEIGHT_DEF||MACRO_HEIGHT_DEF)+DISTANCE_CONN.
[0049] Determining the coordinates of the connection point between the first element and the second element includes: If the second element is an ending step element, the horizontal coordinate of the lower connection point of the first element is calculated according to the horizontal coordinate of the starting step element, the default width of the transfer element and the default width of the macro element, and the vertical coordinate of the lower connection point of the first element is calculated according to the vertical coordinate of the starting step element, the default height of the transfer element and the default height of the macro element; the horizontal coordinate of the upper connection point of the second element is determined according to the horizontal coordinate of the lower connection point of the first element, and the vertical coordinate of the upper connection point of the second element is calculated according to the vertical coordinate of the lower connection point of the first element and the height of the graphic element connection line. Specifically, the horizontal coordinate of the bottom connection point of the transfer element or macro element = GRAPH_MARGIN_LEFT+(TRANSITION_WIDTH_DEF||MACRO_WIDTH_DEF) / 2, the vertical coordinate of the bottom connection point of the transfer element or macro element = INIT_MARGIN_TOP+(TRANSITION_HEIGHT_DEF||MACRO_HEIGHT_DEF), the horizontal coordinate of the top connection point of the end step element = the horizontal coordinate of the bottom connection point of the transfer element or macro element, and the vertical coordinate of the top connection point of the end step element = the vertical coordinate of the bottom connection point of the transfer element or macro element + DISTANCE_CONN.
[0050] Alternatively, if the second element is a jump element, the horizontal coordinate of the lower connection point of the first element is calculated according to the horizontal coordinate of the starting step element, the default width of the transfer element and the default width of the macro element, and the vertical coordinate of the lower connection point of the first element is calculated according to the vertical coordinate of the starting step element, the default height of the transfer element and the default height of the macro element; the horizontal coordinate of the upper connection point of the second element is determined according to the horizontal coordinate of the lower connection point of the first element, and the vertical coordinate of the upper connection point of the second element is calculated according to the vertical coordinate of the lower connection point of the first element and the height of the graphic element connection line. Specifically, the horizontal coordinate of the bottom connection point of the transfer element or macro element = GRAPH_MARGIN_LEFT+(TRANSITION_WIDTH_DEF||MACRO_WIDTH_DEF) / 2, the vertical coordinate of the bottom connection point of the transfer element or macro element = INIT_MARGIN_TOP+(TRANSITION_HEIGHT_DEF||MACRO_HEIGHT_DEF), the horizontal coordinate of the top connection point of the jump element = the horizontal coordinate of the bottom connection point of the transfer element or macro element, and the vertical coordinate of the top connection point of the jump element = the vertical coordinate of the bottom connection point of the transfer element or macro element + DISTANCE_CONN.
[0051] Alternatively, if the second element is a step element or a macro element, the horizontal coordinate of the lower connection point of the first element is calculated according to the horizontal coordinate of the starting step element, the default width of the transfer element and the default width of the macro element, and the vertical coordinate of the lower connection point of the first element is calculated according to the vertical coordinate of the starting step element, the default height of the transfer element and the default height of the macro element; the horizontal coordinate of the upper connection point of the second element is determined according to the horizontal coordinate of the lower connection point of the first element, and the vertical coordinate of the upper connection point of the second element is calculated according to the vertical coordinate of the lower connection point of the first element and the height of the graphic element connection line. Specifically, the horizontal coordinate of the bottom connection point of the transfer element or macro element = GRAPH_MARGIN_LEFT + (TRANSITION_WIDTH_DEF||MACRO_WIDTH_DEF) / 2, the vertical coordinate of the bottom connection point of the transfer element or macro element = INIT_MARGIN_TOP + (TRANSITION_HEIGHT_DEF||MACRO_HEIGHT_DEF), the horizontal coordinate of the top connection point of the step element or macro element = the horizontal coordinate of the bottom connection point of the transfer element or macro element, and the vertical coordinate of the top connection point of the step element or macro element = the vertical coordinate of the bottom connection point of the transfer element or macro element + DISTANCE_CONN.
[0052] Alternatively, if the second element is a branch element, and the branch element includes a selection branch element and a parallel branch element, the horizontal coordinate of the lower connection point of the first element is calculated according to the horizontal coordinate of the starting step element and the default width of the step element, and the vertical coordinate of the lower connection point of the first element is calculated according to the vertical coordinate of the starting step element, the default height of the transfer element and the default height of the macro element; the horizontal coordinate of the upper connection point of the second element is determined according to the horizontal coordinate of the lower connection point of the first element, and the vertical coordinate of the upper connection point of the second element is calculated according to the vertical coordinate of the lower connection point of the first element and the height of the graphic element connection line. Specifically, the horizontal coordinate of the bottom connection point of the transfer element or macro element = GRAPH_MARGIN_LEFT + STEP_WIDTH_DEF / 2, the vertical coordinate of the bottom connection point of the transfer element or macro element = INIT_MARGIN_TOP + (TRANSITION_HEIGHT_DEF||MACRO_HEIGHT_DEF), the horizontal coordinate of the top connection point of the branch element = the horizontal coordinate of the bottom connection point of the transfer element or macro element, and the vertical coordinate of the top connection point of the branch element = the vertical coordinate of the bottom connection point of the transfer element or macro element + DISTANCE_CONN.
[0053] Among them, in the branch elements, at least one step element, a series of graphic primitive elements of the structure of step element + transfer element / macro element / select branch element + step element, etc. can be added to each parallel branch element, and at least one transfer element, a series of graphic primitive elements of the structure of transfer element + step element / macro element / parallel branch element + transfer element, etc. can be added to each select branch element. Assuming that there are 2 sub-branches in the parallel branch element and each branch has a step, the horizontal coordinate of the upper connection point of the step in branch one = GRAPH_MARGIN_LEFT + STEP_WIDTH_DEF / 2, and the vertical coordinate of the upper connection point of the step in branch one = the vertical coordinate of the lower connection point of the branch element + the distance between the graphic primitives. Vertical distance GRAPH_DISTANCE_V; The horizontal coordinate of the upper connection point of the step in branch two = the horizontal coordinate of the upper connection point of the step in branch one + STEP_WIDTH_DEF + the horizontal distance between entities GRAPH_DISTANCE_H + the right distance between entity comment and entity COMMENT_MARGIN_LEFT + the default width of action element ACTION_WDITH_DEF. When the entity comment is empty, COMMENT_MARGIN_LEFT=0, and when the action is empty, ACTION_WDITH_DEF=0; The vertical coordinate of the upper connection point of the step in branch two = the vertical coordinate of the upper connection point of the step in branch one.
[0054] S25. If the second element is an end step element or a jump element, it is determined that the primitive layout is ended.
[0055] S26. If the second element is a step element, a selection branch element, a parallel branch element or a macro element, determine whether there is a third element connected below the second element. If not, determine that the primitive layout is completed. If so, return the third element as the first element to execute the step of determining the coordinates of the first element.
[0056] S27: After the primitive layout is completed, calculate the initial length and initial height of the primitive.
[0057] Among them, for the end step element and the jump step element in the graphic element, the total height TOTAL_HEIGHT of all elements before the end step element and the jump step element is calculated. In the branch elements, the number of branches of each branch element is ≥2, and the branches are drawn in sequence from left to right and from top to bottom. Finally, the width of all elements in the branch element plus the value of the element spacing TOTAL_BRANCH_WIDTH is calculated as the width of the branch element, and the height TOTAL_BRANCH_HEIGHT of the longest branch is used as the height of the branch element. Each right branch needs to rely on the elements on the left for layout calculation. Finally, the length of the branch element is the horizontal coordinate of the actual edge connection point of the rightmost element minus the horizontal coordinate of the actual edge connection point of the leftmost element of the branch.
[0058] S3. Determine the final length and final height of each of the graphic elements according to the initial length and initial height of each of the graphic elements, and complete the layout.
[0059] Specifically, the maximum initial length and initial height are determined according to the initial length and initial height of each of the primitives; the maximum initial length and initial height are used as the final length and final height of each of the primitives to complete the layout, such as Figure 3 shown.
[0060] Please refer to Figure 2 , Embodiment 2 of the present invention is: A terminal for layout of interface of sequential function diagram comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, each step of the method for layout of interface of sequential function diagram in embodiment 1 is implemented.
[0061] In summary, the present invention provides an interface layout method and terminal for a sequential function diagram, which first performs inter-element layout on all graphics elements according to the graphics element numbers, then traverses all graphics elements after the preliminary layout according to the graphics element numbers, and layouts all elements in the traversed graphics elements according to the element types, and after the graphics element layout is completed, calculates the initial length and initial height of the graphics element, and determines the final length and final height of each graphics element according to the initial length and initial height of each graphics element, thereby automatically completing the reasonable layout of the sequential function diagram based on the graphics element numbers and element types by first performing inter-element layout and then performing intra-element layout, thereby reducing the layout complexity and improving the layout efficiency; in addition, the maximum initial length and initial height are used as the final length and final height of each graphics element, ensuring that the content in each graphics element can be fully displayed, thereby ensuring the layout effect.
[0062] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for layout of a sequential function chart interface, characterized in that: Includes steps: Perform inter-element layout on all the elements according to the element numbers to obtain all the elements after preliminary layout; Traversing all the primitives after the preliminary layout according to the primitive numbers, for the traversed primitives, laying out all elements in the primitives according to the element types, and after the primitive layout is completed, calculating the initial length and initial height of the primitives; The final length and final height of each of the graphic elements are determined according to the initial length and initial height of each of the graphic elements to complete the layout.
2. The method for layout of a sequential function chart interface according to claim 1, characterized in that: The laying out of all elements in the primitive according to element type comprises: Determine a starting step element from all elements in the primitive, and determine the name coordinates of the primitive, the annotation coordinates of the primitive, and the coordinates of the starting step element; Determine the first element connected to the bottom of the starting step element, determine the coordinates of the first element, and determine the coordinates of the connection point between the starting step element and the first element; If the first element is an end step element or a jump element, it is determined that the primitive layout is ended; If the first element is a transfer element or a macro element, then determining a second element connected to the lower portion of the first element, determining the coordinates of the second element, and determining the coordinates of the connection point between the first element and the second element; If the second element is an end step element or a jump element, it is determined that the primitive layout is ended; If the second element is a step element, a selection branch element, a parallel branch element or a macro element, determine whether there is a connected third element below the second element. If not, determine that the primitive layout is completed. If so, return the third element as the first element to execute the step of determining the coordinates of the first element.
3. The method for layout of a sequential function chart interface according to claim 2, characterized in that: The determining of the coordinates of the name of the graphic element, the annotation coordinates of the graphic element and the coordinates of the starting step element comprises: Determine that the horizontal coordinate of the start step element is the distance between the preset start step and the left side of the interface, and the vertical coordinate is the distance between the preset start step and the top of the interface; Determine the abscissa of the name coordinates of the graphic element according to the abscissa of the starting step element and the distance between the sequential function diagram after layout is completed and the left side of the interface, and determine the ordinate of the name coordinates of the graphic element according to the ordinate of the starting step element and the distance between the sequential function diagram after layout is completed and the top of the interface; The horizontal coordinate of the annotation coordinate of the graphic element is determined according to the horizontal coordinate of the graphic element, the width of the graphic element and the distance between the default sequential function diagram and the left side of the interface, and the vertical coordinate of the annotation coordinate of the graphic element is determined according to the vertical coordinate of the graphic element.
4. The method for layout of a sequential function chart interface according to claim 3, characterized in that: The determining the coordinates of the first element comprises: If the first element is the end step element, the abscissa of the end step element is determined according to the abscissa of the start step element; Calculate the product of the number of actions in the step element and the preset height of the action; Determine a maximum value from the product and the vertical distance between the preset primitives, and use the maximum value as the height of the primitive connection line; The vertical coordinate of the ending step element is calculated according to the vertical coordinate of the starting step element, the default height of the step element and the height of the primitive connection line.
5. The method for layout of a sequential function chart interface according to claim 3, characterized in that: The determining the coordinates of the first element comprises: If the first element is the jump element, the abscissa of the jump element is calculated according to the abscissa of the start step element and the preset distance between the jump element and the left side of the interface; Calculate the product of the number of actions in the step element and the preset height of the action; Determine a maximum value from the product and the vertical distance between the preset primitives, and use the maximum value as the height of the primitive connection line; The vertical coordinate of the jump element is calculated according to the vertical coordinate of the start step element, the default height of the step element and the height of the primitive connection line.
6. The method for layout of a sequential function chart interface according to claim 3, characterized in that: The determining the coordinates of the first element comprises: If the first element is the transition element, the abscissa of the transition element is calculated according to the abscissa of the starting step element and the preset distance between the transition element and the left side of the interface; Calculate the product of the number of actions in the step element and the preset height of the action; Determine a maximum value from the product and the vertical distance between the preset primitives, and use the maximum value as the height of the primitive connection line; The ordinate of the transfer element is calculated according to the ordinate of the start step element, the default height of the step element and the height of the primitive connection line.
7. The method for layout of a sequential function chart interface according to claim 3, characterized in that: The determining the coordinates of the first element comprises: If the first element is the macro element, determining the abscissa of the macro element according to the abscissa of the start step element; Calculate the product of the number of actions in the step element and the preset height of the action; Determine a maximum value from the product and the vertical distance between the preset primitives, and use the maximum value as the height of the primitive connection line; The vertical coordinate of the macro element is calculated according to the vertical coordinate of the starting step element, the default height of the step element and the height of the primitive connection line.
8. The method for layout of a sequential function chart interface according to claim 4, characterized in that: Determining the coordinates of the connection point between the starting step element and the first element comprises: If the first element is the end step element, the abscissa of the bottom connection point of the start step element is calculated according to the abscissa of the start step element and the default width of the step element, and the ordinate of the bottom connection point of the start step element is calculated according to the ordinate of the start step element and the default height of the step element; The horizontal coordinate of the upper connection point of the first element is determined according to the horizontal coordinate of the lower connection point of the starting step element, and the vertical coordinate of the upper connection point of the first element is calculated according to the vertical coordinate of the lower connection point of the starting step element and the height of the primitive connection line.
9. The method for layout of a sequential function chart interface according to claim 1, characterized in that: Determining the final length and final height of each of the graphic elements according to the initial length and initial height of each of the graphic elements comprises: Determine the maximum initial length and initial height according to the initial length and initial height of each of the graphic elements; The maximum initial length and initial height are used as the final length and final height of each of the primitives.
10. A sequential function chart interface layout terminal, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the processor implements the various steps in the interface layout method of a sequential function chart as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Online debugging implementation method of compiling soft programmable logic controller (PLC)
CN103123598A
Interface layout system and layout method for ladder diagram logic configuration
CN117221146A
Method for exporting and importing SFC language in PLC programming software
CN118012418A
Sequential function chart production device
JP1998326103A
