JP2008084262A - Device, method and program for automatically generating program - Google Patents
Device, method and program for automatically generating program Download PDFInfo
- Publication number
- JP2008084262A JP2008084262A JP2006266437A JP2006266437A JP2008084262A JP 2008084262 A JP2008084262 A JP 2008084262A JP 2006266437 A JP2006266437 A JP 2006266437A JP 2006266437 A JP2006266437 A JP 2006266437A JP 2008084262 A JP2008084262 A JP 2008084262A
- Authority
- JP
- Japan
- Prior art keywords
- state
- transition
- loop control
- transition diagram
- state transition
- 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
Landscapes
- Stored Programmes (AREA)
Abstract
Description
本発明はプログラム自動生成装置、プログラム自動生成方法およびプログラム自動生成プログラムに関し、特に、カウントアップによって、状態が別の状態へ遷移する動作を有するプログラムのプログラム自動生成装置、プログラム自動生成方法およびプログラム自動生成プログラムに関する。 The present invention relates to an automatic program generation device, an automatic program generation method, and an automatic program generation program, and more particularly, an automatic program generation device, an automatic program generation method, and an automatic program for a program having an operation of changing a state to another state by counting up. It relates to the generation program.
従来、プログラムの開発においては、アセンブラやC言語などのプログラミング言語を用いて電子計算機のプログラムを製作する場合には、テキストエディタなどのテキストに直接記述する手段が用いられてきた。 Conventionally, in the development of a program, when an electronic computer program is produced using a programming language such as an assembler or C language, means for directly describing the text in a text editor or the like has been used.
一方、プログラムの規模がある程度の規模に達すると、テキストのみでは可読性に乏しく、プログラムの設計のみならず、検査・管理・保守などに多大な労力を要することとなる。 On the other hand, when the scale of the program reaches a certain level, the text alone is poor in readability, and not only the design of the program but also a lot of labor is required for inspection, management and maintenance.
そこで、このような問題を解決し、効率よくソフトウェアを設計するために各種技術が開発されている。例えば、HCP(Hierarchical and ComPacts description)チャートと呼ばれる木構造の図式プログラムの記述方法(例えば、特許文献1参照。)やPAD(Problem Analysis Diagram)と呼ばれる図式プログラムの記述方法(例えば、特許文献2参照。)などが挙げられる。また、制御系システムのソフトウェア開発においては、ソフトウェアの使用を、複数の状態とその状態間との遷移から成る状態遷移図をベースとして記述し、記述された状態遷移図からプログラムを自動的に生成する方法が開発されて(特許文献3参照。)、状態遷移図を用いたプログラムの記述方法は、UML(Unified Modeling Language)の状態マシン図としても定義されている。 Therefore, various techniques have been developed to solve such problems and to design software efficiently. For example, a description method of a tree structure diagram program called an HCP (Hierarchical and ComPacts description) chart (for example, see Patent Document 1) and a description method of a diagram program called a PAD (Problem Analysis Diagram) (for example, see Patent Document 2) Etc.). In software development for control systems, the use of software is described based on a state transition diagram consisting of multiple states and transitions between them, and a program is automatically generated from the described state transition diagram. A method for describing a program using a state transition diagram is also defined as a UML (Unified Modeling Language) state machine diagram.
なお、この状態遷移図について以下に概要を説明する。
図12は、従来の状態遷移図の記述例である。
図12を用いて、状態遷移図の概要について、以下に説明する。
The outline of this state transition diagram will be described below.
FIG. 12 is a description example of a conventional state transition diagram.
The outline of the state transition diagram will be described below with reference to FIG.
状態遷移図は、状態を表すノードと、状態間の遷移を表す矢印線とから構成されている。また、それぞれの状態遷移に対して、その遷移が生起する条件を示す遷移条件が付加されることがある。 The state transition diagram includes nodes representing states and arrow lines representing transitions between states. In addition, a transition condition indicating a condition in which the transition occurs may be added to each state transition.
具体的には、以下の通りである。すなわち、状態遷移図900は、状態1910から状態2920への遷移911、状態2920から状態1910への遷移921および開始状態940から状態1910への遷移941の状態遷移について示されており、“複数の状態”、“遷移”、“イベント”、“ガード条件”および“アクション”の5つの要素を有している。なお、図12中の、例えば、“eventX[condA]/actA”は“イベント名[ガード条件名]/アクション名”を表しており、以下同様に表すこととする。
Specifically, it is as follows. That is, the state transition diagram 900 shows the state transition of the transition 911 from the state 1910 to the state 2920, the transition 921 from the state 2920 to the state 1910, and the transition 941 from the
以下に、状態遷移図900の状態の遷移の概要について説明する。
まず、開始状態940から状態1910への遷移941を発生させる。
次に、状態1910において、eventX912が発生し、ガード条件のcondA913に適合した場合、actA914が行われ、状態1910から状態2920への遷移911が発生する。なお、condA913に適合しない場合、すなわち¬condA913bに適合する場合、actA914が行われ、状態1910には、自己遷移911bが発生し、状態1910にとどまる。
The outline of the state transition in the state transition diagram 900 will be described below.
First, a transition 941 from the
Next, in state 1910,
また、状態2920において、eventY922が発生し、ガード条件のcondB923に適合する場合、actB924が行われ、状態2920から状態1910への遷移921が発生する。 Also, in the state 2920, eventY922 occurs, and if it matches the guard condition condB923, actB924 is performed, and a transition 921 from the state 2920 to the state 1910 occurs.
以上のように、状態遷移図900では、イベントが発生し、条件の適合状況に応じて、状態の遷移が発生する。
次に、別の状態遷移図の概要について、以下に説明する。
As described above, in the state transition diagram 900, an event occurs, and a state transition occurs according to a condition conformance state.
Next, an outline of another state transition diagram will be described below.
図13は、従来の状態遷移図の別の記述例である。
状態遷移図900aは、状態1910から状態2920への遷移911、状態2920から状態1910への遷移921、開始状態940aから状態1910への遷移941aおよび状態1910から状態3930への遷移911aの状態遷移について示されており、“複数の状態”、“遷移”、“イベント”、“ガード条件”、“アクション”および“カウントクリア”の6つの要素を有している。
FIG. 13 is another description example of the conventional state transition diagram.
The state transition diagram 900a shows the state transition of the transition 911 from the state 1910 to the state 2920, the transition 921 from the state 2920 to the state 1910, the
このような、状態遷移図900aでは、図12の状態遷移図900に、状態1910aから状態3930への遷移911aが新たに加えられている。また、状態1910から状態2920、または状態3930へ遷移する際、カウントの値がクリアされて遷移するようにしたために、カウントクリア(count=0)915,915aが新たに追加されている。 In such a state transition diagram 900a, a transition 911a from the state 1910a to the state 3930 is newly added to the state transition diagram 900 of FIG. In addition, since the count value is cleared when transitioning from the state 1910 to the state 2920 or the state 3930, the count clear (count = 0) 915, 915a is newly added.
以下に、状態遷移図900aの状態の遷移の概要について説明する。
まず、図12と同様に、開始状態940aから状態1910への遷移941aを発生させる。
The outline of the state transition of the state transition diagram 900a will be described below.
First, as in FIG. 12, the
次に、状態1910において、eventX912を発生させ、ガード条件のcondA913に適合する場合、actA914が行われ、状態1910から状態2920への遷移911が発生する。そして、この遷移の時、カウントが値を有する場合、カウントクリア(count=0)915により、カウントの値がクリアされて、状態1910から状態2920への状態遷移が発生する。
Next, in state 1910,
一方、condA913が成立せず、カウント回数の上限値、例えば図13では“5”、よりもカウントが小さい(¬condA∧count<5913b)場合、状態1910には、自己への遷移911bが発生する。そして、¬condAが複数回連続して生じると、カウントの値の数が1ずつ増加する(count+1914b)。
On the other hand, when
さらに、¬condAが5回続いて、そして、6回目が生じると(count≧5)、状態1910から状態3930への遷移911aが発生する。そして、この時、カウントが値を有するので、カウントクリア(count=0)915aにより、カウントの値がクリアされて、状態1910から状態3930への状態遷移が発生する。なお、このように状態1910にとどまっている回数が上限値を超えた場合に遷移が発生する動作を、以下、“ループ制御遷移動作”と呼ぶ。 Further, when ¬cond continues five times and the sixth time occurs (count ≧ 5), a transition 911a from the state 1910 to the state 3930 occurs. At this time, since the count has a value, the count value is cleared by the count clear (count = 0) 915a, and the state transition from the state 1910 to the state 3930 occurs. The operation in which a transition occurs when the number of times of staying in the state 1910 exceeds the upper limit value is hereinafter referred to as a “loop control transition operation”.
次に、状態2920において、eventY922を発生させ、ガード条件のcondB923に適合する場合、actB924が行われ、状態2920から状態1910への遷移921が発生する。 Next, in the state 2920, eventY922 is generated, and when the guard condition condB923 is met, actB924 is performed, and the transition 921 from the state 2920 to the state 1910 occurs.
以上のように、状態遷移図900aでは、イベントが発生し、条件の適応に応じて、状態の遷移が発生する。
しかし、状態遷移図を用いたプログラムの記述方法には以下のような問題点があった。
ループ制御遷移動作を記述するためには、数多くの要素を記述する必要がある。すなわち、プログラム自動生成装置として考えた場合、“状態”、“イベント”、“ガード条件”、“アクション”、“カウントクリア”および“カウント数の上限値”などの要素を全て記述する必要がある。もし、このような要素のうちで1つでも記述されない場合、プログラムの自動生成が正しく行われず、生成されたプログラムは正しく動作しないという問題がある。
However, the program description method using the state transition diagram has the following problems.
In order to describe the loop control transition operation, it is necessary to describe many elements. That is, when considered as an automatic program generation device, it is necessary to describe all of the elements such as “state”, “event”, “guard condition”, “action”, “count clear”, and “count number upper limit”. . If even one of these elements is not described, there is a problem that automatic generation of the program is not performed correctly and the generated program does not operate correctly.
また、このループ制御遷移動作を有するプログラムは、特に、産業用機器装置などへの組み込み用のソフトウェアとして導入されている。そして、組み込み用のソフトウェアの動作を、状態遷移図の利用により記述する場合に、ループ制御遷移動作は、タイムアウトエラーの検出および一定期間のウェイトなどを実現するために定周期イベントと共に用いられることが多く、出現頻度が高い必須の動作である。このため、ソフトウェアの開発効率の面や品質向上に向けて、出現頻度が高い動作を実現させるために、数多くの要素を要するループ制御遷移動作を正しく記述する必要がある。 In addition, the program having the loop control transition operation is introduced as software for incorporation into an industrial equipment device. When describing the operation of embedded software by using a state transition diagram, the loop control transition operation can be used together with a fixed-cycle event in order to detect a timeout error and wait for a certain period of time. It is an essential action that often appears and has a high frequency of appearance. For this reason, it is necessary to correctly describe a loop control transition operation that requires a large number of elements in order to realize an operation with a high appearance frequency in terms of software development efficiency and quality improvement.
本発明はこのような点に鑑みてなされたものであり、プログラム開発の開発効率および品質を向上することができるプログラム自動生成装置、プログラム自動生成方法およびプログラム自動生成プログラムを提供することを目的とする。 The present invention has been made in view of these points, and an object thereof is to provide an automatic program generation device, an automatic program generation method, and an automatic program generation program that can improve the development efficiency and quality of program development. To do.
本発明では上記課題を解決するために、状態遷移図からソースコードを生成するプログラム自動生成装置において、プログラムの状態を記述する状態記述機能と、2つの前記状態をリンクする1つの状態遷移であって、イベントに反応して、前記イベントがユーザの指定回数以下の間はリンク元の前記状態を自己遷移し、前記指定回数を超えるとリンク先の前記状態に遷移する、ことを示すループ制御遷移を記述するループ制御遷移記述機能と、前記ループ制御遷移で表される遷移以外の前記状態遷移を示す通常遷移を記述する通常遷移記述機能と、を有しており、ユーザの操作入力に従って、前記状態、前記ループ制御遷移および前記通常遷移で構成される前記状態遷移図を作成する状態遷移図作成手段と、前記状態遷移図作成手段が作成した前記状態遷移図を保持する状態遷移図記憶手段と、ユーザから生成指示が入力されると、前記状態遷移図記憶手段が保持する前記状態遷移図に記述された前記ループ制御遷移から、実行時に発生する前記イベントを検知し、前記イベントの発生回数を保持し、前記イベントが前記指定回数以下の場合は現在の前記状態を維持し、前記指定回数を超えた場合は前記ループ制御遷移に従って前記状態を更新する、処理を記述したループ制御コードを生成すると共に、前記状態遷移図に記述された前記ループ制御遷移以外の振る舞いを実現する通常処理コードを生成し、前記ループ制御コードと前記通常処理コードとから成る前記ソースコードを生成する、ソースコード生成手段と、を有することを特徴とするプログラム自動生成装置が提供される。 In the present invention, in order to solve the above-described problem, an automatic program generation device that generates source code from a state transition diagram includes a state description function that describes the state of a program and one state transition that links the two states. In response to an event, a loop control transition indicating that the state of the link source self-transitions when the event is less than or equal to the user's designated number of times, and transitions to the state of the link destination when the number of times exceeds the designated number of times. And a normal transition description function for describing a normal transition indicating the state transition other than the transition represented by the loop control transition, and according to a user operation input, State transition diagram creating means for creating the state transition diagram composed of state, loop control transition and normal transition, and created by the state transition diagram creating means When the state transition diagram storage unit that holds the state transition diagram and the generation instruction are input from the user, the loop control transition described in the state transition diagram that the state transition diagram storage unit holds Detecting the event that occurs, holding the number of occurrences of the event, maintaining the current state if the event is less than or equal to the specified number of times, and if the event exceeds the specified number of times, the state according to the loop control transition A loop control code describing the process, and generating a normal process code that realizes a behavior other than the loop control transition described in the state transition diagram, and the loop control code and the normal process code And an automatic program generation device comprising: a source code generation means for generating the source code comprising: That.
このようなプログラム自動生成装置によれば、状態記述機能により、プログラムの状態が記述され、ループ制御遷移記述機能により、2状態間の1つの状態遷移であって、反応されたイベントが指定回数以下の間はリンク元の状態を自己遷移し、指定回数を超えるとリンク先の状態に遷移することを示すループ制御遷移が記述され、通常遷移記述機能により、ループ制御遷移以外の状態遷移を示す通常遷移が記述され、状態遷移図作成手段により、状態、ループ制御遷移および通常遷移から状態遷移図が作成される。そして、ソースコード生成手段により、ループ制御遷移から、実行時のイベントが検知され、イベントの発生回数が指定回数以下の際は現在の状態が維持され、指定回数を超えるとループ制御遷移に従って状態が更新される処理を示すループ制御コードとループ制御遷移以外の振る舞いを実現する通常処理コードとから成るソースコードが生成される。 According to such an automatic program generation device, the state description function describes the state of the program, and the loop control transition description function indicates one state transition between two states, and the reacted event is less than the specified number of times. During this period, a loop control transition indicating that the link source state self-transitions and transitions to the link destination state when the specified number of times is exceeded is described, and the normal transition description function indicates a state transition other than the loop control transition. The transition is described, and a state transition diagram is created from the state, the loop control transition, and the normal transition by the state transition diagram creating means. Then, the source code generation means detects an event at the time of execution from the loop control transition, and the current state is maintained when the number of occurrences of the event is less than or equal to the specified number of times. Source code including a loop control code indicating a process to be updated and a normal process code realizing behavior other than the loop control transition is generated.
また、上記課題を解決するために、状態遷移図からソースコードを生成するプログラム自動生成方法において、状態記述機能が、プログラムの状態を記述し、ループ制御遷移記述機能が、2つの前記状態をリンクする1つの状態遷移であって、イベントに反応して、前記イベントがユーザの指定回数以下の間はリンク元の前記状態を自己遷移し、前記指定回数を超えるとリンク先の前記状態に遷移する、ことを示すループ制御遷移を記述し、通常遷移記述機能が、前記ループ制御遷移で表される遷移以外の前記状態遷移を示す通常遷移を記述し、状態遷移図作成手段が、前記状態記述機能、前記ループ制御遷移記述機能および前記通常遷移記述機能を有しており、ユーザの操作入力に従って、前記状態、前記ループ制御遷移および前記通常遷移で構成される前記状態遷移図を作成し、状態遷移図記憶手段が、前記状態遷移図作成手段が作成した前記状態遷移図を保持し、ソースコード生成手段が、ユーザから生成指示が入力されると、前記状態遷移図記憶手段が保持する前記状態遷移図に記述された前記ループ制御遷移から、実行時に発生する前記イベントを検知し、前記イベントの発生回数を保持し、前記イベントが前記指定回数以下の場合は現在の前記状態を維持し、前記指定回数を超えた場合は前記ループ制御遷移に従って前記状態を更新する、処理を記述したループ制御コードを生成すると共に、前記状態遷移図に記述された前記ループ制御遷移以外の振る舞いを実現する通常処理コードを生成し、前記ループ制御コードと前記通常処理コードとから成る前記ソースコードを生成する、ことを特徴とするプログラム自動生成方法が提供される。 In order to solve the above problem, in the automatic program generation method for generating source code from the state transition diagram, the state description function describes the state of the program, and the loop control transition description function links the two states. In response to an event, the state of the link source self-transitions when the event is less than or equal to the number of times specified by the user, and transitions to the state of the link destination when the number of times exceeds the specified number of times. , The normal transition description function describes the normal transition indicating the state transition other than the transition represented by the loop control transition, and the state transition diagram creating means includes the state description function. The loop control transition description function and the normal transition description function, and according to a user operation input, the state, the loop control transition and the normal transition The state transition diagram configured by the state transition diagram storage unit is created, the state transition diagram storage unit holds the state transition diagram created by the state transition diagram creation unit, and the source code generation unit receives a generation instruction from the user And detecting the event occurring at the time of execution from the loop control transition described in the state transition diagram held by the state transition diagram storage means, holding the number of occurrences of the event, and the event is the specified number of times In the following cases, the current state is maintained, and when the specified number of times is exceeded, the state is updated according to the loop control transition, and a loop control code describing the process is generated and described in the state transition diagram. Generating a normal processing code for realizing a behavior other than the loop control transition, and the source code comprising the loop control code and the normal processing code Generating, automatic program generation method, characterized in that there is provided.
このようなプログラム自動生成方法によれば、状態記述機能により、プログラムの状態が記述され、ループ制御遷移記述機能により、2つの状態をリンクする1つの状態遷移であって、イベントに反応して、イベントがユーザの指定回数以下の間はリンク元の状態を自己遷移し、指定回数を超えるとリンク先の状態に遷移する、ことを示すループ制御遷移が記述され、通常遷移記述機能により、ループ制御遷移で表される遷移以外の状態遷移を示す通常遷移が記述され、状態遷移図作成手段により、状態記述機能、ループ制御遷移記述機能および通常遷移記述機能が有され、ユーザの操作入力に従って、状態、ループ制御遷移および通常遷移で構成される状態遷移図が作成され、状態遷移図記憶手段により、状態遷移図作成手段が作成した状態遷移図が保持され、ソースコード生成手段により、ユーザから生成指示が入力されると、状態遷移図記憶手段が保持する状態遷移図に記述されたループ制御遷移から、実行時に発生するイベントが検知され、イベントの発生回数が保持され、イベントが指定回数以下の場合は現在の状態が維持され、指定回数を超えた場合はループ制御遷移に従って状態が更新される、処理が記述されたループ制御コードが生成されると共に、状態遷移図に記述されたループ制御遷移以外の振る舞いを実現する通常処理コードが生成され、ループ制御コードと通常処理コードとから成るソースコードが生成される。 According to such a program automatic generation method, the state of the program is described by the state description function, and one state transition for linking two states by the loop control transition description function, in response to the event, When the event is less than the user's specified number of times, the state of the link source self-transitions, and when the number of times exceeds the specified number of times, a loop control transition indicating that the state changes to the link destination state is described. A normal transition indicating a state transition other than the transition represented by the transition is described, and the state transition diagram creating means has a state description function, a loop control transition description function, and a normal transition description function. A state transition diagram composed of a loop control transition and a normal transition is created, and the state transition diagram creating unit creates a state transition diagram storing unit. When a transition diagram is held and a source code generation unit inputs a generation instruction from a user, an event that occurs at the time of execution is detected from the loop control transition described in the state transition diagram held by the state transition diagram storage unit If the number of event occurrences is retained, the current state is maintained if the number of events is less than or equal to the specified number of times, and the state is updated according to the loop control transition if the specified number of times is exceeded. At the same time, a normal processing code that realizes behavior other than the loop control transition described in the state transition diagram is generated, and a source code composed of the loop control code and the normal processing code is generated.
また、上記課題を解決するために、状態遷移図からソースコードを生成するプログラム自動生成プログラムにおいて、コンピュータを、プログラムの状態を記述する状態記述機能と、2つの前記状態をリンクする1つの状態遷移であって、イベントに反応して、前記イベントがユーザの指定回数以下の間はリンク元の前記状態を自己遷移し、前記指定回数を超えるとリンク先の前記状態に遷移する、ことを示すループ制御遷移を記述するループ制御遷移記述機能と、前記ループ制御遷移で表される遷移以外の前記状態遷移を示す通常遷移を記述する通常遷移記述機能と、を有しており、ユーザの操作入力に従って、前記状態、前記ループ制御遷移および前記通常遷移で構成される前記状態遷移図を作成する状態遷移図作成手段、前記状態遷移図作成手段が作成した前記状態遷移図を保持する状態遷移図記憶手段、ユーザから生成指示が入力されると、前記状態遷移図記憶手段が保持する前記状態遷移図に記述された前記ループ制御遷移から、実行時に発生する前記イベントを検知し、前記イベントの発生回数を保持し、前記イベントが前記指定回数以下の場合は現在の前記状態を維持し、前記指定回数を超えた場合は前記ループ制御遷移に従って前記状態を更新する、処理を記述したループ制御コードを生成すると共に、前記状態遷移図に記述された前記ループ制御遷移以外の振る舞いを実現する通常処理コードを生成し、前記ループ制御コードと前記通常処理コードとから成る前記ソースコードを生成する、ソースコード生成手段、として機能させることを特徴とするプログラム自動生成プログラムが提供される。 In order to solve the above-mentioned problem, in a program automatic generation program for generating source code from a state transition diagram, a computer describes a state description function that describes the state of the program and one state transition that links the two states. A loop indicating that in response to an event, the state of the link source self-transitions while the event is less than or equal to the user's designated number of times, and when the number of times exceeds the designated number of times, the state of the link destination is transited to A loop control transition description function for describing a control transition, and a normal transition description function for describing a normal transition indicating the state transition other than the transition represented by the loop control transition, and according to a user operation input , A state transition diagram creating means for creating the state transition diagram composed of the state, the loop control transition and the normal transition, and the state transition State transition diagram storage means for holding the state transition diagram created by the creation means, and when a generation instruction is input from the user, from the loop control transition described in the state transition diagram held by the state transition diagram storage means Detecting the event that occurs at the time of execution, holding the number of occurrences of the event, maintaining the current state if the event is less than or equal to the specified number of times, and transitioning to the loop control if the specified number of times is exceeded The state is updated according to the above, a loop control code describing the process is generated, and a normal processing code that realizes behavior other than the loop control transition described in the state transition diagram is generated, and the loop control code and the A program that functions as source code generation means for generating the source code comprising normal processing code Dynamic generation program is provided.
このようなプログラム自動生成プログラムを実行するコンピュータによれば、状態記述機能により、プログラムの状態が記述され、ループ制御遷移記述機能により、2状態間の1つの状態遷移であって、反応されたイベントが指定回数以下の間はリンク元の状態を自己遷移し、指定回数を超えるとリンク先の状態に遷移することを示すループ制御遷移が記述され、通常遷移記述機能により、ループ制御遷移以外の状態遷移を示す通常遷移が記述され、状態遷移図作成手段により、状態、ループ制御遷移および通常遷移から状態遷移図が作成される。そして、ソースコード生成手段により、ループ制御遷移から、実行時のイベントが検知され、イベントの発生回数が指定回数以下の際は現在の状態が維持され、指定回数を超えるとループ制御遷移に従って状態が更新される処理を示すループ制御コードとループ制御遷移以外の振る舞いを実現する通常処理コードとから成るソースコードが生成される。 According to a computer that executes such an automatic program generation program, the state of the program is described by the state description function, and one state transition between the two states by the loop control transition description function. If the specified number of times is less than the specified number of times, the state of the link source will make a self-transition, and if the number of times exceeds the specified number of times, a loop control transition will be described indicating that the state will change to the link destination state. A normal transition indicating the transition is described, and a state transition diagram is created from the state, the loop control transition, and the normal transition by the state transition diagram creating means. Then, the source code generation means detects an event at the time of execution from the loop control transition, and the current state is maintained when the number of occurrences of the event is less than or equal to the specified number of times. Source code including a loop control code indicating a process to be updated and a normal process code realizing behavior other than the loop control transition is generated.
本発明では、2つの状態をリンクする1つの状態遷移であって、イベントに反応して、イベントがユーザの指定回数以下の間はリンク元の状態を自己遷移し、指定回数を超えるとリンク先の状態に遷移する、ことを示すループ制御遷移が記述される。次に、ループ制御遷移で表される遷移以外の状態遷移を示す通常遷移が記述される。そして、ユーザの操作入力に従って、状態、ループ制御遷移および通常遷移で構成される状態遷移図が作成される。そして、ソースコード生成手段により、状態遷移図に記述されたループ制御遷移から、実行時に発生するイベントを検知し、イベントの発生回数を保持し、イベントが指定回数以下の場合は現在の状態を維持し、処理を記述したループ制御コードを生成すると共に、状態遷移図に記述されたループ制御遷移以外の振る舞いを実現する通常処理コードを生成し、ループ制御コードと通常処理コードとから成るソースコードが生成されるようにした。これにより、状態遷移図を用いたプログラムの開発の開発効率および品質を向上させることができる。 In the present invention, one state transition for linking two states, in response to an event, the state of the link source self-transitions when the event is less than or equal to the user's designated number of times, and when the number of times exceeds the designated number, the link destination A loop control transition indicating that a transition is made to the state is described. Next, a normal transition indicating a state transition other than the transition represented by the loop control transition is described. Then, a state transition diagram including a state, a loop control transition, and a normal transition is created in accordance with a user operation input. Then, the source code generation means detects the event that occurs at the time of execution from the loop control transition described in the state transition diagram, holds the number of occurrences of the event, and maintains the current state if the number of events is less than the specified number In addition to generating a loop control code describing the process, a normal processing code that realizes behavior other than the loop control transition described in the state transition diagram is generated, and the source code composed of the loop control code and the normal processing code is It was made to generate. Thereby, the development efficiency and quality of the program development using the state transition diagram can be improved.
以下、本発明の実施の形態を、図面を参照して詳細に説明する。
まず、発明の概要について説明し、続いて、本発明の実施の形態について説明する。
図1は、実施の形態の概要図である。
Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings.
First, an outline of the invention will be described, and then an embodiment of the present invention will be described.
FIG. 1 is a schematic diagram of an embodiment.
図1に示されるプログラム自動生成装置10は、状態遷移図とそれぞれの状態遷移についての遷移条件の詳細な記述とから、プログラムを自動的に生成するものである。プログラム自動生成装置10では、入力装置2を介して、状態遷移図作成手段12が用いられて、状態遷移図11aが作成されて、作成された状態遷移図11aから、ソースコード3が生成されるものである。
The automatic program generation device 10 shown in FIG. 1 automatically generates a program from a state transition diagram and a detailed description of transition conditions for each state transition. In the automatic program generation device 10, the state transition diagram creating means 12 is used via the input device 2 to create the state transition diagram 11 a, and the
プログラム自動生成装置10は、状態遷移図記憶手段11と状態遷移図作成手段12とソースコード生成手段13とを有する。
状態遷移図記憶手段11は、状態遷移図作成手段12により作成される状態遷移図11aが格納される。なお、状態遷移図11aは、既に説明したとおり、状態を表すノードと、状態間の遷移を表す矢印線とから構成されている。また、それぞれの状態遷移に対して、その遷移が生起する条件を示す遷移条件が付加されることがある。ただし、図1中の状態遷移図11aには、それぞれの遷移条件の詳細について記述していない。
The automatic program generation apparatus 10 includes a state transition
The state transition
状態遷移図作成手段12は、状態記述機能12aとループ制御遷移記述機能12bと通常遷移記述機能12cとを有する。
状態記述機能12aでは、ユーザが入力装置2を介して、プログラムの状態を表すノードが記述される。
The state transition diagram creating means 12 has a
In the
ループ制御遷移記述機能12bでは、ユーザが入力装置2を介して、状態記述機能12aにて記述されたうち、2つの状態のノード間において、イベントに反応して、このイベントがユーザの指定回数以下の間はリンク元の状態を自己遷移する。一方、この指定回数を超えた場合には、リンク先の状態へと遷移する。ループ制御遷移記述機能12bでは、これらを示すループ制御遷移を記述する。
In the loop control
通常遷移記述機能12cでは、ユーザが入力装置2を介して、ループ制御遷移で表される遷移以外の状態遷移が記述される。
そして、状態遷移図作成手段12では、これらを有すると共に、ユーザが入力装置2を介して、状態記述機能12aとループ制御遷移記述機能12bと通常遷移記述機能12cとよる“状態”、“ループ制御遷移”、“通常遷移”で構成される状態遷移図11aが作成される。
In the normal
Then, the state transition diagram creating means 12 has these, and the user via the input device 2 "state", "loop control" by the
従来、ループ制御遷移動作などを有する状態遷移図において、ループ制御遷移動作などは、多くの要素から構成されていた。以上のように、状態遷移図作成手段12によって作成されるループ制御遷移動作などを有する状態遷移図は、ループ制御遷移動作などを構成する要素が簡略化されて、状態遷移図11aが作成される。そして、状態遷移図11aは状態遷移図記憶手段11に格納される。
Conventionally, in a state transition diagram having a loop control transition operation or the like, the loop control transition operation or the like has been composed of many elements. As described above, in the state transition diagram having the loop control transition operation and the like created by the state transition diagram creation unit 12, the elements constituting the loop control transition operation and the like are simplified, and the state transition diagram 11a is created. . The state transition diagram 11 a is stored in the state transition
ソースコード生成手段13では、状態遷移図記憶手段11に格納されている状態遷移図11aから、従来技術と同様にして、プログラムの自動生成が行われて、ソースコード3が生成される。
In the source code generation means 13, the program is automatically generated from the state transition diagram 11 a stored in the state transition diagram storage means 11 in the same manner as the prior art, and the
以上のように、プログラム自動生成装置10において、入力装置2を介して、状態遷移図作成手段12によって、簡略化されたループ制御遷移動作などを有する状態遷移図11aが記述される。そして、ソースコード生成手段13によって、状態遷移図11aから従来技術と同様にして、プログラムが自動生成されて、ソースコード3が生成される。
As described above, in the automatic program generation device 10, the state transition diagram 11a having a simplified loop control transition operation is described by the state transition diagram creation means 12 via the input device 2. Then, the source code generation means 13 automatically generates a program from the state transition diagram 11a in the same manner as the prior art, and generates the
この結果から、ユーザは、多数の要素から構成されるループ制御遷移動作などを有する状態遷移図を記述する際に、それらの要素を簡略化して、状態遷移図を作成することができる。このため、状態遷移図を容易に記述することができ、状態遷移図の記述の際、要素などの入力ミスを防止することもできる。そして、ソースコード生成手段13によって、状態遷移図から、ソースコードを生成することができる。したがって、このようなプログラムの自動生成装置によって、状態遷移図を用いたプログラムの開発の開発効率および品質を向上させることができる。 From this result, when describing a state transition diagram having a loop control transition operation composed of a large number of elements, the user can simplify those elements and create a state transition diagram. Therefore, the state transition diagram can be easily described, and input errors such as elements can be prevented when describing the state transition diagram. The source code generation means 13 can generate the source code from the state transition diagram. Therefore, the development efficiency and quality of program development using a state transition diagram can be improved by such an automatic program generation apparatus.
以下に、本発明を利用した実施の形態について、図面を参照にして説明する。
本実施の形態は、1つのプログラム自動生成装置により構成される。ユーザはプログラム自動生成装置を用いて、状態遷移図を記述することができる。そして、記述された状態遷移図からプログラムのソースコードを生成することができる。
Embodiments using the present invention will be described below with reference to the drawings.
This embodiment is composed of one program automatic generation device. A user can describe a state transition diagram using an automatic program generation device. Then, the source code of the program can be generated from the described state transition diagram.
図2は、プログラム自動生成装置のハードウェア構造を示す図である。プログラム自動生成装置100は、CPU(Central Processing Unit)101によって装置全体が制御されている。CPU101には、バス106を介してRAM(Random Access Memory)102、ハードディスクドライブ(HDD:Hard Disc Drive)103、グラフィック処理装置104および入力インタフェース105が接続されている。
FIG. 2 is a diagram illustrating a hardware structure of the automatic program generation device. 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(Operating System)プログラムやアプリケーションプログラムの少なくとも一部が一時的に格納される。また、RAM102には、CPU101による処理に必要な各種データが格納される。HDD103には、OSプログラムやアプリケーションプログラムが格納される。
The
グラフィック処理装置104には、モニタ21が接続されている。グラフィック処理装置104は、CPU101からの命令に従って、画像をモニタ21の画面に表示させる。入力インタフェース105には、キーボード22とマウス23とが接続されている。入力インタフェース105は、キーボード22やマウス23から送られてくる信号を、バス106を介してCPU101に送信する。
A monitor 21 is connected to the
以上のようなハードウェア構成によって、本実施の形態の処理機能を実現することができる。
次に、プログラム自動生成装置100のモジュール構成について説明する。
With the hardware configuration as described above, the processing functions of the present embodiment can be realized.
Next, the module configuration of the automatic program generation device 100 will be described.
図3は、プログラム自動生成装置の機能を示すブロック図である。
プログラム自動生成装置100は、状態遷移図記憶部110、ソースコード記憶部120、状態遷移図作成部130およびソースコード生成部140を有する。
FIG. 3 is a block diagram illustrating functions of the automatic program generation device.
The automatic program generation device 100 includes a state transition
状態遷移図記憶部110は、状態遷移図作成部130によって作成される状態遷移図を格納する。
ソースコード記憶部120は、ソースコード生成部140によって状態遷移図からプログラムの自動生成が行われて生成されたソースコードを格納する。
The state transition
The source
状態遷移図作成部130は、状態記述部131、ループ制御遷移記述部132および通常遷移記述部133により構成される。なお、これらは、モニタ21を介して、キーボード22およびマウス23を通じて、ユーザからの入力を受け付けることができる。
The state transition diagram creation unit 130 includes a
状態記述部131では、ユーザがモニタ21を介して、キーボード22およびマウス23を通じて、プログラムの状態を表すノードが記述される。
ループ制御遷移記述部132では、状態記述部131にて記述されたうち、2つの状態のノード間において、イベントに反応して、このイベントがユーザの指定回数以下の間はリンク元の状態を自己遷移する。一方、この指定回数を超えた場合には、リンク先の状態へと遷移する。ループ制御遷移記述部132では、これらを示すループ制御遷移を記述する。従来、ループ制御遷移動作などを有する状態遷移図において、ループ制御遷移動作などは、自己遷移やカウント操作など、多数の要素により構成される。このため、ループ制御遷移動作を記述するには、これらの全ての要素の記述が必要であった。しかし、ループ制御遷移記述部132では、従来のように、全ての要素の記述を必要とせず、要素を簡略化してループ制御遷移動作を記述することができる。
In the
The loop control
通常遷移記述部133では、ユーザがモニタ21を介して、キーボード22およびマウス23を通じて、ループ制御遷移で表される遷移以外の状態遷移が記述される。
そして、状態遷移図作成部130では、状態記述部131、ループ制御遷移記述部132および通常遷移記述部133を有すると共に、これらによって記述された、“状態遷移”、“ループ制御遷移”および“通常遷移”で構成される状態遷移図が作成される。そして、状態遷移図作成部130において作成された状態遷移図は、状態遷移図記憶部110に格納される。
In the normal
The state transition diagram creation unit 130 includes a
ソースコード生成部140では、状態遷移図からソースコードを生成する。その生成方法の例を以下に挙げると、まず、状態遷移図記憶部110に格納された状態遷移図から簡略化された要素が解析される。そして、解析結果が追加されることによって、状態遷移図記憶部110に格納された状態遷移図が変換される。変換された状態遷移図から、ソースコードが自動生成される。そして、生成されたソースコードは、ソースコード記憶部120に格納される。
The source
以上のようにして、プログラム自動生成装置100において、状態遷移図作成部130より、簡略化されたループ制御遷移動作などを有する状態遷移図が作成される。そして、ソースコード生成部140により、簡略化された要素が解析されて、解析結果が追加されることによって、状態遷移図記憶部110に格納されている状態遷移図が変換され、変換された状態遷移図から、ソースコードが生成される。そして、生成されたソースコードは、ソースコード記憶部120に格納される。
As described above, in the automatic program generation device 100, the state transition diagram creating unit 130 creates a state transition diagram having a simplified loop control transition operation. Then, the source
次に、このようなプログラム自動生成装置100を用いて、具体的に状態遷移図を示して、プログラムの自動生成について説明する。
図4は、ループ制御遷移動作の要素を有する状態を示した図である。
Next, automatic generation of a program will be described with reference to a specific state transition diagram using such an automatic program generation device 100.
FIG. 4 is a diagram showing a state having elements of a loop control transition operation.
第1の例として、カウント回数の上限値の要素を有する状態を用いて記述された状態遷移図の場合について説明する。
図4では、図13の状態1910が有する要素に加えて、カウント回数の上限値(カウントアップ:5210c)の要素およびループ制御遷移211aの動作の要素を有している。
As a first example, a case of a state transition diagram described using a state having an element of an upper limit value of the number of counts will be described.
In FIG. 4, in addition to the elements included in the state 1910 of FIG. 13, there are elements of the upper limit value of the number of counts (count up: 5210c) and elements of the operation of the loop control transition 211a.
そして、状態遷移図作成部130によって状態210を用いて記述された状態遷移図を示したものが図5である。
図5は、第1の例の状態遷移図である。
FIG. 5 shows a state transition diagram described using the
FIG. 5 is a state transition diagram of the first example.
状態遷移図200は、状態1210から状態2220への遷移211、状態2220から状態1210への遷移221、開始状態240aから状態1210への遷移241aおよび状態1210から状態3230への遷移211aの状態遷移について示されており、“複数の状態”、“遷移”、“イベント”、“ガード条件”および“アクション”の5つの要素を有している。
The state transition diagram 200 shows the state transition of the transition 211 from the state 1210 to the state 2220, the transition 221 from the state 2220 to the state 1210, the
以下に、状態遷移図200の状態の遷移の概要について説明する。
まず、開始状態240aから状態1210への遷移241aを発生させる。
次に、状態1210において、eventX212が発生し、ガード条件のcondA213に適合する場合、actA214が行われ、状態1210から状態2220への遷移211が発生する。そして、この時、カウントが値を有する場合、カウントの値がクリアされて、状態1210から状態2220への状態遷移が発生する。
The outline of the state transition of the state transition diagram 200 will be described below.
First, the
Next, in the state 1210, eventX212 occurs, and when it matches the guard condition condA213, actA214 is performed, and the transition 211 from the state 1210 to the state 2220 occurs. At this time, if the count has a value, the count value is cleared and a state transition from the state 1210 to the state 2220 occurs.
一方、condA213が適合しない場合は、カウント回数の上限値であるカウントアップ:5210cよりもカウントが小さい場合、状態1210には、自己遷移が発生する。そして、自己遷移が連続して生じるごとに、カウントの値の数が1ずつ増加する。
On the other hand, when the
さらに、自己遷移が5回を超えて、6回目が生じると、状態1211から状態3230への遷移211aが発生する。そして、この時、カウントの値がクリアされて、状態1210から状態3230への状態遷移が発生する。 Furthermore, when the self-transition exceeds five times and the sixth time occurs, a transition 211a from the state 1211 to the state 3230 occurs. At this time, the count value is cleared and a state transition from the state 1210 to the state 3230 occurs.
次に、状態2220において、eventY222を発生し、ガード条件のcondB223に適する場合、actB224が行われ、状態2220から状態1210への遷移221が発生する。 Next, in the state 2220, eventY222 is generated, and if it is suitable for the guard condition condB223, actB224 is performed, and the transition 221 from the state 2220 to the state 1210 occurs.
そして、この状態遷移図200からソースコード生成部140によってソースコードを生成する処理について以下に説明する。
状態遷移図からソースコードを自動生成する方法の1つの例として、プログラム自動生成装置100によって作成された簡略化されたループ制御遷移動作などを有する状態遷移図から、簡略化された要素が解析されて、解析結果を追加することによって作成された状態遷移図を変換させて、変換された状態遷移図から、プログラムの自動生成によるソースコードの生成方法がある。以下に、状態遷移図の変換処理および変換された状態遷移図からプログラムの自動生成処理について図5の状態遷移図200を例に挙げて順に説明する。
A process for generating a source code by the source
As one example of a method for automatically generating source code from a state transition diagram, simplified elements are analyzed from a state transition diagram having a simplified loop control transition operation created by the automatic program generation apparatus 100. Then, there is a method for generating a source code by automatically generating a program from a converted state transition diagram by converting a state transition diagram created by adding an analysis result. In the following, the state transition diagram conversion processing and the automatic program generation processing from the converted state transition diagram will be described in order by taking the state transition diagram 200 of FIG. 5 as an example.
まず、状態遷移図200から、簡略化された要素が解析され、解析結果を状態遷移図200に追加することによって状態遷移図200を変換する処理について図6のフローチャートを用いて以下に説明する。 First, the process of converting the state transition diagram 200 by analyzing simplified elements from the state transition diagram 200 and adding the analysis result to the state transition diagram 200 will be described below with reference to the flowchart of FIG.
図6は、状態遷移図の解析および解析された要素の追加による変換の処理手順を示すフローチャートである。状態遷移図作成部130によって作成された状態遷移図200から、ソースコード生成部140によって、状態遷移図記憶部110に格納された状態遷移図200から簡略化の要素を解析して、解析結果を追加することによって、状態遷移図記憶部110に格納された状態遷移図200を変換させる処理について、図4を用いて説明する。
FIG. 6 is a flowchart showing the processing procedure of the conversion by analyzing the state transition diagram and adding the analyzed elements. From the state transition diagram 200 created by the state transition diagram creation unit 130, the source
[ステップS11]ソースコード生成部140は、状態遷移図記憶部110から状態遷移図200を受け取る。そして、受け取った状態遷移図200から解析される要素に対応するソースファイル記憶領域を確保する。
[Step S11] The source
[ステップS12]ソースコード生成部140は、状態遷移図記憶部110から状態遷移図200を受け取ると、状態遷移図200に記述されたループ制御遷移動作を有する状態について、例えば図5では状態1について、以下のステップS13からステップS18までの処理を繰り返す。
[Step S12] When the source
[ステップS13]ソースコード生成部140は、状態遷移図記憶部110から受け取った状態遷移図200から、ループ制御遷移動作が生じるイベント(eventX212)を取得する。
[Step S13] The source
[ステップS14]ソースコード生成部140は、状態遷移図記憶部110から受け取った状態遷移図200から、ステップS13にて取得したイベント(eventX212)の全ての条件(condA213)を取得する。
[Step S14] The source
[ステップS15]ソースコード生成部140は、状態遷移図記憶部110から受け取った状態遷移図200から、ループ制御遷移動作が生じるカウント回数の上限値(カウントアップ:5210c)を取得する。
[Step S15] The source
[ステップS16]ソースコード生成部140は、ステップS13、ステップS14、ステップS15により取得した要素を用いて、状態遷移図記憶部110から受け取った状態遷移図200のループ制御遷移に関して、イベント(“eventX”)、条件(“¬condA∧count≧5”)、アクションなどを追加する。
[Step S16] The source
[ステップS17]ソースコード生成部140は、ステップS13、ステップS14、ステップS15により取得した要素を用いて、選択した状態1210に対して、イベント(“eventX”)、条件(“¬condA∧count<5”)、アクション(“count+1”)などから構成される自己遷移を追加する。
[Step S <b> 17] The source
[ステップS18]ソースコード生成部140は、選択した状態から他の状態への遷移に対し、アクションとして、カウントクリア(“count=0”)を追加する。
[ステップS19]ソースコード生成部140は、ステップS11で確保したコード記憶領域にある解析された簡略化された要素を追加することによって、状態遷移図記憶部110から状態遷移図200を変換させる。そして、変換された状態遷移図200をファイルに出力し、ソースコード記憶部120に記憶して、状態遷移図200の変換処理を終了する。
[Step S18] The source
[Step S19] The source
引き続き、ソースコード生成部140では、以上のように変換された状態遷移図200に対して、以下の従来技術と同様の処理を行う。
すなわち、状態遷移図記憶部110が保持する状態遷移図に記述されたループ制御遷移から、実行時に発生するイベントを検知し、このイベントの発生回数を保持して、イベントが指定回数以下の場合には現在の状態を維持し、指定回数を超えた場合は、ループ制御遷移に従ってこの状態を変更する処理を記述したループ制御コードを生成する。これに伴って、この状態遷移図に記述されたループ制御遷移以外の振る舞いを実現する通常処理コードを生成する。よって、このようにして生成されたループ制御コードと通常処理コードとから成るソースコードを生成する。
Subsequently, the source
That is, when an event that occurs at the time of execution is detected from the loop control transition described in the state transition diagram held by the state transition
このようにして、ソースコード生成部140によって生成されたソースコードは、ソースコード記憶部120に保持される。
図7は、プログラムの自動生成によって生成されたソースファイルの例である。
In this way, the source code generated by the source
FIG. 7 shows an example of a source file generated by automatic program generation.
図6のフローチャートに示した処理によって、変換された状態遷移図からプログラムの自動生成を行うとソースファイル121が自動的に生成される。
条件分岐文121aは、プログラムの現在の状態に応じて以後の処理の内容を変えるためのコードである。現在の状態が、状態遷移図に記述された状態“STATE1”、“STATE2”、“STATE3”のいずれかであるか判断される。
When the program is automatically generated from the converted state transition diagram by the process shown in the flowchart of FIG. 6, the source file 121 is automatically generated.
The
条件分岐文121bは、状態“STATE1”において、イベントである“eventX”が発生するか否かが判断される。
条件分岐文121cは、“eventX”が発生した場合、条件である“condA”に適合するか否かが判断される。そして、適合する場合、アクションである“actA()”が生じて、状態“STATE1”から状態“STATE2”へ遷移する。なお、遷移するときに、カウントが値を有する場合は、カウントクリア(“count=0”)となって遷移する。
The
When “eventX” occurs, it is determined whether the
条件分岐文121dは、“condA”に適合せず、且つ、“countA”がカウント回数の上限値(例えば、図5であれば“5”)よりも小さいか否か(“¬condA∧countA<5”)が判断される。ここの条件が真である場合は、自己遷移を表しており、状態“STATE1”から状態“STATE1”へ自己遷移して、カウントに“1”が加えられる(“count++”)。
The
条件分岐文121eは、“condA”に適合せず、且つ、“countA”がカウント回数の上限値(例えば、図5であれば“5”)以上か否か(“¬condA∧countA≧5”)が判断される。ここの条件が真である場合は、ループ制御遷移を表しており、状態“STATE1”から状態“STATE3”へ遷移する。なお、遷移するときには、カウントクリア(“count=0”)となる。
The
条件分岐文121fは、状態“STATE2”において、イベントである“eventY”が発生するか否かが判断される。
条件分岐文121gは、“eventY”が発生した場合、条件である“condB”に適合するか否かが判断される。そして、適合する場合、アクションである“actB()”が生じて、状態“STATE2”から状態“STATE1”へ遷移する。なお、遷移するときには、カウントが値を有する場合は、カウントクリア(“count=0”)となって遷移する。
In the
If “eventY” occurs, it is determined whether the
なお、ソースファイル121では、状態遷移の直前に実行される処理を記述すべき箇所にアクション名のみが記載されているが、予め別の手段で処理内容を示すコードを入力しておくことで、そのコードがアクション名の位置に埋め込まれるようにすることができる。また、生成後にユーザがソースコードを編集するようにしてもよい。
Note that in the
以上により、ユーザは、従来、多数の要素から構成されるループ制御遷移動作などを有する状態遷移図を記述する際に、それらの要素を簡略化して、状態遷移図を作成することができる。このため、状態遷移図を容易に記述することができて、また、要素などの入力ミスを防止することができる。そして、ソースコード生成部140によって、状態遷移図から簡略化された要素などが自動的に解析される。そして、解析されて得た要素を、状態遷移図に追加することによって、全ての要素により構成された状態遷移図へ変換される。そして、変換された状態遷移図からソースコードが生成される。したがって、このようなプログラムの自動生成装置によって、状態遷移図を用いたプログラムの開発の開発効率および品質を向上させることができる。
As described above, when describing a state transition diagram having a loop control transition operation composed of a number of elements, the user can simplify the elements and create a state transition diagram. For this reason, a state transition diagram can be described easily and input mistakes, such as an element, can be prevented. Then, the source
このようなプログラム自動生成装置100による、プログラム化される状態遷移図について、以下に他の状態遷移図の例を挙げて説明する。
第2の例として、状態遷移にカウント回数の上限値の要素が記述された状態遷移図の場合について説明する。
A state transition diagram to be programmed by such an automatic program generation device 100 will be described below with reference to examples of other state transition diagrams.
As a second example, a case of a state transition diagram in which an element of the upper limit value of the count number is described in the state transition will be described.
図8は、状態遷移にループ制御遷移動作の要素を有する状態を示した図である。
図8では、図13の状態1910が有する要素に加えて、カウント回数の上限値(カウントアップ:5310c)の要素およびループ制御遷移311aの動作の要素を有している。
FIG. 8 is a diagram illustrating a state in which the state transition includes an element of a loop control transition operation.
In FIG. 8, in addition to the elements included in the state 1910 of FIG. 13, there are elements of the upper limit value of the number of counts (count up: 5310c) and elements of the operation of the
そして、状態遷移図作成部130によって状態310を用いて記述された状態遷移図を示したものが図9である。
図9は、第2の例の状態遷移図である。
FIG. 9 shows a state transition diagram described using the
FIG. 9 is a state transition diagram of the second example.
状態遷移図300は、状態1310から状態2320への遷移331、状態2320から状態1310への遷移321、開始状態340aから状態1310への遷移341aおよび状態1310から状態3330への遷移311aの状態遷移について示されており、“複数の状態”、“遷移”、“イベント”、“ガード条件”および“アクション”の5つの要素を有している。
The state transition diagram 300 shows the state transition of the transition 331 from the state 1310 to the state 2320, the transition 321 from the state 2320 to the state 1310, the
以下に、状態遷移図300の状態の遷移の概要について説明する。
まず、開始状態340aから状態1310への遷移341aを発生させる。
次に、状態1310において、eventX312が発生し、ガード条件のcondA313に適合する場合、actA314が行われ、状態1310から状態2320への遷移331が発生する。そして、この時、カウントが値を有する場合、カウントの値がクリアされて、状態1310から状態2320への状態遷移が発生する。
The outline of the state transition of the state transition diagram 300 will be described below.
First, a
Next, in state 1310, eventX312 occurs, and if it matches the guard condition condA313, actA314 is performed, and a transition 331 from state 1310 to state 2320 occurs. At this time, if the count has a value, the count value is cleared and a state transition from the state 1310 to the state 2320 occurs.
一方、condA313が適合しない場合は、カウント回数の上限値であるカウントアップ:5310cよりもカウントが小さい場合、状態1310には、自己遷移が発生する。そして、自己遷移が連続して生じるごとに、カウントの値の数が1ずつ増加する。
On the other hand, when the
さらに、自己遷移が5回を超えて、6回目が生じると、状態1310から状態3330への遷移311aが発生する。そして、この時、カウントの値がクリアされて、状態1310から状態3330への状態遷移が発生する。
Furthermore, when the self-transition exceeds five times and the sixth time occurs, a
次に、状態2320において、eventY322を発生し、ガード条件のcondB323に適する場合、actB324が行われ、状態2320から状態1310への遷移321が発生する。 Next, in the state 2320, eventY322 is generated, and if it is suitable for the guard condition condB323, actB324 is performed, and the transition 321 from the state 2320 to the state 1310 occurs.
そして、この状態遷移図300からソースコード生成部140によってソースコードを生成する処理方法は、第1の例と同様にして、まず、状態遷移図300から、簡略化された要素が解析され、解析結果を追加することによって、状態遷移図300を変換させる。そして、変換された状態遷移図300から、従来技術と同様にして、プログラムの自動生成を行って、ソースコードを生成することができる。
In the processing method for generating source code from the state transition diagram 300 by the source
次に、第3の例として、状態遷移にカウント回数の上限値の要素が記述された状態遷移図の場合について説明する。
図10は、状態遷移にループ制御遷移動作の要素を有する状態を示した別の図である。
Next, as a third example, a case of a state transition diagram in which an element of the upper limit value of the number of counts is described in the state transition will be described.
FIG. 10 is another diagram showing a state having a loop control transition operation element in the state transition.
図10では、図13の状態1910が有する要素に加えて、カウント回数の上限値(カウントアップ::[5]410c)の要素およびループ制御遷移411aの動作の要素を有している。
In addition to the elements included in the state 1910 of FIG. 13, FIG. 10 includes an element of the upper limit value of the number of counts (count up: [5] 410c) and an element of the operation of the
そして、状態遷移図作成部130によって状態410を用いて記述された状態遷移図を示したものが図11である。
図11は、第3の例の状態遷移図である。
FIG. 11 shows a state transition diagram described using the
FIG. 11 is a state transition diagram of the third example.
状態遷移図400は、状態1410から状態2420への遷移431、状態2420から状態1410への遷移421、開始状態440aから状態1410への遷移441aおよび状態1410から状態3430への遷移411aの状態遷移について示されており、“複数の状態”、“遷移”、“イベント”、“ガード条件”および“アクション”の5つの要素を有している。
The state transition diagram 400 shows the state transition of the transition 431 from the state 1410 to the state 2420, the transition 421 from the state 2420 to the state 1410, the
以下に、状態遷移図400の状態の遷移の概要について説明する。
まず、開始状態440aから状態1410への遷移441aを発生させる。
次に、状態1410において、eventX412が発生し、ガード条件のcondA413に適合する場合、actA414が行われ、状態1410から状態2420への遷移431が発生する。そして、この時、カウントが値を有する場合、カウントの値がクリアされて、状態1410から状態2420への状態遷移が発生する。
The outline of the state transition of the state transition diagram 400 will be described below.
First, the
Next, in the state 1410, eventX412 occurs, and when it matches the cond A413 of the guard condition, actA414 is performed, and the transition 431 from the state 1410 to the state 2420 occurs. At this time, if the count has a value, the count value is cleared and a state transition from the state 1410 to the state 2420 occurs.
一方、condA413が適合しない場合は、カウント回数の上限値であるカウントアップ::[5]410cよりもカウントが小さい場合、状態1410には、自己遷移が発生する。そして、自己遷移が連続して生じるごとに、カウントの値の数が1ずつ増加する。
On the other hand, if the
さらに、自己遷移が5回を超えて、6回目が生じると、状態1410から状態3430への遷移411aが発生する。そして、この時、カウントの値がクリアされて、状態1410から状態3430への状態遷移が発生する。
Furthermore, when the self-transition exceeds five times and the sixth time occurs, a
次に、状態2420において、eventY422を発生し、ガード条件のcondB423に適する場合、actB424が行われ、状態2420から状態1410への遷移421が発生する。
Next, in state 2420, eventY422 is generated, and if it is suitable for
そして、この状態遷移図400からソースコード生成部140によってソースコードを生成する処理方法は、第1,2の例と同様にして、まず、状態遷移図400から、簡略化された要素が解析され、解析結果を追加することによって、状態遷移図400を変換させる。そして、変換された状態遷移図400から、従来技術と同様に、プログラムの自動生成を行って、ソースコードを生成することができる。
In the processing method for generating source code from the state transition diagram 400 by the source
なお、本実施の形態ではC言語で記述されたソースコードを生成したが、本実施の形態に係るプログラム自動生成装置は、様々なプログラミング言語への応用が可能である。生成されるソースコードの記述は汎用的な内容であり、様々な分野のソフトウェア開発に適用することができる。 In the present embodiment, the source code described in the C language is generated. However, the automatic program generation device according to the present embodiment can be applied to various programming languages. The description of the generated source code is general-purpose content and can be applied to software development in various fields.
以上、本発明のプログラム自動生成装置、プログラム自動生成方法およびプログラム自動生成プログラムを、図示の実施の形態について基づいて説明したが、本発明はこれに限定されるものではなく、各部の構成は、同様の機能を有する任意の構成のものに置換することができる。また本発明に、他の任意の構成物や工程が付加されてもよい。 As described above, the automatic program generation device, the automatic program generation method, and the automatic program generation program of the present invention have been described based on the illustrated embodiment, but the present invention is not limited to this, and the configuration of each unit is as follows. Any structure having a similar function can be substituted. Moreover, other arbitrary structures and processes may be added to the present invention.
なお、上記の処理機能は、コンピュータによって実現することができる。その場合、プログラム自動生成装置100が有すべき機能の処理内容を記述したプログラムが提供される。そのプログラムをコンピュータで実行することにより、上記処理機能がコンピュータ上で実現される。処理内容を記述したプログラムは、コンピュータで読み取り可能な記録媒体に記録しておくことができる。コンピュータで読み取り可能な記録媒体としては、例えば、磁気記録装置、光ディスク、光磁気記録媒体、半導体メモリなどが挙げられる。磁気記録装置としては、例えば、ハードディスク装置(HDD)、フレキシブルディスク(FD)、磁気テープなどが挙げられる。光ディスクとしては、例えば、DVD(Digital Versatile Disc)、DVD−RAM、CD−ROM(Compact Disc Read Only Memory)、CD−R(Recordable)/RW(Rewritable)などが挙げられる。光磁気記録媒体としては、例えば、MO(Magneto-Optical disk)などが挙げられる。 The above processing functions can be realized by a computer. In that case, a program describing the processing contents of the functions that the automatic program generation device 100 should have is provided. By executing the program on a computer, the above processing functions are realized on the computer. The program describing the processing contents can be recorded on a computer-readable recording medium. Examples of the computer-readable recording medium include a magnetic recording device, an optical disk, a magneto-optical recording medium, and a semiconductor memory. Examples of the magnetic recording device include a hard disk device (HDD), a flexible disk (FD), and a magnetic tape. Examples of the optical disc include a DVD (Digital Versatile Disc), a DVD-RAM, a CD-ROM (Compact Disc Read Only Memory), and a CD-R (Recordable) / RW (Rewritable). Examples of the magneto-optical recording medium include an MO (Magneto-Optical disk).
プログラムを流通させる場合には、例えば、そのプログラムが記録されたDVD、CD−ROMなどの可搬型記録媒体が販売される。また、プログラムをサーバコンピュータの記憶装置に格納しておき、ネットワークを介して、サーバコンピュータから他のコンピュータにそのプログラムを転送することもできる。 When distributing the program, for example, portable recording media such as a DVD and a CD-ROM on which the program is recorded are sold. It is also possible to store the program in a storage device of a server computer and transfer the program from the server computer to another computer via a network.
プログラム自動生成装置を実行するコンピュータは、例えば、可搬型記録媒体に記録されたプログラムもしくはサーバコンピュータから転送されたプログラムを、自己の記録装置に格納する。そして、コンピュータは、自己の記録装置からプログラムを読み取り、プログラムに従った処理を実行する。なお、コンピュータは、可搬型記録媒体から直接プログラムを読み取り、そのプログラムに従った処理を実行することもできる。また、コンピュータは、サーバコンピュータからプログラムが転送されるごとに、逐次、受け取ったプログラムに従った処理を実行することもできる。 A computer that executes an automatic program generation device stores, for example, a program recorded on a portable recording medium or a program transferred from a server computer in its own recording device. Then, the computer reads the program from its own recording device and executes processing according to the program. The computer can also read the program directly from the portable recording medium and execute processing according to the program. Further, each time the program is transferred from the server computer, the computer can sequentially execute processing according to the received program.
2 入力装置
3 ソースコード
10 プログラム自動生成装置
11 状態遷移図記憶手段
11a 状態遷移図
12 状態遷移図作成手段
12a 状態記述機能
12b ループ制御遷移記述機能
12c 通常遷移記述機能
13 ソースコード生成手段
2
Claims (5)
プログラムの状態を記述する状態記述機能と、2つの前記状態をリンクする1つの状態遷移であって、イベントに反応して、前記イベントがユーザの指定回数以下の間はリンク元の前記状態を自己遷移し、前記指定回数を超えるとリンク先の前記状態に遷移する、ことを示すループ制御遷移を記述するループ制御遷移記述機能と、前記ループ制御遷移で表される遷移以外の前記状態遷移を示す通常遷移を記述する通常遷移記述機能と、を有しており、ユーザの操作入力に従って、前記状態、前記ループ制御遷移および前記通常遷移で構成される前記状態遷移図を作成する状態遷移図作成手段と、
前記状態遷移図作成手段が作成した前記状態遷移図を保持する状態遷移図記憶手段と、
ユーザから生成指示が入力されると、前記状態遷移図記憶手段が保持する前記状態遷移図に記述された前記ループ制御遷移から、実行時に発生する前記イベントを検知し、前記イベントの発生回数を保持し、前記イベントが前記指定回数以下の場合は現在の前記状態を維持し、前記指定回数を超えた場合は前記ループ制御遷移に従って前記状態を更新する、処理を記述したループ制御コードを生成すると共に、前記状態遷移図に記述された前記ループ制御遷移以外の振る舞いを実現する通常処理コードを生成し、前記ループ制御コードと前記通常処理コードとから成る前記ソースコードを生成する、ソースコード生成手段と、
を有することを特徴とするプログラム自動生成装置。 In an automatic program generation device that generates source code from a state transition diagram,
A state description function that describes the state of the program and one state transition that links the two states. In response to an event, the state of the link source is self-reactive while the event is less than or equal to the number of times specified by the user. A loop control transition description function that describes a loop control transition indicating that a transition is made and the link destination state is transitioned when the specified number of times is exceeded, and the state transition other than the transition represented by the loop control transition is indicated. A state transition diagram creating means for creating the state transition diagram composed of the state, the loop control transition, and the normal transition in accordance with a user operation input. When,
State transition diagram storage means for holding the state transition diagram created by the state transition diagram creation means;
When a generation instruction is input from a user, the event occurring at the time of execution is detected from the loop control transition described in the state transition diagram held by the state transition diagram storage unit, and the number of occurrences of the event is retained. When the event is less than or equal to the specified number of times, the current state is maintained, and when the specified number of times is exceeded, the state is updated according to the loop control transition, and a loop control code describing the process is generated. Source code generation means for generating normal processing code that realizes behavior other than the loop control transition described in the state transition diagram, and generating the source code composed of the loop control code and the normal processing code; ,
A program automatic generation apparatus characterized by comprising:
前記ソースコード生成手段は、前記ループ制御遷移のリンク元の前記状態に設定された前記指定回数に基づいて前記ループ制御遷移を生成する、
ことを特徴とする請求項1記載のプログラム自動生成装置。 The loop control transition description function of the state transition diagram creating means sets the specified number of times specified by the user as an attribute of the state of the link source of the loop control transition,
The source code generation means generates the loop control transition based on the specified number of times set in the state of the link source of the loop control transition;
The automatic program generation device according to claim 1.
前記ソースコード生成手段は、前記ループ制御遷移に設定された前記指定回数に基づいて前記ループ制御遷移を生成する、
ことを特徴とする請求項1記載のプログラム自動生成装置。 The loop control transition description function of the state transition diagram creating means sets the specified number of times specified by the user as an attribute of the loop control transition,
The source code generation means generates the loop control transition based on the specified number of times set in the loop control transition;
The automatic program generation device according to claim 1.
状態記述機能が、プログラムの状態を記述し、ループ制御遷移記述機能が、2つの前記状態をリンクする1つの状態遷移であって、イベントに反応して、前記イベントがユーザの指定回数以下の間はリンク元の前記状態を自己遷移し、前記指定回数を超えるとリンク先の前記状態に遷移する、ことを示すループ制御遷移を記述し、通常遷移記述機能が、前記ループ制御遷移で表される遷移以外の前記状態遷移を示す通常遷移を記述し、状態遷移図作成手段が、前記状態記述機能、前記ループ制御遷移記述機能および前記通常遷移記述機能を有しており、ユーザの操作入力に従って、前記状態、前記ループ制御遷移および前記通常遷移で構成される前記状態遷移図を作成し、
状態遷移図記憶手段が、前記状態遷移図作成手段が作成した前記状態遷移図を保持し、
ソースコード生成手段が、ユーザから生成指示が入力されると、前記状態遷移図記憶手段が保持する前記状態遷移図に記述された前記ループ制御遷移から、実行時に発生する前記イベントを検知し、前記イベントの発生回数を保持し、前記イベントが前記指定回数以下の場合は現在の前記状態を維持し、前記指定回数を超えた場合は前記ループ制御遷移に従って前記状態を更新する、処理を記述したループ制御コードを生成すると共に、前記状態遷移図に記述された前記ループ制御遷移以外の振る舞いを実現する通常処理コードを生成し、前記ループ制御コードと前記通常処理コードとから成る前記ソースコードを生成する、
ことを特徴とするプログラム自動生成方法。 In an automatic program generation method for generating source code from a state transition diagram,
The state description function describes the state of the program, and the loop control transition description function is one state transition that links the two states, and the event is not more than the user-specified number of times in response to the event. Describes a loop control transition indicating that the state of the link source self-transitions and transitions to the link destination state when the specified number of times is exceeded, and a normal transition description function is represented by the loop control transition. The normal transition indicating the state transition other than the transition is described, and the state transition diagram creating means has the state description function, the loop control transition description function, and the normal transition description function, and according to a user operation input, Creating the state transition diagram composed of the state, the loop control transition and the normal transition;
State transition diagram storage means holds the state transition diagram created by the state transition diagram creation means,
When a source code generation unit receives a generation instruction from a user, the source code generation unit detects the event that occurs during execution from the loop control transition described in the state transition diagram held by the state transition diagram storage unit, and A loop describing a process that holds the number of occurrences of an event, maintains the current state when the event is less than or equal to the specified number of times, and updates the state according to the loop control transition when the specified number of times is exceeded A control code is generated, a normal processing code that realizes a behavior other than the loop control transition described in the state transition diagram is generated, and the source code composed of the loop control code and the normal processing code is generated. ,
A method for automatically generating a program.
コンピュータを、
プログラムの状態を記述する状態記述機能と、2つの前記状態をリンクする1つの状態遷移であって、イベントに反応して、前記イベントがユーザの指定回数以下の間はリンク元の前記状態を自己遷移し、前記指定回数を超えるとリンク先の前記状態に遷移する、ことを示すループ制御遷移を記述するループ制御遷移記述機能と、前記ループ制御遷移で表される遷移以外の前記状態遷移を示す通常遷移を記述する通常遷移記述機能と、を有しており、ユーザの操作入力に従って、前記状態、前記ループ制御遷移および前記通常遷移で構成される前記状態遷移図を作成する状態遷移図作成手段、
前記状態遷移図作成手段が作成した前記状態遷移図を保持する状態遷移図記憶手段、
ユーザから生成指示が入力されると、前記状態遷移図記憶手段が保持する前記状態遷移図に記述された前記ループ制御遷移から、実行時に発生する前記イベントを検知し、前記イベントの発生回数を保持し、前記イベントが前記指定回数以下の場合は現在の前記状態を維持し、前記指定回数を超えた場合は前記ループ制御遷移に従って前記状態を更新する、処理を記述したループ制御コードを生成すると共に、前記状態遷移図に記述された前記ループ制御遷移以外の振る舞いを実現する通常処理コードを生成し、前記ループ制御コードと前記通常処理コードとから成る前記ソースコードを生成する、ソースコード生成手段、
として機能させることを特徴とするプログラム自動生成プログラム。 In an automatic program generation program that generates source code from a state transition diagram,
Computer
A state description function that describes the state of the program and one state transition that links the two states. In response to an event, the state of the link source is self-reactive while the event is less than or equal to the number of times specified by the user. A loop control transition description function that describes a loop control transition indicating that a transition is made and the link destination state is transitioned when the specified number of times is exceeded, and the state transition other than the transition represented by the loop control transition is indicated. A state transition diagram creating means for creating the state transition diagram composed of the state, the loop control transition, and the normal transition in accordance with a user operation input. ,
State transition diagram storage means for holding the state transition diagram created by the state transition diagram creation means;
When a generation instruction is input from a user, the event occurring at the time of execution is detected from the loop control transition described in the state transition diagram held by the state transition diagram storage unit, and the number of occurrences of the event is retained. When the event is less than or equal to the specified number of times, the current state is maintained, and when the specified number of times is exceeded, the state is updated according to the loop control transition, and a loop control code describing the process is generated. Source code generation means for generating normal processing code that realizes behavior other than the loop control transition described in the state transition diagram, and generating the source code composed of the loop control code and the normal processing code;
An automatic program generation program characterized in that it functions as a program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2006266437A JP2008084262A (en) | 2006-09-29 | 2006-09-29 | Device, method and program for automatically generating program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2006266437A JP2008084262A (en) | 2006-09-29 | 2006-09-29 | Device, method and program for automatically generating program |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2008084262A true JP2008084262A (en) | 2008-04-10 |
Family
ID=39355020
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2006266437A Pending JP2008084262A (en) | 2006-09-29 | 2006-09-29 | Device, method and program for automatically generating program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2008084262A (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH0778076A (en) * | 1993-09-08 | 1995-03-20 | Toshiba Corp | Automatic program generating device |
JP2001265573A (en) * | 2000-03-15 | 2001-09-28 | Daikin Ind Ltd | Control program preparing method, its device and storing medium |
-
2006
- 2006-09-29 JP JP2006266437A patent/JP2008084262A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH0778076A (en) * | 1993-09-08 | 1995-03-20 | Toshiba Corp | Automatic program generating device |
JP2001265573A (en) * | 2000-03-15 | 2001-09-28 | Daikin Ind Ltd | Control program preparing method, its device and storing medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20140013313A1 (en) | Editor/Development Tool for Dataflow Programs | |
JP2009265810A (en) | Status transition test support device, status transition test support program and status transition test support method | |
US7539992B2 (en) | Scheduling method, program product for use in such method, and task scheduling apparatus | |
JP5233355B2 (en) | Property generation system and property verification system | |
JP2020060919A (en) | System migration support device, system migration support method and program | |
JP2006185055A (en) | Design support system and design support program for computer system | |
JP4966386B2 (en) | Test item generation method, apparatus and program | |
JP2008084262A (en) | Device, method and program for automatically generating program | |
GB2397905A (en) | Method for automatically generating and ordering test scripts | |
JP2008305019A (en) | Simulation device, simulation method and program | |
JP4730536B2 (en) | Behavioral synthesis system, behavioral synthesis method and program | |
JP2018124901A (en) | Program analyzing apparatus, program analyzing method, and program analyzing program | |
JP3930255B2 (en) | System specification information processing apparatus, system specification information processing method, and program | |
JP2008299423A (en) | Information processor and information processing program | |
JP2006031326A (en) | Information processor, information processing method and program | |
JP2016042317A (en) | Software design support device, and method | |
JP4698943B2 (en) | Program production method, program production apparatus, program automatic conversion method, and program | |
JP3019922B2 (en) | Trace data reduction method | |
JP4472768B2 (en) | Program analysis apparatus, program analysis method, and program | |
JP2012083934A (en) | Scan time estimation device, scan time estimation program and record medium | |
JP4354514B2 (en) | Program automatic conversion method, program automatic conversion device, and program | |
JP6890738B2 (en) | Information processing equipment, information processing methods and information processing programs | |
WO2023243103A1 (en) | Determination device, determination method, and program | |
JP4670724B2 (en) | Source code generation apparatus, source code generation method, and source code generation program | |
JP2010026968A (en) | Circuit generation support program and circuit generation support method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Effective date: 20090714 Free format text: JAPANESE INTERMEDIATE CODE: A621 |
|
A131 | Notification of reasons for refusal |
Effective date: 20101116 Free format text: JAPANESE INTERMEDIATE CODE: A131 |
|
A02 | Decision of refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A02 Effective date: 20110412 |