Structuring support device, structuring support method, and structuring support program

JPWO2024247284A5Active Publication Date: 2025-05-13MITSUBISHI ELECTRIC CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
JP2024571925
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Filing Date
2023-06-02
Publication Date
2025-05-13
Estimated Expiration
2043-06-02

AI Technical Summary

Benefits of technology

【0007】 本開示では、対象の変数が複数のプログラムブロックの外で使用されておらず、かつ、複数のプログラムブロックで共通で使用されているという条件を満たすか否かに応じて、対象の変数の種別を決定する。これにより、変数の種別を適切に決定でき適切な変数に変換可能にすることができる。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000009_0000
    Figure 00000009_0000
  • Figure 00000009_0001
    Figure 00000009_0001
  • Figure 00000010_0000
    Figure 00000010_0000
Patent Text Reader

Abstract

The structuring support device (10) sets one or more variables used in a plurality of similar program blocks included in a ladder program as target variables. The structuring support device (10) determines the type of the target variable depending on whether the target variable satisfies the conditions that the target variable is not used outside the plurality of program blocks in the ladder program and is used in common in the plurality of program blocks. Based on the determined type, the structuring support device (10) generates a function block in which the plurality of program blocks are turned into a function.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The present disclosure relates to a technique for supporting the structuring of ladder programs. [Background technology]

[0002] Structuring is also being promoted in ladder programs for programmable logic controllers. Program creation support tools for ladder programs are also required to have functions to support structuring of ladder programs. Structuring of ladder programs includes creating function blocks that turn functions into functions.

[0003] Patent Document 1 describes a technology in which, when a user specifies the range of a program that he or she wants to use as a function block, the specified range is converted into a function block. When converting into a function block, it is necessary to convert variables such as devices and labels used in the selected range into appropriate types of variables and convert them into function blocks. In Patent Document 1, variables are converted into types such as input / output variables and internal variables depending on whether or not they are used outside the specified range. [Prior art documents] [Patent documents]

[0004] [Patent Document 1] JP 2008-33913 A Summary of the Invention [Problem to be solved by the invention]

[0005] There is a code clone detection technology that detects similar programs. When similar programs extracted using code clone technology are organized into function blocks, it is necessary to organize multiple programs into one function block. However, with the technology described in Patent Document 1, when multiple programs are organized into function blocks at the same time, there is a possibility that variables such as devices and labels cannot be converted into variables of appropriate types. The present disclosure aims to make it possible to convert multiple programs into appropriate variables when combining them into one function block. [Means for solving the problem]

[0006] The structuring support device according to the present disclosure comprises: a program analysis unit that identifies a plurality of similar program blocks included in a ladder program; a function block generating unit which regards each of one or more variables used in the plurality of program blocks identified by the program analysis unit as a target variable, determines a type of the target variable depending on whether or not the target variable satisfies a condition that the target variable is not used outside the plurality of program blocks in the ladder program and is used in common in the plurality of program blocks, and generates a function block in which the plurality of program blocks are turned into a function; Equipped with. Effect of the Invention

[0007] In the present disclosure, the type of a target variable is determined depending on whether or not the target variable satisfies the conditions that the target variable is not used outside of multiple program blocks and is commonly used in multiple program blocks. This makes it possible to appropriately determine the type of the variable and convert it to an appropriate variable. [Brief description of the drawings]

[0008] [Figure 1] FIG. 1 is a configuration diagram of a structuring support device 10 according to a first embodiment. [Diagram 2] 3 is a flowchart of the process of the structuring support device 10 according to the first embodiment. [Diagram 3] FIG. 2 is a diagram showing an example of a ladder program 30 according to the first embodiment. [Figure 4] FIG. 4 is an explanatory diagram of a variable analysis process according to the first embodiment. [Diagram 5] 5 is a flowchart of a process for determining a type of a variable according to the first embodiment. [Figure 6] FIG. 4 is an explanatory diagram of a process for determining a type of a variable according to the first embodiment. [Figure 7] FIG. 4 is an explanatory diagram of a generation process of a function block 32 according to the first embodiment. [Figure 8] FIG. 2 is an explanatory diagram of a program conversion process according to the first embodiment. [Figure 9] FIG. 2 is a configuration diagram of a structuring support device 10 according to a first modified example. [Figure 10] FIG. 11 is a configuration diagram of a structuring support device 10 according to a second embodiment. [Figure 11] 11 is a flowchart of the process of the structuring support device 10 according to the second embodiment. [Figure 12] FIG. 11 is an explanatory diagram of a program comparison process according to the second embodiment. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0009] Embodiment 1 ***Configuration Description*** The configuration of a structuring support device 10 according to the first embodiment will be described with reference to FIG. The structuring support device 10 is a computer that supports the structuring of a ladder program by analyzing the ladder program and dividing it into function blocks. The structuring support device 10 includes the following hardware components: a processor 11, a memory 12, a storage 13, and a communication interface 14. The processor 11 is connected to other hardware components via signal lines and controls the other hardware components.

