JP2007094922A - Automatic program generation, method, and program - Google Patents
Automatic program generation, method, and program Download PDFInfo
- Publication number
- JP2007094922A JP2007094922A JP2005285802A JP2005285802A JP2007094922A JP 2007094922 A JP2007094922 A JP 2007094922A JP 2005285802 A JP2005285802 A JP 2005285802A JP 2005285802 A JP2005285802 A JP 2005285802A JP 2007094922 A JP2007094922 A JP 2007094922A
- Authority
- JP
- Japan
- Prior art keywords
- program
- source code
- state
- exception
- exception processing
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Abstract
Description
本発明は、プログラム自動生成装置、方法、およびプログラムに関し、特にプログラムの振る舞いを図形式で表現した図形式データからプログラムを生成するプログラム自動生成装置、方法、およびプログラムに関する。 The present invention relates to an automatic program generation device, method, and program, and more particularly, to an automatic program generation device, method, and program for generating a program from graphic data that represents the behavior of the program in graphic format.
従来より、プログラムの振る舞いが状態遷移図によって表されることはよく知られている。状態遷移図の標準的な表記方法は、UML(Unified Modeling Language)の状態マシン図としても定義されている。また、状態遷移図をベースに記述されたプログラムの仕様をもとに、プログラムのソースコードを自動生成する装置が提案されている(たとえば、特許文献1参照)。 Conventionally, it is well known that the behavior of a program is represented by a state transition diagram. The standard notation method of the state transition diagram is also defined as a UML (Unified Modeling Language) state machine diagram. Also, an apparatus for automatically generating a program source code based on a program specification described based on a state transition diagram has been proposed (see, for example, Patent Document 1).
図9は、従来のプログラム自動生成装置によるプログラムを自動生成する自動生成処理の手順を示すフローチャートである。
従来のプログラム自動生成装置は、キーボードやマウスなどの入力手段を介してユーザからの指示を受けて状態遷移図を生成する(ステップS31)。そして、プログラム自動生成装置は、生成した状態遷移図に対応するソースコードを自動で生成する(ステップS32)。
FIG. 9 is a flowchart showing a procedure of automatic generation processing for automatically generating a program by a conventional automatic program generation device.
The conventional automatic program generation device generates a state transition diagram in response to an instruction from the user via an input unit such as a keyboard or a mouse (step S31). Then, the program automatic generation device automatically generates a source code corresponding to the generated state transition diagram (step S32).
図10は、従来のプログラム自動生成装置で生成されたプログラムの振る舞いを示すフローチャートである。
生成されたプログラムは、イベントの生起を待つ処理が行われ(ステップS41)、イベントが発生すると、現在の状態を判定する処理が行われる(ステップS42)。そして、判定された現在の状態別に生起イベントとガード条件によって遷移先の状態を決定する処理が行われ(ステップS43)、決定された遷移先の状態に更新する処理が行われる(ステップS44)。
FIG. 10 is a flowchart showing the behavior of a program generated by a conventional automatic program generation device.
The generated program is processed to wait for the occurrence of an event (step S41), and when an event occurs, a process for determining the current state is performed (step S42). Then, processing for determining the transition destination state is performed for each determined current state based on the occurrence event and the guard condition (step S43), and processing for updating to the determined transition destination state is performed (step S44).
図11は、従来のプログラム自動生成装置が生成したプログラムソースコードの内容の概略を示す図である。
プログラムソースコード400は、従来のプログラム自動生成装置が生成したプログラムソースコードの内容の概略を示している。プログラムソースコード400は、C言語形式でプログラムソースコードが生成されたときのソースコードを示している。プログラムソースコード400に記載されている内容は、図10に示したフローチャートの各処理に対応している。
FIG. 11 is a diagram showing an outline of the contents of a program source code generated by a conventional automatic program generation device.
The
上から3行目の“if”から始まる行は、図10に示したフローチャートのステップS41の処理に対応する。つまり、イベントの生起を待つ処理を行う。上から4行目の“switch”から始まる行は、図10に示したフローチャートのステップS42の処理に対応する。つまり、現在の状態を判定し、判定された現在の状態別に生起イベントとガード条件によって遷移先を決定する処理を行う。遷移先の処理は、この行の一番後ろの“{”から始まるかっこで囲われている各処理である。 The third line starting from “if” from the top corresponds to the process in step S41 of the flowchart shown in FIG. That is, a process of waiting for the occurrence of an event is performed. The line starting from “switch” on the fourth line from the top corresponds to the processing in step S42 in the flowchart shown in FIG. That is, the current state is determined, and a transition destination is determined according to the occurrence event and the guard condition for each determined current state. The transition destination process is each process enclosed in parentheses starting from “{” at the end of this line.
プログラムの状態が状態0から1、2、3、・・・、n−1、nまであるとしたとき、上から5行目の“case 状態0;”と書いてある行を含めて“break;”と書いてある行までの3行が状態0と判定されたときに実行されるコードであり、図10に示したフローチャートのステップS43aの処理に対応する。以下同様に、上から8行目の“case 状態1;”と書いてある行を含めて“break;”と書いてある行までの3行が状態1と判定されたときに実行されるコードであり、図10に示したフローチャートのステップS43bの処理に対応し、上から12行目の“case 状態n;”と書いてある行を含めて“break;”と書いてある行までの3行が状態nと判定されたときに実行されるコードであり、図10に示したフローチャートのステップS43dの処理に対応する。また、下から3行目の“現在の”から始まる行は、図10に示したフローチャートのステップS44の処理に対応する。
しかし、従来のプログラム自動生成装置で生成されるソースコードは、現在の状態を保持するメモリ領域が、このソースコードが示す処理以外の場所で何らかの原因により書き換えられ、現在の状態が想定したすべての状態に当てはまらなかった場合、つまり、上記例においては、状態0から1、2、3、・・・、n−1、nまで定義されたいずれの状態にも当てはまらなかった場合の例外処理がない。現在の状態がすべての状態に当てはまらないということは、明らかにプログラムが異常な動作をしている状態であり、対象システムによっては異常状態を放置しておくことが致命的な障害につながる場合もあるため、何らかの警告を発したり、場合によってはシステムの機能を停止させるなどの対策が必要となる。つまり、実際のシステムの一部としてこのプログラムを実行させることを考えた場合、このソースコードでは信頼性が低いということになる。そのため、従来は例外処理がなくても問題がないと判断できる部分にしか自動生成を適用することができないという問題があった。また、例外処理がないと問題があると判断された場合には、自動生成されたソースコードに例外処理を人手で追加しなければならないという問題もあった。つまり、プログラムを自動で生成するメリットが損なわれていた。
However, in the source code generated by the conventional automatic program generation device, the memory area that holds the current state is rewritten for some reason other than the processing indicated by the source code, and all the current states assumed In the above example, there is no exception handling when the state does not apply to any state defined from
本発明はこのような点に鑑みてなされたものであり、プログラムに自動で例外処理を追加できるプログラム自動生成装置、方法、およびプログラムを提供することを目的とする。 The present invention has been made in view of these points, and an object thereof is to provide an automatic program generation apparatus, method, and program capable of automatically adding exception processing to a program.
本発明では上記問題を解決するために、プログラムの振る舞いを図形式で表現した図形式データからプログラムを生成するプログラム自動生成装置において、ユーザからの指示を受けて、前記図形式データを生成する図形式データ生成手段と、前記図形式データからコンパイル可能なプログラムソースコードを生成するソースコード生成手段と、前記図形式データで定義されたどの状態とも異なっている場合に行う例外処理のソースコードを受け付ける例外処理受付手段と、前記プログラムソースコードに前記例外処理のソースコードを埋め込み、新たなプログラムソースコードとして出力する例外処理埋込手段とを有することを特徴とするプログラム自動生成装置が提供される。 In the present invention, in order to solve the above-described problem, a diagram of generating the diagram format data in response to an instruction from a user in an automatic program generation device that generates a program from diagram format data expressing the behavior of the program in a diagram format Format data generation means, source code generation means for generating compilable program source code from the diagram format data, and source code for exception processing that is performed when any state defined by the diagram format data is different There is provided an automatic program generation apparatus comprising: an exception process accepting unit; and an exception process embedding unit that embeds the exception process source code in the program source code and outputs the program as a new program source code.
このようなプログラム自動生成装置によれば、図形式データ生成手段が、ユーザからの指示を受けて、図形式データを生成する。ソースコード生成手段が、図形式データからコンパイル可能なプログラムソースコードを生成する。例外処理受付手段が、図形式データで定義されたどの状態とも異なっている場合に行う例外処理のソースコードを受け付ける。例外処理埋込手段が、プログラムソースコードに例外処理のソースコードを埋め込み、新たなプログラムソースコードとして出力する。 According to such an automatic program generation device, the graphic data generation means generates graphic data in response to an instruction from the user. Source code generation means generates compilable program source code from graphic data. The exception process accepting unit accepts a source code of exception process to be performed when different from any state defined by the graphic data. The exception processing embedding means embeds the exception processing source code in the program source code and outputs it as a new program source code.
また、本発明では、プログラムの振る舞いを図形式で表現した図形式データからプログラムを生成するプログラム自動生成方法において、図形式データ生成手段が、ユーザからの指示を受けて、前記図形式データを生成するステップと、ソースコード生成手段が、前記図形式データからコンパイル可能なプログラムソースコードを生成するステップと、例外処理受付手段が、前記図形式データで定義されたどの状態とも異なっている場合に行う例外処理のソースコードを受け付けるステップと、例外処理埋込手段が、前記プログラムソースコードに前記例外処理のソースコードを埋め込み、新たなプログラムソースコードとして出力するステップとを含むことを特徴とするプログラム自動生成方法が提供される。 Further, in the present invention, in a program automatic generation method for generating a program from diagram format data representing the behavior of the program in diagram format, diagram format data generation means generates the diagram format data in response to an instruction from a user. And a step in which the source code generating means generates a program source code that can be compiled from the graphic data, and an exception processing accepting means is performed when it is different from any state defined in the graphic data. Receiving a source code of exception processing; and an exception processing embedding unit that embeds the source code of exception processing in the program source code and outputs the program as a new program source code. A generation method is provided.
このようなプログラム自動生成方法によれば、図形式データ生成手段が、ユーザからの指示を受けて、図形式データを生成する。ソースコード生成手段が、図形式データからコンパイル可能なプログラムソースコードを生成する。例外処理受付手段が、図形式データで定義されたどの状態とも異なっている場合に行う例外処理のソースコードを受け付ける。例外処理埋込手段が、プログラムソースコードに例外処理のソースコードを埋め込み、新たなプログラムソースコードとして出力する。 According to such a program automatic generation method, the graphic data generation means generates graphic data in response to an instruction from the user. Source code generation means generates compilable program source code from graphic data. The exception process accepting unit accepts a source code of exception process to be performed when different from any state defined by the graphic data. The exception processing embedding means embeds the exception processing source code in the program source code and outputs it as a new program source code.
また、本発明では、プログラムの振る舞いを図形式で表現した図形式データからプログラムを生成するプログラム自動生成プログラムにおいて、コンピュータに、ユーザからの指示を受けて、前記図形式データを生成する図形式データ生成手段と、前記図形式データからコンパイル可能なプログラムソースコードを生成するソースコード生成手段、前記図形式データで定義されたどの状態とも異なっている場合に行う例外処理のソースコードを受け付ける例外処理受付手段、前記プログラムソースコードに前記例外処理のソースコードを埋め込み、新たなプログラムソースコードとして出力する例外処理埋込手段として機能させることを特徴とするプログラム自動生成プログラムが提供される。 Further, in the present invention, in a program automatic generation program for generating a program from diagram format data expressing the behavior of the program in diagram format, diagram format data for generating the diagram format data in response to an instruction from a user to a computer Generating means, source code generating means for generating compilable program source code from the diagram format data, exception processing acceptance for receiving source code of exception processing performed when different from any state defined in the diagram format data And an automatic program generation program characterized by functioning as an exception processing embedding means for embedding the source code of the exception processing in the program source code and outputting it as a new program source code.
このようなプログラム自動生成プログラムによれば、図形式データ生成手段が、ユーザからの指示を受けて、図形式データを生成する。ソースコード生成手段が、図形式データからコンパイル可能なプログラムソースコードを生成する。例外処理受付手段が、図形式データで定義されたどの状態とも異なっている場合に行う例外処理のソースコードを受け付ける。例外処理埋込手段が、プログラムソースコードに例外処理のソースコードを埋め込み、新たなプログラムソースコードとして出力する。 According to such a program automatic generation program, the graphic data generation means generates graphic data in response to an instruction from the user. Source code generation means generates compilable program source code from graphic data. The exception process accepting unit accepts a source code of exception process to be performed when different from any state defined by the graphic data. The exception processing embedding means embeds the exception processing source code in the program source code and outputs it as a new program source code.
本発明のプログラム自動生成装置、方法、およびプログラムによれば、例外処理をプログラムに自動で追加できるので、例外処理がないと問題がある場合であるか否かに関係なくプログラムを自動で生成することができる。また、例外処理を人手で追加しなくてもよくなる。したがって、プログラムを自動で生成するメリットが向上する。 According to the program automatic generation apparatus, method, and program of the present invention, exception processing can be automatically added to the program, so that the program is automatically generated regardless of whether there is a problem if there is no exception processing. be able to. Also, it is not necessary to add exception handling manually. Therefore, the merit of automatically generating the program is improved.
以下、本発明の実施の形態を図面を参照して詳細に説明する。
図1は、本実施の形態に適用される発明の概念図である。図1に示すように、プログラム自動生成装置100は、データ受付手段110、ソースコード生成手段120、および例外処理埋込手段130を備えている。また、データ受付手段110は、図形式データ生成手段111と例外処理受付手段112から構成されている。また、データ受付手段110は、入力手段12を介してユーザの指示を受け、図形式データの生成や例外処理の受け付けを行う。生成した図形式データや受け付けた例外処理は逐次モニタ11に表示する。図形式データ生成手段111は、入力手段12を介してユーザからの指示を受けて、ユーザが生成したいプログラムを表す図形式データを生成する。例外処理受付手段112は、入力手段12を介してユーザから例外処理を行う例外処理ソースコードを受け付ける。
Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings.
FIG. 1 is a conceptual diagram of the invention applied to this embodiment. As shown in FIG. 1, the automatic program generation device 100 includes a
ソースコード生成手段120は、図形式データ生成手段111から図形式データを受け取ると、図形式データとして表現されているプログラムを実現するためのソースコードを図形式データに基づいて生成する。例外処理埋込手段130は、例外処理受付手段112が受け付けた例外処理ソースコードを受け取る。また、ソースコード生成手段120が生成したソースコード(以下、生成ソースコードという。)を受け取る。そして、生成ソースコードの所定の位置に例外処理ソースコードを埋め込む。そして、例外処理を行うことができる新たなプログラムソースコード200として出力する。
When the source
このようにプログラム自動生成装置100は、例外処理埋込手段130によって例外処理ソースコードを生成ソースコードに自動で埋め込み、新たに例外処理をすることができるプログラムソースコード200として出力することができるので、例外処理が必要か不必要かに関係なくプログラム自動生成装置100を用いてプログラムの自動生成を行わせることができる。また、例外処理を自動で必要な場所に埋め込むことができるので、容易に例外処理機能が盛り込まれたプログラムを自動で生成することができる。
As described above, the automatic program generation apparatus 100 can automatically embed the exception processing source code in the generated source code by the exception
図2は、本実施の形態に用いるプログラム自動生成装置のハードウェア構成例を示す図である。プログラム自動生成装置100は、CPU(Central Processing Unit)101によって装置全体が制御されている。CPU101には、バス106を介してRAM(Random Access Memory)102、ハードディスクドライブ(HDD:Hard Disk Drive)103、グラフィック処理装置104、および入力インタフェース105が接続されている。
FIG. 2 is a diagram illustrating a hardware configuration example of the automatic program generation device used in the present embodiment. The entire automatic program generation apparatus 100 is controlled by a CPU (Central Processing Unit) 101. A random access memory (RAM) 102, a hard disk drive (HDD) 103, a
RAM102には、CPU101に実行させるOSのプログラムやアプリケーションプログラムの少なくとも一部が一時的に格納される。また、RAM102には、CPU101による処理に必要な各種データが格納される。HDD103には、OS(Operating System)やアプリケーションプログラムが格納される。
The
グラフィック処理装置104には、モニタ11が接続されている。グラフィック処理装置104は、CPU101からの命令に従って、画像をモニタ11の画面に表示させる。入力インタフェース105には、キーボード12aとマウス12bとが接続されている。入力インタフェース105は、キーボード12aやマウス12bから送られてくる信号を、バス106を介してCPU101に送信する。以上のようなハードウェア構成によって、本実施の形態の処理機能を実現することができる。
A monitor 11 is connected to the
図3は、本実施の形態のプログラム自動生成装置によるプログラムを自動生成する自動生成処理の手順を示すフローチャートである。以下、図3に示す処理をステップ番号に沿って説明する。 FIG. 3 is a flowchart showing a procedure of automatic generation processing for automatically generating a program by the automatic program generation device of the present embodiment. Hereinafter, the process illustrated in FIG. 3 will be described in order of step number.
〔ステップS11〕図形式データ生成手段111は、入力手段12を介して入力されるユーザからの指示を受け付ける。この指示に基づいて、図形式データであり、プログラムの振る舞いを表現する状態遷移図を生成する。
[Step S11] The graphic
〔ステップS12〕例外処理受付手段112は、入力手段12を介して入力される例外処理ソースコードを受け付ける。
〔ステップS13〕ソースコード生成手段120は、図形式データ生成手段111から状態遷移図を受け取る。そして、受け取った状態遷移図に基づいて状態遷移図が表す処理を行うプログラムのソースコードを自動生成する。
[Step S12] The exception
[Step S13] The source
〔ステップS14〕例外処理埋込手段130は、ソースコード生成手段120から生成ソースコードを受け取る。また、例外処理受付手段112から例外処理ソースコードを受け取る。そして、生成ソースコードの所定の位置に例外処理ソースコードを埋め込み、新たなプログラムソースコード200として出力する。
[Step S14] The exception
図4は、本実施の形態のプログラム自動生成装置が生成したプログラムの振る舞いを示すフローチャートである。以下、図4に示す処理をステップ番号に沿って説明する。
〔ステップS21〕イベントの生起を判断する。イベントが発生したときは処理をステップS22へ進める。
FIG. 4 is a flowchart showing the behavior of the program generated by the automatic program generation device of this embodiment. In the following, the process illustrated in FIG. 4 will be described in order of step number.
[Step S21] The occurrence of an event is determined. If an event occurs, the process proceeds to step S22.
〔ステップS22〕現在の状態を判断する。状態0と判断した場合には、処理をステップS23aへ進め、状態1と判断した場合には、処理をステップS23bへ進め、状態n−1と判断した場合には、処理をステップS23cへ進め、状態nと判断した場合には、処理をステップS23dへ進め、状態0からnまでに該当しないと判断した場合には、処理をステップS25へ進める。
[Step S22] The current state is determined. If it is determined that the state is 0, the process proceeds to step S23a. If it is determined that the state is 1, the process proceeds to step S23b. If it is determined that the state is n-1, the process proceeds to step S23c. If it is determined that the state is n, the process proceeds to step S23d. If it is determined that
〔ステップS23〕現在の状態別に生起イベントとガード条件によって遷移先の状態を決定する。
〔ステップS24〕決定された遷移先の状態に更新し、処理をステップS21へ進める。
[Step S23] The transition destination state is determined according to the occurrence event and the guard condition for each current state.
[Step S24] The state is updated to the determined transition destination state, and the process proceeds to Step S21.
〔ステップS25〕例外処理ソースコードで表される例外処理を行い、処理をステップS21へ進める。
図5は、本実施の形態のプログラム自動生成装置が生成したプログラムソースコードの概略を示す図である。
[Step S25] Exception processing Exception processing represented by source code is performed, and the processing proceeds to step S21.
FIG. 5 is a diagram showing an outline of the program source code generated by the automatic program generation device of the present embodiment.
プログラムソースコード201は、プログラム自動生成装置100が生成したプログラムソースコード200の概略を示している。プログラムソースコード201は、C言語形式でプログラムソースコード200が生成されたときのソースコードを示している。プログラムソースコード201に記載されている内容は、図4に示したフローチャートの各処理に対応している。
A
上から3行目の“if”から始まる行は、図4に示したフローチャートのステップS21の処理に対応する。つまり、イベントの生起を待つ処理を行う。上から4行目の“switch”から始まる行は、図4に示したフローチャートのステップS22の処理に対応する。つまり、現在の状態を判定する。また、判定された現在の状態別に生起イベントとガード条件によって遷移先を決定する処理は、この行の一番後ろの“{”から始まるかっこで囲われている各処理である。 The third line starting from “if” from the top corresponds to the process of step S21 in the flowchart shown in FIG. That is, a process of waiting for the occurrence of an event is performed. The line starting from “switch” on the fourth line from the top corresponds to the processing in step S22 of the flowchart shown in FIG. That is, the current state is determined. Further, the process of determining the transition destination by the occurrence event and the guard condition for each determined current state is each process enclosed in parentheses starting from “{” at the back of this line.
プログラムの状態が状態0から1、2、3、・・・、n−1、nまであるとしたとき、上から5行目の“case 状態0;”と書いてある行を含めて“break;”と書いてある行までの3行が状態0と判定されたときに実行されるコードであり、図4に示したフローチャートのステップS23aの処理に対応する。以下同様に、上から8行目の“case 状態1;”と書いてある行を含めて“break;”と書いてある行までの3行が状態1と判定されたときに実行されるコードであり、図4に示したフローチャートのステップS23bの処理に対応し、上から12行目の“case 状態n;”と書いてある行を含めて“break;”と書いてある行までの3行が状態nと判定されたときに実行されるコードであり、図4に示したフローチャートのステップS23dの処理に対応する。
When the state of the program is from
下から7行目の“default;”と書いてある行を含めて“break;” と書いてある行までの3行が上記状態0からn以外の状態になったときに行われる処理である。つまり、図5に示しているプログラムソースコード201中において点線で囲われた部分のコードが例外処理ソースコード210であり、図4に示したフローチャートのステップS25の処理に対応する。また、下から3行目の“現在の”から始まる行は、図4に示したフローチャートのステップS24の処理に対応する。つまり、決定された遷移先の状態に更新する。
This is a process that is performed when three lines from the bottom to the line written “break;” including the line written “default;” on the seventh line change from the
図6は、データ受付手段が受け付けたデータの表示の一例を示す図である。
表示例300は、入力手段12を介して入力されたデータをデータ受付手段110が受け付け、モニタ11に出力したときの表示例である。表示例300には、状態遷移図および例外アクティビティが示されており、状態311、312、313、遷移321、322、323、324、325、ラベル331、332、333、334、335、および例外アクティビティ370によってプログラムの振る舞いを表している。また、ラベル331は、イベント341、ガード条件351、およびアクション式361で構成されている。同様に、ラベル332は、イベント342、ガード条件352、およびアクション式362で構成されており、ラベル333は、イベント343、ガード条件353、およびアクション式363で構成されており、ラベル334は、イベント344、ガード条件354、およびアクション式364で構成されており、ラベル335は、イベント345、ガード条件355、およびアクション式365で構成されている。
FIG. 6 is a diagram illustrating an example of display of data received by the data receiving unit.
The display example 300 is a display example when the
遷移321は、状態311から状態312に進むことを示しており、ラベル331が関連づけられている。つまり、状態311のときに、イベント341に示されている“event1”が発生し、ガード条件351に示されている“x==1”の条件を満たすと、アクション式361に示されている“a=x+1”が実行され、状態312に状態が遷移する。
A
同様に、遷移322は、状態312から状態311に進むことを示しており、ラベル332が関連づけられている。つまり、状態312のときに、イベント342に示されている“event2_1”が発生し、ガード条件352に示されている“x==2”の条件を満たすと、アクション式362に示されている“a=x+2”が実行され、状態311に状態が遷移し、遷移323は、状態312から状態313に進むことを示しており、ラベル333が関連づけられている。つまり、状態312のときに、イベント343に示されている“event2_2”が発生し、ガード条件353に示されている“x==3”の条件を満たすと、アクション式363に示されている“a=x+3”が実行され、状態313に状態が遷移する。
Similarly,
また、遷移324は、状態313から状態312に進むことを示しており、ラベル334が関連づけられている。つまり、状態313のときに、イベント344に示されている“event3_1”が発生し、ガード条件354に示されている“x==4”の条件を満たすと、アクション式364に示されている“a=x−3”が実行され、状態312に状態が遷移し、遷移325は、状態313から状態311に進むことを示しており、ラベル335が関連づけられている。つまり、状態313のときに、イベント345に示されている“event3_2”が発生し、ガード条件355に示されている“x==5”の条件を満たすと、アクション式365に示されている“a=0”が実行され、状態311に状態が遷移する。
A
また、例外アクティビティ370には、状態遷移図には定義されていない状態になったときに実行される処理である例外処理のコードが属性として記述されている。この例外アクティビティ370は、入力手段12を介して例外処理ソースコードが入力できるようになっている。
In addition, the
図7は、本実施の形態のプログラム自動生成装置が生成したプログラムソースコードの内容の一例を示す図である。
プログラムソースコード202は、図6に示した表示例300の内容から自動生成されたプログラムソースコードの内容を示している。上から3行目の“if”から始まる行は、イベントの生起を待つ処理であり、図4に示したフローチャートのステップS21の処理に対応する。図6に示したとおり、表示例300に示した状態遷移図では、“event1”、“event2_1”、“event2_2”、“event3_1”、および“event3_2”がイベントとして定義されており、プログラムソースコード例202においても上記各イベントが発生したときに遷移する旨が、上から4行目の“next_state”から始まる行に記載されている。
FIG. 7 is a diagram showing an example of the contents of the program source code generated by the automatic program generation device of the present embodiment.
The
上から5行目の“switch”から始まる行は、図4に示したフローチャートのステップS22の処理に対応する。つまり、現在の状態を判定する。また、判定された現在の状態別に生起イベントとガード条件によって遷移先を決定する処理は、この行の一番後ろの“{”から始まるかっこで囲われている各処理である。本実施の形態のプログラム自動生成装置100においては、図6の状態311、312、313にあるように、プログラムの状態がそれぞれ“STATE1”、“STATE2”、および“STATE3”と定義されている。
The line starting from “switch” on the fifth line from the top corresponds to the process in step S22 of the flowchart shown in FIG. That is, the current state is determined. Further, the process of determining the transition destination based on the occurrence event and the guard condition for each determined current state is each process enclosed in parentheses starting from “{” at the end of this line. In the automatic program generation device 100 of the present embodiment, as shown in the
このとき上から6行目の“case STATE1;”と書いてある行を含めて“break;”と書いてある行までの6行が、状態が“STATE1”と判定されたときに実行されるコードであり、たとえば、図4に示したフローチャートのステップS23aの処理に対応する。以下同様に、上から12行目の“case STATE2;”と書いてある行を含めて“break;”と書いてある行までの10行が、状態が“STATE2”と判定されたときに実行されるコードであり、たとえば、図4に示したフローチャートのステップS23bの処理に対応し、上から22行目の“case STATE3;”と書いてある行を含めて“break;”と書いてある行までの10行が、状態が“STATE3”と判定されたときに実行されるコードであり、図4に示したフローチャートのステップS23dの処理に対応する。
At this time, six lines from the top to the line written as “break;” including the line written as “case STATE1;” on the sixth line are executed when the state is determined as “STATE1”. For example, it corresponds to the processing of step S23a in the flowchart shown in FIG. In the same manner, 10 lines including “break
また、下から8行目の“default;”と書いてある行を含めて“break;” と書いてある行までの4行が上記状態“STATE1”、“STATE2”、および“STATE3”以外の状態になったときに行われる処理である。つまり、この4行のコードが例外処理ソースコード210であり、図4に示したフローチャートのステップS25の処理に対応する。また、下から3行目の“now_state”から始まる行は、図4に示したフローチャートのステップS24の処理に対応する。以下に、ソースコード生成手段120が表示例300に示されている状態遷移図を使ってどのようにしてソースコードを生成するかを説明する。
In addition, the four lines up to the line written “break;” including the line written “default;” on the eighth line from the bottom are other than the above states “STATE1,” “STATE2,” and “STATE3”. This process is performed when a state is reached. That is, the four lines of code are the exception
まずは状態を“STATE1”と判定したときに実行するコードについて説明する。ソースコード生成手段120は、図6に示した状態遷移図の状態311から伸びている矢印がどの状態に対して伸びているかを検索する。表示例300においては、状態311から状態312に対してのみ遷移321が表示されている。つまり、状態311からは状態312にしか遷移しないということになる。また、ソースコード生成手段120は、遷移321に関連づけられているラベル331を読み取る。そして、プログラムソースコード202の上から7行目にあるように“if”から始まる行にイベント341とガード条件351を所定の位置に挿入する。また、上から8行目にアクション式361を挿入する。また、上から9行目の“next_state=”の後ろに遷移321の遷移先である状態312に対応する“STATE2”を挿入する。
First, the code executed when the state is determined as “
また、状態を“STATE2”と判定したときに実行するコードについて説明する。ソースコード生成手段120は、状態312から伸びている矢印がどの状態に対して伸びているかを検索する。表示例300においては、状態312から状態311と状態313に対して遷移322、323が表示されている。つまり、状態312からは状態311と状態313に対して遷移するということになる。また、ソースコード生成手段120は、遷移322に対応づけられているラベル332を読み取る。そして、プログラムソースコード202の上から13行目にあるように“if”から始まる行にイベント342とガード条件352を所定の位置に挿入する。また、上から14行目にアクション式362を挿入する。また、上から15行目の“next_state=”の後ろに遷移322の遷移先である状態311に対応する“STATE1”を挿入する。また、ソースコード生成手段120は、遷移323に対応づけられているラベル333を読み取る。そして、上から17行目にあるように“else if”から始まる行にイベント343とガード条件353を所定の位置に挿入する。また、上から18行目にアクション式363を挿入する。また、上から19行目の“next_state=”の後ろに遷移323の遷移先である状態313に対応する“STATE3”を挿入する。
A code executed when the state is determined to be “STATE2” will be described. The source
また、状態を“STATE3”と判定したときに実行するコードについて説明する。ソースコード生成手段120は、状態313から伸びている矢印がどの状態に対して伸びているかを検索する。表示例300においては、状態313から状態311と状態312に対して遷移324、325が表示されている。つまり、状態313からは状態311と状態312に対して遷移するということになる。また、ソースコード生成手段120は、遷移324に対応づけられているラベル334を読み取る。そして、プログラムソースコード202の上から23行目にあるように“if”から始まる行にイベント344とガード条件354を所定の位置に挿入する。また、上から24行目にアクション式364を挿入する。また、上から25行目の“next_state=”の後ろに遷移324の遷移先である状態312に対応する“STATE2”を挿入する。また、ソースコード生成手段120は、遷移325に対応づけられているラベル335を読み取る。そして、上から27行目にあるように“else if”から始まる行にイベント345とガード条件355を所定の位置に挿入する。また、上から28行目にアクション式365を挿入する。また、上から29行目の“next_state=”の後ろに遷移325の遷移先である状態311に対応する“STATE1”を挿入する。
A code executed when the state is determined to be “
また、状態が“STATE1”、“STATE2”、および“STATE3”以外の状態と判定したときに実行するコードについて説明する。例外処理埋込手段130は、例外処理受付手段112が受け付けた、例外アクティビティ370に記載された例外処理ソースコードを読み取る。そして、ソースコード生成手段120が生成した生成ソースコードにある、いわゆる“switch文”の最後に“default文”を挿入する。このようにすることによって、“case文”に定義されている“STATE1”、“STATE2”、および“STATE3”以外の状態になったときには下から8行目からの“default文”が実行されることになる。つまり、定義されている状態以外の状態になったときに例外処理が行われることになる。
In addition, a code that is executed when it is determined that the state is other than “
以上のようなプログラム自動生成装置100を用いることにより、例外アクティビティ370に記載した例外処理ソースコードが、ソースコード生成手段120が生成した生成ソースコードに自動で挿入されるので、新たに生成されたプログラムソースコード200には想定されている状態以外の状態になっても例外処理が行われることになる。つまり、例外処理がないと問題がある場合であるか否かに関係なくプログラムを自動で生成することができる。また、例外処理を人手で追加しなくてもよくなる。したがって、プログラムを自動で生成するメリットが向上する。
By using the automatic program generation device 100 as described above, the exception processing source code described in the
なお、図6において、入力手段12を介して入力されたデータをデータ受付手段110が受け付け、モニタ11に出力したときの表示例を表示例300として示した。しかし、表示例300のように例外アクティビティ370を必ずしも図形式データの一部として取り扱う必要はない。そこで、図形式データの属性として取り扱う場合の表示例を図8に示す。
In FIG. 6, a display example is shown as a display example 300 when the
図8は、データ受付手段が受け付けたデータの表示の別の例を示す図である。
表示例301には、図形データ表示部302と図面属性表示部303が表示されている。また、図面属性表示部303には、例外アクティビティ371が表示されている。図形データ表示部302は、図形データである状態遷移図を表示する。また、図面属性表示部303は、図形データ表示部302に表示されている状態遷移図の属性を表示する。その属性として例外アクティビティ371が表示されている。例外アクティビティ371に例外処理ソースコードを入力することによって、図形データ表示部302に表示されている状態遷移図の例外処理を行えるようにしてもよい。
FIG. 8 is a diagram illustrating another example of the display of data received by the data receiving unit.
In the display example 301, a graphic
このように、例外処理ソースコードを状態遷移図の属性データとして扱うことにより、例外アクティビティ371に入力した例外処理ソースコードを他の状態遷移図の例外処理のための例外処理ソースコードとして使うこともできる。したがって、状態遷移図を生成するたびに例外処理ソースコードを入力することなく例外処理を含んだプログラムソースコード200を生成することができ、さらにプログラムを自動で生成するメリットが向上する。
As described above, by handling the exception processing source code as the attribute data of the state transition diagram, the exception processing source code input to the
また、例外アクティビティから入力手段を介して例外処理ソースコードを入力する旨を説明したが、例外処理ソースコードをプログラム自動生成装置とは別個に作成して、できあがった例外処理ソースコードを、たとえば、記録装置などに格納し、プログラム自動生成装置がその記録媒体を読み取ることによって例外処理ソースコードを受け取ってもよい。また、ネットワークを介して例外処理のソースコードを受け取ってもよい。その場合には、図2に示したハードウェアにネットワークインタフェースなどを設ける。 Also, the exception processing source code is input from the exception activity via the input means. However, the exception processing source code is created separately from the program automatic generation device, and the resulting exception processing source code is, for example, The exception processing source code may be received by being stored in a recording device or the like, and the automatic program generation device reading the recording medium. Also, exception processing source code may be received via a network. In that case, a network interface or the like is provided in the hardware shown in FIG.
11 モニタ
12 入力手段
100 プログラム自動生成装置
110 データ受付手段
111 図形式データ生成手段
112 例外処理受付手段
120 ソースコード生成手段
130 例外処理埋込手段
200 プログラムソースコード
DESCRIPTION OF SYMBOLS 11
Claims (8)
ユーザからの指示を受けて、前記図形式データを生成する図形式データ生成手段と、
前記図形式データからコンパイル可能なプログラムソースコードを生成するソースコード生成手段と、
前記図形式データで定義されたどの状態とも異なっている場合に行う例外処理のソースコードを受け付ける例外処理受付手段と、
前記プログラムソースコードに前記例外処理のソースコードを埋め込み、新たなプログラムソースコードとして出力する例外処理埋込手段と、
を有することを特徴とするプログラム自動生成装置。 In an automatic program generation device that generates a program from diagram data representing the behavior of the program in diagram format,
In response to an instruction from the user, graphic data generation means for generating the graphic data,
Source code generation means for generating a compilable program source code from the graphic data;
Exception processing receiving means for receiving source code of exception processing to be performed when different from any state defined in the diagram format data;
Exception processing embedding means for embedding the exception processing source code in the program source code and outputting as a new program source code;
An apparatus for automatically generating a program, comprising:
図形式データ生成手段が、ユーザからの指示を受けて、前記図形式データを生成するステップと、
ソースコード生成手段が、前記図形式データからコンパイル可能なプログラムソースコードを生成するステップと、
例外処理受付手段が、前記図形式データで定義されたどの状態とも異なっている場合に行う例外処理のソースコードを受け付けるステップと、
例外処理埋込手段が、前記プログラムソースコードに前記例外処理のソースコードを埋め込み、新たなプログラムソースコードとして出力するステップと、
を含むことを特徴とするプログラム自動生成方法。 In an automatic program generation method for generating a program from diagram data representing the behavior of the program in diagram format,
A step of generating graphic data in response to an instruction from a user;
Source code generation means for generating compilable program source code from the diagram data;
A step of receiving an exception processing source code when the exception processing receiving means is different from any state defined in the graphic data;
An exception processing embedding unit embeds the source code of the exception processing in the program source code and outputs it as a new program source code;
A method for automatically generating a program, comprising:
コンピュータに、
ユーザからの指示を受けて、前記図形式データを生成する図形式データ生成手段と、
前記図形式データからコンパイル可能なプログラムソースコードを生成するソースコード生成手段、
前記図形式データで定義されたどの状態とも異なっている場合に行う例外処理のソースコードを受け付ける例外処理受付手段、
前記プログラムソースコードに前記例外処理のソースコードを埋め込み、新たなプログラムソースコードとして出力する例外処理埋込手段、
として機能させることを特徴とするプログラム自動生成プログラム。 In an automatic program generation program that generates a program from diagram format data that represents the behavior of the program in diagram format,
On the computer,
In response to an instruction from the user, graphic data generation means for generating the graphic data,
Source code generating means for generating compilable program source code from the diagram format data;
Exception processing receiving means for receiving source code of exception processing performed when different from any state defined in the diagram format data,
Exception processing embedding means for embedding the exception processing source code in the program source code and outputting as a new program source code;
An automatic program generation program characterized in that it functions as a program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2005285802A JP2007094922A (en) | 2005-09-30 | 2005-09-30 | Automatic program generation, method, and program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2005285802A JP2007094922A (en) | 2005-09-30 | 2005-09-30 | Automatic program generation, method, and program |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2007094922A true JP2007094922A (en) | 2007-04-12 |
Family
ID=37980537
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2005285802A Pending JP2007094922A (en) | 2005-09-30 | 2005-09-30 | Automatic program generation, method, and program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2007094922A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2014060595A (en) * | 2012-09-18 | 2014-04-03 | Mitsubishi Electric Corp | Message sequence generation method and message sequence generation device |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS60178795A (en) * | 1984-02-24 | 1985-09-12 | Fujitsu Ltd | Condition transition processing system |
JPH06332689A (en) * | 1993-05-21 | 1994-12-02 | Hitachi Ltd | Program displaying method and program edition accepting method |
JPH0778076A (en) * | 1993-09-08 | 1995-03-20 | Toshiba Corp | Automatic program generating device |
JPH1091411A (en) * | 1996-09-18 | 1998-04-10 | Hitachi Ltd | Source program generation system |
JP2003256203A (en) * | 2002-03-01 | 2003-09-10 | Mitsubishi Electric Corp | System and method for developing automatic machine application program, program for executing the method and storage medium stored with the program |
-
2005
- 2005-09-30 JP JP2005285802A patent/JP2007094922A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS60178795A (en) * | 1984-02-24 | 1985-09-12 | Fujitsu Ltd | Condition transition processing system |
JPH06332689A (en) * | 1993-05-21 | 1994-12-02 | Hitachi Ltd | Program displaying method and program edition accepting method |
JPH0778076A (en) * | 1993-09-08 | 1995-03-20 | Toshiba Corp | Automatic program generating device |
JPH1091411A (en) * | 1996-09-18 | 1998-04-10 | Hitachi Ltd | Source program generation system |
JP2003256203A (en) * | 2002-03-01 | 2003-09-10 | Mitsubishi Electric Corp | System and method for developing automatic machine application program, program for executing the method and storage medium stored with the program |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2014060595A (en) * | 2012-09-18 | 2014-04-03 | Mitsubishi Electric Corp | Message sequence generation method and message sequence generation device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR101238550B1 (en) | Method and computer-readable medium for commanding | |
US8201143B2 (en) | Dynamic mating of a modified user interface with pre-modified user interface code library | |
US8792116B2 (en) | Printing controller, GUI display method, printer driver, and recording medium | |
US8797335B2 (en) | Platform agnostic screen capture tool | |
KR20120026055A (en) | Displaying transition images during a slide transition | |
JP2007293548A (en) | Information processor and information processing method | |
JP2006301989A (en) | Method, apparatus and program for automatically generating program in computer language from block diagram | |
JP5086296B2 (en) | Programmable controller control program creation method and programmable controller control program creation system | |
JP2007094922A (en) | Automatic program generation, method, and program | |
JP2007012037A (en) | Information processor, display control processing method and program | |
US20180373512A1 (en) | Method and device for simulating synchronous blocking in asynchronous environment, storage medium, server and terminal | |
JP2007287025A (en) | Method and apparatus for creating screen transition program | |
JP2009211622A (en) | Contract definition function verification device, method thereof, and program thereof | |
JP2007034825A (en) | Debugging device | |
JP2006285754A (en) | Program source code automatic generation system | |
JP5702265B2 (en) | Program automatic generation apparatus and program automatic generation method | |
JP2008299423A (en) | Information processor and information processing program | |
JP3544462B2 (en) | Source program analysis device and computer-readable recording medium storing source program analysis program | |
JP2007219893A (en) | Firmware evaluation system and firmware evaluation method | |
WO2022249358A1 (en) | Robot control device and robot control system | |
KR102000543B1 (en) | Apparatus for editing web electric document and operating method thereof | |
JP2010026968A (en) | Circuit generation support program and circuit generation support method | |
JP2011128864A (en) | Data processor, and data processing method and program | |
JP2006172003A (en) | Program execution monitoring device, program execution monitoring method and program preparing method | |
JP2009015579A (en) | Information processor and window display method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20080916 |
|
A977 | Report on retrieval |
Effective date: 20110513 Free format text: JAPANESE INTERMEDIATE CODE: A971007 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20110524 |
|
A02 | Decision of refusal |
Effective date: 20111004 Free format text: JAPANESE INTERMEDIATE CODE: A02 |