JP2004094837A - State transition control method - Google Patents

State transition control method Download PDF

Info

Publication number
JP2004094837A
JP2004094837A JP2002258370A JP2002258370A JP2004094837A JP 2004094837 A JP2004094837 A JP 2004094837A JP 2002258370 A JP2002258370 A JP 2002258370A JP 2002258370 A JP2002258370 A JP 2002258370A JP 2004094837 A JP2004094837 A JP 2004094837A
Authority
JP
Japan
Prior art keywords
state transition
callback function
state
transition table
function
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
Application number
JP2002258370A
Other languages
Japanese (ja)
Inventor
Hideki Inoue
井上 秀樹
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hitachi Ltd
Original Assignee
Hitachi Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP2002258370A priority Critical patent/JP2004094837A/en
Publication of JP2004094837A publication Critical patent/JP2004094837A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To provide a technique for preventing a control program using a state transition table from miscalling a callback function with a static/dynamic change of the state transition table, while securing the readability of a source generated by the state transition table. <P>SOLUTION: In this state transition control method, there are provided an event analysis manager, generated event storage means, current state storage means, callback function name pointer solution means, state transition table storage/management means, a state transition control manager, callback function execution means, callback function operation input/output means, the state transition table, and transition description unit current value storage means. The callback function name pointer solution means for converting a callback function name as a character string described in the state transition table into a pointer of a corresponding callback function is utilized to determine the callback function to be executed. <P>COPYRIGHT: (C)2004,JPO

Description