[0010] The processor 11 is an IC that performs processing. IC is an abbreviation for Integrated Circuit. Specific examples of the processor 11 include a CPU, a DSP, and a GPU. CPU is an abbreviation for Central Processing Unit. DSP is an abbreviation for Digital Signal Processor. GPU is an abbreviation for Graphics Processing Unit.

[0011] The memory 12 is a storage device that temporarily stores data. Specific examples of the memory 12 include SRAM and DRAM. SRAM is an abbreviation for Static Random Access Memory. DRAM is an abbreviation for Dynamic Random Access Memory.

[0012] The storage 13 is a storage device that stores data. A specific example of the storage 13 is an HDD. HDD is an abbreviation for Hard Disk Drive. The storage 13 may also be a portable recording medium such as an SD (registered trademark) memory card, CompactFlash (registered trademark), NAND flash, a flexible disk, an optical disk, a compact disk, a Blu-ray (registered trademark) disk, or a DVD. SD is an abbreviation for Secure Digital. DVD is an abbreviation for Digital Versatile Disk.

[0013] The communication interface 14 is an interface for communicating with an external device. Specific examples of the communication interface 14 include Ethernet (registered trademark), USB, and HDMI (registered trademark) ports. USB is an abbreviation for Universal Serial Bus. HDMI is an abbreviation for High-Definition Multimedia Interface.

[0014] The structuring support device 10 is connected to a transmission line 90 to which a programmable logic controller is connected via a communication interface 14. Specific examples of the transmission line 90 include a bus or a network such as a LAN. LAN is an abbreviation for Local Area Network.

[0015] The structuring support device 10 includes, as functional components, a program analysis unit 21, a variable analysis unit 22, a function block generation unit 23, and a program conversion unit 24. The functions of the functional components of the structuring support device 10 are realized by software. The storage 13 stores a program that realizes the function of each functional component of the structuring support device 10. The program is loaded into the memory 12 by the processor 11 and executed by the processor 11. This realizes the function of each functional component of the structuring support device 10.

[0016] 1 shows only one processor 11. However, there may be a plurality of processors 11, and the plurality of processors 11 may cooperate to execute programs that realize the respective functions.

[0017] ***Explanation of Operation*** The operation of the structuring support device 10 according to the first embodiment will be described with reference to FIGS. The operation procedure of the structuring support device 10 according to the embodiment 1 corresponds to the structuring support method according to the embodiment 1. Moreover, the program for realizing the operation of the structuring support device 10 according to the embodiment 1 corresponds to the structuring support program according to the embodiment 1.

[0018] The flow of processing performed by the structuring support device 10 according to the first embodiment will be described with reference to FIG. (Step S11: Program analysis process) The program analysis unit 21 analyzes the ladder program 30 and identifies a plurality of similar program blocks 31 included in the ladder program 30. The program blocks 31 are partial programs that constitute the ladder program 30. The ladder program 30 is configured using variables such as devices and labels. In FIG. 3, the ladder program 30 is configured using five variables, Label1 to Label5. The program analysis unit 21 identifies a plurality of similar program blocks 31 from the ladder program 30 using a code clone detection technique or the like. Similar means, for example, program blocks 31 that have the same structure but use different variables. Any method may be used as long as it can identify similar program blocks 31. In FIG. 3, program block 31X and program block 31Y are identified as similar program blocks 31.

[0019] (Step S12: Variable analysis process) The variable analysis unit 22 analyzes the variables used in the multiple program blocks 31 identified in step S11. Specifically, the variable analysis unit 22 sets, as a target variable, one or more variables used in a plurality of program blocks 31. The variable analysis unit 22 identifies the location and the situation of use of the target variable. There are three usage points: input, output, and input / output. Input is the case where the target variable is used in an input command. Output is the case where the target variable is used in an output command. Input / output is the case where the target variable is used in both an input command and an output command. There are three usage situations, (1) to (3). (1) is a case where the variable is used outside of multiple program blocks 31 in the ladder program 30. (2) is a case where the target variable is not used outside of multiple program blocks 31 in the ladder program 30, and is not used in common among the multiple program blocks 31. (3) is a case where the target variable is not used outside of multiple program blocks 31 in the ladder program 30, and is used in common among the multiple program blocks 31.

