構成マネージャー API ¶
モジュール: typhoon.api.configuration_manager
構成マネージャー API には、新しいプロジェクト構成を作成したり、既存のプロジェクト構成を操作するための一連の関数が含まれています。
例¶
次の例は、構成マネージャー API の全機能を示しています。
この例では、まず既存の.tcpファイルからプロジェクトが読み込まれます。次に、既存の.tcfgファイルから設定が読み込まれます。読み込まれた項目へのハンドルを使用して、プロジェクト設定で可能なオプションを選択することで設定が変更されます。これが完了すると、プロジェクト設定を生成できます。
#
# Demonstrate use of load_project function
#
from typhoon.api.configuration_manager import ConfigurationManagerAPI
from os.path import join, dirname, realpath
# Get path to the assets dir, which will hold all required files.
assets_path = join(dirname(realpath(__file__)), "assets")
print(assets_path)
cfg_manager = ConfigurationManagerAPI()
project_handle = cfg_manager.load_project(join(assets_path, "project-file.tcp"))
#
# Load configuration from file and generate output using it.
#
config1 = cfg_manager.load_config(join(assets_path, "config1.tcfg"))
# Generate output model based on configuration specified by 'config1'.
generate_result = cfg_manager.generate(project_handle, config1)
print("Output model is located in file: '{}'".format(
generate_result.generated_schematic_path)
)
#
# Create another configuration from scratch (using API).
#
config2 = cfg_manager.create_config("Config2")
cfg_manager.picks(config2,
[cfg_manager.make_pick("Rectifier", "Thyristor Rectifier"),
cfg_manager.make_pick("Motor", "Induction machine squirrel",
{
"el_trq_out": "True",
"mech_speed_out": "True",
"load_src": "Model"
})])
# Generate output model based on configuration specified by 'config2'.
generate_result = cfg_manager.generate(project_handle, config2)
print("Output model is located in file: '{}'".format(
generate_result.generated_schematic_path)
)
# Also, configuration created using API (in memory) can be saved for later use.
config3 = cfg_manager.create_config("Config3")
print("Created configuration named '{0}'".format(cfg_manager.get_name(config3)))
cfg_manager.picks(config3, [cfg_manager.make_pick("Rectifier",
"Thyristor Rectifier")])
cfg_manager.save_config(config3, "config3.tcfg")
# End.
スクリプト出力:
C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\configuration_manager_api_examples\main.example:12: DeprecationWarning: Configuration manager API and its functions will be deprecated in near future.Contact Typhoon HIL for details.
cfg_manager = ConfigurationManagerAPI()
C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\configuration_manager_api_examples\main.example:13: DeprecationWarning: Configuration manager API and its functions will be deprecated in near future.Contact Typhoon HIL for details.
project_handle = cfg_manager.load_project(join(assets_path, "project-file.tcp"))
C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\configuration_manager_api_examples\main.example:18: DeprecationWarning: Configuration manager API and its functions will be deprecated in near future.Contact Typhoon HIL for details.
config1 = cfg_manager.load_config(join(assets_path, "config1.tcfg"))
C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\configuration_manager_api_examples\main.example:20: DeprecationWarning: Configuration manager API and its functions will be deprecated in near future.Contact Typhoon HIL for details.
generate_result = cfg_manager.generate(project_handle, config1)
C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\configuration_manager_api_examples\main.example:28: DeprecationWarning: Configuration manager API and its functions will be deprecated in near future.Contact Typhoon HIL for details.
config2 = cfg_manager.create_config("Config2")
C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\configuration_manager_api_examples\main.example:30: DeprecationWarning: Configuration manager API and its functions will be deprecated in near future.Contact Typhoon HIL for details.
[cfg_manager.make_pick("Rectifier", "Thyristor Rectifier"),
C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\configuration_manager_api_examples\main.example:31: DeprecationWarning: Configuration manager API and its functions will be deprecated in near future.Contact Typhoon HIL for details.
cfg_manager.make_pick("Motor", "Induction machine squirrel",
C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\configuration_manager_api_examples\main.example:29: DeprecationWarning: Configuration manager API and its functions will be deprecated in near future.Contact Typhoon HIL for details.
cfg_manager.picks(config2,
C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\configuration_manager_api_examples\main.example:38: DeprecationWarning: Configuration manager API and its functions will be deprecated in near future.Contact Typhoon HIL for details.
generate_result = cfg_manager.generate(project_handle, config2)
C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\configuration_manager_api_examples\main.example:44: DeprecationWarning: Configuration manager API and its functions will be deprecated in near future.Contact Typhoon HIL for details.
config3 = cfg_manager.create_config("Config3")
C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\configuration_manager_api_examples\main.example:45: DeprecationWarning: Configuration manager API and its functions will be deprecated in near future.Contact Typhoon HIL for details.
print("Created configuration named '{0}'".format(cfg_manager.get_name(config3)))
C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\configuration_manager_api_examples\main.example:46: DeprecationWarning: Configuration manager API and its functions will be deprecated in near future.Contact Typhoon HIL for details.
cfg_manager.picks(config3, [cfg_manager.make_pick("Rectifier",
C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\configuration_manager_api_examples\main.example:48: DeprecationWarning: Configuration manager API and its functions will be deprecated in near future.Contact Typhoon HIL for details.
cfg_manager.save_config(config3, "config3.tcfg")
C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\configuration_manager_api_examples\assets
Output model is located in file: 'C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\Config managment example project_Config 1.tse'
Output model is located in file: 'C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\Config managment example project_Config2.tse'
Created configuration named 'Config3'
APIリファレンス¶
- クラス ConfigurationManagerAPI ( * args , ** kwargs ) ¶
- create_config ( config_name ) ¶
新しい構成を作成します。
- パラメータ:
config_name ( str ) – 設定名。
- 戻り値:
構成オブジェクトへのハンドル。
- 生成( project_handle , config_handle , out_dir = '' , file_name = '' , standalone_model = True ) ¶
指定された構成を使用して、指定されたプロジェクトを生成します。
- パラメータ:
project_handle – 生成するプロジェクト。
config_handle – 生成する構成ハンドル。
out_dir – 結果の .tse ファイルを保存するディレクトリ(絶対または相対)
file_name – 生成される.tseファイルを保存するファイル名。ファイル名のみを指定し、ディレクトリ部分は含めないでください。
standalone_model ( bool ) – 生成されたモデルが自己完結型(ユーザー/カスタムライブラリから独立)であるかどうかを指定します。
- 戻り値:
GenerateResult オブジェクト (生成されたモデルへのパスが含まれます)。
- get_name (アイテムハンドル) ¶
指定されたアイテムの名前を返します
アイテムハンドル
アイテムには名前が必要です。- パラメータ:
item_handle ( ItemHandle ) – ItemHandle オブジェクト。
- 戻り値:
名前を str として指定します。
- 昇給:
ConfigurationManagerAPIException の場合、item_handle は無効です( –
タイプが間違っているか、名前がありません) –
- get_options (プロジェクトハンドル,バリアントハンドル) ¶
指定されたオプションのリストを返します
バリアントハンドル
そしてプロジェクトハンドル
.- パラメータ:
project_handle ( ItemHandle ) – ItemHandle オブジェクト。
variant_handle ( ItemHandle ) – プロジェクト内に存在するItemHandleオブジェクト
- 戻り値:
オプションハンドルのリスト
- 昇給:
ConfigurationManagerAPIException の場合 project_handle または–
variant_handle` が無効です–
- get_project_variants (プロジェクトハンドル) ¶
すべてのバリアントを返す
プロジェクトハンドル
.- パラメータ:
project_handle ( ItemHandle ) – ItemHandle オブジェクト。
- 戻り値:
プロジェクトのバリアントのリスト。
- 昇給:
project_handle が無効な場合は ConfigurationManagerAPIException が発生します。 –
- load_config ( config_path ) ¶
指定された構成ファイルから既存の構成を読み込みます。
- パラメータ:
config_path ( str ) – 既存の設定ファイルへのパス (.tcfg)
- 戻り値:
ロードされた構成へのハンドル。
- load_project (プロジェクトパス) ¶
指定されたプロジェクト ファイルからプロジェクトを読み込みます。
- パラメータ:
project_path ( str ) – 既存のプロジェクトファイルへのパス (.tcp)
- 戻り値:
読み込まれたプロジェクトへのハンドル。
- make_pick (バリアント名,オプション名,オプション構成= None ) ¶
picks メソッドと組み合わせて使用できる pick オブジェクトを作成します。
- パラメータ:
variant_name ( str ) – 選択する構成バリアント(コンポーネントプレースホルダー)の名前。
option_name ( str ) – 選択したバリアントの既存のオプションの名前。
option_configuration ( dict ) – オプションコンポーネントのプロパティ値をオーバーライドするために使用されるプロパティ名と値の辞書。
- 戻り値:
選択オブジェクトのハンドル。
- picks ( config_handle , pick_handles ) ¶
提供されたピックを指定された構成に挿入します
config_handle。
- パラメータ:
config_handle ( ItemHandle ) – 構成オブジェクトへのハンドル
pick_handles ( list ) – 置換用の選択ハンドルのリスト。
- 戻り値:
なし
- save_config ( config_handle , save_path ) ¶
既存の構成をファイルに保存します。
- パラメータ:
config_handle ( ItemHandle ) – 保存する構成へのハンドル。
save_path ( str ) – 設定を保存するディレクトリ/ファイルへのパス。
- 戻り値:
なし