【0001】
【発明の属する技術分野】
本発明は、状態遷移を用いた制御を行うプログラムに係り、特に状態遷移表に記述したコールバック関数の原始コード(ソースコード,元プログラム)への反映方法とプログラム実行時に呼び出すべきコールバック関数の選択方法の改良に関する。
【0002】
【従来の技術】
一般に内部状態をもつプログラムの制御構造は、状態遷移表を用いて定義する場合が多い。このとき、状態遷移表に忠実な動作を行うために、何らかの方法で状態遷移表に定義している動作を実現する仕組みが必要である。
【0003】
従来の状態遷移表を用いた制御構造の構築では、状態遷移表における列番号及び行番号等から機械的に生成されるコールバック関数名を用いるか、あるいは、コールバック関数を列挙したコールテーブルを用いてコールバック関数を呼び出す構造をとっていた。このような例として、特開平8−190476号公報や特開平11−282658号公報に記載の技術がある。
【0004】
状態遷移表定義の動作を実現させるための1つの方法としては、状態遷移表中にコールバック関数名ではなくコールバック関数の処理内容を直接記述し、状態遷移表の列と行から機械的にコールバック関数名称を生成するものがある。このような例として、「最新状態遷移表設計手法とデザインフェーズでのシミュレーション」(渡辺政彦,CQ出版社刊,Interface ,1999年2月号,p169〜175)が挙げられる。状態遷移表定義の動作を実現させるもう1つの方法は、状態遷移表中にコールバック関数名のみを記述し、状態遷移表の記述順に従ったコールテーブル(コールバック関数へのポインタの配列)を作成するものである。
【0005】
【発明が解決しようとする課題】
状態遷移表の列と行から機械的にコールバック関数名称を生成する場合、生成後のソースコード中のコールバック関数名称からその動作を類推することが非常に難しくなりソースコードの可読性が低下する問題があった。
【0006】
状態遷移表の記述順に従ったコールテーブルを作成する場合、コールテーブル生成時と状態遷移実行時で、状態遷移表が変更された場合、誤ったコールバック関数をコールするエラーを防止できないという問題があった。
【0007】
【課題を解決するための手段】
上記課題を解決するため、本発明では、状態遷移表中にコールバック関数名を記述し、かつ状態遷移表中の“文字列”としてのコールバック関数名と、ソースコード中の“識別子”としてのコールバック関数名とを結合させ、状態遷移実行時にコールバック関数をその“文字列”としての名称でコールする手段を備える。本手段によりソースコードの可読性を確保しつつ、コールバック関数のミスコールを防止する。
【0008】
【発明の実施の形態】
図1に本発明を用いた実施例の構成を示す。状態遷移制御マネージャ0160は、全体動作の制御を行う。事象解析マネージャ0110は、状態遷移制御の対象となるプログラムの動作に伴い発生する事象の解析を行い、事象の解析結果を発生事象格納手段0120に格納する。現在状態格納手段0130は、状態遷移制御の対象となるプログラムの現在の状態を保持する。コールバック関数名称ポインタ解決手段0140は、文字列として与えられたコールバック関数の名称から、対応するコールバック関数のポインタを返す機能を提供する。
【0009】
状態遷移表格納/管理手段0150は、現在の状態値と発生した事象から、状態遷移表中で対応する1組の状態遷移表記述内容を返す機能を提供する。以下では、状態遷移表において1つの状態と1つの事象を指定することにより決定されるこの1組の状態遷移表記述内容を、遷移記述単位と呼ぶ。コールバック関数実行手段0170は、ポインタとして与えられたコールバック関数をコールすることにより、コールバック関数の実行を行う。コールバック関数作用入出力手段
0180は、コールバック関数の実行により発生する入出力の動作を提供する。状態遷移表0190はファイル等に格納された状態遷移表である。遷移記述単位現在値記憶手段01100は、現在の遷移記述単位の内容を格納する。
【0010】
次に図1の動作について説明する。まず初期化に際し、状態遷移表格納/管理手段0150には状態遷移表0190の情報が読み込まれているとする。更に現在状態格納手段0130には初期状態値が入力されているとする。ここで、状態遷移制御の対象となるプログラムの動作に伴い発生した事象が、事象解析マネージャ0110により解析され、発生事象格納手段0120に格納される。図1で外界とは、状態遷移を制御する部分を除いた状態遷移制御の対象となるプログラムである。状態遷移制御の部分以外は、同一のプログラムのプロセスであっても、入出力ハードウェアであってもここでは“外界”と表記する。なお、事象の発生源は状態遷移制御マネージャ0160自身も含める。状態遷移制御マネージャ0160は、発生事象格納手段0120に事象が格納されている場合、その事象と現在状態格納手段0130から得た状態値を元に、状態遷移表格納/管理手段0150から遷移記述単位を取得する。取得した遷移記述単位は、遷移記述単位現在値記憶手段01100に格納する。
【0011】
次に、遷移記述単位現在値記憶手段01100から、文字列としてのコールバック関数の名称を取得する。そしてコールバック関数名称ポインタ解決手段0140を用いて、この文字列としてのコールバック関数名称を、対応するコールバック関数のポインタへ変換する。そして変換されたコールバック関数ポインタを、コールバック関数実行手段0170に送り、実際のコールバック関数を実行する。このコールバック関数の実行に伴う情報の外界との情報の入出力は、コールバック関数作用入出力手段0180により行う。コールバック関数の実行後、実行結果の戻り値が、コールバック関数実行手段0170から状態遷移制御マネージャ0160へ渡される。状態遷移制御マネージャ0160は、渡ってきたコールバック関数の戻り値を元に遷移記述単位現在値記憶手段01100から、遷移すべき次の状態値を取得し、現在状態格納手段0130の現在状態を更新する。
【0012】
図2は、本発明の実行時のフローチャートである。本発明の実施例で特徴的である点は、状態遷移動作時に、文字列としてのコールバック関数名称を含んだ状態遷移表を参照し、所望のコールバック関数をコールバック関数名称で検索して、そのコールバック関数名称と結び付けられているコールバック関数のポインタを取得するという段階を踏むことである。
【0013】
以下実行時の動作を順を追って説明する。プログラム開始後、全体の初期化処理を行う(0210)。次に処理0220で外部ファイル等に定義された状態遷移表データ0230を読み込む。処理0240では、プログラム全体の動作のうち、状態遷移関連以外の処理を行う。処理0250〜処理0290に状態遷移関連の処理をまとめて示している。処理0250では、状態遷移に必要な前提条件として、処理0240において状態遷移関連以外の処理を行った結果発生した事象と、現在の状態値を取得する。
【0014】
次に処理0260において、取得した発生事象と現在の状態値に基づき、状態遷移を辿ることによって、対応するコールバック関数の名称を取得する。処理
0270では、取得したコールバック関数名称を元に、コールバック関数名称とコールバック関数ポインタの関係を示す辞書を参照して、対応するコールバック関数のポインタを取得する。処理0280では、取得したコールバック関数のポインタをコールすることにより、状態遷移の伴うコールバック関数を実行する。最後に0290において、コールバック関数の実行後、その戻り値情報を元に、次の遷移先を決定して、遷移を行う。ここで遷移とは、現在の状態値を遷移すべき新しい状態値で更新することである。
【0015】
状態遷移表は、プログラム作成時にハードコード(プログラム中に直接書き込むこと)しても良い。あるいは、状態遷移表から必要なコールバック関数を検索する直前(0260)に毎回読み込みを行ってもよい。これは、状態遷移表がプログラムの動作中に外部プログラムによって変更され得る場合に適用する。一度読み込んで計算機のメモリ上に存在する状態遷移表を動的に変更してもよい。
【0016】
次に図3を用い、本発明による実施例の実装時の手順について説明する。本実施例の状態遷移表0310は、最左列に状態を列挙した状態列(0320)、最上行に事象を列挙した事象行(0330)をそれぞれ見出しとして持つ。状態列0320の右側かつ事象行0330の下側に位置する状態遷移の動作を特徴づける表の部分を状態遷移動作記述部(0340)と呼び、状態遷移動作記述部
(0340)のうち1つの状態と1つの事象を指定することで決定する1組の状態遷移表の記述内容を遷移記述単位(0350)と呼ぶ。遷移記述単位(0350)は1つあるいは複数のセルからなり、少なくともコールバック関数を記述するセルを有する。状態列0320,事象行0330とも他の要素と区別できればよく、必ずしも最左列および最上行に無くてもよい。更に行と列を入れ替えてもよい。以下の説明では、図3に示した状態遷移表0310の書式を前提に説明する。
【0017】
実装時この状態遷移表をもとに、大きく分けて2つのファイル群を作成する。1つは定義ファイルで、実行を伴わない各種定義を記述するものである。もう1つは、実行文記述ファイルで、コールバック関数の動作についての記述を含むものである。
【0018】
状態遷移表を元に生成する定義ファイルとは、事象定義ファイル(0360),コールバック関数定義ファイル(0370),状態定義ファイル(0380)のうちの少なくとも1つである。事象定義ファイル(0360)は、状態遷移表(0310)中の事象行(0330)の内容を列挙したものである。同様に状態定義ファイル(0380)は、状態遷移表(0310)中の状態列(0320)の内容を列挙したものである。コールバック関数定義ファイル(0370)は、状態遷移動作記述部(0340)全てに関し、遷移記述単位(0350)中のコールバック関数を列挙したヘッダファイルである。コールバック関数のうち同一名称のものは、同一関数として1つのみ列挙する。これらの定義ファイルのうち、コールバック関数定義ファイル(0370)のみが本発明の実施例に必須であり、その他は必要に応じ使用する。
【0019】
実行文記述ファイルには、関数名称マッピングファイル(0390)及び関数本体記述(03100)がある。関数名称マッピングファイル(0390)は、状態遷移表より抽出した“文字列”としてのコールバック関数名称と、コールバック関数定義ファイル(0370)に記述した“識別子”としてのコールバック関数名称とを関連付ける。
【0020】
関数名称マッピングファイル(0390)の作成においては、状態遷移表
(0310)あるいはコールバック関数定義ファイル(0370)からコールバック関数名称を抽出した後、コールバック関数名称を文字列として引用したものと関数ポインタとして引用したものを、関連付けする操作の引数として与える形式とする。関連付けする操作では、文字列を検索キーとしてポインタを得る機構を利用する。例えばC/C++言語においてはmap ライブラリが利用できる。その他の言語や環境においても、辞書や連想配列的な機能を提供するライブラリを利用すれば、本発明において必要となる機能を簡便に実現できる。
【0021】
本実施例における関数名称マッピングファイル0390の書式例では、文字列として関数名称を与えるために関数名称をダブルクオート(”)で囲み、関数名称のポインタを表わすために、関数名称に「&」記号を付けている。C/C++言語以外の言語/ライブラリを利用する場合でも、文字列をキーとしてポインタを得る仕組みを利用すれば同様の機能を実現できる。関連付けを行う関数名称マッピングファイルの書式は単純であるため、状態遷移表を与えて機械的に生成する場合に有利である。
【0022】
関数本体記述03100はコールバック関数の本体記述であり、各コールバック関数の実際の動作に関する記述を行う。関数名称マッピング(0390)及び関数本体記述(03100)においては、コールバック関数定義ファイル(0370)を参照する。
【0023】
図4に遷移記述単位(図3における0350)の記述内容の例を示す。0410が状態遷移表、0420が遷移記述単位である。この例では、遷移記述単位は、コールバック関数名称を示すセル(0430)、遷移先を示すセル(0440)、注釈セル(0450)から構成されている。この遷移記述単位で最低限必要な項目は、コールバック関数名称を示すセル0430である。また、状態遷移表の性質上、遷移先を示すセル(0440)を設けることにより、遷移先を表中に明示することができるため利便性が向上する。遷移先を示すセルを利用しない場合には、遷移処理をコールバック関数の中で行う。同様に注釈セル(0450)を設けることで、コールバック関数名称(0430)のみでは表現できない情報を盛り込むことが出来る。0460〜04100は遷移先を示すセル(0440)の書式の例である。0460は、同じ状態遷移表内の別状態への遷移する場合の書式であり、遷移可能な状態を列挙した形式となっている。現在の状態からどの遷移先に遷移するかは、コールバック関数の戻り値により決定する。例えばコールバック関数の戻り値が0の場合は遷移先状態1へ遷移し、同様に戻り値が1の場合は、遷移先状態2へ遷移する等の方式が考えられる。
【0024】
0470は、遷移先として別の状態遷移表の遷移状態を含む場合の書式の例である。この書式の例では、遷移先並びの先頭に遷移先となる状態遷移表を列挙した記述(0480)をもち、これに引き続いて、同一表内への遷移先状態が列挙されている(0490)。遷移先の表の列挙と、遷移先状態の列挙を分離して記述するのは、別の状態遷移表に遷移した後に元の状態遷移表へ状態が復帰する際の利便性のためである。例えば、0470において遷移先が遷移先表2(04100)であった場合、現在の状態遷移表が遷移先表2で示される表に切り替わる(いわゆる状態遷移表の入れ子構造)。その後、遷移先表2に基づいた処理を経て、しかるべき事象の発生に伴い、元の状態遷移表に復帰する局面が来る。その際、元の状態遷移表中のどの状態へ遷移すべきかの指定が必要となる。その復帰時の遷移先の指定に遷移先状態の列挙(0490)が用いられる。尚、遷移先状態の列挙(0490)は別表からの復帰時に限らず、入れ子の別表へ移行しない場合の同一表内への遷移先状態の指定にも用いる。
【0025】
これまでの実施例においては、説明のためにコールバック関数名称は機械的に番号付けをした抽象的なものであった。本方式においては、コンパイラ等の言語処理系が認識できる範囲において任意のコールバック関数名称を付与できるため、生成後のソースの可読性が良いことが特徴である。そこで、図5および図6に示す、通信プログラムにおけるトランスポートコネクションの確立の動作を例として、より具体的なコールバック関数名称を用いた実際例に近い実施例を説明する。
【0026】
図5が説明の対象とするコネクション確立関連のシーケンスチャートである。本実施例の範囲では、コネクションの確立及び開放における一連の動作に絞って説明し、例外処理系の説明は省く。0510及び0520は着目している局の通信プログラムの階層である。0510が着目している局のトランスポート層、
0520はその上層に相当する。同様に0540と0550は着目している局と対向する局のトランスポート層及びその上層である。0530は着目局と対向局双方のトランスポート層以下の階層、及び両局間に介在する通信媒体である。
【0027】
ここで着目局側からトランスポートコネクションの接続要求および切断要求を発し、対向局がそれに応答する場合を考える。0560が着目局の上層よりの接続要求である。この要求は着目局の上層からのrequest の受信後、着目局のトランスポート層を通り、対向するトランスポート層への接続要求が発信され、対向局のトランスポート層に到達後、対向局の上層への接続要求のindicationとして伝達される。そのindicationに対する接続要求受理のresponseは、対向局のトランスポート層を介して着目局のトランスポート層に到達し、大元の接続要求元である着目局の上層へconfirmationとして伝達される(0570)。切断においても同様のシーケンスを辿る。0580が切断要求、0590が切断要求受理のメッセージシーケンスである。05100は、着目局のトランスポート層の状態遷移を示している。
【0028】
図5における着目局の状態遷移を表にしたものが次の図6である。0610は状態を列挙した状態列、0620は事象を列挙した事象行、0630は状態遷移の動作を記述する状態遷移動作記述部、0640〜0670は遷移記述単位、
0680は遷移記述単位におけるセルの説明である。0680は実施例の説明のために付けたもので、必ずしも必要ではない。なお状態遷移表における状態の初期値の指定方法は別フラグで指定する方法も考えられるが、状態列の最上行とするのが簡便である。トランスポート層のコネクションに関する初期状態は“切断”状態であるため、図6の状態列の最上行を“切断”状態としている。同表で対角要素のみに内容を記述しているのは、説明のために正常系のみの動作を示すためである。一般的には例外的処理を適切に行えるよう対角要素以外にも内容を記述する。
【0029】
次に、この図6において初期状態である“切断”状態から、“接続受理待ち”状態へ遷移する場合の例を、各種変数値の変化を追いながら説明する。図7がこの変数値の変化を示す図である。0710は一連の遷移動作の最初のステップにおける変数値を示し、それに続く0720〜0760が状態遷移動作のステップを追った変数値の変化を示している。図7の1つの表で、左半分が変数の項目名、同右半分が変数項目名に対応する変数の値の例である。変数の値のうち、不定あるいは不問の場合を横棒“−”で示す。直前の変数値との比較で変化したものは太枠で示す。変数値0770は、現在の状態を保持する。変数値0780は、入力された事象、0790はコールバック関数名称の文字列、07100はコールバック関数へのポインタ、07110はコールバック関数実行後の戻り値を格納する。
【0030】
まず状態遷移動作開始時における変数値は0710に示すように、現在の状態として“切断”状態であるという情報のみを保持している。次に事象“上層よりの接続要求受信”が発生したとすると、0720のように入力事象の項目に発生した事象の値(07120)が入力される。次に、現在の状態および入力事象の2つの値から、状態遷移表07130を参照する(07140)。参照した結果得られるコールバック関数の文字列としての名称を、0730に示すようにコールバック関数名称へ入力する(07150)。次にこのコールバック関数名称を元に、関数名称マッピングファイルに基づき生成されたコールバック関数マッピング07170を参照する(07160)ことで、該当するコールバック関数へのポインタを取得する(07180)。ここまでの動作で、コールバック関数のポインタが得られたため、次のステップにおいては、その関数へのポインタをコールすることで(07190)、コールバック関数の実行を行う(07230)。コールバック関数の実行の結果得られるコールバック関数の戻り値を0750の変数値の状態において格納する(07200)。
【0031】
次にこの戻り値を元に、更新後の状態の遷移先を決定するため、変数値の状態0750において、状態遷移表07130から遷移先を検索する。得られた遷移先現在の状態へ上書きすることで、現在の状態を更新した結果、変数値の状態は0760の様になる。以下、同様の動作を繰り返す。
【0032】
本発明の実施例では、実行すべきコールバック関数を、その名称で指定可能であるため、実行時に状態遷移表が動的に変更された場合でも対応可能である。状態遷移表の動的変更の場合、変更後のコールバック関数が、予め定義されている必要がある。変更後のコールバック関数が状態遷移表中で既に使用されている場合を除き、動的変更後に使用され得るコールバック関数は、コールバック関数定義ファイル(0370)と関数名称マッピングファイル(0390)及び関数本体記述(03100)に予め定義しておく必要がある。また、使用頻度の高いと思われるコールバック関数を、標準コールバック関数として用意しておくと工数削減と管理の容易化が可能である。その他、標準コールバック関数の例としては、回線を活性状態に保つkeep Alive用の定型的なack 応答を送信する関数や、何もしないnop 関数が挙げられる。
【0033】
本発明の特徴として、コードの管理効率の良さが挙げられる。例えば、状態遷移表の行番号及び列番号から機械的にコールバック関数の名称を生成する方式の場合、全ての要素について、コールバック関数が生成されるため、コールバック関数は、状態遷移表の要素数必要となり管理工数の増大を招く。更に、状態遷移表の変更に伴い、列番号や行番号が変動するため、コードの確認は常に状態遷移表との突き合わせが必要となる。ところが本発明の方式に寄れば、上記のような不具合は生じない。
【0034】
本発明において不要なコールバック関数が増えないのは、名称によりコールバック関数を管理しているためである。本発明では、同一名称に対しては1つのコールバック関数を対応させることで、状態遷移表の複数の箇所から同一関数を参照可能である。例えば、状態遷移表中の非対角要素には、例外処理的な動作を記述することが多いが、例外処理は内容が同一である場合が多く、本発明ではこれらに同一のコールバック関数名を与えることができるため、コールバック関数の数を削減可能である。このように、必ずしも全ての非対角要素に関し、異なったコールバック関数を定義する必要が無いため、本発明においてはコールバック関数の作成と管理を大幅に簡略化できる。
【0035】
また、本発明では、状態遷移表中にコードを直接記述しない。この方式には、下記に示す複数の利点がある。
【0036】
利点の1つは、状態遷移表の階層化が容易となることである。専用のCASEツールを利用すれば、状態遷移表のセル中に直接コードを書き、なおかつ状態遷移表の入れ子構造化も可能である。しかしこの場合、そのCASEツールの用意されていない環境においては、閲覧や編集が不可能となる。一方、本発明の方式によれば、遷移先に別の状態遷移表名を指定して入れ子構造を実現しているため、全ての入れ子レベルにおいて、画一的な状態遷移表のフォーマットとすることが出来、通常の表計算ソフトやエディタを利用して状態遷移表の閲覧や編集が可能である。
【0037】
もう1つの利点は、コールバック関数の再利用性の向上である。通常、プログラムの開発が進展するにつれ、コールバック関数の処理内容は変更されていく。この際、試行錯誤に伴って、以前使用したコールバック関数の処理を再利用したくなる場合がある。状態遷移表中にコードを直接各方式であれば、状態遷移表の編集に伴い、変更前のコールバック関数の処理内容は失われる。ところが本発明の方式では、コールバック関数処理内容の変更の際、コールバック関数の名称を変えて保存することで、変更前の処理内容を保持しておくことが容易である。再利用が必要となった際は、コールバック関数の名称のみを変更することで、変更前のコールバック関数を利用できることになる。
【0038】
1つのプロジェクトに対し、状態遷移表が複数存在する場合、コールバック関数に、表を識別するprefixを付けて区別する。イベント名称も同様に複数の状態遷移表に対応してprefixを付ける。
【0039】
図8に、図6の状態遷移表を用いた場合の各種ファイルの書式の例を示す。
0810はコールバック関数定義ファイルの例である。状態遷移表中からコールバック関数の定義部を抽出し、列挙する。引数に関しては、各コールバック関数に必要な値を網羅するよう抽象化した引数タイプ(0810の例では、“ARG_TYPE”)を作成すると、引数部分の書式の統一が図れるため、機械的処理に有効である。また、関数の“名称”でコールバック関数をコールする本発明の方式においては、コールバック関数にその処理内容を反映した任意の名称を付与することが可能であるため、コールバック関数定義ファイル単体での可読性に優れる。一方、列番号と行番号よりコールバック関数名称を抽象化して生成する方式では、コールバック関数名称のみからその処理内容を類推することは困難である。
【0040】
0820は関数名称マッピングファイルの例である。map 等の文字列の検索キーとそれに対応するポインタ等の値を対で格納/検索できる仕組みを利用し、文字列としての関数名称と、識別子としての関数へのポインタを対で格納している。識別子としての関数へのポインタを、この書式で利用できるのは、コールバック関数定義ファイル0810において既にコールバック関数を定義しているためである。この関数名称マッピングファイルも、単純な書式であるため状態遷移表より自動生成する機械的処理に好適である。0830は関数本体記述である。コールバック関数は、その戻り値の型と、引数の型を共通化しているため、関数毎の固有の処理部以外の部分(いわゆる雛型あるいはスケルトン)は、状態遷移表よりの機械処理により自動生成可能である。また、状態遷移表よりコールバック関数のスケルトンを作成する際、手動あるは自動を問わず、状態遷移表中の注釈(遷移記述単位中の注釈セルの内容)を対応するコールバック関数へコメントとして挿入すると、利便性が向上する。関数本体記述0830のみでなく、コールバック関数定義ファイル(0810),関数名称マッピングファイル(0820)にも状態遷移表中の注釈を挿入しても良い。
【0041】
0840は状態遷移実行ログの例である。本発明を適用したプログラムの動作時、状態遷移表の記述内容を利用し、0840に示すような状態遷移実行ログを出力すると、動作解析に有効である。これらのログ出力は、状態遷移表の内容をベースに出来るため、新たなデータの入力は不要である。かつ状態遷移表本体を修正すれば、以降のプログラム動作時には、修正後状態遷移表ベースのログ出力とすることが出来る。
【0042】
各種ファイル生成のための機械的処理とは、状態遷移表よりコールバック関数定義ファイルを自動的に作成する処理を指す。機械処理の対象としては図3におけるファイル群の場合、事象定義ファイル0360,状態定義ファイル0380,関数名称マッピングファイル0390,関数本体記述03100のうち関数毎の固有処理をのぞく共通書式のスケルトン部である。
【0043】
次に図9を用い、状態遷移表よりコールバック関数の雛型を生成する処理について説明する。雛型の生成には、更新された最新状態の状態遷移表0910と、状態遷移表の更新が反映される前の状態の既存ソースコード0920を用いる。これら状態遷移表0910と既存ソースコード0920からの自動生成ファイル0930として、文字列としてのコールバック関数名称とコールバック関数のポインタとを結びつけるコールバック関数マッピング定義ファイルとコールバック関数スケルトンファイルの少なくとも一方が作成される。0940はコールバック関数定義ファイルの例、0950はコールバック関数スケルトン(雛型)ファイルの例である。これらのファイルを生成する際、状態遷移表と既存コールバック関数記述の双方に一致して存在するコールバック関数か、又は状態遷移表のみに存在し今回の状態遷移表の更新により新たに追加されたコールバック関数か、あるいは既存のコールバック関数記述にのみ存在し今回の状態遷移表の更新により削除されたコールバック関数かの3種類に分類する。分類の具体例を、コールバック関数マッピング定義ファイルを用いて示したものが0960,0970,0980である。
【0044】
0960は状態遷移表と既存ソースコードの双方に存在するコールバック関数の定義、0970が既存ソースコードのみに存在するコールバック関数の定義、0980が状態遷移表のみに存在するコールバック関数の定義である。0960は更新された状態遷移表と既存のソースコード中との双方に一致して存在することを示しているため、特に変更をする必要のないコールバック関数を示している。0970は状態遷移表の更新に伴い状態遷移表から削除され、更新前の既存のソースコード中にのみ存在するコールバック関数を示している。
【0045】
もし、これらのコールバック関数を将来にわたり使用しないことが明らかな場合は削除することが可能である。逆に、状態遷移表の更なる変更に伴い再び0970に記述されているコールバック関数を使用する可能性がある場合は、削除しない方がコードの管理が容易となる。状態遷移表を実行時の動的に変更する際に、新たに使用するコールバック関数も0970の欄に出現するが、この場合も削除を行わない。0980は状態遷移表の更新により新たに追加されたコールバック関数である。従って本欄に示されたコールバック関数は、新たにソースコードに追加する必要がある。その際コールバック関数スケルトンファイル0950のようなコールバック関数の雛型を自動的に生成することで、工数が削減可能であるとともに、コールバック関数の本来の中身のみの記述に集中できる。
【0046】
コールバック関数の雛型を自動で生成する場合は、既存のソースコードを直接編集せず、元ファイル名より類推しやすい別ファイルとすることで、予期せぬコードの消失を防止できる。逆に既存のソースコードを自動で編集することで、コード管理の工数を低減させることが可能である。これらのどちらの方式をとるかを、必要に応じて切り替えられるオプションを設けることで、より柔軟な運用が可能となる。
【0047】
【発明の効果】
本発明によれば、状態遷移表を用いた制御を行うプログラムにおいて、文字列としてのコールバック関数名と、ソースコード中の識別子としてのコールバック関数名を関連させて呼び出す仕組みを設けることによって、コールバック関数をその識別子名称(つまりは関数名)の“文字列”として呼び出す方式としたため、コールバック関数名称をその内容を把握しやすい任意の名称とすることが出来、状態遷移表より生成したソースコードの可読性を向上させることが可能である。また、動的な状態遷移表の変更によるコールバック関数のミスコールを防止できる。
【図面の簡単な説明】
【図1】発明の構成。
【図2】実行時のフローチャート。
【図3】実装時の手順。
【図4】遷移記述単位における記述内容の例。
【図5】コネクション確立関連のシーケンスチャート。
【図6】トランスポート層コネクション確立時の状態遷移表の例。
【図7】変数値の変化を示す図。
【図8】各種ファイルの書式の例。
【図9】雛型の生成。
【符号の説明】
0110…事象解析マネージャ、0120…発生事象格納手段、0130…現在状態格納手段、0140…コールバック関数名称ポインタ解決手段、0150…状態遷移表格納/管理手段、0160…状態遷移制御マネージャ、0170…コールバック関数実行手段、0180…コールバック関数作用入出力手段、0190,0310,0410,07130…状態遷移表、0230…状態遷移表データ、0360…事象定義ファイル、0370,0810…コールバック関数定義ファイル、0380…状態定義ファイル、0390…関数名称マッピングファイル、0820…コールバック関数名称マッピングファイル、0840…状態遷移実行ログ、01100…遷移記述単位現在値記憶手段、07170…コールバック関数マッピング。
[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a program for performing control using a state transition, and particularly to a method of reflecting a callback function described in a state transition table on source code (source code, original program) and a callback function to be called at the time of program execution. It relates to improvement of the selection method.
[0002]
[Prior art]
In general, the control structure of a program having an internal state is often defined using a state transition table. At this time, in order to perform the operation faithful to the state transition table, a mechanism for realizing the operation defined in the state transition table by some method is necessary.
[0003]
In the construction of a control structure using the conventional state transition table, a callback function name generated mechanically from column numbers and row numbers in the state transition table is used, or a callback table listing callback functions is used. Used to call the callback function. As such an example, there is a technique described in JP-A-8-190476 or JP-A-11-282658.
[0004]
One method for realizing the operation of the state transition table definition is to directly describe the processing contents of the callback function instead of the callback function name in the state transition table, and to mechanically read from the columns and rows of the state transition table. Some generate a callback function name. An example of such an example is “Latest State Transition Table Design Method and Simulation in the Design Phase” (Masahiko Watanabe, CQ Publishing Company, Interface, February 1999, p. 169-175). Another method for realizing the operation of the state transition table definition is to describe only the callback function name in the state transition table, and to store the call table (array of pointers to the callback functions) according to the description order of the state transition table. To create.
[0005]
[Problems to be solved by the invention]
When a callback function name is generated mechanically from the columns and rows of the state transition table, it is very difficult to infer the operation from the callback function name in the generated source code, and the readability of the source code is reduced. There was a problem.
[0006]
When creating a call table according to the description order of the state transition table, if the state transition table is changed between when the call table is created and when the state transition is executed, it is not possible to prevent an error that calls the wrong callback function. there were.
[0007]
[Means for Solving the Problems]
In order to solve the above-mentioned problem, in the present invention, a callback function name is described in a state transition table, and a callback function name as a “character string” in the state transition table and an “identifier” in a source code. And a means for calling the callback function by its name as a “character string” when executing the state transition. By this means, the readability of the source code is ensured, and the miscall of the callback function is prevented.
[0008]
BEST MODE FOR CARRYING OUT THE INVENTION
FIG. 1 shows the configuration of an embodiment using the present invention. The state transition control manager 0160 controls the overall operation. The event analysis manager 0110 analyzes an event that occurs along with the operation of the program to be subjected to the state transition control, and stores the analysis result of the event in the event storage unit 0120. The current state storage unit 0130 holds the current state of the program to be subjected to state transition control. The callback function name pointer resolving means 0140 provides a function of returning a pointer of the corresponding callback function from the name of the callback function given as a character string.
[0009]
The state transition table storage / management unit 0150 provides a function of returning a set of contents described in the state transition table in the state transition table from the current state value and the event that has occurred. Hereinafter, this set of state transition table description contents determined by designating one state and one event in the state transition table is referred to as a transition description unit. The callback function executing means 0170 executes the callback function by calling the callback function given as a pointer. Callback function action input / output means
0180 provides input / output operations generated by the execution of the callback function. The state transition table 0190 is a state transition table stored in a file or the like. The transition description unit current value storage unit 01100 stores the contents of the current transition description unit.
[0010]
Next, the operation of FIG. 1 will be described. First, it is assumed that the information of the state transition table 0190 has been read into the state transition table storage / management unit 0150 upon initialization. Further, it is assumed that an initial state value has been input to the current state storage unit 0130. Here, an event that occurs with the operation of the program to be subjected to the state transition control is analyzed by the event analysis manager 0110 and stored in the event storage unit 0120. In FIG. 1, the external world is a program to be subjected to state transition control excluding a part that controls state transition. Except for the part of the state transition control, whether it is a process of the same program or input / output hardware, it is described as “outside world” here. The event source includes the state transition control manager 0160 itself. When an event is stored in the occurred event storage unit 0120, the state transition control manager 0160 sends the transition description unit from the state transition table storage / management unit 0150 based on the event and the state value obtained from the current state storage unit 0130. To get. The acquired transition description unit is stored in the transition description unit current value storage unit 01100.
[0011]
Next, the name of the callback function as a character string is obtained from the transition description unit current value storage unit 01100. Then, the callback function name as a character string is converted into a pointer of the corresponding callback function using the callback function name pointer solving means 0140. Then, the converted callback function pointer is sent to the callback function execution means 0170, and the actual callback function is executed. Input and output of information with the outside world due to execution of the callback function is performed by the callback function action input / output unit 0180. After the execution of the callback function, the return value of the execution result is passed from the callback function execution means 0170 to the state transition control manager 0160. The state transition control manager 0160 acquires the next state value to be transitioned from the transition description unit current value storage unit 01100 based on the return value of the passed callback function, and updates the current state of the current state storage unit 0130. I do.
[0012]
FIG. 2 is a flowchart when the present invention is executed. The feature of the embodiment of the present invention is that, at the time of the state transition operation, a desired callback function is searched by the callback function name by referring to the state transition table including the callback function name as a character string. And obtaining a pointer to the callback function associated with the callback function name.
[0013]
Hereinafter, the operation at the time of execution will be described step by step. After the program starts, the whole initialization processing is performed (0210). Next, in a process 0220, the state transition table data 0230 defined in the external file or the like is read. In the process 0240, processes other than those related to the state transition are performed among the operations of the entire program. Processes 0250 to 0290 collectively show status transition-related processes. In the process 0250, as a prerequisite necessary for the state transition, an event generated as a result of performing a process other than the state transition related in the process 0240 and the current state value are acquired.
[0014]
Next, in process 0260, the name of the corresponding callback function is acquired by following the state transition based on the acquired occurrence event and the current state value. processing
At 0270, a pointer to the corresponding callback function is acquired by referring to a dictionary indicating the relationship between the callback function name and the callback function pointer based on the acquired callback function name. In the process 0280, the callback function accompanied by the state transition is executed by calling the pointer of the acquired callback function. Finally, at 0290, after the execution of the callback function, the next transition destination is determined based on the return value information, and the transition is performed. Here, the transition means updating the current state value with a new state value to be transited.
[0015]
The state transition table may be hard-coded (written directly into the program) when the program is created. Alternatively, the reading may be performed every time immediately before searching for a necessary callback function from the state transition table (0260). This applies when the state transition table can be changed by an external program during the operation of the program. The state transition table which is read once and exists in the memory of the computer may be dynamically changed.
[0016]
Next, a procedure for mounting the embodiment according to the present invention will be described with reference to FIG. The state transition table 0310 of this embodiment has, as headings, a state column (0320) listing states in the leftmost column and an event row (0330) listing events in the top row. The part of the table characterizing the state transition operation located on the right side of the state column 0320 and below the event row 0330 is called a state transition operation description section (0340), and the state transition operation description section
(0340) A description of a set of state transition tables determined by designating one state and one event is called a transition description unit (0350). The transition description unit (0350) is composed of one or a plurality of cells, and has at least a cell that describes a callback function. Both the state column 0320 and the event row 0330 need only be distinguishable from other elements, and need not necessarily be in the leftmost column and the uppermost row. Further, the rows and columns may be exchanged. The following description is based on the format of the state transition table 0310 shown in FIG.
[0017]
At the time of mounting, two file groups are roughly divided based on this state transition table. One is a definition file, which describes various definitions that do not involve execution. The other is an executable statement description file that contains a description of the operation of the callback function.
[0018]
The definition file generated based on the state transition table is at least one of an event definition file (0360), a callback function definition file (0370), and a state definition file (0380). The event definition file (0360) lists the contents of the event row (0330) in the state transition table (0310). Similarly, the state definition file (0380) lists the contents of the state column (0320) in the state transition table (0310). The callback function definition file (0370) is a header file listing the callback functions in the transition description unit (0350) for all the state transition operation description sections (0340). Only one callback function having the same name is listed as the same function. Of these definition files, only the callback function definition file (0370) is essential for the embodiment of the present invention, and the others are used as needed.
[0019]
The executable statement description file includes a function name mapping file (0390) and a function body description (03100). The function name mapping file (0390) associates the callback function name as “character string” extracted from the state transition table with the callback function name as “identifier” described in the callback function definition file (0370). .
[0020]
When creating the function name mapping file (0390), the state transition table
(0310) Alternatively, after extracting the callback function name from the callback function definition file (0370), a form in which the callback function name is quoted as a character string and the function pointer is quoted as a function argument is given as an argument of the operation to be associated. And The associating operation uses a mechanism for obtaining a pointer using a character string as a search key. For example, in the C / C ++ language, a map library can be used. In other languages and environments, the functions required in the present invention can be easily realized by using a dictionary or a library that provides an associative array function.
[0021]
In the example of the format of the function name mapping file 0390 in this embodiment, the function name is enclosed in double quotes (") to give the function name as a character string, and an"&"symbol is added to the function name to indicate a pointer to the function name. I have. Even when a language / library other than the C / C ++ language is used, the same function can be realized by using a mechanism for obtaining a pointer using a character string as a key. Since the format of the function name mapping file for performing the association is simple, it is advantageous when a state transition table is provided and generated mechanically.
[0022]
The function body description 03100 is the body description of the callback function, and describes the actual operation of each callback function. The function name mapping (0390) and the function body description (03100) refer to the callback function definition file (0370).
[0023]
FIG. 4 shows an example of the description content of the transition description unit (0350 in FIG. 3). 0410 is a state transition table, and 0420 is a transition description unit. In this example, the transition description unit is composed of a cell (0430) indicating a callback function name, a cell (0440) indicating a transition destination, and an annotation cell (0450). The minimum required item in this transition description unit is a cell 0430 indicating a callback function name. Also, due to the nature of the state transition table, by providing a cell (0440) indicating the transition destination, the transition destination can be clearly indicated in the table, thereby improving the convenience. When the cell indicating the transition destination is not used, the transition processing is performed in the callback function. Similarly, by providing the annotation cell (0450), information that cannot be expressed only by the callback function name (0430) can be included. 0460 to 04100 are examples of the format of the cell (0440) indicating the transition destination. 0460 is a format in the case of transition to another state in the same state transition table, and has a format in which transitionable states are listed. The transition destination from the current state is determined by the return value of the callback function. For example, when the return value of the callback function is 0, a transition is made to the transition destination state 1, and similarly, when the return value is 1, a transition is made to the transition destination state 2, and the like.
[0024]
Reference numeral 0470 is an example of a format when a transition state of another state transition table is included as a transition destination. In the example of this format, a description (0480) listing a state transition table to be a transition destination is provided at the head of the list of transition destinations, and subsequently, a transition destination state in the same table is listed (0490). . The reason why the enumeration of the transition destination table and the enumeration of the transition destination state are described separately is for convenience when the state returns to the original state transition table after transitioning to another state transition table. For example, when the transition destination is the transition destination table 2 (04100) in 0470, the current state transition table is switched to the table indicated by the transition destination table 2 (a so-called nested state transition table structure). After that, after the process based on the transition destination table 2, an appropriate event occurs, and the phase of returning to the original state transition table comes. At that time, it is necessary to specify to which state in the original state transition table to transition. The list of transition destination states (0490) is used to specify the transition destination at the time of the return. Note that the list of transition destination states (0490) is used not only when returning from another table, but also when specifying a transition destination state in the same table when not shifting to a nested another table.
[0025]
In the embodiments described above, the callback function name is an abstract one that is mechanically numbered for explanation. The present method is characterized in that since the name of an arbitrary callback function can be assigned within a range that can be recognized by a language processing system such as a compiler, the readability of the generated source is good. Therefore, an example close to the actual example using a more specific callback function name will be described by taking the operation of establishing the transport connection in the communication program shown in FIGS. 5 and 6 as an example.
[0026]
FIG. 5 is a sequence chart related to the connection establishment to be described. In the scope of the present embodiment, a description will be given focusing on a series of operations in establishing and releasing a connection, and a description of an exception handling system will be omitted. Reference numerals 0510 and 0520 denote communication program layers of the station of interest. The transport layer of the station which 0510 focuses on,
0520 corresponds to the upper layer. Similarly, 0540 and 0550 are a transport layer of a station facing the station of interest and an upper layer thereof. Reference numeral 0530 denotes a layer below the transport layer of both the target station and the opposite station, and a communication medium interposed between the two stations.
[0027]
Here, a case is considered in which the connection request and disconnection request of the transport connection are issued from the target station side, and the opposite station responds thereto. 0560 is a connection request from the upper layer of the station of interest. After receiving the request from the upper layer of the target station, the request passes through the transport layer of the target station, a connection request to the opposite transport layer is transmitted, and after reaching the transport layer of the opposite station, the upper layer of the opposite station. As an indication of a connection request to The response of the connection request reception for the indication reaches the transport layer of the target station via the transport layer of the opposite station, and is transmitted as a confirmation to the upper layer of the target station which is the original connection request source (0570). . A similar sequence is followed for disconnection. Reference numeral 0580 denotes a disconnection request message, and 0590 denotes a disconnection request acceptance message sequence. 05100 indicates a state transition of the transport layer of the station of interest.
[0028]
FIG. 6 is a table showing the state transition of the target station in FIG. 0610 is a state column listing states, 0620 is an event row listing events, 0630 is a state transition operation description section describing the state transition operation, 0640 to 0670 is a transition description unit,
0680 is the description of the cell in the transition description unit. 0680 is provided for the description of the embodiment and is not always necessary. Note that the initial value of the state in the state transition table can be specified by another flag, but it is convenient to use the uppermost row of the state column. Since the initial state related to the connection of the transport layer is the “disconnected” state, the top row of the state column in FIG. 6 is set to the “disconnected” state. The reason why the contents are described only in the diagonal elements in the table is to show the operation of only the normal system for the sake of explanation. Generally, the contents are described in addition to the diagonal elements so that the exceptional processing can be appropriately performed.
[0029]
Next, an example of a transition from the “disconnected” state, which is the initial state, to the “waiting for connection acceptance” state in FIG. FIG. 7 is a diagram showing the change of the variable value. Reference numeral 0710 denotes a variable value in the first step of a series of transition operations, and subsequent reference numerals 0720 to 0760 indicate changes in the variable value following the steps of the state transition operation. In one table of FIG. 7, the left half is an example of a variable item name, and the right half is an example of a variable value corresponding to a variable item name. Of the variable values, the case of indefinite or unquestionable is indicated by a horizontal bar "-". Those that have changed in comparison with the immediately preceding variable value are indicated by thick frames. The variable value 0770 holds the current state. The variable value 0780 stores the input event, 0790 stores the character string of the callback function name, 07100 stores the pointer to the callback function, and 07110 stores the return value after executing the callback function.
[0030]
First, as shown at 0710, the variable value at the start of the state transition operation holds only information indicating that the current state is the “disconnected” state. Next, assuming that the event “reception of connection request from upper layer” has occurred, the value of the occurred event (07120) is input to the input event item, such as 0720. Next, the state transition table 07130 is referred to from the two values of the current state and the input event (07140). The name as a character string of the callback function obtained as a result of the reference is input to the callback function name as shown by 0730 (07150). Next, by referring to the callback function mapping 07170 generated based on the function name mapping file based on the callback function name (07160), a pointer to the corresponding callback function is obtained (07180). Since the pointer of the callback function has been obtained by the above operations, in the next step, the callback function is executed by calling the pointer to the function (07190) (07230). The return value of the callback function obtained as a result of executing the callback function is stored in the state of the variable value of 0750 (07200).
[0031]
Next, based on this return value, in order to determine the transition destination of the updated state, the transition destination is searched from the state transition table 07130 in the variable value state 0750. As a result of updating the current state by overwriting the obtained current state of the transition destination, the state of the variable value becomes 0760. Hereinafter, the same operation is repeated.
[0032]
In the embodiment of the present invention, since the callback function to be executed can be specified by its name, it is possible to cope with a case where the state transition table is dynamically changed at the time of execution. In the case of the dynamic change of the state transition table, the callback function after the change needs to be defined in advance. Unless the changed callback function is already used in the state transition table, the callback functions that can be used after the dynamic change are a callback function definition file (0370), a function name mapping file (0390), and It must be defined in advance in the function body description (03100). If a callback function that is considered to be frequently used is prepared as a standard callback function, the number of steps can be reduced and the management can be facilitated. In addition, examples of the standard callback function include a function for transmitting a standard ack response for keep alive that keeps the line active, and a nop function that does nothing.
[0033]
A feature of the present invention is that code management efficiency is high. For example, in the case of a method of mechanically generating a name of a callback function from a row number and a column number of a state transition table, a callback function is generated for all elements. Since the number of elements is required, the number of management steps is increased. Furthermore, since the column number and the row number change with the change of the state transition table, it is necessary to always check the code with the state transition table. However, according to the method of the present invention, the above problems do not occur.
[0034]
The reason why unnecessary callback functions do not increase in the present invention is that callback functions are managed by name. In the present invention, the same function can be referred to from a plurality of places in the state transition table by associating one callback function with the same name. For example, an off-diagonal element in the state transition table often describes an exceptional operation, but the exception processing often has the same content, and in the present invention, the same callback function name is used for these. , The number of callback functions can be reduced. As described above, since it is not necessary to define different callback functions for all off-diagonal elements, the creation and management of callback functions can be greatly simplified in the present invention.
[0035]
Further, in the present invention, a code is not directly described in the state transition table. This approach has several advantages, as described below.
[0036]
One of the advantages is that the layering of the state transition table is facilitated. If a dedicated CASE tool is used, a code can be directly written in the cells of the state transition table, and the state transition table can be nested. However, in this case, browsing and editing become impossible in an environment where the CASE tool is not prepared. On the other hand, according to the method of the present invention, since a nested structure is realized by specifying another state transition table name for the transition destination, a uniform state transition table format is used at all nesting levels. It is possible to browse and edit the state transition table using ordinary spreadsheet software or editor.
[0037]
Another advantage is improved reusability of the callback function. Usually, as the development of the program progresses, the processing content of the callback function changes. At this time, there is a case where it is desired to reuse the processing of the callback function used previously with trial and error. If the codes are directly written in the state transition table, the contents of the callback function before the change are lost when the state transition table is edited. However, in the method of the present invention, when the callback function processing content is changed, by changing the name of the callback function and storing it, it is easy to retain the processing content before the change. When the reuse becomes necessary, the callback function before the change can be used by changing only the name of the callback function.
[0038]
When there are a plurality of state transition tables for one project, the callback functions are distinguished by adding a prefix identifying the table to the callback function. Similarly, the event name is given a prefix according to a plurality of state transition tables.
[0039]
FIG. 8 shows an example of the format of various files when the state transition table of FIG. 6 is used.
0810 is an example of a callback function definition file. The definition part of the callback function is extracted from the state transition table and enumerated. For arguments, creating an abstracted argument type (“ARG_TYPE” in the example of 0810) that covers the values required for each callback function can be used for mechanical processing because the format of the argument part can be unified. It is. Further, in the method of the present invention in which the callback function is called by the “name” of the function, it is possible to give the callback function an arbitrary name reflecting the processing contents, and thus the callback function definition file alone Excellent readability at On the other hand, in a method of generating a callback function name by abstracting it from a column number and a row number, it is difficult to infer the processing content from only the callback function name.
[0040]
0820 is an example of a function name mapping file. Using a mechanism in which a search key of a character string such as map and a value of a pointer or the like corresponding to the search key can be stored / retrieved as a pair, a function name as a character string and a pointer to a function as an identifier are stored as a pair. . The pointer to the function as the identifier can be used in this format because the callback function definition file 0810 has already defined the callback function. Since the function name mapping file has a simple format, it is suitable for mechanical processing that is automatically generated from the state transition table. Reference numeral 0830 is a function body description. Since the callback function has a common return type and argument type, parts other than the processing unit unique to each function (so-called templates or skeletons) are automatically processed by machine processing from the state transition table. Can be generated. Also, when creating a skeleton of a callback function from the state transition table, regardless of whether it is manual or automatic, the annotation in the state transition table (the contents of the annotation cell in the transition description unit) is commented to the corresponding callback function. When inserted, convenience is improved. Annotations in the state transition table may be inserted not only in the function body description 0830 but also in the callback function definition file (0810) and the function name mapping file (0820).
[0041]
0840 is an example of a state transition execution log. When a program to which the present invention is applied operates, outputting a state transition execution log such as 0840 using the description contents of the state transition table is effective for operation analysis. Since these log outputs can be based on the contents of the state transition table, it is not necessary to input new data. In addition, if the state transition table body is modified, a log output based on the modified state transition table can be output during the subsequent program operation.
[0042]
The mechanical processing for generating various files refers to processing for automatically creating a callback function definition file from a state transition table. In the case of the file group in FIG. 3 as the target of the machine processing, the skeleton part of the common format excluding the specific processing for each function among the event definition file 0360, the state definition file 0380, the function name mapping file 0390, and the function body description 03100 .
[0043]
Next, a process for generating a template of a callback function from the state transition table will be described with reference to FIG. To generate the template, the updated state transition table 0910 and the existing source code 0920 in the state before the update of the state transition table is reflected are used. As the automatically generated file 0930 from the state transition table 0910 and the existing source code 0920, at least one of a callback function mapping definition file and a callback function skeleton file for linking a callback function name as a character string and a callback function pointer. Is created. 0940 is an example of a callback function definition file, and 0950 is an example of a callback function skeleton (model) file. When these files are generated, either a callback function that matches both the state transition table and the existing callback function description, or a function that exists only in the state transition table and is newly added by updating this state transition table These are classified into three types: callback functions that have been added, or callback functions that exist only in the existing callback function description and have been deleted by updating the current state transition table. 0960, 0970, and 0980 show specific examples of the classification using the callback function mapping definition file.
[0044]
0960 is a definition of the callback function existing in both the state transition table and the existing source code, 0970 is a definition of the callback function existing only in the existing source code, and 0980 is a definition of the callback function existing only in the state transition table. is there. Since 0960 indicates that it exists in both the updated state transition table and the existing source code, it indicates a callback function that does not need to be changed. Reference numeral 0970 denotes a callback function that is deleted from the state transition table with the update of the state transition table and exists only in the existing source code before the update.
[0045]
If it is clear that these callback functions will not be used in the future, they can be deleted. Conversely, if there is a possibility that the callback function described in 0970 may be used again due to a further change in the state transition table, it is easier to manage the code without deleting it. When the state transition table is dynamically changed at the time of execution, a newly used callback function also appears in the column of 0970, but also in this case, the callback function is not deleted. Reference numeral 0980 denotes a callback function newly added by updating the state transition table. Therefore, the callback function shown in this section needs to be newly added to the source code. At that time, by automatically generating a template of the callback function such as the callback function skeleton file 0950, the man-hour can be reduced and the description of only the original contents of the callback function can be concentrated.
[0046]
When automatically generating a callback function template, unexpected loss of code can be prevented by not editing the existing source code directly but using a separate file that is easier to guess than the original file name. Conversely, by automatically editing the existing source code, it is possible to reduce the number of code management steps. By providing an option to switch between these methods as needed, more flexible operation becomes possible.
[0047]
【The invention's effect】
According to the present invention, in a program that performs control using a state transition table, by providing a mechanism for associating a callback function name as a character string with a callback function name as an identifier in source code, Since the callback function is called as the "character string" of the identifier name (that is, the function name), the callback function name can be any name that makes it easy to grasp the contents, and is generated from the state transition table. It is possible to improve the readability of the source code. In addition, it is possible to prevent a callback function from being missed due to a dynamic state transition table change.
[Brief description of the drawings]
FIG. 1 is a configuration of the invention.
FIG. 2 is a flowchart at the time of execution.
FIG. 3 shows a procedure at the time of mounting.
FIG. 4 is an example of description content in a transition description unit.
FIG. 5 is a sequence chart related to connection establishment.
FIG. 6 is an example of a state transition table when a transport layer connection is established.
FIG. 7 is a diagram showing a change in a variable value.
FIG. 8 shows examples of formats of various files.
FIG. 9 Generation of a template.
[Explanation of symbols]
0110: Event analysis manager, 0120: Occurrence event storage means, 0130: Current state storage means, 0140: Callback function name pointer resolution means, 0150: State transition table storage / management means, 0160: State transition control manager, 0170: Call Back function execution means, 0180 ... callback function action input / output means, 0190,0310,0410,07130 ... state transition table, 0230 ... state transition table data, 0360 ... event definition file, 0370,0810 ... callback function definition file, 0380: State definition file, 0390: Function name mapping file, 0820: Callback function name mapping file, 0840: State transition execution log, 01100: Transition description unit current value storage means, 07170: Callback function mapping.

Claims (4)

事象及び状態の組み合わせにより処理を選択する状態遷移表に基づき制御を行う状態遷移制御方法において、
現在状態及び発生事象により決定される処理方法を記述したコールバック関数を選択する際、
現在状態及び発生事象から実行するコールバック関数の状態遷移表に記述した関数名称の文字列を求め、
この関数名称の文字列から、実行する関数のアドレスを求めて、該関数のアドレスに実行を移し、
該関数の実行が終了した際の戻り値を用いて、状態遷移表に基づく次の遷移状態を求めて現在状態を更新することを特徴とする状態遷移制御方法。
In a state transition control method for performing control based on a state transition table for selecting a process by a combination of an event and a state,
When selecting a callback function that describes the processing method determined by the current state and the event,
Obtain the character string of the function name described in the state transition table of the callback function executed from the current state and the occurrence event,
From the character string of this function name, the address of the function to be executed is obtained, and execution is moved to the address of the function.
A state transition control method comprising: obtaining a next transition state based on a state transition table using a return value when the execution of the function is completed; and updating a current state.
上記請求項1の状態遷移制御方法において、状態遷移表は、状態遷移の動作を特徴づける状態遷移動作記述部を備え、状態遷移動作記述部のうち1つの状態と1つの事象を指定することで決定される1組の状態遷移表記述内容を遷移記述単位とし、遷移記述単位が1つあるいは複数のセルからなり、少なくともコールバック関数を記述するセルを有し、
コールバック関数を記述するセルに記述されたコールバック関数名に基づき、文字列としてのコールバック関数名称と、原始コード中の識別子としてのコールバック関数を対応付けることにより、状態遷移制御を実行することを特徴とする状態遷移制御方法。
2. The state transition control method according to claim 1, wherein the state transition table includes a state transition operation description section characterizing the operation of the state transition, and specifies one state and one event in the state transition operation description section. A set of determined state transition table description contents is a transition description unit, and the transition description unit is composed of one or more cells, and has at least a cell that describes a callback function;
Execute state transition control by associating the callback function name as a character string with the callback function as an identifier in the source code based on the callback function name described in the cell that describes the callback function A state transition control method characterized by the following.
上記請求項2に記載の状態遷移制御方法において、状態遷移表記述単位は更に、注釈を入力するセルと遷移状態を入力するセルを有することを特徴とする状態遷移制御方法。3. The state transition control method according to claim 2, wherein the state transition table description unit further includes a cell for inputting an annotation and a cell for inputting a transition state. 上記請求項2に記載の状態遷移制御方法において、前記状態遷移表に含まれる事象名を列挙した事象定義ファイル、及び前記状態遷移表に含まれる状態を列挙した状態定義ファイル及び少なくとも一方を生成し、状態遷移表と状態遷移表からの生成ファイル内容との整合性を確保する状態遷移制御方法。3. The state transition control method according to claim 2, wherein at least one of an event definition file listing event names included in the state transition table and a state definition file listing states included in the state transition table is generated. A state transition control method for ensuring consistency between a state transition table and contents of a file generated from the state transition table.
JP2002258370A 2002-09-04 2002-09-04 State transition control method Pending JP2004094837A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2002258370A JP2004094837A (en) 2002-09-04 2002-09-04 State transition control method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2002258370A JP2004094837A (en) 2002-09-04 2002-09-04 State transition control method

Publications (1)

Publication Number Publication Date
JP2004094837A true JP2004094837A (en) 2004-03-25

Family

ID=32062994

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2002258370A Pending JP2004094837A (en) 2002-09-04 2002-09-04 State transition control method

Country Status (1)

Country Link
JP (1) JP2004094837A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2006134640A1 (en) * 2005-06-14 2006-12-21 Fujitsu Limited Information processing device, state transition management method, and state transition management program
WO2008111382A1 (en) * 2007-02-22 2008-09-18 Nec Corporation Information processing device, information processing method, and program
JP2009230713A (en) * 2008-03-25 2009-10-08 Nec Corp Message processing method, message processor, and program

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2006134640A1 (en) * 2005-06-14 2006-12-21 Fujitsu Limited Information processing device, state transition management method, and state transition management program
WO2008111382A1 (en) * 2007-02-22 2008-09-18 Nec Corporation Information processing device, information processing method, and program
JP5067723B2 (en) * 2007-02-22 2012-11-07 日本電気株式会社 Information processing apparatus, information processing method, and program
JP2009230713A (en) * 2008-03-25 2009-10-08 Nec Corp Message processing method, message processor, and program

Similar Documents

Publication Publication Date Title
JP4141556B2 (en) Structured document management method, apparatus for implementing the method, and medium storing the processing program
US7373595B2 (en) System and method for validating an XML document and reporting schema violations
US7254784B2 (en) User-driven menu generation system with multiple submenus
US20040210573A1 (en) Method, system and program for generating structure pattern candidates
JP2000148461A (en) Software model and existing source code synchronizing method and device
US20100001834A1 (en) System and method for a message registry and message handling in a service -oriented business framework
EP1679615A2 (en) Programmability for binding data
JP2010033373A (en) Software configuration management method and system
JPWO2004061713A1 (en) Structured document structure conversion apparatus, structure conversion method, and recording medium
JPH11167584A (en) Page shift method and its execution device and medium recording page shift processing program and data
JPWO2005098660A1 (en) Document processing apparatus and document processing method
JPWO2006051712A1 (en) Document processing apparatus and document processing method
JP2004094837A (en) State transition control method
JP2003030016A (en) Method and system for converting data, and processing program therefor
KR101342560B1 (en) Mobile Database System for Navigation and Method Therefor
JP2006309697A (en) Computer system, program for computer system, and program generating application program based on spreadsheet program among the programs
JP7059757B2 (en) API processing method, terminal, API processing program
JPH117445A (en) Integrated document management device
JP2005078119A (en) Support system and method for software development support, program, and recording medium
JP4809739B2 (en) User interface changing device and recording medium
JP2005346434A (en) Widget operation method, device, program and recording medium with this program recorded thereon
CN115051904B (en) Method and device for managing single disk state based on markup language
JPH08202692A (en) Decentralized editing device
JP4180099B2 (en) Recording medium recording sequence analysis program, sequence analysis apparatus, and sequence analysis method
JP2000089946A (en) Method for customizing message text and help text and recording medium storing program for executing the customizing method