[0020] As a result, each variable used in the ladder program 30 shown in FIG. 3 is analyzed as shown in FIG. 3 are used outside of multiple program blocks 31, so the answer is (1). Labels 3 and 4 are not used outside of multiple program blocks 31. However, Label 3 is only used in program block 31X, and Label 4 is only used in program block 31Y, so the answer is (2). Label 5 is not used outside of multiple program blocks 31, and is used in common by program blocks 31X and 31Y, so the answer is (3).

[0021] (Step S13: Function block generation process) The function block generator 23 determines the type of the variable by referring to the analysis result obtained in step S12. Then, the function block generator 23 generates a function block 32 in which a plurality of program blocks are converted into a function based on the type of the variable.

[0022] The process of determining the type of a variable will be described with reference to FIGS. The function block generation unit 23 sets one or more variables used in the plurality of program blocks 31 as target variables. Then, the function block generation unit 23 executes the process shown in FIG. 5 for the target variables.

[0023] (Step S121: External use determination process) The function block generation unit 23 determines whether or not the target variable is used outside the multiple program blocks 31 in the ladder program 30. If the target variable is not used outside, the function block generation unit 23 advances the process to step S122. On the other hand, if the target variable is used outside, the function block generation unit 23 advances the process to step S123.

[0024] (Step S122: Common specification determination process) The function block generation unit 23 determines whether or not the target variable is commonly used in a plurality of program blocks 31. If the target variable is not commonly used, the function block generation unit 23 advances the process to step S123. On the other hand, if the target variable is commonly used, the function block generation unit 23 advances the process to step S127.

[0025] (Step S123: Command determination process) The function block generation unit 23 determines whether the target variable is used in an input command or an output command. If the target variable is used in an input command, the function block generation unit 23 advances the process to step S124. If the target variable is used in an output command, the function block generation unit 23 advances the process to step S125. If the target variable is used in both an input command and an output command, the function block generation unit 23 advances the process to step S126.

[0026] (Step S124: First determination process) The function block generator 23 determines the type of the target variable to be an input variable.

[0027] (Step S125: Second determination process) The function block generator 23 determines the type of the target variable to be an output variable.

[0028] (Step S126: Third decision process) The function block generator 23 determines the type of the target variable to be an input / output variable.

[0029] (Step S127: Fourth decision process) The function block generator 23 determines the type of the target variable to be an internal variable. Therefore, Label1 is an input variable, Label2 is an output variable, Label3 and 4 are input / output variables, and Label5 is an internal variable.

[0030] The process of generating the function block 32 will be described with reference to FIG. The function block generation unit 23 selects one of the multiple program blocks 31. The function block generation unit 23 sets the variable name in the function block 32 to each variable of the selected program block 31, and also sets the determined type. Assume that program block 31X in Fig. 3 is selected. In this case, FBLabel1 is set as the name in Label1, and an input variable is set as the type. FBLabel2 is set as the name in Label2, and an output variable is set as the type. FBLabel3 is set as the name in Label3, and an input / output variable is set as the type. FBLabel4 is set as the name in Label5, and an internal variable is set as the type. As a result, function block 32 is generated. Assume that program block 31Y in Fig. 3 is selected. In this case, FBLabel1 is set as the name in Label1, and an input variable is set as the type. FBLabel2 is set as the name in Label2, and an output variable is set as the type. FBLabel3 is set as the name in Label4, and an input / output variable is set as the type. FBLabel4 is set as the name in Label5, and an internal variable is set as the type. As a result, the same function block 32 is generated as when program block 31X is selected.

[0031] (Step S14: Program conversion process) The program conversion unit 24 converts the ladder program 30 by replacing the multiple program blocks 31 with the function blocks 32 generated in step S13. Any method may be used to replace the program blocks 31 with the function blocks 32 as long as it ensures that the ladder program 30 is equivalent before and after the replacement. For example, for each program block 31 in the ladder program 30, the program conversion unit 24 replaces the remaining part with a function block 32 while leaving only the input instructions from outside and the output instructions to outside. At this time, the program conversion unit 24 associates variables used in the remaining input instructions with the corresponding variables in the function block 32.

