Program development assistance device, program development assistance method, and program development assistance program
The program development support device automates the conversion of control programs into model-based development assets by analyzing control programs and performing similarity searches, addressing the inefficiencies of manual conversion and information loss in existing technologies.
Patent Information
- Application Number
- PCT/JP2023/013688
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-03-31
- Publication Date
- 2024-10-03
AI Technical Summary
Existing control programs in factory and process automation lack efficient conversion to model-based development assets, requiring manual intervention and significant man-hours, and there is no known technique for automated conversion without losing developer intent and design information.
A program development support device and method that analyzes control programs to detect program fragments, creates side effect lists, and performs similarity searches to identify matching fragments, enabling the generation of control program models without assuming attached design information.
Automates the conversion of existing control programs into model-based development assets, reducing man-hours and enabling efficient model modification and reuse, while maintaining developer intent and design information.
Smart Images

Figure JP2023013688_03102024_PF_FP_ABST
Abstract
Description
Program development support device, program development support method, and program development support program
[0001] The present disclosure relates to a program development support device, a program development support method, and a program development support program, and to improving the efficiency of development of control programs in the fields of factory automation (FA) and process automation (PA).
[0002] Machine tools and production lines (hereinafter collectively referred to as production equipment) are often controlled using a programmable logic controller (PLC). Because the control content varies depending on the production equipment, machine tool manufacturers or system integrators (hereinafter collectively referred to as production equipment manufacturers) create control programs according to the production equipment.
[0003] The application of model-based development is spreading in some areas to improve the efficiency of control program development. As of 2022, the scope of application of model-based development remains limited, and it cannot be said that it is widely applied to the development of production equipment and control programs. For this reason, a large proportion of development assets (hereinafter referred to as existing development assets) have not yet been applied to model-based development among all production equipment on the market. Considering the need for business efficiency in recent years, it is preferable to convert existing development assets into development assets that have applied model-based development (hereinafter referred to as model-based development assets) and use them in future model modifications and model reuse development.
[0004] It would be useful to be able to convert existing control programs, which are development assets, into model-based development assets. However, manual conversion requires a significant amount of man-hours, and no technology is known for performing this conversion without manual intervention.
[0005] To recover a model from a control program, it is necessary to recover the intent of the developer who created the control program. However, information is often lost due to changes in engineers, and supplementary information (labels, comments) or design documents in the control program that can serve as clues for analysis are often insufficient.
[0006] As a result, it is often determined that the benefits obtained by manual work are not commensurate with the effort invested.In addition, since it is necessary to restore the developer's intent and deriving a model from a control program is not a problem that can be solved deterministically, there are no known techniques for performing conversion using software.
[0007] Japanese Patent Application Laid-Open No. 2001-306108
[0008] Patent Document 1 discloses a control program creation method characterized by associating a state transition diagram, which is a type of model, with a control program and saving it. The state transition diagram must be created and edited on a screen in advance by the user, and Patent Document 1 mentions generating a control program from the state transition diagram. However, it does not mention models other than the state transition diagram. The technology disclosed in Patent Document 1 also does not disclose or suggest deriving a state transition diagram from a control program. The problem that this disclosure aims to solve is to detect program fragments that serve as building blocks of a model from an existing control program and generate a control program model, without assuming that design information for production equipment is attached to the control program.
[0009] The program development support device of the present disclosure includes a program fragment database that registers multiple fragment side effect lists, in which multiple side effects included in program fragments corresponding to mechanism elements are described as multiple fragment side effects, in correspondence with multiple program fragments; a program analysis unit that analyzes a control program and creates a program side effect list, in which multiple side effects included in the control program are described as multiple program side effects; and a similarity search unit that compares the multiple program side effects described in the program side effect list with the multiple fragment side effects described in the multiple fragment side effect lists, and searches for program fragments that correspond to the fragment side effect list in which the multiple fragment side effects are included in the multiple program side effects, as similar program fragments.
[0010] In the present disclosure, the similarity search unit compares the side effects of an existing control program with those of a program fragment, thereby making it possible to detect program fragments that serve as building blocks of a model from the existing control program.
[0011] 1 is a diagram showing an example of a control program. FIG. 1 is a diagram showing an example of a block definition diagram. FIG. 1 is a diagram showing an example of an internal block diagram. FIG. 1 is a diagram showing an example of a state transition diagram. FIG. 2 is a diagram showing a system configuration. FIG. 2 is a diagram showing the configuration of an engineering workstation 9. FIG. 3 is a diagram showing the configuration of a program development support device 1. FIG. 3 is a diagram showing the configuration of a model extraction unit 104. FIG. 4 is a diagram showing a mechanism element side effect table. FIG. 4 is a diagram showing the structure of a program fragment database 1043. A flowchart showing the operation of the program analysis unit 1041. FIG. 5 is a diagram showing an example of a program list converted into text by the program analysis unit 1041. FIG. 6 is a diagram showing an example of a variable abstraction table by the program analysis unit 1041. FIG. 7 is a diagram showing an example of a program after normalization and abstraction by the program analysis unit 1041. FIG. 8 is a diagram showing an example of a side effect target algebra by the program analysis unit 1041. FIG. 9 is a diagram showing an example of a program side effect list by the program analysis unit 1041. FIG. 10 is a diagram showing an example of program side effect dependencies of program side effects by the program analysis unit 1041. FIG. 11 is a diagram showing a program dependency graph of program side effects by the program analysis unit 1041. FIG. 11 is a diagram showing an example of a side effect list after program normalization by the program analysis unit 1041. FIG. 12 is a diagram showing the relationship of information by the program analysis unit 1041. 1. A flowchart showing the operation of the similarity search unit 1042. A diagram showing an example of a determination of a side effect search by the similarity search unit 1042. A diagram showing the data structure of the search results by the similarity search unit 1042. A diagram showing an example of a search result table by the similarity search unit 1042. A diagram showing an example of a search result correspondence table by the similarity search unit 1042. A diagram showing an example of a side effect matching table by the similarity search unit 1042. A diagram showing another example of a side effect matching table by the similarity search unit 1042. A diagram showing a side effect combination list by the mechanism element estimation unit 1044. A diagram showing the structure of a model database. A diagram showing a model database management table. A diagram showing a monitor screen by the model configuration unit 1045. A diagram showing a monitor screen by the model configuration unit 1045.
[0012] Hereinafter, embodiments of the present disclosure will be described with reference to the drawings. In each drawing, identical or corresponding parts are designated by the same reference numerals. In the description of the embodiments, the description of identical or corresponding parts will be omitted or simplified as appropriate.
[0013] Embodiment 1. In this embodiment, the control program will be described on the assumption that it is a program developed using ladder diagrams, which are graphical programming languages that mimic electric circuits. Four other languages have also been standardized by IEC (International Electrotechnical Commission) 61131-3, and the subject of this embodiment is not limited to ladder diagrams.
[0014] An example of a control program created using a ladder diagram is shown in Figure 1. The language specifications for ladder diagrams are based on IEC 61131-3 and other documents, but the outline is as follows: - Horizontal lines in the program are connection lines. - The left side of a connection line is a conditional statement, and the right side is a command statement. When a conditional statement is met, the command statement on that connection line is executed. - Conditional statements written in parallel by integrating connection lines become OR conditions. In other words, when one or more conditional statements are met, the command statement is executed. - Conditional statements written in series on a connection line become AND conditions. In other words, when all conditional statements are met, the command statement is executed. - Command statements written in parallel by branching connection lines are all executed when the conditional statement is met.
[0015] The created control program is executed by a controller. The control program is implemented to execute within a predetermined time constraint, triggered by a fixed period or event-driven trigger. Typically, the control program is executed periodically, repeatedly at a set time called the basic processing cycle. Based on the original concept of a ladder diagram, which mimics an electrical circuit, parallel connection lines are not sequentially executed, and the execution timing of the conditional statements and command statements of each connection line is parallel. However, in actual controllers, because control programs are executed using a finite number of processor cores, they are often executed sequentially, as if there was an order from the upper connection line to the lower connection line. The behavior of this sequential execution order can change the control results, and behavior can vary depending on the controller manufacturer or model, but these behavioral differences are rarely taken into account in practice.
[0016] In model-based development, production equipment is described in SysML (Systems Modeling Language) or other abstract models during the design stage, and the model is used to automatically design mechanical or electrical equipment and automatically generate control programs, improving efficiency. Describing production equipment as a model also makes its modification and reuse development more efficient. SysML defines multiple types of models, but the following three types are effective for automatically generating control programs. These models are explained below with simple examples: Block Definition Diagram (BDD). Internal Block Diagram (IBD). State Machine Diagram (STM).
[0017] An example of a block definition diagram is shown in Figure 2. Figure 2 is a diagram showing the structural relationships of production equipment. Production Line A is shown to consist of one transfer system 1 (Transfer 1), a press machine (Press), and transfer system 2 (Transfer 2). Furthermore, transfer system 1 is shown to consist of three subsystems: a work detector (Work Detector), a conveyor 1 (Conveyor 1), and a turntable 1 (Turntable 1). The press machine and transfer system 2 are also similarly structured in a hierarchical structure.
[0018] An example of an internal block diagram is shown in Figure 3. Figure 3 is a diagram showing the internal configuration and connection relationship of the transport system 1. The transport system 1 is configured around a controller subsystem. Figure 3 shows that a detection sensor is connected, and that the controller subsystem uses input information bDetect from the detection sensor for control.
[0019] An example of a state transition diagram is shown in Figure 4. Figure 4 is a diagram showing the state transitions of the operation of the conveyance system 1. The conveyance system 1 has three states: stopped, conveying on the conveyor, and turning on the turntable, and when a workpiece is detected in the stopped state, it transitions to conveying on the conveyor.
[0020] ***Problem that the embodiment aims to solve*** The problem that the embodiment aims to solve is to generate a control program model based on an existing control program, without assuming that the control program is accompanied by design information for the production equipment.
[0021] The problem that this embodiment aims to solve can be broken down into the following two sub-problems. (Sub-problem 1) Detecting program fragments that serve as building blocks for a control program model from within a control program Large-scale control programs can range from thousands to tens of thousands of lines, and often contain a mixture of control processes for multiple subsystems. Because control programs are implemented with a degree of freedom depending on the developer, control programs are not necessarily organized into files or consecutive lines for each target subsystem. A model cannot be generated without organizing the control program into meaningful units. Therefore, the first problem is to divide the control program into blocks, which are meaningful units that correspond to the subsystems.
[0022] (Subtask 2) Generating a control program model from program fragments Program fragments merely represent the content of control processing, not highly abstract block definitions or state transitions. For this reason, the second task is to generate a control program model from program fragments. When generating a model, it is necessary to consider the fact that countless program fragments with the same behavior can be written, and to ensure that a model can be derived based on the behavior of even program fragments with different descriptions. Since there are countless possible descriptions of program fragments, differences are not limited to minor differences in the variable assignments and conditional statements used, but can also be at the syntax level, and therefore simple matching comparisons using wildcard searches and other searches cannot confirm the identity of behavior.
[0023] ***Description of the Configuration of the Embodiment*** An embodiment of this embodiment will be described. Note that the content described in this embodiment does not limit the scope of the present disclosure. The production equipment (hereinafter referred to as the control object) controlled by the control program is a combination of mechanical mechanisms or electric circuits (both collectively referred to as mechanism elements). A portion (fragment) of the control program and the entire control program are collectively referred to as the control program.
[0024] The program development support device 1 of this embodiment is used in a system configuration as shown in FIG. 5 . The program development support device 1 is connected to a controller 3 via a setting bus 2 and is a device for developing programs to be executed by a controller for controlling production equipment. The setting bus 2 is a serial bus, a wired network, or a wireless network. The setting bus 2 is used to write programs to the controller 3 and can be disconnected when not in use. The setting bus 2 may be replaced with a storage medium or other means that can be used to transfer programs. The controller 3 controls the production equipment. The nearby devices 4 and remote devices 5 are various devices that input and output information to the controller 3 and perform operations based on commands from the controller 3. The nearby devices 4 are installed near the controller 3 via a backplane bus. The remote devices 5 are connected to the controller 3 via a control network 6.
[0025] The program development support device 1 executes program development support software on an engineering workstation 9 configured as shown in FIG. 6 . The engineering workstation 9 is a general-purpose computer. In the engineering workstation 9, a CPU 91, a memory 92, a non-volatile memory 93, and a setting port 94 are connected to a bus 95. The engineering workstation 9 can be of any type as long as it has the resources necessary to execute the program development support software. The engineering workstation 9 may be a desktop computer, a notebook computer, a tablet computer, or a virtual computer executed in the cloud. The engineering workstation 9 may be a multiprocessor, a multi-core processor, a parallel computing accelerator using a GPU (Graphics Processing Unit), or may use quantum or pseudo-quantum processing technology to speed up processing.
[0026] The configuration of the program development support device 1 realized by executing the above-mentioned program development support software is as shown in FIG.
[0027] The programming unit 101 provides a means for developers to create or edit control programs and is realized by a program editor or other editor. The programming unit 101 is basically designed to enable programming in all or part of five languages, including ladder diagrams standardized by IEC 61131-3. The programming unit 101 may also support other languages as long as they can write control programs. The program memory 103 is a storage area for temporarily storing control programs developed by developers using the programming unit 101 during the creation and editing process, or for permanently storing them after creation. A control program represents the entire series of programs that control production equipment, and is generally stored, saved, and managed under the name of a project.
[0028] The program setting storage unit 105 permanently stores the program in the program memory 103. Alternatively, the program setting storage unit 105 provides a function for writing to the controller 3 via the setting port 94. The model extraction unit 104 is a means for analyzing the control program stored in the program memory 103 and extracting a model. The model extraction unit 104 generates a block definition diagram, an internal block diagram, and a state transition diagram, which are models corresponding to the control program. The model extraction unit 104 is an element constituting a feature of this embodiment and is composed of multiple components, so details of the model extraction unit 104 will be described separately.
[0029] The display operation unit 102 is a means for providing a developer with the display and operation of the process and results of model extraction using a monitor, keyboard, and mouse. The display operation unit 102 also serves as a means for registering data in the program fragment database 1043 and the model database 1046.
[0030] The internal configuration of the model extraction unit 104 is shown in Figure 8. The functions of each unit are outlined as follows: The program analysis unit 1041 converts the control program P into a form in which side effects are extracted to facilitate similarity searches. The similarity search unit 1042 uses the output of the program analysis unit 1041 and the program fragment database 1043 to search the control program P for program fragments that have side effects equivalent to those of mechanism elements registered in the program fragment database 1043, and obtains a list of matching search results. The mechanism element estimation unit 1044 estimates which combinations of mechanism elements make up the control program P based on the list of search results. Since the search results may include combinations of mechanism elements that cannot coexist in the control program, the mechanism element estimation unit 1044 eliminates combinations of mechanism elements that cannot coexist. The model construction unit 1045 searches the model database 1046 for models corresponding to the mechanism elements estimated by the mechanism element estimation unit 1044, and estimates the connection relationships between them to estimate a model of the entire control program.
[0031] The "part" of each of the program analysis unit 1041, similarity search unit 1042, mechanism element estimation unit 1044, and model configuration unit 1045 may be read as a "process," "procedure," or "step." The program development support method is a method performed by executing a program development support program. The program development support program causes a computer to execute each of the processes, procedures, or steps in which the "part" of each of the above-mentioned parts is read as a "process," "procedure," or "step." The program development support program may be provided as a program product or a computer-readable non-volatile recording medium on which the program is recorded.
[0032] The functions of the program analysis unit 1041, the similarity search unit 1042, the mechanism element estimation unit 1044, and the model construction unit 1045 may be realized by a single electronic circuit or may be distributed across multiple electronic circuits. Some of the functions of the program analysis unit 1041, the similarity search unit 1042, the mechanism element estimation unit 1044, and the model construction unit 1045 may be realized by electronic circuits, and the remaining functions may be realized by software. Some or all of the functions of the program analysis unit 1041, the similarity search unit 1042, the mechanism element estimation unit 1044, and the model construction unit 1045 may be realized by firmware. Each of the processor 901 and the electronic circuit is also referred to as a processing circuitry. The functions of the program analysis unit 1041, the similarity search unit 1042, the mechanism element estimation unit 1044, and the model construction unit 1045 are realized by the processing circuitry.
[0033] The program fragment database 1043 and the model database 1046 are stored in the non-volatile memory 93 (or the memory 92). In addition, the various lists, tables, and graphs described below are stored in the memory 92 (or the non-volatile memory 93) in list format, table format, or file format.
[0034] Similarity Search: Although minor differences may occur depending on the control target, there are standard patterns for mechanism elements, and mechanism elements can be categorized. For this reason, control programs for controlling mechanism elements of the same type can be expected to have similar control content. Therefore, a program fragment database 1043 is provided that records control program fragments (program fragments F) that control standard mechanism elements. If a control program contains a fragment similar to a program fragment F registered in the program fragment database 1043, that program fragment F is searched for as a similar program fragment. During the search, a similarity search is performed that absorbs differences in the implementation of the control program depending on the developer or the production equipment. A program analysis unit 1041 and a similarity search unit 1042 are provided, and a similarity search is performed based on the "side effects" of the program fragment F.
[0035] ●Side effects and order constraints● A side effect is a term used in the field of programming, and refers to the effect of a program changing variables inside and outside the program. Specifically, a side effect is a change in the value of a variable or a change in the value of a port number. Here, even if the control programs are completely different at the syntax level, the side effects are considered to match if the changes in variables as a result of execution are the same. Since different developers use different variable names and port numbers, the side effects are considered to match if only the correspondence between variables and ports matches.
[0036] The similarity search unit 1042 searches for a fragment similar to the program fragment F to be searched in the control program to be searched, based on the following criteria: (1) Identity of multiple side effects: Whether the control program contains the same multiple side effects as the program fragment F. (2) Identity of order constraints of multiple side effects: Whether the control program contains multiple side effects with the same order constraints as the multiple side effects of the program fragment F.
[0037] The similarity search unit 1042 searches for program fragments by allowing the following differences in the control program as long as they satisfy the order constraints: - A change in the processing order of the control program. - A replacement of instructions used by the control program. The same side effect may occur in a different instruction. - A process unrelated to the side effect may be inserted into the control program.
[0038] Side effects are structured and defined as data that represents the change in the value of a variable or output port before and after execution of a basic processing cycle of a control program. Side effects are not limited to those with definite results, such as changing data X from 0 to 1. For this reason, a data structure is adopted that can define side effects in which the way data changes changes depending on conditions, or side effects in which the change is expressed as an expression rather than a constant. The reason for extracting information on the order constraints of multiple side effects in addition to side effects is to distinguish whether the execution result in one basic processing cycle is completely maintained or different. It is conceivable that some control programs achieve side effects through multiple basic processing cycles.
[0039] Specifically, a control program may be programmed to manipulate only internal variables in the first basic processing cycle and output the result to an external variable in the second basic processing cycle when the condition for the internal variable is met, even though the processing content can be programmed to produce a side effect in only one basic processing cycle. More specifically, in the case of a control program in which a side effect on variable A occurs first and then a side effect on variable B occurs in response to a change in the value of variable A, if the side effect on variable A occurs first, then a side effect on both variables A and B will occur as a result of one basic processing cycle.
[0040] On the other hand, in a control program in which the order of side effects is reversed, with a side effect on variable B occurring first in response to a change in the value of variable A, and then a side effect on variable A, only the side effect on variable A occurs in the first basic processing cycle, and the side effect on variable B occurs in the second basic processing cycle. In the latter case, the same result as in the former case, achieved in one basic processing cycle, is achieved through two basic processing cycles. In such cases, the processing time required for the former and latter cases differs. However, because the basic processing cycle time is generally small, measured in milliseconds, and data input and output in control programs may occur at intervals longer than the basic processing cycle, production equipment control often achieves equivalent results even if the processing time is different. In this way, we will leave room for differences even in program fragments that require different numbers of basic processing cycles but achieve the same side effects.
[0041] ●Model Configuration● A model database 1046 stores a plurality of models in association with a plurality of program fragments F, and the model configuration unit 1045 extracts models from the model database 1046. Furthermore, the model configuration unit 1045 analyzes the connectivity of the plurality of models extracted from the control program and configures a model of the entire control program. The results obtained by the model configuration unit 1045 are displayed to the user via the display operation unit 102. Furthermore, by storing the results in a memory unit by the program setting storage unit 105, it is possible to reuse the model in the development of other control programs. Note that if a model cannot be uniquely identified during the model extraction process, it may be possible to identify it from multiple options via the display operation unit 102.
[0042] ***Description of Operation of Model Extraction Unit 104*** Below, we will explain each unit of the model extraction unit 104. Below, the subject of the operation of each unit is basically the subject of the explanation in each paragraph.
[0043] ●Program fragment database 1043● The program fragment database 1043 stores multiple program fragments F corresponding to multiple mechanism elements of a set of moves. The program fragment database 1043 stores multiple program fragments F in association with multiple mechanism element identifiers (mechanism element serial numbers) listed in a mechanism element side effect table. The program fragment database 1043 stores a side effect list for each mechanism element (hereinafter referred to as a fragment side effect list) and a side effect dependency graph for each mechanism element (hereinafter referred to as a fragment side effect dependency graph) in association with the mechanism elements using the mechanism element side effect table shown in Figure 9.
[0044] As shown in Figure 10, the program fragment database 1043 stores a program fragment F for each mechanism element, a fragment side-effect list, and a fragment side-effect dependency graph. Many types of program fragments F for standard mechanism elements are widely published in reference books on control programs for developers, and one possible method is to predefine the program fragment database 1043 based on these. Also, when developing production equipment that handles uncommon mechanism elements, it is possible for developers to manually register program fragments F in the program fragment database 1043. The fragment side-effect list and fragment side-effect dependency graph can be created by inputting the program fragment F instead of the control program P into the program analysis unit 1041 described below.
[0045] ●Program analysis unit 1041● The program analysis unit 1041 takes the control program P as input and generates side effect order constraint information for the control program P (a normalized fragmented side effect list for the control program P and a program side effect dependency graph for the control program P, which will be described later). Examples will be described separately. The flow of operation of the program analysis unit 1041 is shown in Figure 11. It is assumed that the control program P to be analyzed by the program analysis unit 1041 has been loaded into the program memory 103 in advance. It is assumed that the program memory 103 stores a program list (the program list shown in Figure 12) in which the control program P in Figure 1 has been converted into text.
[0046] Step S1: Normalization and Abstraction of Control Program P As preprocessing, the program analysis unit 1041 normalizes the control program P into a program sequence that can be handled as a character string and whose description is constrained according to certain rules, and also performs abstraction by replacing the variables and port numbers in the control program with implementation-independent algebra. The algebra is a variable that replaces the variables implemented in the control program P. The result of these processes is called the program after normalization and abstraction.
[0047] Conversion rules for normalization can be freely set as long as they minimize program variation, but examples are as follows: ・Organize so that a single conditional statement does not contain complex conditions. Specifically, organize multiple AND conditions into conditional statements that are combined in multiple layers. Also, separate multiple OR conditions into multiple parallel conditional statements. ・If the same condition involves multiple side effects, separate them so that each variable or output port is its own statement. ・Variables or output ports are replaced with temporary variables that have the same type as the original type. A type is a general programming term that describes the meaning of data. Specifically, types include 1-bit data, 16-bit unsigned discrete values, and 32-bit signed floating-point numbers. ・Fixed values (magic numbers) are made into unique variables that represent fixed values.
[0048] An example of abstraction is shown below. Hereinafter, variables and port numbers are collectively referred to as variables. The program analysis unit 1041 replaces each of the multiple variables used in the control program P with multiple algebras and creates a variable abstraction table showing the correspondence between the replacements. An example of the variable abstraction table is shown in FIG. 13. The "Variable Name of Control Program P" column lists the multiple variables that appear in the control program in order of appearance without duplication. There is no particular restriction on the order in which they are listed in the variable abstraction table. The "Type" column describes the type of the listed variable. The type is determined for each variable during the programming stage. The types include the following, including those given in the examples: bit: 1-bit data intN: signed N-bit integer. N is generally 8, 16, 32, or 64 inclusive. uintN: unsigned N-bit integer. N is generally 8, 16, 32, or 64 inclusive. timer: timer. 1-bit data that becomes 1 after a set time has elapsed and becomes 0 otherwise. The "variable name after abstraction" is an algebraic name for a variable that appears in the control program P, and it should be assigned without duplication. Here, an algebraic name is used that combines an alphabetic prefix determined by the type and a numeric suffix that indicates the order in which the variable appears for each type. Here, the prefix m is used for the bit type, t for the timer type, and sl for the signed 16-bit integer type.
[0049] An example of a program after normalization and abstraction is shown in Figure 14. A variable abstraction table is used to convert variables into algebraic expressions for the program list. Also, commands such as RESET and ADD are replaced with numerical assignment statements. As a result, the normalized and abstracted program shown in Figure 14 is obtained.
[0050] Step S2: Extraction of Side Effect Target Algebra In order to organize changes in the values of variables that are side effects, the program analysis unit 1041 extracts a side effect target algebra that lists algebras that are subject to change from the normalized and abstracted program. In other words, the side effect target algebra is an algebra that corresponds to variables that are rewritten by the execution of the control program P, and does not include variables that are only referenced and not changed by the execution of the control program P. However, if a variable is subject to rewriting even under rare conditions, it will be included in the side effect target algebra. An example of an extracted side effect target algebra is shown in Figure 15. The side effect target algebra table is an extraction of all variables to which values are assigned in the command parts of the program after normalization and abstraction. Variables that are only referenced are not included in the side effect target algebra table.
[0051] Step S3: Extraction of Side Effects The program analysis unit 1041 lists the side effects of one basic processing cycle, i.e., the change results for each condition, for the side effect target algebra shown in Figure 15. The program analysis unit 1041 describes the side effects for each condition for each side effect target algebra so that they are complete. In other words, while the program after normalization and abstraction describes the processing flow as the control program P, in this step 3, the change results organized for each side effect target algebra are described. With regard to side effects, the conditions for the side effects or the output values of the side effects may not be fixed in the control program and may depend on the results of other side effects. In such cases, the side effects necessary to obtain the conditions or output values are also extracted. On the other hand, side effects on variables that do not affect the side effects on the side effect target algebra do not need to be extracted as side effects.
[0052] An example of extracted side effects is shown in Figure 16. The program side effect list in Figure 16 is a collection of value changes that occur in each of multiple side effect target algebras. For ease of understanding, the column "Corresponding line number of the program after normalization and abstraction" lists the line number of the control program P where the side effect is described (line number in the program list). The program side effect list contains the following: Serial number: A serial number assigned to the program side effect. Identifier of the program side effect. Variable: A variable whose value changes due to a program side effect. Program side effect: A program side effect of the control program P. Line number of the program after normalization and abstraction: A line number in the program list where the side effect of the control program P is described.
[0053] Step S4: Extraction of side effect dependencies of side effects The program analysis unit 1041 organizes the multiple program side effects extracted in the program side effect list into serial order if the order dependency relationship must be maintained in order to obtain equivalent side effects, and into parallel order if it is not.The multiple program side effects with their order dependency relationships organized can be expressed, for example, in a directed graph structure.
[0054] FIG. 17 shows a table of the order dependencies of multiple program side effects. The program side effect dependency table shown in FIG. 17 indicates which algebras a side effect on a side effect target algebra references. Specifically, a side effect on t1 references m1 and sl1. The program side effect dependency graph in FIG. 18 shows these dependencies in a directed graph. The program side effect dependency graph uses the side effect target algebras shown in FIG. 17 as nodes and represents their dependencies with arrows, with algebras that are not side effect targets (m4, m5, sl1, sl3, sl5) excluded from the graph. The program side effect dependency graph is order constraint information (hereinafter referred to as program order constraint information) that represents the order constraint relationships of side effects to ensure the equivalence of the side effects of control program P.
[0055] Step S5: Normalizing Side Effects The program analysis unit 1041 normalizes the side effects after dependency extraction according to separately defined normalization rules so that synonymous conditions are expressed in a unified manner and so that synonymous side effects are expressed in a unified manner. Examples of normalization rules are shown below. Inequalities are expressed using only less-than "<" or less-than / equal "≦", and inequalities involving only integers are expressed using only less-than "<". Specifically, the inequality 2≧X using only integers is expressed as X<3. Furthermore, the inequality 3.6≧X using floating-point numbers is replaced with X≦3.6. Identities and precomputable expressions are replaced with the result of the expression, and conditional statements are omitted. Specifically, the first expression below is replaced with the second expression. First formula: if (2>1) then (X=0) else (NOP) Second formula: X=0 - Instructions that output values such as OUT, RESET, and SET are replaced with assignment statements. Specifically, RESET X is an instruction to set X to 0, so it is replaced with X=0, which assigns 0 to X. - Conditional statements using the inequality sign "!=" are replaced with conditional statements using an equal sign. Specifically, the first formula below is replaced with the second formula. First formula: if (X!=1) then (Y=1) else (Z=1) Second formula: if (X==1) then (Z=1) else (Y=1)
[0056] The above normalization rules are merely examples, and other normalization rules may be used as long as synonymous conditions and synonymous side effects are expressed in a unified manner. An example of side effects after normalization is shown in FIG. 19. In the normalized program side-effect list shown in FIG. 19, the conditional statement for t2 has been replaced without an inequality sign as a result of normalizing the program side effects in the program side-effect list. Furthermore, the direction of the inequality sign in the conditional statement for sl4 has been reversed.
[0057] The information obtained by the program analysis unit 1041 as described above is organized as shown in Fig. 20. The program analysis unit 1041 creates one normalized and abstracted program and one normalized program side effect table for each control program P. One normalized program side effect table references one normalized program side effect list and one program side effect dependency graph.
[0058] The normalized fragmented side effect list of the control program P and the program side effect dependency graph of the control program P are collectively referred to as program side effect order constraint information.
[0059] ●Fragment side effect list and fragment side effect dependency graph in program fragment database 1043 The fragment side effect list and fragment side effect dependency graph registered in the program fragment database 1043 can be created by the program analysis unit 1041 analyzing program fragment F instead of control program P. Specifically, the program analysis unit 1041 creates the following from program fragment F: A program list in which program fragment F has been converted to text. A variable abstraction table for program fragment F. The program after normalization and abstraction of program fragment F. A side effect target algebra table for program fragment F. A fragment side effect list for program fragment F. A fragment side effect dependency table of fragment side effects of program fragment F. A fragment side effect dependency graph for program fragment F. A fragment side effect list after normalization of program fragment F.
[0060] The description formats of the tables, lists, and graphs of these program fragments F are the same as those of the tables, lists, and graphs of the control program P. Specifically, the description formats of the fragment side effect list and the program side effect list are the same. Furthermore, the description formats of the fragment side effect dependency graph and the program side effect dependency graph are the same. The fragment side effect list after normalization of the program fragment F and the fragment side effect dependency graph of the program fragment F are collectively referred to as fragment side effect order constraint information. The program analysis unit 1041 creates multiple pieces of fragment side effect order constraint information from multiple program fragments F.
[0061] Similarity Search Unit 1042 The similarity search unit 1042 searches the control program P in the program memory 103 to determine whether it contains a similar program fragment that has the same side effect as the program fragment F in the program fragment database 1043 .
[0062] The similarity search unit 1042 inputs the control program P to be searched, which is created by the developer, and the program fragment F to be searched, which is registered in the program fragment database 1043. The similarity search unit 1042 performs a similarity search using the program side effect order constraint information (the normalized program side effect list and program order constraint information) and the fragment side effect order constraint information (the normalized fragment side effect list and the fragment side effect dependency graph of the program fragment F) regarding the side effects obtained by the program analysis unit 1041. The flow of operation of the similarity search unit 1042 is shown in FIG. 21 .
[0063] Step S11: Reading Search Options The similarity search unit 1042 reads search options from the memory 92, which define the strictness of the matching conditions in the search. The reason for using the search options is to broaden the range of matches that the similarity search unit 1042 will determine when the control program P to be searched is created using complex control logic and the similarity search does not sufficiently determine a match. The search options are manually set in the memory 92 by the developer using the display / operation unit 102 of the program development support device, or the similarity search unit 1042 may change the option settings in the memory 92 depending on the search results. Specifically, if the search results in too many matching results, the search options may be set to tighten the matching conditions, and conversely, if the search results are too few, the opposite setting may be used.
[0064] The following search options are possible: Search Option 1: Whether or not to require a perfect match of the order constraints of side effects. If the control program P to be searched contains all of the side effects of the program fragment F to be searched but does not satisfy the order constraints, the side effects may not chain in a single basic processing cycle, and the same side effects may be obtained after multiple basic processing cycles are executed. In other words, by searching for partial matches of the order constraints of side effects, it may be possible to find many similar program fragments that obtain the same side effects. Here, we assume that Search Option 1 is set to require a perfect match of the order constraints of side effects. Search Option 2: Whether or not to allow differences in algebraic types. In the control program P, the same operations can be performed using variables with a wider value range. Specifically, operations on 16-bit integer types can also be performed using 32-bit integer types. By allowing type differences for variables with a wider value range, it may be possible to find many similar program fragments that obtain the same side effects. Here, we assume that Search Option 2 is set to not allow differences in algebraic types.
[0065] Step S12: Search for program side effects by fragment side effects The similarity search unit 1042 checks whether there are any matching program side effects among all of the multiple normalized fragment side effects for each of the multiple program fragments F listed in the fragment side effect list in the program fragment database 1043. If all of the multiple normalized fragment side effects in the fragment side effect list are included in the program side effect list, the similarity search unit 1042 determines that the program fragment F corresponding to the fragment side effect list is a similar program fragment. In other words, for each mechanism element registered in the program fragment database 1043, the similarity search unit 1042 checks whether the control program P satisfies all of the multiple side effects of the mechanism element. If all side effects are satisfied, it is determined that the mechanism element is included in the control program P. If any side effects are not satisfied, it is determined that the mechanism element is not included in the control program P.
[0066] In step S12, only the presence or absence of matching side effects is considered, and whether the multiple matching side effects are consistent with each other is not taken into consideration. Whether the multiple matching side effects are consistent with each other is determined by the mechanism element estimation unit 1044.
[0067] The criteria for determining whether a side effect matches are as follows: (a) the structure and conditions of the conditional branch of the side effect are the same, and (b) the results of the side effect are the same, and (c) the algebra related to the side effect is consistent.
[0068] An example of determining whether a match is made is shown in Fig. 22. Assume that the fragment side effects (search target side effects) after multiple normalization for a program fragment F are (1) and the program side effects (search target side effects) are (2) to (5).
[0069] Although (2) has a different algebra from (1), if m1 and m4, and m3 and m5 in (2) are swapped, the conditional branch structure and conditions become the same as those in (1), so it satisfies (a) above. If sl1 and sl2 are swapped, the same side effect sl2+=1 occurs, so the result of the side effect is the same, and it satisfies (b) above. sl1 in (1) and sl2 in (3) have the same type, there is no algebraic inconsistency, and it satisfies (c) above. As a result of these, it is determined that (2) matches (1).
[0070] Although the order of the branch statements in (3) is different from (1), if m1 and m5, and m3 and m4 are swapped, the conditional branch structure and conditions become the same as those in (1), so (a) above is satisfied. The same side effect sl2+=1 occurs, so the result of the side effect is the same, and (b) above is satisfied. sl2 in (1) and sl2 in (3) have the same type, there is no algebraic inconsistency, and (c) above is satisfied. As a result, (3) is judged to match (1).
[0071] In (4), no matter how the variables are rearranged, the side effect algebra sl2 is of a different type from the algebra m4 of (1), resulting in an algebraic inconsistency. This contradicts (c) above, and (4) is judged to be inconsistent with (1).
[0072] In (5), the side effect result for sl1 (sl1=0) differs from the side effect result for sl2 in (1) (sl2+=1), so (5) contradicts (b) above and is judged to be inconsistent with (1).
[0073] Next, the similarity search unit 1042 determines whether the order dependency of the fragment side effects satisfies the order dependency of the program side effects for a program fragment F whose fragment side effects all match the program side effects. Specifically, the similarity search unit 1042 compares the program order constraint information (program order dependency graph) with the fragment order constraint information (fragment order dependency graph) to check whether the dependencies of the side effect target algebras match. If the dependencies of the side effect target algebras match, the similarity search unit 1042 determines that the program side effect and the fragment side effect are equivalent.
[0074] Step S13: There is a fragment side effect that matches the program side effect If the similarity search unit 1042 determines that all of the multiple normalized fragment side effects in the fragment side effect list are included in the program side effects in the program side effect list and that there is at least one fragment side effect list whose side effect dependency matches, it transitions to step S14. Otherwise, it transitions to step S16. In other words, if it determines that there is at least one similar program fragment, it transitions to step S14, and if not, it transitions to step S16.
[0075] Step S14: Record results The similarity search unit 1042 records in the search result table whether there is a match for the program fragment F (mechanism element) corresponding to the fragment side effect list. The similarity search unit 1042 estimates that the program fragment F (mechanism element) corresponding to the fragment side effect list, in which all of the multiple normalized fragment side effects in the fragment side effect list are included in the program side effects and in which the side effect dependencies match, is a similar program fragment included in the control program P. The similarity search unit 1042 records the correspondence between the similar program fragment F (mechanism element) and the lines of the program after normalization and abstraction in the search result correspondence table. The relationship between the search result table and the search result correspondence table is as shown in Figure 23, and the search result correspondence table is referenced from the search result table.
[0076] An example of the search result table is shown in Fig. 24. Each row of the search result table corresponds to a mechanism element described in the mechanism element side effect table registered in the program fragment database 1043. The result column indicates whether or not the program fragment F of the mechanism element is included in the control program P. If the result is "Yes," a search result correspondence table ID for identifying the corresponding search result correspondence table is recorded.
[0077] An example of the search result correspondence table is shown in Fig. 25. Each row in the search result correspondence table corresponds to a side effect of the program fragment F of the mechanism element in the program fragment database 1043. The "serial number of the program after normalization and abstraction" field contains one or more line numbers that are determined to match the corresponding side effect in the control program P (the program after normalization and abstraction).
[0078] Step S15: Check the consistency of side effects for each mechanism element. If there are multiple corresponding rows in the normalized and abstracted control program P for one side effect in the search result correspondence table, the similarity search unit 1042 creates a side effect consistency table to check which combination of rows can realize the mechanism element. An example of the side effect consistency table is shown in FIG. 26. One side effect consistency table is created corresponding to a mechanism element determined to be included in the control program P. Each row in the side effect consistency table corresponds to a side effect of the program fragment F of the mechanism element in the program fragment database 1043. The similarity search unit 1042 creates one or more pairs of line numbers (line number pairs) in which multiple fragment side effects in the program fragment F correspond one-to-one to each of the line numbers of one or more line numbers in the program list. As shown in the search result correspondence table, there are eight possible line number pairs in the normalized and abstracted program that realize each side effect. Each column of the side effect consistency table lists all eight possible pairs.
[0079] Of the eight combinations, any combinations with overlapping line numbers in the normalized and abstracted program indicate that the control program does not include the processing required to realize the side effect, and thus a "NO" is entered in the judgment column as an inconsistency. Furthermore, if the line numbers in the normalized and abstracted program corresponding to the side effect of the program fragment F of the mechanism element are not in ascending order, a "?" is entered because there is a possibility that the side effect of the control program P will not be realized in the order of the side effects of the program fragment F. Finally, if there are no overlapping line numbers in the normalized and abstracted program and the line numbers in the normalized and abstracted program are in ascending order, an "OK" is entered. The similarity search unit 1042 determines that a line number combination is consistent if all of the fragment side effects in the line number combination correspond to program side effects obtained from different lines in the program list of the control program. In other words, the similarity search unit 1042 determines that a line number combination is consistent if all of the line numbers in the line number combination are different. The similarity search unit 1042 determines a program fragment F corresponding to a fragment side effect list having one or more consistent line number pairs as a similar program fragment.
[0080] In step S15, in accordance with the search option settings, "OK" is marked to pairs whose order constraints of side effects completely match, and "?" is marked to pairs whose order constraints of side effects do not completely match. The similarity search unit 1042 obtains the following tables and ends the process. Search result table Search result correspondence table Side effect matching table by line number of the normalized and abstracted program
[0081] ● Step S16: No Match If it is determined that the search results are no match, the similarity search unit 1042 terminates its processing. If it is determined that there is no match, the search options are changed to loosen the matching conditions, and then this procedure is performed again. Alternatively, if there is no room for further relaxation of the search options, it is determined that there are no modelable fragments in the control program. Specific examples of changing the search options are as follows: (1) Relaxing Search Option 1 The similarity search unit 1042 performs a search assuming that an exact match of the order constraint of side effects is not required. In other words, the similarity search unit 1042 searches for a partial match of the order constraint of side effects. If it is determined that there is no match based on the partial match, the similarity search unit 1042 further relaxes search option 1 and performs a search while ignoring the order constraint of side effects.
[0082] (2) Relaxation of Search Option 2 The similarity search unit 1042 performs a search while allowing differences in algebra types. When checking (c) of the side effect matching criteria, the similarity search unit 1042 determines that there is no contradiction in the algebra related to the side effect even if the types do not match and there is a difference in type that is upwardly compatible. Specifically, it determines that an algebra of a 16-bit integer type can also be an algebra of a 32-bit integer type.
[0083] ●Mechanism element estimation unit 1044● Based on the side effect matching table obtained by searching for one control program P (search target), the mechanism element estimation unit 1044 estimates which combination of mechanism elements the control program P controls from among multiple possible combinations of mechanism elements.
[0084] An example is shown below. (1) Case where two mechanism elements are included Suppose that a search result table indicating that two mechanism elements are included is obtained as a result of a search for one control program P (search target) by the similarity search unit 1042. The side effect matching table obtained for the first mechanism element is shown in FIG. 26, and the side effect matching table obtained for the second mechanism element is shown in FIG. 27. In this case, if both of the two mechanism elements correspond to lines of the control program P after normalization and abstraction that do not overlap, the two mechanism elements are compatible.
[0085] If the search option is set to require a complete match of the side effect order constraints, all combinations are generated by extracting one column from each of the two side effect consistency tables using the pairs whose judgment is "OK" and excluding pairs whose judgment is "NO" and "?" in the side effect consistency tables, and all combinations whose row numbers do not overlap are extracted. The combinations are expressed using the notation {column of the first side effect consistency table, column of the second side effect consistency table}. The list of these combinations is called the side effect combination list. If only pairs whose judgment is "OK" are included, extracting all combinations whose row numbers do not overlap results in the following side effect combination list: {pair 1, pair 1}, {pair 1, pair 2}, {pair 1, pair 3}, {pair 1, pair 4}, {pair 2, pair 2}, {pair 2, pair 4}. {pair 2, pair 1} and {pair 2, pair 3} are incompatible because both mechanism elements require line 42 of the normalized and abstracted program.
[0086] If the search option is set to not require a complete match of the order constraints of side effects, columns for which the judgment in the side effect consistency table is "NO" are excluded, and all combinations are generated by extracting one column from each of the two side effect consistency tables, and all combinations with no overlapping row numbers are extracted. When the combinations for which the judgment is "NO" are excluded, all combinations with no overlaps are extracted, resulting in the side effect combination list shown in Figure 28. {Set 1, Set 1}, {Set 1, Set 2}, {Set 1, Set 3}, {Set 1, Set 4}, {Set 2, Set 2}, {Set 2, Set 4}, {Set 3, Set 1}, {Set 3, Set 2}, {Set 3, Set 3}, {Set 3, Set 4}, {Set 4, Set 2}, {Set 4, Set 4}, {Set 7, Set 1}, {Set 7, Set 2}, {Set 7, Set 3}, {Set 7, Set 4}, {Set 8, Set 2}, {Set 8, Set 4}. The following combinations are incompatible because both mechanism elements require line 42 of the normalized and abstracted program: {tuple 2, tuple 1}, {tuple 2, tuple 3}, {tuple 4, tuple 1}, {tuple 4, tuple 3}, {tuple 8, tuple 1}, {tuple 8, tuple 3}.
[0087] (2) When one mechanism element is included: Suppose that the search result for one control program P (search target) by the similarity search unit 1042 indicates that only one mechanism element is included. The side effect matching table obtained for the first mechanism element is as shown in Figure 26. The combination is expressed using the notation {column of the first side effect matching table}.
[0088] If the search option is set to require a perfect match in the order constraints of side effects, the side effect combination list will be as follows: {Set 1}, {Set 2}. If the search option is set to not require a perfect match in the order constraints of side effects, the side effect combination list will be as follows: {Set 1}, {Set 2}, {Set 3}, {Set 4}, {Set 7}, {Set 8}. Even if two mechanism elements as in (1) above are included, if all of the pairs in the side effect matching table obtained for one of the mechanism elements are "NO," it will be treated the same as when one mechanism element as in (2) is included, and the side effect combination list will be created using only the side effect matching table obtained for the other mechanism element.
[0089] (3) When three or more mechanism elements are included Three or more mechanism elements may be included as a result of a search for one control program P (search target) by the similarity search unit 1042. Three or more mechanism elements are compatible if they correspond to rows of the control program P after normalization and abstraction that do not overlap. When three mechanism elements are found, the side effect combination list is written as {first column of the side effect consistency table, second column of the side effect consistency table, third column of the side effect consistency table}.
[0090] In this way, the side effect combination list is a list in which one or more pairs of line numbers are written on each line. Mechanism elements corresponding to the combinations written in the side effect combination list are mechanism elements that can be realized simultaneously. The mechanism element estimation unit 1044 outputs the side effect combination list. By combining the search result table, the side effect combination list, and the program list of the normalized and abstracted program, all combinations of which mechanism elements may be realized by which lines in the program list of the normalized and abstracted program can be determined.
[0091] It should be noted that it is not necessarily determined that all lines of the program after normalization and abstraction correspond comprehensively to mechanism elements, and there is a possibility that lines for controlling mechanism elements that are not registered in the program fragment database 1043, lines for peripheral processing for controlling mechanism elements, or lines for other processing will remain unmatched.
[0092] ●Model Database 1046● The model database 1046 registers models corresponding to program fragments F registered in the program fragment database 1043 as mechanism element models. The model database 1046 has the structure shown in FIG. 29. Models corresponding to mechanism element identifiers (mechanism element serial numbers) can be referenced from the model database management table in FIG. 30. In this embodiment, models are assumed to be block definition diagrams, internal block diagrams, and state transition diagrams, but are not limited to these. The model database 1046 may be predefined, as with the program fragment database 1043, or may have a means for developers to register, edit, and delete them. In either case, the registered models must be generated manually (by a developer of the program development support device). However, because it is sufficient to consider models for multiple program fragments F in advance, model generation is less complex than generating a model from the entire large-scale control program. Furthermore, model generation is feasible because the content of the model can be defined based on the behavior of mechanism elements described in the aforementioned books, etc.
[0093] ●Model configuration unit 1045● The model configuration unit 1045 extracts the corresponding mechanism element model from the model database 1046 for each of the multiple combinations in the side effect combination list. The model configuration unit 1045 indicates the connection relationships between the interfaces of the mechanism element models, and then adds the following information and displays it on the monitor via the display operation unit 102: - Variables and output port names of the control program P corresponding to the interfaces of the mechanism element model. - Line numbers of the control program P corresponding to the mechanism element model.
[0094] Basically, the model construction unit 1045 is expected to extract all mechanism elements that have results in the search result table, but it may happen that not all mechanism elements can be realized simultaneously due to the side effect combination list. In such cases, the model construction unit 1045 extracts mechanism element models by narrowing down to only mechanism elements that can be realized simultaneously and are listed in the side effect combination list.
[0095] To extract a mechanism element model, the model configuration unit 1045 refers to the side effect matching table, search result correspondence table, and search result table from the side effect combination list to identify the mechanism element serial number. The model configuration unit 1045 uses the model database management table to extract various models corresponding to the mechanism element serial number. Figure 31 shows an example of a monitor display for {Set 1, Set 1}. The monitor combines the state transition diagram, block definition diagram, and internal block diagram of the pusher mechanism type 2 and the state transition diagram, block definition diagram, and internal block diagram of the turntable mechanism type 2 to display a control program model of the state transition diagram, block definition diagram, and internal block diagram.
[0096] The connection relationships between multiple mechanism elements are identified for the block definition diagram and the internal block diagram. The mechanism element models in the model database 1046 record the algebra appearing in the side effects in association with the input / output interfaces of the models. If the interfaces between mechanism element models are connected, these mechanism element models are connected with wires to combine the connection relationships and display them as a control program model. The connection relationships between mechanism elements or models may change depending on which combination in the side effect combination list is used for display. The side effect combination list may include combinations that correctly represent the actual production equipment model, and others that do not. To select a correctly represented model, the display / operation unit 102 provides a function for the developer to select a combination from the side effect combination list, and the model configuration unit 1045 configures the model according to the selection.
[0097] 32 , the model configuration unit 1045 displays on the monitor at the display operation unit 102, fragments of the control program P that were not used in configuring the control program model, as fragments not reflected in the control program model, to leave room for the developer to interpret them separately. The model configuration unit 1045 also displays on the monitor at the display operation unit 102, a message indicating that the fragment is unknown, for parts that could not be identified due to insufficient information or inconsistency in the connection relationships between mechanism element models. The model configuration unit 1045 also displays information that cannot be determined as blank in the control program model, allowing the user to input it later at the display operation unit 102.
[0098] As described above, in the first embodiment, the standard control program for each mechanism element is stored in a database as program fragment F, and a fragment similar to program fragment F is searched for in the control program P to detect the program fragment F from the database. The similarity search is realized by extracting the changes that the control program P causes to external variables as a result of execution as "side effects" and comparing their equivalence. The program fragment F and its mechanism element model are associated with each other in a database, and the corresponding mechanism element model is extracted and combined based on the results of the similarity search, thereby converting the control program P to a control program model. In this way, it is possible to generate a control program model from the control program P.
[0099] ***Summary of First Embodiment*** The program development support device 1 includes a program analysis unit 1041 and a similarity search unit 1042. The program fragment database 1043 registers a plurality of fragment side effect lists, in which a plurality of side effects included in a program fragment F corresponding to a mechanism element are described as a plurality of fragment side effects, in association with the plurality of program fragments F. The program fragment database 1043 registers order constraints of the plurality of fragment side effects included in the program fragment F corresponding to the mechanism element as a plurality of fragment order constraint information in association with the plurality of program fragments F.
[0100] The program analysis unit 1041 analyzes the control program and creates a program side effect list in which multiple side effects included in the control program are described as multiple program side effects. The program analysis unit 1041 creates order constraints for the multiple program side effects as program order constraint information.
[0101] The similarity search unit 1042 compares multiple program side effects listed in the program side effect list with multiple fragment side effects listed in multiple fragment side effect lists, and searches for a program fragment F corresponding to a fragment side effect list in which multiple fragment side effects are included in multiple program side effects, as a similar program fragment.
[0102] The similarity search unit 1042 compares the order constraints of the program order constraint information with the order constraints of multiple fragment order constraint information, and classifies the program fragment F whose order constraints of the fragment order constraint information correspond to the fragment order constraint information included in the order constraints of the program order constraint information as a similar program fragment.
[0103] Based on the search option settings, the similarity search unit 1042 determines, among the searched program fragments F, those program fragments F whose order constraints in the fragment order constraint information do not completely match the order constraints in the program order constraint information as similar program fragments that can obtain the same side effects after passing through multiple basic processing cycles.
[0104] The program analysis unit 1041 performs normalization to constrain the description of the program list of the control program and abstraction to replace variables in the program list of the control program with algebra, and the program analysis unit 1041 normalizes the program side effects by expressing synonymous conditions in a unified description and expressing synonymous side effects in a unified description for multiple program side effect descriptions listed in the program side effect list.
[0105] The similarity search unit determines whether a fragment side effect matches a program side effect using the following criteria: (a) the structure and conditions of the conditional branch of the side effect are the same, and (b) the results of the side effect are the same, and (c) there is no contradiction in the algebra related to the side effect.
[0106] The program fragment database 1043 registers, as a plurality of pieces of fragment order constraint information, the variables used by each of a plurality of program fragments F and the variables referenced by the variables. The program analysis unit 1041 creates, as program order constraint information, the variables used by the control program and the variables referenced by the variables.
[0107] The similarity search unit 1042 determines that the program fragment F corresponding to the fragment order constraint information is a similar program fragment if the order constraints described in each of the multiple fragment order constraint information match the order constraints described in the program order constraint information.
[0108] The program analysis unit 1041 detects, for each line in the program list of the control program, variables whose values are changed by side effects and one or more line numbers that change the values of the variables. The program analysis unit 1041 creates a list in which variables, side effects, and one or more line numbers correspond to each other as a program side effect list. The similarity search unit 1042 creates one or more line number pairs in which multiple fragment side effects of the program fragment F correspond one-to-one to each of the one or more line numbers in the program list. If there is a line number pair among the one or more line number pairs in which all of the multiple fragment side effects correspond to program side effects obtained from different lines in the program list of the control program, the similarity search unit 1042 determines that there are one or more consistent line number pairs, and identifies the program fragment F corresponding to the fragment side effect list as a similar program fragment.
[0109] The program development support device 1 includes a mechanism element estimation unit 1044 , a model database 1046 , and a model configuration unit 1045 .
[0110] When the similarity search unit 1042 searches for multiple similar program fragments, the mechanism element estimation unit 1044 determines whether different lines of the control program correspond to all of the multiple fragment side effects included in the multiple similar program fragments. If different lines of the control program correspond to all of the multiple fragment side effects, the mechanism element estimation unit 1044 estimates the combination of mechanism elements corresponding to the multiple similar program fragments as a consistent combination of mechanism elements.
[0111] The mechanism element estimation unit 1044 creates a side effect combination list that combines one or more consistent line number pairs of the multiple similar program fragments searched by the similarity search unit 1042. If the lines described in the multiple line number pairs of each combination in the side effect combination list correspond to different lines of the control program, the mechanism element estimation unit 1044 estimates the combination of mechanism elements corresponding to the multiple similar program fragments as a consistent combination of mechanism elements.
[0112] The model database 1046 stores a plurality of mechanism element models corresponding to the plurality of program fragments F. The model database 1046 includes, as mechanism element models, at least one of a block configuration diagram, an internal block diagram, and a state transition diagram.
[0113] The model configuration unit 1045 extracts from the model database 1046 a plurality of models corresponding to a plurality of program fragments F described in combinations of consistent mechanism elements, and combines the plurality of models to configure a control program model for the control program.
[0114] The program analysis unit 1041 creates a program side effect list from the control program using the same process as that used to create a plurality of fragment side effect lists from each of a plurality of program fragments.
[0115] The program analysis unit 1041 creates program order constraint information from the control program using the same process as that used to create a plurality of pieces of fragment order constraint information from each of a plurality of program fragments.
[0116] The program development support device is characterized by searching for and displaying a program fragment F from a control program that will produce equivalent results for variables or ports after execution.The program development support device is characterized by using a control program as input to generate a control program model that abstractly represents the object to be controlled by the control program.The program development support device is characterized by being able to search for fragments from the control program that produce the same side effects through multiple basic processing cycles by determining, by setting an option, as a match a fragment that includes all the same side effects as program fragment F but whose order constraints do not completely match.
[0117] The program development support device includes the following: a program memory 103 for storing a control program; a program analysis unit 1041 for extracting side effects, which are changes in the values of variables or ports after execution of the control program, from the control program, and extracting a list of program side effects after normalization and abstraction, and program order constraint information that indicates the order relationships of the side effects to ensure equivalence of the side effects; a program fragment database 1043 in which multiple program fragments F, multiple side effect lists after normalization and abstraction, and multiple pieces of order constraint information are registered; a similarity search unit 1042 for comparing the side effect list and order constraint information of the control program after normalization and abstraction with the side effect list and order constraint information of the program fragment F after normalization and abstraction; a mechanism element estimation unit 1044 for estimating elements, such as mechanical mechanisms or electric circuits, that are to be controlled by the control program; and a model database 1046 for storing models corresponding to the program fragments stored in the program fragment database 1043. A model configuration unit 1045 that obtains mechanism element models corresponding to the mechanical mechanisms or electrical circuits controlled by the control program from the model database and configures a control program model by identifying the connection relationships between the interfaces of the mechanism element models.
[0118] ***Description of Effects of First Embodiment*** According to this embodiment, a similarity search for the behavior of a program fragment F is performed from a control program P using a program fragment database 1043 that stores standard program fragments F and a program analysis unit 1041 that extracts side effects that represent the behavior of a control program P and their order constraints from the control program P. This makes it possible to identify the mechanism elements controlled by the control program P. Furthermore, by making it possible to select the degree of agreement of the order constraints, it becomes possible to perform a similarity search for control program fragments that require multiple basic processing cycles but have the same behavior, thereby enabling modeling of the control program.
[0119] According to this embodiment, a control program model used in model-based development can be derived based on a production equipment control program P. In this case, even if the control program P is not implemented based on common rules and has inconsistent syntax, a control program model can be derived based on the behavior.
[0120] This embodiment makes it easy to implement model-based development that utilizes the development assets of existing control programs P. If model-based development can be implemented, existing assets can be reinterpreted at a high level of abstraction, making them available for similar development, reducing development man-hours and preventing the introduction of defects, thereby improving the efficiency of control program development.
[0121] Furthermore, a secondary effect of this embodiment is that it can improve the efficiency of reuse development of the control program P even when model-based development is not applied. As mentioned above, when a third party other than the developer reuses and develops the control program P, the third party does not have as sufficient an understanding of the structure or design concept of the control program P as the developer does, making it difficult to determine the parts that need to be changed and the impact of the changes. In contrast, if the control program P can be converted into a control program model, a top-down understanding of the structure and design concept can be improved, making reuse development more efficient.
[0122] In addition, by using part of the functions of this embodiment, it is possible to find similar program fragments F (so-called code clones) in a control program. This makes it possible to create a library of processes that frequently appear in control programs, and also realizes a refactoring function.
[0123] ***Description of Other Configurations of First Embodiment*** ●Variation 1: Program Order Constraint Information and Fragment Order Constraint Information As the program order constraint information, a program side effect dependency table may be used instead of a program side effect dependency graph. The program order constraint information may be expressed in any way as long as the order constraints of the program side effects are known. As the fragment order constraint information, a fragment side effect dependency table may be used instead of a fragment side effect dependency graph. The fragment order constraint information may be expressed in any way as long as the order constraints of the fragment side effects are known.
[0124] Variation 2: Program fragment F As program fragment F, a part of control program P may be registered in program fragment database 1043. As program fragment F, a fragment similar to program fragment F of control program P may be registered in program fragment database 1043. As program fragment F, fragment side effect order constraint information obtained by analyzing program fragment F by program analysis unit 1041 may be stored.
[0125] Variation 3: Creation of fragment side effect list and fragment side effect dependency graph The fragment side effect list and fragment side effect dependency graph in the program fragment database 1043 do not have to be created by the program analysis unit 1041, but may be created by other means or manually. The fragment side effect list and fragment side effect dependency graph may be a mixture of those created by the program analysis unit 1041, those created by other means, and those created manually.
[0126] Variation 4: Description format of fragment side-effect list and fragment side-effect dependency graph The description format of the tables, lists, and graphs of program fragment F does not have to be the same as the description format of the tables, lists, and graphs of control program P, as long as the two are in a description format that can be compared by the similarity search unit 1042. Specifically, the fragment side-effect dependency table of program fragment F may be compared with the program side-effect dependency graph of the control program.
[0127] Variation 5: The similarity search unit 1042 may search for fragment side effects for the program fragment F that do not all match the program side effects but mostly match them. Since there may be cases where not all of the fragment side effects are essential side effects for the program fragment F, it may search for fragment side effects where many of the fragment side effects match the program side effects. Specifically, the percentage of matches between the fragment side effects and the program side effects can be set by an option setting, such as 100% match, 90% match, or 80% match.
[0128] 1 Program development support device, 2 Setting bus, 3 Controller, 4 Proximal device, 5 Remote device, 6 Control network, 9 Engineering workstation, 91 CPU, 92 Memory, 93 Non-volatile memory, 94 Setting port, 95 Bus, 101 Programming unit, 102 Display operation unit, 103 Program memory, 104 Model extraction unit, 105 Program setting storage unit, 1041 Program analysis unit, 1042 Similarity search unit, 1043 Program fragment database, 1044 Mechanism element estimation unit, 1045 Model construction unit, 1046 Model database, F Program fragment, P Control program.
Claims
1. A program development support device comprising: a program fragment database that registers multiple fragment side effect lists, in which multiple side effects contained in a program fragment corresponding to a mechanism element are described as multiple fragment side effects, in correspondence with multiple program fragments; a program analysis unit that analyzes a control program and creates a program side effect list, in which multiple side effects contained in the control program are described as multiple program side effects; and a similarity search unit that compares the multiple program side effects described in the program side effect list with the multiple fragment side effects described in the multiple fragment side effect lists, and searches for program fragments corresponding to the fragment side effect list in which the multiple fragment side effects are included in the multiple program side effects, as similar program fragments.
2. The program fragment database registers the order constraints of the multiple fragment side effects as multiple fragment order constraint information corresponding to the multiple program fragments, the program analysis unit creates the order constraints of the multiple program side effects as program order constraint information, and the similarity search unit compares the order constraints of the program order constraint information with the order constraints of the multiple fragment order constraint information, and classifies program fragments whose order constraints of the fragment order constraint information correspond to the fragment order constraint information included in the order constraints of the program order constraint information as similar program fragments.
3. The program development support device described in claim 2, wherein the similarity search unit, based on the setting of a search option, classifies program fragments whose order constraints of the fragment order constraint information do not completely match the order constraints of the program order constraint information as similar program fragments that produce the same side effects after passing through multiple basic processing cycles.
4. A program development support device as described in any one of claims 1 to 3, further comprising a mechanism element estimation unit that, when the similarity search unit searches for a plurality of similar program fragments, estimates a combination of mechanism elements corresponding to a plurality of similar program fragments in which different lines of the control program correspond to all of the plurality of fragment side effects contained in the plurality of similar program fragments as a combination of consistent mechanism elements.
5. A program development support device as described in claim 4, comprising: a model database that stores a plurality of mechanism element models corresponding to each of the plurality of program fragments; and a model construction unit that extracts from the model database a plurality of models corresponding to the plurality of program fragments described in the combination of consistent mechanism elements, and combines the plurality of models to construct a control program model of the control program.
6. A program development support device as described in any one of claims 1 to 5, wherein the program analysis unit performs normalization to constrain the description of the program list of the control program and abstraction to replace variables in the program list of the control program with algebra, and the program analysis unit normalizes program side effects by expressing synonymous conditions in a unified description and expressing synonymous side effects in a unified description for descriptions of multiple program side effects listed in the program side effect list.
7. A program development support device as claimed in any one of claims 1 to 6, wherein the similarity search unit determines whether a fragment side effect matches a program side effect using the following criteria: (a) the structure and conditions of the conditional branch of the side effect are the same, and (b) the results of the side effect are the same, and (c) there is no contradiction in the algebra related to the side effect.
8. The program fragment database registers variables used by each of the multiple program fragments and variables referenced by the variables as the multiple fragment order constraint information, the program analysis unit creates the variables used by the control program and variables referenced by the variables as the program order constraint information, and the similarity search unit classifies program fragments corresponding to the fragment order constraint information as similar program fragments when the order constraint described in each of the multiple fragment order constraint information matches the order constraint described in the program order constraint information.
9. The program analysis unit detects, for each line of the program list of the control program, variables whose values are changed by side effects and one or more line numbers that change the values of the variables, and creates a list in which the variables, the side effects, and the one or more line numbers correspond to each other as the program side effect list; the similarity search unit creates one or more line number pairs in which the multiple fragment side effects of the program fragment correspond one-to-one to each of the one or more line numbers of the program list; and when there is a line number pair among the one or more line number pairs in which all of the multiple fragment side effects correspond to program side effects obtained from different lines of the program list of the control program, it is determined that there are one or more consistent line number pairs, and the program fragment corresponding to the fragment side effect list is determined to be the similar program fragment.
10. The program development support device described in claim 9, wherein the mechanism element estimation unit creates a side effect combination list by combining each of the one or more consistent line number pairs of a plurality of similar program fragments, and when the lines listed in the multiple line number pairs of each combination in the side effect combination list correspond to different lines of the control program, the combination of mechanism elements corresponding to the plurality of similar program fragments is estimated to be a consistent combination of mechanism elements.
11. The program development support device according to claim 5, wherein said model database includes at least one of a block configuration diagram, an internal block diagram, and a state transition diagram as said mechanism element models.
12. A program development support method comprising: registering multiple fragment side effect lists in a program fragment database, each of which lists multiple side effects contained in a program fragment corresponding to a mechanism element as multiple fragment side effects, corresponding to multiple program fragments; a program analysis unit analyzes a control program to create a program side effect list in which multiple side effects contained in the control program are listed as multiple program side effects; and a similarity search unit compares the multiple program side effects listed in the program side effect list with the multiple fragment side effects listed in the multiple fragment side effect lists, and searching for program fragments corresponding to the fragment side effect list in which the multiple fragment side effects are included in the multiple program side effects, as similar program fragments.
13. A program development support program that causes a computer having a program fragment database that registers multiple fragment side effect lists, in which multiple side effects contained in a program fragment corresponding to a mechanism element are described as multiple fragment side effects, in correspondence with multiple program fragments, to execute a program analysis process that analyzes a control program and creates a program side effect list in which multiple side effects contained in the control program are described as multiple program side effects, and a similarity search process that compares the multiple program side effects described in the program side effect list with the multiple fragment side effects described in the multiple fragment side effect lists, and searches for program fragments in which the multiple fragment side effects are included in the multiple program side effects and correspond to the fragment side effect list, as similar program fragments.
Citation Information
Patent Citations
Reverse engineering support device, reverse engineering support method and program thereof
JP2012164148A
Information processor, information processing method and program
JP2012256178A