[0032] In the case of the ladder program 30 shown in FIG. 3, the program blocks 31X and 31Y are replaced with a function block 32 as shown in FIG. For the program block 31X, only the input instruction of Label1, 3, which is an input instruction from the outside, and the output instruction of Label2, 3, which is an output instruction to the outside, are left, and the remaining part is replaced with the function block 32. Then, the input instruction of Label1 is associated with FBLabel1, Label2 is associated with FBLabel2, and Label3 is associated with FBLabel3. For the program block 31Y, the input instruction of Label1, 4, which is an external input instruction, and the output instruction of Label2, 4, which is an external output instruction, are left, and the remaining part is replaced with the function block 32. Then, the input instruction of Label1 is associated with FBLabel1, Label2 is associated with FBLabel2, and Label4 is associated with FBLabel3.

[0033] ***Advantages of the First Embodiment*** As described above, the structuring support device 10 according to the first embodiment determines the type of a target variable depending on whether or not the target variable satisfies the conditions that the target variable is not used outside of multiple program blocks and is used in common among multiple program blocks. This makes it possible to appropriately determine the type of a variable and convert it into an appropriate variable. This makes it possible to reduce the number of steps required to structure a ladder program.

[0034] ***Other configurations*** <Variation 1> In the first embodiment, each functional component is realized by software. However, as a first modification, each functional component may be realized by hardware. The following describes the first modification in terms of differences from the first embodiment.

[0035] The configuration of a structuring support device 10 according to the first modification will be described with reference to FIG. When each functional component is realized by hardware, the structuring support device 10 includes an electronic circuit 15 instead of the processor 11, the memory 12, and the storage 13. The electronic circuit 15 is a dedicated circuit for realizing the functions of each functional component, the memory 12, and the storage 13.

[0036] The electronic circuit 15 may be a single circuit, a composite circuit, a programmed processor, a parallel programmed processor, a logic IC, a GA, an ASIC, or an FPGA. GA is an abbreviation for Gate Array. ASIC is an abbreviation for Application Specific Integrated Circuit. FPGA is an abbreviation for Field-Programmable Gate Array. Each functional component may be realized by one electronic circuit 15, or each functional component may be distributed across multiple electronic circuits 15.

[0037] <Variation 2> As a second modification, some of the functional components may be realized by hardware, and other functional components may be realized by software.

[0038] The processor 11, the memory 12, the storage 13, and the electronic circuit 15 are collectively referred to as a processing circuit. In other words, the functions of the respective functional components are realized by the processing circuit.

[0039] Embodiment 2 The second embodiment differs from the first embodiment in that it avoids generating a function block 32 that is the same as an existing function block 32. In the second embodiment, this difference will be explained, and explanations of the same points will be omitted.

[0040] ***Configuration Description*** The configuration of a structuring support device 10 according to the second embodiment will be described with reference to FIG. 1 in that the structuring support device 10 includes a program comparison unit 25 as a functional component. The functions of the program comparison unit 25 and the storage unit 26 are realized by software or hardware, like the other functional components.

[0041] ***Explanation of Operation*** The operation of the structuring support device 10 according to the second embodiment will be described with reference to FIGS. An operation procedure of the structuring support device 10 according to the embodiment 2 corresponds to a structuring support method according to the embodiment 2. Moreover, a program for realizing the operation of the structuring support device 10 according to the embodiment 2 corresponds to a structuring support program according to the embodiment 2.

[0042] The flow of processing by the structuring support device 10 according to the second embodiment will be described with reference to FIG. The processing from step S21 to step S22 is the same as the processing from step S11 to step S12 in FIG.

[0043] (Step S23: Program comparison process) The program comparison unit 25 compares the multiple program blocks 31 identified in step S21 with existing function blocks 32. The existing function blocks 32 include function blocks 32 generated by the function block generation unit 23 in the past and function blocks 32 provided by device manufacturers, etc. The program comparison unit 25 determines whether or not there is an existing function block 32 having the same configuration as the multiple program blocks 31. The same configuration as the multiple program blocks 31 means that it has the same structure as the multiple program blocks 31 and uses variables of the same type as each of the one or more variables used in the multiple program blocks 31. If there is no such function block, the program comparison unit 25 proceeds to step S24. On the other hand, if there is an existing function block 32, the program comparison unit 25 identifies an existing function block 32 with the same configuration and proceeds to step S25.

[0044] A specific example will be described with reference to FIG. Here, it is assumed that a program block 31Z is identified as one of the multiple program blocks 31 in step S21. Also, it is assumed that an AND function exists as an existing function block 32. The program block 31Z outputs the logical product of two inputs. Therefore, the program block 31Z has the same structure as the AND function, and the types of each variable are the same. Therefore, in the example of FIG. 12, the program comparison unit 25 determines that an existing function block 32 having the same configuration exists, identifies the AND function, and then proceeds to step S25.

[0045] (Step S24: Function block generation process) The function block generator 23 generates the function block 32 in the same manner as in step S13 of Fig. 2. Then, the function block generator 23 writes the generated function block 32 into the storage 13 as an existing function block 32.

[0046] (Step S25: Program conversion process) The program conversion unit 24 converts the ladder program 30 by replacing the program block 31 with the existing function block 32 identified in step S23 or with the function block 32 generated in step S24.

[0047] In other words, when an existing function block 32 is identified in step S23, the function block generator 23 stops generating the function block 32 in which a plurality of program blocks 31 are made into a common function.

[0048] ***Effects of the second embodiment*** As described above, the structuring support device 10 according to the second embodiment determines whether or not there is an existing function block 32 having the same configuration as the program block 31 for which the function block 32 is to be generated. If there is an existing function block 32, the structuring support device 10 stops generating the function block 32. This prevents multiple equivalent function blocks 32 from being generated. As a result, the configuration of the converted ladder program 30 is prevented from becoming complicated, and efficient structuring can be achieved.

[0049] In addition, the word "part" in the above description may be read as a "circuit," "step," "procedure," "processing," or "processing circuit."

[0050] The above describes the embodiments and modifications of the present disclosure. Some of these embodiments and modifications may be combined and implemented. Also, one or some of them may be partially implemented. Note that the present disclosure is not limited to the above embodiments and modifications, and various modifications are possible as necessary. [Explanation of symbols]

[0051] 10 structuring support device, 11 processor, 12 memory, 13 storage, 14 communication interface, 21 program analysis unit, 22 variable analysis unit, 23 function block generation unit, 24 program conversion unit, 25 program comparison unit, 30 ladder program, 31 program block, 32 function block.

Claims

1. a program analysis unit that identifies a plurality of similar program blocks included in a ladder program; a function block generating unit which regards each of one or more variables used in the plurality of program blocks identified by the program analysis unit as a target variable, determines a type of the target variable depending on whether or not the target variable satisfies a condition that the target variable is not used outside the plurality of program blocks in the ladder program and is used in common in the plurality of program blocks, and generates a function block by converting the plurality of program blocks into a function; A structuring support device comprising:

2. When the condition is satisfied, the function block generation unit sets the type of the target variable as an internal variable, and when the condition is not satisfied, the function block generation unit determines the type of the target variable depending on whether the target variable is used in an input command or an output command. The structuring support device according to claim 1 .

3. When the condition is not satisfied, if the target variable is used in an input instruction and is not used in an output instruction, the function block generation unit sets the type of the target variable to an input variable, if the target variable is used in an output instruction and is not used in an input instruction, the function block generation unit sets the type of the target variable to an output variable, if the target variable is used in an output instruction and is not used in an input instruction, the function block generation unit sets the type of the target variable to an input / output variable, if the target variable is used in both an input instruction and an output instruction The structuring support device according to claim 2.

4. The structuring support device further comprises: a program conversion unit that converts the ladder program by replacing the plurality of program blocks with the function blocks generated by the function block generation unit; The structuring support device according to claim 1 .

5. The structuring support device further comprises: a program comparison unit that identifies an existing function block that has the same structure as the plurality of program blocks and uses one or more variables of the same type as each of the one or more variables used in the plurality of program blocks; Equipped with The function block generating unit stops generating a function block obtained by converting the plurality of program blocks into a common function when an existing function block is identified by the program comparing unit. The structuring support device according to claim 1 .

6. The plurality of program blocks have the same structure but use different variables. The structuring support device according to claim 1 .

7. The computer identifies a plurality of similar program blocks included in the ladder program, A structuring support method in which a computer determines the type of one or more variables used in the plurality of program blocks as target variables depending on whether the target variables are not used outside the plurality of program blocks in the ladder program and are used in common in the plurality of program blocks, and generates function blocks that turn the plurality of program blocks into functions.

8. A program analysis process for identifying a plurality of similar program blocks included in a ladder program; a function block generation process in which one or more variables used in the plurality of program blocks identified by the program analysis process are set as target variables, and a type of the target variable is determined depending on whether or not the target variable satisfies a condition that the target variable is not used outside the plurality of program blocks in the ladder program and is used in common in the plurality of program blocks, thereby generating a function block in which the plurality of program blocks are turned into functions; A structuring support program that causes a computer to function as a structuring support device that performs the above steps.