回路図エディタ API

モジュール: typhoon.api.schematic_editor

Schematic APIは、既存の回路図モデル(TSEファイル)を操作したり、プログラム的に新しいモデルをゼロから作成したりするための関数/メソッドのセットを提供します。これは、テストや反復タスクの自動化のためのスクリプトの作成に最もよく使用されますが、これらのユースケースに限定されるものではありません。

次の 2 つの例は、Typhoon Schematic Editor API の使用方法を示しています。

例1

この例では、モデルを最初から作成し、それを保存して、最後のステップとしてコンパイルする方法を示します。

import os
from typhoon.api.schematic_editor import SchematicAPI

sys.path.insert(0, os.path.split(os.path.abspath(os.path.join(os.path.realpath(__file__), '..','..', '..','..')))[0])

# Create SchematicAPI object
model = SchematicAPI()

# Create new model
model.create_new_model()

# Starting coordinates
x0 = 8192
y0 = 8192

# Component values
r_in_value = 100.0
l_value = 1e-5
r_value = 0.1
c_value = 5e-4

print("Creating scheme items...")
# Create Voltage Source component
v_in = model.create_component(
    "core/Voltage Source",
    name="Vin",
    position=(x0-300, y0),
    rotation="right"
)

# Create Resistor component
r_in = model.create_component(
    "core/Resistor",
    name="Rin",
    position=(x0-200, y0-100)
)

# Create Current Measurement component
i_meas = model.create_component(
    "core/Current Measurement",
    name="I",
    position=(x0-100, y0-100)
)

# Create Ground component
gnd = model.create_component(
    "core/Ground",
    name="gnd",
    position=(x0-300, y0+200)
)

# Create Inductor component
ind = model.create_component(
    "core/Inductor",
    name="L",
    position=(x0, y0),
    rotation="right"
)

# Create Voltage Measurement component
v_meas = model.create_component(
    "core/Voltage Measurement",
    name="V",
    position=(x0+200, y0),
    rotation="right"
)

# Create RC Load Subsystem component
rc_load = model.create_component(
    "core/Empty Subsystem",
    name="RC Load",
    position=(x0+100, y0),
)

# Create port in Subsystem
p1 = model.create_port(
    name="P1",
    parent=rc_load,
    terminal_position=("top", "auto"),
    rotation="right",
    position=(x0, y0-200)
)

# Create port in Subsystem
p2 = model.create_port(
    name="P2",
    parent=rc_load,
    terminal_position=("bottom", "auto"),
    rotation="left",
    position=(x0, y0+200)
)

# Create Resistor component
r = model.create_component(
    "core/Resistor",
    parent=rc_load,
    name="R",
    position=(x0, y0-50),
    rotation="right"
)

# Create Capacitor component
c = model.create_component(
    "core/Capacitor",
    parent=rc_load,
    name="C",
    position=(x0, y0+50),
    rotation="right"
)

# Create necessary junctions
junction1 = model.create_junction(
    name="J1",
    position=(x0-300, y0+100),
)

junction2 = model.create_junction(
    name="J2",
    position=(x0, y0-100),
)

junction3 = model.create_junction(
    name="J3",
    position=(x0, y0+100),
)

junction4 = model.create_junction(
    name="J4",
    position=(x0+100, y0-100),
)

junction5 = model.create_junction(
    name="J5",
    position=(x0+100, y0+100),
)

# Connect all the components
print("Connecting components...")
model.create_connection(model.term(v_in, "p_node"), model.term(r_in, "p_node"))
model.create_connection(model.term(v_in, "n_node"), junction1)
model.create_connection(model.term(gnd, "node"), junction1)
model.create_connection(model.term(r_in, "n_node"), model.term(i_meas, "p_node"))
model.create_connection(model.term(i_meas, "n_node"), junction2)
model.create_connection(junction2, model.term(ind, "p_node"))
model.create_connection(model.term(ind, "n_node"), junction3)
model.create_connection(junction1, junction3)
model.create_connection(junction2, junction4)
model.create_connection(junction3, junction5)
model.create_connection(model.term(rc_load, "P1"), junction4)
model.create_connection(junction5, model.term(rc_load, "P2"))
model.create_connection(junction4, model.term(v_meas, "p_node"))
model.create_connection(model.term(v_meas, "n_node"), junction5)

model.create_connection(p1, model.term(r, "p_node"))
model.create_connection(model.term(r, "n_node"), model.term(c, "p_node"))
model.create_connection(model.term(c, "n_node"), p2)

# Set component parameters
print("Setting component properties...")
model.set_property_value(model.prop(r_in, "resistance"), r_in_value)
model.set_property_value(model.prop(ind, "inductance"), l_value)
model.set_property_value(model.prop(r, "resistance"), r_value)
model.set_property_value(model.prop(c, "capacitance"), c_value)

# Save the model
file_name = "RLC_example.tse"
print(f"Saving model to '{file_name}'...")
model.save_as(file_name)

# Compile model
if model.compile():
    print("Model successfully compiled.")
else:
    print("Model failed to compile")

# Close the model
model.close_model()

スクリプト出力:

スキーム アイテムを作成しています... コンポーネントを接続しています... コンポーネント プロパティを設定しています... モデルを 'RLC_example.tse' に保存しています... モデルは正常にコンパイルされました。

このスクリプトを実行すると、スクリプトが配置されているディレクトリ内のファイル「RLC_example.tse」にモデルが保存されます。

次の画像は、Typhoon Schematic Editor で開いた場合のモデルの様子を示しています。

_images/rlc_example_pic.png

例2

この例では、既存のモデル (前の例で作成) を読み込んで変更し、変更を保存して、最後の手順としてコンパイルする方法を示します。

import os
from typhoon.api.schematic_editor import SchematicAPI

sys.path.insert(0, os.path.split(os.path.abspath(os.path.join(os.path.realpath(__file__), '..','..', '..','..')))[0])

# Create SchematicAPI object
model = SchematicAPI()

# Load the model from file
print("Loading model...")
model.load("RLC_example.tse")

# Starting coordinates
x0 = 8192
y0 = 8192

print("Modifying model...")
# Get the handler for Rin component
r_in = model.get_item("Rin", item_type="component")
if r_in:
    # Delete the component
    model.delete_item(r_in)

# Get the handler for I component
i_meas = model.get_item("I", item_type="component")
if i_meas:
    # Delete the component
    model.delete_item(i_meas)

# Create a contactor component
switch = model.create_component(
    "core/Single Pole Single Throw Contactor",
    name="SW",
    position=(x0-200, y0-100)
)

# Get the component handlers to create connections with the contactor
v_in = model.get_item("Vin", item_type="component")
junction = model.get_item("J2", item_type="junction")

# Create the connections
model.create_connection(model.term(v_in, "p_node"), model.term(switch, "a_in"))
model.create_connection(model.term(switch, "a_out"), junction)

# Get the handler for RC Load subsystem
rc_load = model.get_item("RC Load", item_type="component")

# Get the handler for R component inside the RC Load subsystem
r = model.get_item("R", parent=rc_load, item_type="component")

# Read and change the resistor value of R component
old_r_value = model.get_property_value(model.prop(r, "resistance"))
new_r_value = old_r_value * 10
model.set_property_value(model.prop(r, "resistance"), new_r_value)

# Save the model
print("Saving model...")
model.save()

# Compile model
if model.compile():
    print("Model successfully compiled.")
else:
    print("Model failed to compile")

# Close the model
model.close_model()

スクリプト出力:

モデルを読み込んでいます... モデルを変更しています... モデルを保存しています... モデルは正常にコンパイルされました。

回路図API定数

モジュール: typhoon.api.schematic_editor.const

さまざまな Schematic API メソッドでは、一部のパラメータに対して事前定義された定数が必要です。

以下は、Schematic API メソッドで使用されるすべての定数のリスト (Python モジュール) です。

# This file is a part of Typhoon HIL API library.
#
# Typhoon HIL API is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# Icon rotate behavior constants.
ICON_ROTATE = "rotate"
ICON_NO_ROTATE = "no_rotate"
ICON_TEXT_LIKE = "text_like"

# Fully qualified name separator
FQN_SEP = "."

# Signal types
SIG_TYPE_ANALOG = "analog"
SIG_TYPE_DIGITAL = "digital"

# Signal processing type constants.
SP_TYPE_INHERIT = "inherit"
SP_TYPE_INT = "int"
SP_TYPE_UINT = "uint"
SP_TYPE_REAL = "real"

# Kind constants.
KIND_SP = "sp"
KIND_PE = "pe"

# Direction constants.
DIRECTION_IN = "in"
DIRECTION_OUT = "out"

# Constants for specifying rotation.
ROTATION_DOWN = "down"
ROTATION_UP = "up"
ROTATION_LEFT = "left"
ROTATION_RIGHT = "right"

# Constants for specifying tag scopes.
TAG_SCOPE_LOCAL = "local"
TAG_SCOPE_GLOBAL = "global"
TAG_SCOPE_MASKED_SUBSYSTEM = "masked_subsystem"

# Constant for ItemHandle type
ITEM_HANDLE = "item_handle"

# Constant for DataFrame type
DATA_FRAME = "data_frame"

# Flip constants.
FLIP_NONE = "flip_none"
FLIP_HORIZONTAL = "flip_horizontal"
FLIP_VERTICAL = "flip_vertical"
FLIP_BOTH = "flip_both"

# Constants used for specifying item types.
ITEM_ANY = "unknown"
ITEM_COMPONENT = "component"
ITEM_MASKED_COMPONENT = "masked_component"
ITEM_MASK = "mask"
ITEM_CONNECTION = "connection"
ITEM_TAG = "tag"
ITEM_PORT = "port"
ITEM_COMMENT = "comment"
ITEM_JUNCTION = "junction"
ITEM_TERMINAL = "terminal"
ITEM_PROPERTY = "property"
ITEM_SIGNAL = "signal"
ITEM_SIGNAL_REF = "signal_ref"

# Constants used for specifying kind of error and/or warning.
ERROR_GENERAL = "General error"
ERROR_PROPERTY_VALUE_INVALID = "Invalid property value"

WARNING_GENERAL = "General warning"

# Constants used for specifying simulation method.
SIM_METHOD_EXACT = "exact"
SIM_METHOD_EULER = "euler"
SIM_METHOD_TRAPEZOIDAL = "trapezoidal"

GRID_RESOLUTION = 4
COMPONENT_SIZE_GRID_RESOLUTION = 2 * GRID_RESOLUTION

# Constants for handler names.
HANDLER_MODEL_INIT = "model_init"
HANDLER_MODEL_LOADED = "model_loaded"
HANDLER_OPEN = "open"
HANDLER_INIT = "init"
HANDLER_MASK_INIT = "mask_init"
HANDLER_CONFIGURATION_CHANGED = "configuration_changed"
HANDLER_PRE_COMPILE = "pre_compile"
HANDLER_BEFORE_CHANGE = "before_change"
HANDLER_PRE_VALIDATE = "pre_validate"
HANDLER_ON_DIALOG_OPEN = "on_dialog_open"
HANDLER_ON_DIALOG_CLOSE = "on_dialog_close"
HANDLER_CALC_TYPE = "calc_type"
HANDLER_CALC_DIMENSION = "calc_dimension"
HANDLER_BUTTON_CLICKED = "button_clicked"
HANDLER_DEFINE_ICON = "define_icon"
HANDLER_POST_RESOLVE = "post_resolve"
HANDLER_PRE_COPY = "pre_copy"
HANDLER_POST_COPY = "post_copy"
HANDLER_PRE_DELETE = "pre_delete"
HANDLER_POST_DELETE = "post_delete"
HANDLER_NAME_CHANGED = "name_changed"
HANDLER_POST_C_CODE_EXPORT = "post_c_code_export"
HANDLER_MASK_PRE_COMPILE = "mask_pre_cmpl"
HANDLER_PROPERTY_VALUE_CHANGED = "property_value_changed"
HANDLER_PROPERTY_VALUE_EDITED = "property_value_edited"

#
# Utility constants which are used with handlers.
#

#
# These REASON_CLOSE_* further explains how dialog is closing in context
# of ON_DIALOG_CLOSE handler.
#
REASON_CLOSE_OK = "reason_close_ok"
REASON_CLOSE_CANCEL = "reason_close_cancel"

# Constants for specifying widget types.
# One exception is file chooser widget which must be
# specified by string value "file_chooser *.ext", where *.ext
# specifies desired file extension.
#
WIDGET_COMBO = "combo"
WIDGET_EDIT = "edit"
WIDGET_CHECKBOX = "checkbox"
WIDGET_BUTTON = "button"
WIDGET_TOGGLE_BUTTON = "togglebutton"
WIDGET_SIGNAL_CHOOSER = "signal_chooser"
WIDGET_SIGNAL_ACCESS = "signal_access"

#
# For file chooser widget, there is no constant but direct string is used
# as this widget type is parametrized with extension, so for example to specify
# file chooser for extension *.dll and *.so, string will be:
# file_chooser '*.dll *.so'
#

WIDGET_EDIT_MAX_LENGTH = 2**31 - 1

#
# Constants used to determine how hierarchy traversal is performed in context
# of various functions which traverse model.
#
RECURSE_INTO_LINKED_COMPS = "recurse_linked_components"

# Constants for representing contexts (be it real time or typhoon sim)
CONTEXT_REAL_TIME = "real_time"
CONTEXT_TYPHOONSIM = "typhoonsim"

位置決め

スケマティックシーン座標系の原点 (0, 0) は、シーン全体の左上隅にあります。スケマティックシーンのサイズは16kピクセル (16384) なので、スケマティックシーンの中心点は (8192, 8192) になります。

概略モデルの構成

概略モデルの構成は、 get_model_property_value そして モデルプロパティ値の設定 メソッド。これら2つの関数の詳細な説明については、APIリファレンスセクションを参照してください。

APIリファレンス

クラス SchematicAPI ( * args , ** kwargs )

クラスは概略モデルをモデル化し、概略モデルを操作するためのメソッドを提供します。

add_library_path ( library_path , add_subdirs = False , persist = False )

ライブラリファイルが配置されているパスをライブラリ検索パスに追加します。ライブラリパスの追加は一時的なものです(この関数を呼び出すプロセスでは変更が反映されますが、処理が完了した後には追加されたパスは保存されません)。

パラメータ:
  • library_path ( str ) – ライブラリファイルが配置されているディレクトリパス。

  • add_subdirs ( bool ) – サブディレクトリでライブラリ ファイルを検索します。

  • persist ( bool ) – ライブラリパスの変更を永続的にします。

戻り値:

なし

例:

#
# Demonstrate use of {add,remove}_library_path and reload_library functions.
#
# All the path operations are temporary for the current running session.
#

from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()

#
# Library file is located in directory 'custom_lib' one level above this
# example file.
#
directory, __ = os.path.split(os.path.realpath(__file__))
lib_path = os.path.join(directory, "custom_lib")

# Get all current library paths and remove them
old_paths = mdl.get_library_paths()
for path in old_paths:
    mdl.remove_library_path(path)

# Add library path and reload library to be able to use added library.
mdl.add_library_path(lib_path)
mdl.reload_libraries()

# Create components from loaded libraries.
comp = mdl.create_component("my_lib/CustomComponent")
print("Component is '{0}'.".format(comp))

comp2 = mdl.create_component("archived_user_lib/CustomComponent1")
print("Second component (from archived library) is '{0}'.".format(
    comp2
))

# Remove library from the path.
mdl.remove_library_path(lib_path)

# Add again the previous library paths
for path in old_paths:
    mdl.add_library_path(path)

mdl.close_model()

出力

コンポーネントは「masked_component: CustomComponent1」です。2番目のコンポーネント(アーカイブライブラリから)は「component: CustomComponent11」です。
bypass_component ( item_handle )

反対側の端子の番号が同じ場合は、コンポーネントを無効にして端子をバイパスします。

戻り値:

なし

例:

#
# Demonstrates the use of the bypass_component and is_bypassed functions.
#
from typhoon.api.schematic_editor import SchematicAPI

mdl = SchematicAPI()

# Create new model
mdl.create_new_model()

# Starting coordinates
x0 = 8192
y0 = 8192

print("Creating scheme items...")

# Create Voltage Source component
v_in = mdl.create_component(
    "core/Voltage Source",
    name="Vin",
    position=(x0 - 300, y0),
    rotation="right"
)
mdl.set_property_value(mdl.prop(v_in, "init_rms_value"), 100)

# Create Resistor component
r_1 = mdl.create_component(
    "core/Resistor",
    name="R1",
    position=(x0 - 200, y0 - 100)
)
mdl.set_property_value(mdl.prop(r_1, "resistance"), 50)

# Create Resistor component
r_2 = mdl.create_component(
    "core/Resistor",
    name="R2",
    position=(x0 - 100, y0 - 100)
)
mdl.set_property_value(mdl.prop(r_2, "resistance"), 50)

i_meas = mdl.create_component(
    "core/Current Measurement",
    name="I",
    position=(x0, y0),
    rotation="right"
)

mdl.create_connection(mdl.term(v_in, "p_node"), mdl.term(r_1, "p_node"))
mdl.create_connection(mdl.term(r_1, "n_node"), mdl.term(r_2, "p_node"))
mdl.create_connection(mdl.term(r_2, "n_node"), mdl.term(i_meas, "p_node"))
mdl.create_connection(mdl.term(i_meas, "n_node"), mdl.term(v_in, "n_node"))


print("Initial bypass status:")
print(f"{mdl.is_bypassed(r_1)=}")

mdl.bypass_component(r_1)
print("After bypassing component R1:")
print(f"{mdl.is_bypassed(r_1)=}")

mdl.enable_items(r_1)
print("Disabling or enabling a component removes its bypass. After enabling:")
print(f"{mdl.is_bypassed(r_1)=}")

mdl.close_model()

出力

スキーム項目を作成しています... 初期バイパス状態: mdl.is_bypassed(r_1)=False コンポーネントR1をバイパスした後: mdl.is_bypassed(r_1)=True コンポーネントを無効化または有効化すると、バイパスが解除されます。有効化後: mdl.is_bypassed(r_1)=False
close_model ( )

モデルを閉じます。

パラメータ:

なし

戻り値:

なし

例:

# # create_model() と close_model() の使い方を説明します。 #から typhoon.api.schematic_editor SchematicAPIインポートします。mdl = SchematicAPI ( ) mdl.create_new_model ( name = "MyModel" ) mdl.create_component ( type_name = " core / Resistor" ) mdl.close_model ( )

出力


コンパイル( conditional_compile = False )

回路図モデルをコンパイルします。conditional_compile が True に設定されていて、モデルとその依存関係が変更されていない場合、コンパイルは実行されません。

注記

この関数はハンドラーでは使用できません。

パラメータ:

conditional_compile ( bool ) – trueの場合、モデルが変更されていない場合はコンパイルをスキップする

戻り値:

真実 コンパイルが成功した場合、 間違い さもないと。

例:

# # コンパイル関数の使い方を示します。 #から typhoon.api.schematic_editor SchematicAPIインポートしますmdl = SchematicAPI () mdl.create_new_model () volt_src = mdl.create_component ( " core/Voltage Source" ) c = mdl.create_component ( " core / Capacitor " , name = "C1" ) r = mdl.create_component ( " core /Resistor" , name = " R1 " ) con1 = mdl.create_connection ( mdl.term ( volt_src , "p_node" ) , mdl.term ( r , " p_node " ) ) con2 = mdl.create_connection ( mdl.term ( r , " n_node " ) , mdl.term ( c , " p_node " ) ) con3 = mdl . create_connection ( mdl . term ( volt_src , "n_node " ), mdl . term ( c , "n_node " )) # モデルを保存mdl . save_as ( "model.tse" ) # モデルを読み込んでコンパイルmdl . load ( "model.tse" ) mdl . compile () mdl . close_model ()

出力


create_c_library ( source_filescompiler_options = Noneplatform = 'HIL'library_type = 'static'output_lib_path = None )

提供されたソース ファイルから静的ライブラリ ファイルを作成します。

パラメータ:
  • source_files (リスト) – ソースファイルのリスト

  • compiler_options (辞書) – コンパイルプロセスの追加パラメータ

  • プラットフォーム( str ) – ライブラリが使用されるデバイス (HIL、Windows、Linux)

  • library_type ( str ) – 作成するライブラリの種類(静的または動的)

  • output_lib_path ( str ) – 静的ライブラリを保存するパス。引数が指定されていない場合、ファイルはソースファイルと同じパスに保存されます。

戻り値:

なし

create_comment (テキスト= None名前= None位置= None )

によって指定されたコンテナ コンポーネント内に、指定されたテキストを含むコメントを作成します。

パラメータ:
  • text ( str ) – コメントテキスト。

  • ( ItemHandle ) – 親コンポーネントのハンドル。

  • name ( str ) – コメントの名前。

  • 位置(シーケンス) – コンテナ内のタグの X 座標と Y 座標。

戻り値:

作成されたコメントのハンドル。

昇給

接続の作成に失敗した場合の SchApiException。

例:

# # create_comment関数の使い方を説明します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # テキストを含むコメントを作成しますcomment1 = mdl . create_comment ( "This is a comment" ) # # テキスト、カスタム名、スキーム内の指定された位置を含むコメントを作成します。 # comment2 = mdl . create_comment ( "This is a comment 2" , name = "Comment 2" , position = ( 100 , 200 )) print ( "Comment is {0} ." . format ( comment2 )) mdl . close_model ()

出力

コメントはコメントです: コメント 2。
create_component ( type_nameparent = Nonename = Nonerotation = 'up'flip = 'flip_none'position = Nonesize = (None, None)hide_name = Falserequire = ''visible = ''layout = 'dynamic'context_typhoonsim = Nonecontext_real_time = None )

指定された型名を使用して、 parentで指定されたコンテナコンポーネント内にコンポーネントを作成します。parent が指定されていない場合は、最上位の(スキーム)が親として使用されます。

パラメータ 回転 そして フリップ それぞれの定数を値として期待します( 回路図API定数)。

パラメータ:
  • type_name ( str ) – コンポーネントタイプ名。作成するコンポーネントを指定します。

  • ( ItemHandle ) – コンテナ コンポーネント ハンドル。

  • name ( str ) – コンポーネント名。

  • rotation ( str ) – コンポーネントの回転。

  • flip ( str ) – コンポーネントの反転状態。

  • 位置(シーケンス) – コンポーネントの X 座標と Y 座標。

  • size (シーケンス) – コンポーネントの幅と高さ。

  • hide_name ( bool ) – このフラグが True に設定されている場合、コンポーネント名は非表示になります。

  • require ( str ) – このプロパティが依存するツールボックスを指定する文字列を指定します。ライブラリコンポーネントの場合は無視されます。

  • visible ( str ) – 表示される文字列、つまりこのプロパティが依存するツールボックスを指定します。ライブラリコンポーネントの場合は無視されます。

  • layout ( str ) – レイアウト文字列を指定します。静的または動的に指定できます。ライブラリコンポーネントの場合は無視されます。

  • context_typhoonsim ( dict ) – typhoonsimコンテキストのコンテキスト辞書。指定可能なキーは、 require (str)、 visible (str)、 nonsupported(bool)、 nonvisible(bool)、 ignore(bool)、 allowed_values(tuple) です。

  • context_real_time ( dict ) – typhoonsimコンテキストのコンテキスト辞書。指定可能なキーは、 require (str)、 visible (str)、 nonsupported(bool)、 nonvisible(bool)、 ignore(bool)、 allowed_values(tuple) です。

戻り値:

作成されたコンポーネントのハンドル。

昇給

コンポーネントの作成に失敗した場合の SchApiException。

例:

# # create_component関数の使い方を説明します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # 最上位レベルのスキームにコンポーネントを作成します。 r = mdl . create_component ( type_name = "core/Resistor" , name = "R1" ) # 最上位レベルのサブシステム コンポーネントを作成します。 sub1 = mdl . create_component ( "core/Subsystem" , name = "Subsystem 1" ) # 以前に作成したサブシステム コンポーネント内にインダクタ コンポーネントを作成します。 inner_l = mdl . create_component ( type_name = "core/Inductor" , parent = sub1 , name = "Inner inductor" ) mdl . close_model ()

出力


create_connection ( start , end , name = None , breakpoints = None )

指定された開始および終了の接続可能ハンドルを使用して接続を作成します。ConnectableMixin は、コンポーネント ターミナル、ジャンクション、ポート、またはタグのいずれかになります。

注記

開始と終了は両方とも同じ種類である必要があり、両方とも同じ親に配置されている必要があります。

パラメータ:
  • start ( ItemHandle ) – 接続開始のハンドル。

  • end ( ItemHandle ) – 接続終了のハンドル。

  • name ( str ) – 接続名。

  • ブレークポイント(リスト) – 接続ブレークポイントを表すために使用される座標タプル (x, y) のリスト。

戻り値:

作成された接続のハンドル。

昇給
  • 接続の作成に失敗した場合の SchApiException。

  • SchApiDuplicateConnectionException が指定された場合

  • connectables はすでに接続されています。

例:

#
# Demonstrate use of create_connection function.
#
from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()

#
# At the top level create two components, one junction and connect them.
#
#    |r|--------bp1
#               |
#               |
#               bp2----------|j|------------|l|
#
r = mdl.create_component("core/Resistor")
j = mdl.create_junction(name="Junction 1")
l = mdl.create_component("core/Inductor")
con1 = mdl.create_connection(mdl.term(r, "n_node"), j,
                             breakpoints=[(100, 200), (100, 0)])
con2 = mdl.create_connection(j, mdl.term(l, "p_node"))



#
# Create connection between tag and component (capacitor positive terminal
# named `n_node`).
#
tag1 = mdl.create_tag(value="A", name="Tag 1")
cap = mdl.create_component("core/Capacitor", name="Capacitor 1")
con3 = mdl.create_connection(tag1, mdl.term(cap, "n_node"))

#
# Create subsystem and inside one port and one component
# and connect them.
#
sub1 = mdl.create_component("core/Subsystem", name="Subsystem 1")
port1 = mdl.create_port(name="Port 1", parent=sub1)
super_cap = mdl.create_component("core/Super Capacitor",
                                 name="Super cap 1",
                                 parent=sub1)
con4 = mdl.create_connection(start=port1,
                             end=mdl.term(super_cap, "p_node"),
                             name="Inner connection")
print(con4)

mdl.close_model()

出力

接続: サブシステム1.内部接続
create_junction ( name = Noneparent = Nonekind = 'pe'position = None )

によって指定されたコンテナ コンポーネント内にジャンクションを作成します。

パラメータ 親切 それぞれの定数を値として期待します( 回路図API定数)。

パラメータ:
  • name ( str ) – ジャンクション名。

  • ( ItemHandle ) – コンテナ コンポーネント ハンドル。

  • kind ( str ) – ジャンクションの種類(信号処理またはパワーエレクトロニクスの種類)

  • 位置(シーケンス) – コンテナ内のジャンクションの X 座標と Y 座標。

戻り値:

作成されたジャンクションのハンドル。

昇給

ジャンクションの作成に失敗した場合の SchApiException。

例:

# # create_junction関数の使い方を説明します。 #から typhoon.api.schematic_editor SchematicAPIインポートする typhoon.api.schematic_editor import const mdl = SchematicAPI () mdl . create_new_model () # 指定された名前でジャンクションを作成します。 j = mdl . create_junction ( name = "Junction 1" ) print ( j ) # SP (信号処理の種類) を使用してサブシステム内にジャンクションを作成します。 sub1 = mdl . create_component ( "core/Subsystem" ) j2 = mdl . create_junction ( name = "Junction 2" , kind = const . KIND_SP ) print ( j2 ) mdl . close_model ()

出力

ジャンクション: ジャンクション 1 ジャンクション: ジャンクション 2
create_library_model ( lib_name , file_name )

新しいライブラリ (.tlib) モデルを作成します。

パラメータ:
  • lib_name ( str ) – 実際のライブラリ名

  • file_name ( str ) – ファイル名

戻り値:

なし

例:

# # create_library_model関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () file_path = os . path . join ( os . path . dirname ( os . path . realpath ( __file__ )), "create_library_model_lib" , "example_library.tlib" ) lib_name = "Example Library" mdl . create_library_model ( lib_name , file_path ) # # 基本コンポーネントを作成し、接続してライブラリに追加します# r = mdl . create_component ( "core/Resistor" , name = "R1" ) c = mdl . create_component ( "core/Capacitor" , name = "C1" ) con = mdl . create_connection ( mdl . term ( c , "n_node" ), mdl . term ( r , "p_node" )) con1 = mdl . create_connection ( mdl . term ( c , "p_node " ), mdl . term ( r , "n_node " )) # # ライブラリを保存し、ロードして、ロードされたライブラリの保存を試みます#そうでない場合os . path . exists ( file_path ): os . makedirs ( os . path . dirname ( file_path )) mdl . save_as ( file_path ) mdl . load ( file_path ) mdl . save ()

出力


create_mask ( item_handle )

指定されたアイテムにマスクを作成します アイテムハンドル.

パラメータ:

item_handle ( ItemHandle ) – ItemHandle オブジェクト。

戻り値:

マスク ハンドル オブジェクト。

昇給
  • SchApiException アイテムがマスク作成をサポートしていない場合そのアイテム上で 、または

  • item_handleが無効です。

  • アイテムが見つからない場合は SchApiItemNotFoundException が発生します。

例:

#
# Demonstrate use of create_mask function.
#
from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()

sub = mdl.create_component("core/Subsystem", name="Subsystem 1")
mask = mdl.create_mask(sub)

print("Created mask is: '{0}'.".format(mask))

mdl.close_model()

出力

作成されたマスクは「mask: Subsystem 1.Mask@top」です。
create_new_model ( name = None )

新しいモデルを作成します。

パラメータ:

name ( str ) – オプションのモデル名。指定されていない場合は自動的に生成されます。

戻り値:

なし

例:

# # create_model() と close_model() の使い方を説明します。 #から typhoon.api.schematic_editor SchematicAPIインポートします。mdl = SchematicAPI ( ) mdl.create_new_model ( name = "MyModel" ) mdl.create_component ( type_name = " core / Resistor" ) mdl.close_model ( )

出力


create_port ( name = Noneparent = Nonelabel = Nonekind = 'pe'direction = 'out'dimension = (1,)sp_type = 'real'termin_position = ('left', 'auto')rotation = 'up'flip = 'flip_none'hide_name = Falseposition = None )

によって指定されたコンテナ コンポーネント内にポートを作成します。

パラメータ 親切, 方向, sp_type, 回転 そして フリップ それぞれの定数を値として想定します。( 回路図API定数)。

パラメータ:
  • name ( str ) – ポート名。

  • ( ItemHandle ) – コンテナ コンポーネント ハンドル。

  • label ( str ) – ポート名の代わりに端末名として使用するオプションのラベル。

  • kind ( str ) – ポートの種類(信号処理または電力電子の種類)。

  • direction ( str ) – ポートの方向(信号処理ポートにのみ適用)

  • 次元(タプル) – 次元を指定します。

  • sp_type ( str ) – ポートのSPタイプ。

  • terminal_position (タプル) – コンポーネント上のポートベース端末の位置を指定します。

  • rotation ( str ) – ポートの回転。

  • flip ( str ) – ポートの反転状態。

  • hide_name ( bool ) – 端末のラベル(このポートの結果としてコンポーネント上に作成される)を非表示にするかどうかを示します。

  • 位置(シーケンス) – ポートのX座標とY座標。

戻り値:

作成されたポートのハンドル。

昇給
  • ポートの作成に失敗した場合の SchApiException (:

  • ポートがトップレベルの親に作成されるか、その他の原因により、

  • エラー -

例:

# # create_port関数のデモンストレーション。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # # ポートは最上位スキームでは作成できません (例外が発生します)。 # なので、最初にポートが作成されるサブシステムを作成する必要があります。 # sub1 = mdl . create_component ( type_name = "core/Subsystem" , name = "Subsystem 1" ) port1 = mdl . create_port ( parent = sub1 , name = "Port 1" , dimension = ( 2 ,)) print ( port1 ) mdl . close_model ()



出力

ポート: サブシステム1.ポート1
create_property(item_handle, name, label='', widget='edit', combo_values=(), evaluate=True, enabled=True, supported=True, visible=True, serializable=True, tab_name='', unit='', button_label='', previous_names=(), description='', require='', type='', default_value=None, min_value=None, max_value=None, keepline=False, ignored=False, skip=None, skip_step=None, section=None, vector=False, tunable=False, index=None, allowed_values=None, context_typhoonsim=None, context_real_time=None)

指定されたアイテムにプロパティを作成します アイテムハンドル.

パラメータ プロパティウィジェット 値として定数を期待します。( 回路図API定数)。

パラメータ:
  • item_handle ( ItemHandle ) – ItemHandle オブジェクト。

  • name ( str ) – プロパティの名前。

  • label ( str ) – プロパティのオプションのラベル。

  • widget ( str ) – 文字列定数。プロパティを表す GUI ウィジェットのタイプを指定します。

  • combo_values (タプル) – ウィジェットがWIDGET_COMBOに設定されている場合、このパラメータは許可されるコンボ値を指定します。

  • assess ( bool ) – プロパティを評価するかどうかを指定します。

  • enabled ( bool ) – このプロパティが有効かどうか(GUI 上でグレー表示されるかどうか)を指定します。

  • support ( bool ) – プロパティがサポートされているかどうかを指定します。

  • visible ( bool ) – プロパティが表示されるかどうかを指定します。

  • serializable ( bool ) – JSON へのシリアル化中にプロパティを含めるかどうかを指定します。

  • tab_name – (str): プロパティが表示されるタブのオプションの名前 (GUI 上)。

  • unit ( str ) – プロパティのオプションの単位。

  • button_label ( str ) – プロパティウィジェットがボタンの場合のラベルを定義します。

  • previous_names (タプル) – プロパティの以前の名前を含むタプル。

  • description ( str ) – プロパティの説明。

  • require ( str ) – このプロパティが依存するツールボックスを指定するための文字列を指定します。

  • type ( str ) – プロパティの型。(noqa: A002)

  • default_value – プロパティのデフォルト値。

  • min_value – プロパティの最小値。

  • max_value – プロパティの最大値。

  • keepline ( bool ) – プロパティがGUI内でその行を保持するかどうかを指定します。

  • 無視( bool ) – プロパティを無視するかどうかを指定します。

  • skip ( str ) – プロパティをスキップするかどうかを指定します。

  • skip_step – スキップするステップを指定します。

  • section – タブ内でのこのプロパティのセクション。

  • ベクトル( bool ) – プロパティがベクトルかどうかを指定します。

  • tunable ( bool ) – プロパティが調整可能かどうかを指定します。

  • index ( int ) – すべてのプロパティのリストにおける、新しいプロパティのインデックス(位置)を指定します。プロパティの位置は0から始まります。インデックスが負の数の場合、プロパティは0番目の位置に配置されます。インデックスが最後のインデックスより大きい場合、プロパティのインデックスは最後のインデックスの後に設定されます。

  • allowed_values ( tuple ) – プロパティに許可される値のタプル。現在の値が許可された範囲内にある場合、検証中に require 文字列は評価されません。

  • context_typhoonsim ( dict ) – typhoonsimコンテキストのコンテキスト辞書。指定可能なキーは、 require (str)、 visible (str)、 nonsupported(bool)、 nonvisible(bool)、 ignore(bool)、 allowed_values(tuple) です。

  • context_real_time ( dict ) – typhoonsimコンテキストのコンテキスト辞書。指定可能なキーは、 require (str)、 visible (str)、 nonsupported(bool)、 nonvisible(bool)、 ignore(bool)、 allowed_values(tuple) です。

戻り値:

新しく作成されたプロパティのプロパティ ハンドル。

昇給
  • アイテムが見つからない場合は SchApiItemNotFound です。

  • SchApiException アイテムハンドルが無効な場合アイテムハンドルは

  • プロパティの作成をサポートします。

  • 同じ名前のプロパティがすでに存在する場合、SchApiItemNameExistsException が発生します

  • 存在します。

例:

# # create_property およびremove_property関数の使用方法を示します。 # from typhoon.api.schematic_editor SchematicAPIインポートする typhoon.api.schematic_editor import const mdl = SchematicAPI () mdl . create_new_model () # サブシステム コンポーネントを作成します。 sub = mdl . create_component ( "core/Subsystem"  name = "Sub1" ) # サブシステム 'Sub1' にマスクを作成しますmask = mdl . create_mask ( sub ) # マスクに 2 つのプロパティを作成します。 prop1 = mdl . create_property ( mask  name = "prop_1"  label = "Property 1"  widget = const . WIDGET_COMBO  combo_values = ( "Choice 1"  "Choice 2"  "Choice 3" ) 、 tab_name = "First tab" ) prop2 = mdl . create_property ( mask , name = "prop_2" , label = "プロパティ2" , widget = const.WIDGET_BUTTON , tab_name = " 2番目のタブ" ) # prop2を削除します。 mdl.remove_property ( mask , " prop_2 " ) mdl.close_model ( )

出力


create_tag ( valuename = Noneparent = Nonescope = 'global'kind = 'pe'direction = Nonerotation = 'up'flip = 'flip_none'position = Nonehide_name = False )

ハンドルによって指定されたコンテナ コンポーネント内にタグを作成します。

パラメータ 範囲, 親切, 方向, 回転 それぞれの定数を値として期待します( 回路図API定数)。

パラメータ:
  • value ( str ) – 他のタグと照合するために使用されるタグの値。

  • name ( str ) – タグ名。

  • ( ItemHandle ) – コンテナ コンポーネント ハンドル。

  • スコープ( str ) – タグのスコープ。一致するタグを検索するスコープを指定します。

  • kind ( str ) – タグの種類(KIND_SP または KIND_PE のいずれか)。

  • direction ( str ) – タグの方向(信号処理タグ用)。信号処理タグが作成されると、このパラメータは値が指定されていない場合は DIRECTION_IN になります。

  • rotation ( str ) – タグの回転。次のいずれかになります: ROTATION_UP、ROTATION_DOWN、ROTATION_LEFT、ROTATION_RIGHT。

  • flip ( str ) – タグの反転状態。

  • 位置(シーケンス) – コンテナ内のタグの X 座標と Y 座標。

  • hide_name ( bool ) – このフラグが True に設定されている場合、タグ名は非表示になります。

戻り値:

作成されたタグのハンドル。

昇給

タグの作成に失敗した場合の SchApiException。

例:

# # create_tag関数の使い方を説明します。 #から typhoon.api.schematic_editor SchematicAPIインポートする typhoon.api.schematic_editor import const mdl = SchematicAPI () mdl . create_new_model () # 指定された値と名前でタグを作成します。 tag1 = mdl . create_tag ( value = "A" , name = "Tag 1" ) # カスタムのスコープ、種類、方向で、サブシステムに 2 番目のタグを作成します。 sub1 = mdl . create_component ( "core/Subsystem" ) tag2 = mdl . create_tag ( parent = sub1 , value = "B" , name = "Tag 2" , scope = const . TAG_SCOPE_LOCAL , kind = const . KIND_SP , direction = const . DIRECTION_OUT ) mdl . close_model ()

出力


delete_item ( item_handle )

指定された名前のアイテムを削除します アイテムハンドル.

パラメータ:

item_handle ( ItemHandle ) – アイテムハンドル。

戻り値:

なし

昇給

削除に失敗した場合は SchApiException が発生します。

例:

# # delete_item関数の使い方を説明します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # いくつかのアイテムを作成してから削除します。 r = mdl . create_component ( "core/Resistor" ) j = mdl . create_junction () tag = mdl . create_tag ( value = "Val 1" ) sub1 = mdl . create_component ( "core/Subsystem" ) inner_port = mdl . create_port ( parent = sub1 , name = "Inner port1" ) # # アイテムを削除# mdl . delete_item ( r ) mdl . delete_item ( j ) mdl . delete_item ( tag ) # サブシステムを削除mdl . delete_item ( sub1 ) mdl . close_model ()

出力


ハードウェア設定を検出する( )

ハードウェア デバイスを照会してハードウェア設定を検出し、設定します。

注記

この関数はハンドラーでは使用できません。

引数:

なし

戻り値:

タプル (hw_product_name, hw_revision, configuration_id) または 間違い 自動検出に失敗した場合。

例:

#
# Demonstrate use of detect_hw_settings function.
#
from typhoon.api.schematic_editor import SchematicAPI

mdl = SchematicAPI()
mdl.create_new_model()

hw_sett = mdl.detect_hw_settings()

if hw_sett:
    print("HIL device was detected and model "
          "configuration was changed to {0}.".format(hw_sett))
else:
    print("HIL device autodetection failed, maybe HIL device is not connected.")

mdl.close_model()
disable_items ( item_handles )

提供されたアイテムを無効にする アイテムハンドル.

パラメータ:

item_handles ( iterable ) – 無効にするスキーム項目を反復処理するオブジェクト。

戻り値:

操作によって影響を受ける項目のリスト。

例:

#
# Demonstrate the use of the following functions:
# enable_items, disable_items, is_enabled
#
from typhoon.api.schematic_editor import SchematicAPI

mdl = SchematicAPI()

model_path = os.path.join(
    os.path.dirname(os.path.realpath(__file__)),
    "enable_disable",
    "3050_enable_disable_items.tse"
)
mdl.load(model_path)

#
# Names of items that can be disabled
#
item_disable_names = [
    "AI_1",
    "AI_2",
    "SM_1",
    "Probe1",
]

#
# Names of subsystem [0] and item [1] inside subsystem for
# example when an item inside a subsystem is disabled
#
subsystem_get_item_example = ["SS_1", "SM_6"]

#
# Names of items that cannot be disabled
#
# These are not the only items that cannot be disabled ... just an
# example
item_dont_disable_names = [
    "Subsystem1",
    "SM_5",
    "Min Max 1",
    "GA_2"
]

#
# Fetch all items that can be disabled and that cannot be disabled
#
items_disable = []
items_dont_disable = []
for item_name in item_disable_names:
    items_disable.append(mdl.get_item(item_name))
for item_name in item_dont_disable_names:
    items_dont_disable.append(mdl.get_item(item_name))

#
# Disable, compile, enable - items that can be disabled
#
disabled_items = mdl.disable_items(items_disable)
mdl.compile()
affected_items = mdl.enable_items(items_disable)
mdl.compile()

#
# Disable, compile, enable - items that can not be disabled
#
disabled_items = mdl.disable_items(items_dont_disable)
try:
    mdl.compile()
except Exception as e:
    print(e.args)
affected_items = mdl.enable_items(items_dont_disable)
mdl.compile()

#
# Disable, compile, enable - items inside subsystem
#
parent_item = mdl.get_item(subsystem_get_item_example[0])
concrete_item = mdl.get_item(subsystem_get_item_example[1], parent_item)
disabled_items = mdl.disable_items([concrete_item])
try:
    mdl.compile()
except Exception as e:
    print(e.args)
affected_items = mdl.enable_items(concrete_item)
mdl.compile()

mdl.close_model()

出力

コンポーネントの「SM_3」入力「in1」が接続されていません。コンポーネントの「SS_1.Probe3」入力「in」が接続されていません。
disable_property ( prop_handle )

プロパティを編集不可に設定します。

注記

この機能の効果は、回路図エディターの UI でのみ表示されます。

プロパティが無効になっている場合、ダイアログで値を変更することはできません。プロパティを有効にするには、 enable_property() 関数。

パラメータ:

prop_handle ( ItemHandle ) – プロパティハンドル。

戻り値:

なし

例:

# # disable_property、enable_property、is_property_enabled関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # コンポーネントを作成r = mdl . create_component ( "core/Resistor" ) # プロパティを無効にするmdl . disable_property ( mdl . prop ( r , "resistance" )) # プロパティが有効になっているかどうかを確認します。 print ( mdl . is_property_enabled ( mdl . prop ( r , "resistance" ))) # プロパティを有効にするmdl . enable_property ( mdl . prop ( r , "resistance" )) print ( mdl . is_property_enabled ( mdl . prop ( r , "resistance" ))) mdl . close_model ()

出力

偽 真
無効化プロパティシリアル化( prop_handle )

コンポーネント プロパティの JSON へのシリアル化を無効にします。

この関数が呼び出されると、プロパティはシリアル化不可になります。そのプロパティは、(例えばコンパイル時に)シリアル化されたJSONファイルに含まれません。プロパティのシリアル化を有効にするには、 enable_property_serialization() 関数。

パラメータ:

prop_handle ( ItemHandle ) – プロパティハンドル。

例:

# # 例では、disable_property_serialization、 # enable_property_serialization、およびis_property_serializable関数の使用方法を示します。 #から typhoon.api.schematic_editor SchematicAPIインポートします。mdl = SchematicAPI ( ) mdl.create_new_model ( ) const = mdl.create_component ( type_name = " core / Constant " ) print ( mdl.is_property_serializable ( mdl.prop ( const , " value " ) ) ) mdl.disable_property_serialization ( mdl.prop ( const , " value " ) ) print ( mdl.is_property_serializable ( mdl.prop ( const , " value " ) ) ) mdl.enable_property_serialization ( mdl.prop ( const , " value " ) ) print ( mdl.is_property_serializable ( mdl.prop ( const , " value " ) ) ) mdl.close_model ( )

出力

真偽 真
disp_component_icon_text ( item_handle , text , rotate = 'text_like' , size = 10 , relpos_x = 0.5 , relpos_y = 0.5 , trim_factor = 1.0 )

アイコン内に表示されるテキストを指定します。

パラメータ:
  • item_handle ( ItemHandle ) – アイテムハンドルオブジェクト。

  • text ( str ) – 表示するテキスト。

  • rotate ( str ) – アイコンの回転動作を指定する定数 ( Schematic API 定数を参照)。

  • size ( int ) – テキストのサイズ。

  • relpos_x ( float ) – テキスト長方形の中心(X軸上)。

  • relpos_y ( float ) – テキスト長方形の中心(Y軸上)。

  • trim_factor ( float ) – テキストを短縮するテキスト長方形の幅の相対的な幅を指定する範囲 (0.0 .. 1.0) の数値。

戻り値:

なし

例:

# # Schematic APIアイコン関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () tr1 = mdl . create_component ( "core/Three Phase Two Winding Transformer" ) mdl . set_component_icon_image ( tr1 , "/path/to/image.png" ) # テキストを書き込む前に色を赤に設定mdl . set_color ( tr1 , "red" ) mdl . disp_component_icon_text ( tr1 , "Sample text" ) # シーンのコンポーネント ビューの更新を開始mdl . refresh_icon ( tr1 ) mdl . close_model ()

出力


enable_items ( item_handles )

提供されているものを使用してアイテムを有効にする アイテムハンドル.

パラメータ:

item_handles ( iterable ) – スキーム項目に対して反復可能。

戻り値:

操作によって影響を受ける項目のリスト。

例:

#
# Demonstrate the use of the following functions:
# enable_items, disable_items, is_enabled
#
from typhoon.api.schematic_editor import SchematicAPI

mdl = SchematicAPI()

model_path = os.path.join(
    os.path.dirname(os.path.realpath(__file__)),
    "enable_disable",
    "3050_enable_disable_items.tse"
)
mdl.load(model_path)

#
# Names of items that can be disabled
#
item_disable_names = [
    "AI_1",
    "AI_2",
    "SM_1",
    "Probe1",
]

#
# Names of subsystem [0] and item [1] inside subsystem for
# example when an item inside a subsystem is disabled
#
subsystem_get_item_example = ["SS_1", "SM_6"]

#
# Names of items that cannot be disabled
#
# These are not the only items that cannot be disabled ... just an
# example
item_dont_disable_names = [
    "Subsystem1",
    "SM_5",
    "Min Max 1",
    "GA_2"
]

#
# Fetch all items that can be disabled and that cannot be disabled
#
items_disable = []
items_dont_disable = []
for item_name in item_disable_names:
    items_disable.append(mdl.get_item(item_name))
for item_name in item_dont_disable_names:
    items_dont_disable.append(mdl.get_item(item_name))

#
# Disable, compile, enable - items that can be disabled
#
disabled_items = mdl.disable_items(items_disable)
mdl.compile()
affected_items = mdl.enable_items(items_disable)
mdl.compile()

#
# Disable, compile, enable - items that can not be disabled
#
disabled_items = mdl.disable_items(items_dont_disable)
try:
    mdl.compile()
except Exception as e:
    print(e.args)
affected_items = mdl.enable_items(items_dont_disable)
mdl.compile()

#
# Disable, compile, enable - items inside subsystem
#
parent_item = mdl.get_item(subsystem_get_item_example[0])
concrete_item = mdl.get_item(subsystem_get_item_example[1], parent_item)
disabled_items = mdl.disable_items([concrete_item])
try:
    mdl.compile()
except Exception as e:
    print(e.args)
affected_items = mdl.enable_items(concrete_item)
mdl.compile()

mdl.close_model()

出力

コンポーネントの「SM_4」入力「in」が接続されていません。コンポーネントの「SS_1.Probe3」入力「in」が接続されていません。
enable_property ( prop_handle )

プロパティを編集可能に設定します。

注記

この機能の効果は、回路図エディターの UI でのみ表示されます。

プロパティが有効になっている場合、ダイアログで値を変更できます。プロパティを無効にするには、 無効化プロパティ() 関数。

パラメータ:

prop_handle ( ItemHandle ) – プロパティハンドル。

戻り値:

なし

昇給:

例:

# # disable_property、enable_property、is_property_enabled関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # コンポーネントを作成r = mdl . create_component ( "core/Resistor" ) # プロパティを無効にするmdl . disable_property ( mdl . prop ( r , "resistance" )) # プロパティが有効になっているかどうかを確認します。 print ( mdl . is_property_enabled ( mdl . prop ( r , "resistance" ))) # プロパティを有効にするmdl . enable_property ( mdl . prop ( r , "resistance" )) print ( mdl . is_property_enabled ( mdl . prop ( r , "resistance" ))) mdl . close_model ()

出力

偽 真
enable_property_serialization ( prop_handle )

コンポーネント プロパティの JSON へのシリアル化を有効にします。

この関数が呼び出されると、プロパティはシリアル化可能になります。そのプロパティは、例えばコンパイル時にシリアル化されたJSONファイルに含まれます。プロパティのシリアル化を無効にするには、 無効化プロパティシリアル化() 関数。

パラメータ:

prop_handle ( ItemHandle ) – プロパティハンドル。

戻り値:

なし

例:

# # 例では、disable_property_serialization、 # enable_property_serialization、およびis_property_serializable関数の使用方法を示します。 #から typhoon.api.schematic_editor SchematicAPIインポートします。mdl = SchematicAPI ( ) mdl.create_new_model ( ) const = mdl.create_component ( type_name = " core / Constant " ) print ( mdl.is_property_serializable ( mdl.prop ( const , " value " ) ) ) mdl.disable_property_serialization ( mdl.prop ( const , " value " ) ) print ( mdl.is_property_serializable ( mdl.prop ( const , " value " ) ) ) mdl.enable_property_serialization ( mdl.prop ( const , " value " ) ) print ( mdl.is_property_serializable ( mdl.prop ( const , " value " ) ) ) mdl.close_model ( )

出力

真偽 真
error ( msg , kind = '一般エラー' , context = None )

何らかのエラー状態を通知します。

パラメータ:
  • msg ( str ) – メッセージ文字列。

  • kind ( str ) – エラー種類定数。

  • context ( ItemHandle ) – コンテキスト項目のハンドル。

戻り値:

なし

例:

# # エラー関数の使い方を説明します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl.create_new_model () const = mdl.create_component ( " core /Constant" , name = " Constant 1" ) mdl.error ( "定数コンポーネントに関するエラーメッセージ" , context = const ) mdl.close_model ( )

出力


存在する(名前= Noneitem_type = 'unknown' )

アイテム名が 名前 指定された親コンポーネント内のコンテナです ハンドル。親ハンドルが指定されていない場合は、ルート スキームが親として使用されます。

注記

アイテムタイプ 検索するアイテムの種類を指定する定数です。 回路図API定数.

パラメータ:
  • name ( str ) – チェックするアイテム名。

  • ( ItemHandle ) – 親ハンドル。

  • item_type ( str ) – アイテムタイプ定数。

戻り値:

指定された名前の項目が親に存在する場合は True、存在しない場合は False。

例:

# # exists_in関数の使い方を説明します。 #から typhoon.api.schematic_editor SchematicAPIインポートする typhoon.api.schematic_editor import const mdl = SchematicAPI () mdl . create_new_model () r = mdl . create_component ( "core/Resistor" , name = "R 1" ) print ( mdl . exists ( "R 1" )) sub1 = mdl . create_component ( "core/Subsystem" ) inner_c = mdl . create_component ( "core/Capacitor" , parent = sub1 , name = "Capacitor 1" ) print ( mdl . exists ( "Capacitor 1" , sub1 )) # フィルタリングを使用して存在をテストしますsub2 = mdl . create_component ( "core/Subsystem" , name = "Sub 2" ) mdl . create_port ( name = "Port 2" , parent = sub2 ) # ポートの作成により、Sub 2 サブシステムにターミナルも作成されましたprint ( mdl . exists ( name = "Port 2" , parent = sub2 , item_type = const . ITEM_TERMINAL )) mdl . close_model ()

出力

真偽 真
export_c_from_model ( output_dir = None )

モデルのルートからCコードをエクスポートします。ルートのコンテンツから空のサブシステムを作成し、そのサブシステムからCコードをエクスポートするためのショートカットとして機能します。Cコードエクスポーターはまだベータ版です。

注記

この関数はハンドラーでの使用はお勧めしません。

パラメータ:

output_dir ( str ) – コードがエクスポートされるディレクトリへのパス

戻り値:

なし

例:

#
# Demonstrate use of export_c_from_subsystem function.
#
from typhoon.api.schematic_editor import SchematicAPI
from typhoon.api.schematic_editor import const

mdl = SchematicAPI()
mdl.create_new_model(name="export_example")

#
# Create components on Root
#
constant = mdl.create_component("core/Constant")
probe1 = mdl.create_component("core/Probe")
probe2 = mdl.create_component("core/Probe")
subsystem = mdl.create_component("core/Empty Subsystem")

#
# Create ports for subsystem
#
sub_in = mdl.create_port(parent=subsystem,
                         direction=const.DIRECTION_IN,
                         kind=const.KIND_SP,
                         name="in")

sub_out = mdl.create_port(parent=subsystem,
                         kind=const.KIND_SP,
                         direction=const.DIRECTION_OUT,
                         name="out")

sub_out1 = mdl.create_port(parent=subsystem,
                           kind=const.KIND_SP,
                           direction=const.DIRECTION_OUT,
                           name="out1")
#
# Create components inside subsystem
#
sub_sum = mdl.create_component("core/Sum", parent=subsystem)
sub_const = mdl.create_component("core/Constant", parent=subsystem)
sub_gain = mdl.create_component("core/Gain", parent=subsystem)
sub_j = mdl.create_junction(kind=const.KIND_SP, parent=subsystem)

#
# Connect everything
#
mdl.create_connection(mdl.term(constant, "out"),
                      mdl.term(subsystem, "in"))

mdl.create_connection(sub_in,
                      mdl.term(sub_sum, "in"))

mdl.create_connection(mdl.term(sub_const, "out"),
                      mdl.term(sub_sum, "in1"))

mdl.create_connection(mdl.term(sub_sum, "out"),
                      sub_j)

mdl.create_connection(sub_j,
                      mdl.term(sub_gain, "in"))

mdl.create_connection(mdl.term(sub_gain, "out"),
                      sub_out)

mdl.create_connection(sub_j, sub_out1)

mdl.create_connection(mdl.term(subsystem, "out"),
                      mdl.term(probe1, "in"))

mdl.create_connection(mdl.term(subsystem, "out1"),
                      mdl.term(probe2, "in"))

#
# Export C code
#
output_dir = os.path.join(
    os.path.dirname(os.path.realpath(__file__)),
    "c_export"
)

mdl.export_c_from_model(output_dir)

mdl.close_model()





出力


export_c_from_selection ( comp_handles , output_dir )

バージョン 1.10.1 以降では非推奨: この関数はサポートされておらず、エラーが発生します。 サブシステムからのエクスポート その代わり。

選択したコンポーネントから C コードをエクスポートします。C コード エクスポーターはまだベータ段階です。

注記

この関数はハンドラーでは使用できません。

パラメータ:
  • comp_handles (リスト) – コンポーネント項目ハンドルオブジェクトのリスト。

  • output_dir ( str ) – コードがエクスポートされるディレクトリへのパス

戻り値:

なし

昇給

例外-

export_c_from_subsystem ( comp_handle , output_dir = None )

指定されたサブシステムから C コードをエクスポートします。C コード エクスポーターはまだベータ段階です。

注記

この関数はハンドラーでの使用はお勧めしません。

パラメータ:
  • comp_handle ( ItemHandle ) – コンポーネント項目ハンドルオブジェクト。

  • output_dir ( str ) – コードがエクスポートされるディレクトリへのパス

戻り値:

なし

昇給
  • SchApiException -次のいずれかが発生した場合

  • 指定されたItemHandleはコンポーネントではありません。

  • コンポーネントはアトミックコンポーネントです。

  • コンポーネントが見つからない場合は SchApiItemNotFoundException が発生します。

例:

#
# Demonstrate use of export_c_from_subsystem function.
#
from typhoon.api.schematic_editor import SchematicAPI
from typhoon.api.schematic_editor import const

mdl = SchematicAPI()
mdl.create_new_model(name="export_example")

#
# Create components on Root
#
constant = mdl.create_component("core/Constant")
probe1 = mdl.create_component("core/Probe")
probe2 = mdl.create_component("core/Probe")
subsystem = mdl.create_component("core/Empty Subsystem")

#
# Create ports for subsystem
#
sub_in = mdl.create_port(parent=subsystem,
                         direction=const.DIRECTION_IN,
                         kind=const.KIND_SP,
                         name="in")

sub_out = mdl.create_port(parent=subsystem,
                         kind=const.KIND_SP,
                         direction=const.DIRECTION_OUT,
                         name="out")

sub_out1 = mdl.create_port(parent=subsystem,
                           kind=const.KIND_SP,
                           direction=const.DIRECTION_OUT,
                           name="out1")
#
# Create components inside subsystem
#
sub_sum = mdl.create_component("core/Sum", parent=subsystem)
sub_const = mdl.create_component("core/Constant", parent=subsystem)
sub_gain = mdl.create_component("core/Gain", parent=subsystem)
sub_j = mdl.create_junction(kind=const.KIND_SP, parent=subsystem)

#
# Connect everything
#
mdl.create_connection(mdl.term(constant, "out"),
                      mdl.term(subsystem, "in"))

mdl.create_connection(sub_in,
                      mdl.term(sub_sum, "in"))

mdl.create_connection(mdl.term(sub_const, "out"),
                      mdl.term(sub_sum, "in1"))

mdl.create_connection(mdl.term(sub_sum, "out"),
                      sub_j)

mdl.create_connection(sub_j,
                      mdl.term(sub_gain, "in"))

mdl.create_connection(mdl.term(sub_gain, "out"),
                      sub_out)

mdl.create_connection(sub_j, sub_out1)

mdl.create_connection(mdl.term(subsystem, "out"),
                      mdl.term(probe1, "in"))

mdl.create_connection(mdl.term(subsystem, "out1"),
                      mdl.term(probe2, "in"))

#
# Export C code
#
output_dir = os.path.join(
    os.path.dirname(os.path.realpath(__file__)),
    "c_export"
)

mdl.export_c_from_subsystem(subsystem, output_dir)

mdl.close_model()

出力


export_library ( output_fileresource_paths = ()dependency_paths = ()lock_top_level_components = Trueexclude_from_locking = ()encrypt_library = Trueencrypt_resource_files = Trueexclude_from_encryption = () )

指定された出力ファイルパスにライブラリをエクスポートします。コアモデルはscm.core.Libraryオブジェクトである必要があります。

パラメータ:
  • output_file ( str ) – ライブラリをエクスポートするパス(.atlib が自動的に追加されます)

  • resource_paths (タプル) – このライブラリをエクスポートするために必要なリソースパスのタプル

  • dependency_paths ( tuple ) – このライブラリをエクスポートするために必要な依存パスのタプル

  • lock_top_level_components ( bool ) – True または False

  • exclude_from_locking ( tuple ) – トップレベルのコンポーネントロックプロセスで除外されるコンポーネントfqnのタプル

  • encrypt_library ( bool ) – True または False

  • encrypt_resource_files ( bool ) – True または False

  • exclude_from_encryption (タプル) – 暗号化プロセスで除外されるリソースパスのタプル

戻り値:

ブール

例:

#
# Demonstrate use of export_library function.
#

from typhoon.api.schematic_editor import SchematicAPI

mdl = SchematicAPI()

directory_path = os.path.join(
    os.path.dirname(os.path.realpath(__file__)),
    "export_lib")
lib_path = os.path.join(directory_path, "example_library.tlib")
atlib_directory_path = os.path.join(directory_path, "export_atlib")
atlib_path = os.path.join(atlib_directory_path, "export_lib")

if not os.path.exists(directory_path):
    os.makedirs(directory_path)
if not os.path.exists(atlib_directory_path):
    os.makedirs(atlib_directory_path)

lib_name = "Example Library"

mdl.create_library_model(
    lib_name,
    lib_path
)

#
# Create basic components, connect them and add them to the library
#
category = mdl.create_component("core/Category", name="CATEGORY")
s1 = mdl.create_component("core/Subsystem", parent=category, name="S1")
r = mdl.create_component("core/Resistor", parent=s1, name="R1")
c = mdl.create_component("core/Capacitor", parent=s1, name="C1")

s2 = mdl.create_component("core/Subsystem", parent=category, name="S2")
s3 = mdl.create_component("core/Subsystem", parent=category, name="S3")

con = mdl.create_connection(mdl.term(c, "n_node"),
                            mdl.term(r, "p_node"))
con1 = mdl.create_connection(mdl.term(c, "p_node"),
                             mdl.term(r, "n_node"))

#
# Export the library with basic settings
#

mdl.export_library(atlib_path, resource_paths=(),
                   lock_top_level_components=True,
                   exclude_from_locking=["S1"],
                   encrypt_library=True,
                   encrypt_resource_files=True,
                   exclude_from_encryption=())

出力


export_model_to_json ( output_dir = Nonerecursion_strategy = None )

モデルをJSON表現にエクスポートします。

パラメータ:
  • output_dir ( str ) – 出力ディレクトリフォルダへのパス。パスが指定されていない場合は、ファイルはターゲットファイルフォルダに送信されます。

  • recursion_strategy ( str ) – 階層モデルのトラバーサルを指定する定数。「Schematic API定数」で定義されている定数RECURSE_*が想定されています。

例:

# # export_model_to_json関数の使い方を説明します。 # from typhoon.api.schematic_editor SchematicAPIインポートする typhoon.api.schematic_editor import const output_dir = os.path.join ( os.path.dirname ( os.path.realpath ( __ file__ ) ) , " export_to_json " ) # #モデルロード# model_path = os.path.join ( output_dir , " rlc_circuit.tse " ) mdl = SchematicAPI ( ) mdl.load ( model_path ) # # jsonエクスポート# mdl.export_model_to_json ( ) mdl.close_model ( )





出力


find_connections ( connectable_handle1 , connectable_handle2 = None )

接続されているすべての接続ハンドルを返します 接続可能なハンドル1.

もし 接続可能なハンドル2 も指定されている場合は、共有接続(接続しているもの)のハンドルを返します。 接続可能なハンドル1 そして 接続可能なハンドル2 直接。

パラメータ:
  • connectable_handle1 ( ItemHandle ) – ConnectableMixin ハンドル。

  • connectable_handle2 ( ItemHandle ) – 他の接続可能なハンドル。

戻り値:

接続ハンドルのリスト。

昇給

一方または両方の接続可能オブジェクトが見つからない場合は、SchApiItemNotFound が発生します。

例:

#
# Demonstrate find_connections function.
#
from typhoon.api.schematic_editor import SchematicAPI
from typhoon.api.schematic_editor import const

mdl = SchematicAPI()
mdl.create_new_model()

const1 = mdl.create_component("core/Constant", name="Constant 1")
junction = mdl.create_junction(kind=const.KIND_SP, name="Junction 1")
probe1 = mdl.create_component("core/Probe", name="Probe 1")
probe2 = mdl.create_component("core/Probe", name="Probe 2")
con1 = mdl.create_connection(mdl.term(const1, "out"), junction)
con2 = mdl.create_connection(junction, mdl.term(probe1, "in"))
con3 = mdl.create_connection(junction, mdl.term(probe2, "in"))

#
# find_connections called with junction as connectable will return all three
# connections.
#
for connection_handle in mdl.find_connections(junction):
    print(connection_handle)

#
# To get only connection which connects junction and "Probe 2"
# find_connections is called with second parameter specified.
#
print("find_connection() specified with both connectables.")
for connection_handle in mdl.find_connections(junction,
                                              mdl.term(probe2, "in")):
    print(connection_handle)
    
mdl.close_model()

出力

接続: Connection3 接続: Connection1 接続: Connection2 両方の接続可能オブジェクトで find_connection() が指定されました。 接続: Connection3
静的 fqn ( *引数)

提供された複数の引数を、FQN セパレータを使用して結合します。

パラメータ:

*args – 可変数の文字列引数。

戻り値:

結合された文字列。

例:

# # fqn関数の使い方を説明します。 #から typhoon.api.schematic_editor SchematicAPIインポートします。mdl = SchematicAPI () mdl.create_new_model () parent_name = "サブシステム1"コンポーネント名= "抵抗1" comp_fqn = mdl.fqn ( parent_name , component_name ) print ( comp_fqn ) mdl.close_model ( )

出力

サブシステム1.抵抗器1
get_available_library_components ( library_name = '' , context = 'real_time' )

指定されたライブラリから利用可能なコンポーネント名を反復的に返します。 ライブラリ名.

ライブラリ名を省略すると、利用可能なすべてのライブラリが検索されます。

パラメータ:
  • library_name ( str ) – 利用可能なライブラリの名前

  • 名前。 (コンポーネント)

戻り値:

利用可能なライブラリ コンポーネント名を「library_name/component name」の形式で反復処理します。

昇給
  • SchApiException ライブラリが明示的に指定され

  • 存在しません。

例:

#
# Demonstrate use of get_available_library_components.
#

from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()

# Get component names from all libraries.
comp_names = tuple(mdl.get_available_library_components())

# Print component names from aquired names (up to 10 names).
print("Some component names are (up-to 10): {0}".format(comp_names[:10]))

# Try with explicitly specified library.

# Determine path to the library.
directory, __ = os.path.split(os.path.realpath(__file__))
lib_path = os.path.join(directory, "custom_lib")

# Add library path and reload library to be able to use added library.
mdl.add_library_path(lib_path)
mdl.reload_libraries()

# Print components from added library.
comp_names2 = tuple(mdl.get_available_library_components(library_name="my_lib"))
msg = "Here are some component names from specified library: {0}"
print(msg.format(comp_names2[:10]))

mdl.remove_library_path(lib_path)
mdl.reload_libraries()

mdl.close_model()

出力

コンポーネント名の一部は次のとおりです (最大 10 個): ('core/Constant Impedance Load'、'core/VBR Variable Load'、'core/Variable Load (Generic) UI'、'core/Variable Load (Generic)'、'core/Wind Power Plant (Switching)'、'core/Wind Power Plant (Average)'、'core/Wind Power Plant (Generic) UI'、'core/Wind Power Plant (Generic)'、'core/PV Plant (Switching)'、'core/PV Plant (Average)') 指定されたライブラリからのコンポーネント名の一部は次のとおりです: ('my_lib/CustomComponent'、)
get_breakpoints ( item_handle )

指定された項目ハンドルのブレークポイント座標のリストを返します。

パラメータ:

item_handle ( ItemHandle ) – アイテムハンドル。

戻り値:

リスト

昇給

指定された項目が見つからない場合は SchApiItemNotFoundException が発生します。

例:

#
# Demonstrate use of get_terminal_sp_type and get_terminal_sp_type_value.
#
from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()

const = mdl.create_component("core/Constant")
probe = mdl.create_component("core/Probe")
connection = mdl.create_connection(
    mdl.term(const, "out"),
    mdl.term(probe, "in"),
    breakpoints=[(100, 200), (100, 0)]
)

breakpoints = mdl.get_breakpoints(connection)
print("Breakpoints: {}".format(breakpoints))

出力

ブレークポイント: [[100, 200], [100, 0]]
get_calculated_terminal_position ( item_handle )

親コンポーネントの中心点を基準とした端子の X 値と Y 値を取得します。

パラメータ:

item_handle ( ItemHandle ) – ポートまたは端末のアイテムハンドル。

戻り値:

計算された位置座標はリスト形式[x, y]で表されます

昇給
  • 指定された項目が見つからない場合は SchApiItemNotFoundException が発生します。

  • 指定されたアイテムタイプが有効でない場合、SchApiException が発生します。

例:

#
# Demonstrate use of the get_calculated_terminal_position function.
#
from typhoon.api.schematic_editor import SchematicAPI
from typhoon.api.schematic_editor import const

mdl = SchematicAPI()
mdl.create_new_model()

# Create one component on model root level.
sub1 = mdl.create_component("core/Subsystem", name="Subsystem1")

# A port called P1 is automatically created and the terminal
# position is set to ('left', 'auto')
p1 = mdl.get_item("P1", parent=sub1, item_type=const.ITEM_PORT)

x_old, y_old = mdl.get_calculated_terminal_position(p1)
print("Calculated terminal position for port P1:")
print(f"x = {x_old}, y = {y_old}")

# Add another port to the left side and verify the new position
print("\nAdding new port to the left side\n")
mdl.create_port("P3", parent=sub1)

x_new, y_new = mdl.get_calculated_terminal_position(p1)
print(f"New calculated position for P1:")
print(f"x = {x_new}, y = {y_new}")

出力

ポート P1 の計算された端子位置: x = -24、y = 0 左側に新しいポートを追加 P1 の新しい計算された位置: x = -24、y = -8.0
get_comment_text (コメントハンドル)

指定されたコメント ハンドルのコメント テキストを取得します。

パラメータ:

comment_handle ( ItemHandle ) – コメントのアイテムハンドル。

戻り値:

str

昇給

comment_handle が - コンポーネントのハンドルではない場合、SchApiException が発生します

例:

#
# Demonstrate use of get_terminal_sp_type and get_terminal_sp_type_value.
#
from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()

comment1 = mdl.create_comment("This is a comment")
print("Comment is: '{0}'.".format(mdl.get_comment_text(comment1)))

出力

コメントは「これはコメントです」です。
get_compiled_model_file ( sch_path )

回路図の.tseファイルパスに基づいて、.cpdファイルへのパスを返します。この関数はモデルをコンパイルせず、 compile()関数によって生成されたファイルへのパスを返すだけです。

パラメータ:

sch_path (文字列) – .tse回路図ファイルへのパス

戻り値:

生成される .cpd ファイルへのパス。

戻り値の型:

例:

# # get_compiled_model_file関数の使い方を示します。 #から typhoon.api.schematic_editor import model typhoon.api.hil as hil #任意tse回路ファイルsch = " C : \\ Users \\ User1 \\ Desktop \\ model.tse " cpd = model.get_compiled_model_file ( sch ) model.load ( sch ) model.compile ( ) hil.load_model ( cpd )
get_component_type_name ( comp_handle )

コンポーネント タイプ名を返します。

パラメータ:

comp_handle ( ItemHandle ) – コンポーネントハンドル。

戻り値:

コンポーネント タイプ名 (文字列)。コンポーネントにタイプがない場合は空の文字列 (例: コンポーネントがユーザー サブシステム)。

昇給

指定されたコンポーネントが見つからない場合は SchApiItemNotFoundException が発生します。

例:

#
# Demonstrate use of get_component_type_name function.
#

from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()

r = mdl.create_component("core/Resistor")
core_coupling = mdl.create_component("Single Phase Core Coupling")
sub = mdl.create_component("core/Subsystem")


for comp_handle in (r, core_coupling, sub):
    print("Component '{0}' has type '{1}'.".format(
        mdl.get_name(comp_handle),
        mdl.get_component_type_name(comp_handle)
    ))

出力

コンポーネント「R1」のタイプは「pas_resistor」です。コンポーネント「コアカップリング1」のタイプは「単相コアカップリング」です。コンポーネント「サブシステム1」のタイプは「」です。
get_connectable_direction ( connectable_handle )

接続可能なオブジェクトの方向を返します。

ConnectableMixin はターミナルまたはポートのいずれかになります。方向は DIRECTION_IN または DIRECTION_OUT のいずれかです。

パラメータ:

connectable_handle ( ItemHandle ) – 端末ハンドル。

戻り値:

str

昇給

SchApiException は connectable_handle がConnectableMixin 型はない場合に発生します –

例:

# # get_connectable_direction関数の使用例#から typhoon.api.schematic_editor SchematicAPIインポートします。mdl = SchematicAPI ( ) mdl.create_new_model () const = mdl.create_component ( " core/Constant"  name = "Constant 1" ) print ( mdl.get_connectable_direction ( mdl.term ( const , " out " ))) probe = mdl.create_component ( " core / Probe "  name = " Probe 1 " ) print ( mdl.get_connectable_direction ( mdl.term ( probe , " in " ) ) ) mdl.close_model ( )

出力

外に出て
get_connectable_kind ( connectable_handle )

接続可能なオブジェクトの種類を返します。

ConnectableMixin はターミナル、ジャンクション、ポートのいずれかになります。Kind は KIND_SP または KIND_PE のいずれかです。

パラメータ:

connectable_handle ( ItemHandle ) – 端末ハンドル。

戻り値:

str

昇給

SchApiException は connectable_handle がConnectableMixin 型はない場合に発生します –

例:

# # get_connectable_kind関数の使用例#から typhoon.api.schematic_editor SchematicAPIインポートします。mdl = SchematicAPI ( ) mdl.create_new_model () const = mdl.create_component ( " core/Constant"  name = "Constant 1" ) print ( mdl.get_connectable_kind ( mdl.term ( const , " out" ) )) resistance = mdl.create_component ( " core / Resistor "  name = "Resistor 1 " ) print ( mdl.get_connectable_kind ( mdl.term ( resistor , " p_node " ) ) ) mdl.close_model ( )

出力

スペペ
get_connected_items ( item_handle )

指定されたアイテムに接続されたアイテムハンドルのコレクションを返します。 アイテムハンドルアイテム ハンドルは、「接続可能なオブジェクト」(ターミナル、ジャンクション、ポート、タグ) またはターミナルを独自に保持するコンポーネントへの参照になります。

パラメータ:

item_handle ( ItemHandle ) – 回路図アイテムへの参照。

戻り値:

接続されたアイテムのハンドルのコレクション。

例:

#
# Demonstrate use of get_connected_items function
#
from typhoon.api.schematic_editor import SchematicAPI
from typhoon.api.schematic_editor.const import KIND_SP

mdl = SchematicAPI()
mdl.create_new_model()

# Create scheme.
const1 = mdl.create_component("core/Constant", name="Constant1")
const2 = mdl.create_component("core/Constant", name="Constant2")
junction = mdl.create_junction(kind=KIND_SP)
sum1 = mdl.create_component("core/Sum", name="Sum1")
probe1 = mdl.create_component("core/Probe", name="Probe1")
probe2 = mdl.create_component("core/Probe", name="Probe2")

con1 = mdl.create_connection(mdl.term(const1, "out"), junction)
con2 = mdl.create_connection(junction, mdl.term(probe2, "in"))
con3 = mdl.create_connection(junction, mdl.term(sum1, "in"))
con4 = mdl.create_connection(mdl.term(const2, "out"), mdl.term(sum1, "in1"))
con5 = mdl.create_connection(mdl.term(sum1, "out"), mdl.term(probe1, "in"))

# Get items connected to component const1.
for item in mdl.get_connected_items(const1):
    print(mdl.get_name(item))

mdl.close_model()

出力

プローブ2 合計1
get_conv_prop ( prop_handle , value = None )

提供された値を、プロパティ型指定で指定された型に変換します。値が指定されていない場合は、代わりにプロパティの表示値が使用されます。

パラメータ:
  • prop_handle ( ItemHandle ) – プロパティハンドル。

  • value ( str ) – 変換する値。

戻り値:

Python オブジェクト、変換された値。

昇給

値を変換できない場合は SchApiException が発生します。

例:

# # get_conv_prop の使い方を説明します。 #から typhoon.api.schematic_editor SchematicAPIインポートしますmdl = SchematicAPI () mdl.create_new_model () r = mdl.create_component ( " core/Resistor" , name = " R1 " ) print ( mdl.get_conv_prop ( mdl.prop ( r , " resistance" ) , " 234 " ) ) mdl.close_model ( )

出力

234.0
get_description ( item_handle )

指定されたアイテムの説明を返します アイテムハンドル.

パラメータ:

item_handle ( ItemHandle ) – ItemHandle オブジェクト。

戻り値:

商品の説明。

昇給
  • アイテムが見つからない場合は SchApiItemNotFoundException が発生します。

  • item_handle が指すアイテムが存在しない場合の SchApiException

  • 説明属性がないか、指定されたアイテムハンドルが無効です。

例:

# # set_description関数とget_description関数の使い方を説明します。 # from typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # # コンポーネントにマスクを作成し、 set_description を使用してマスクの説明を設定します。 # sub = mdl . create_component ( "core/Subsystem" , name = "Subsystem 1" ) mask = mdl . create_mask ( sub ) mdl . set_description ( mask , "Mask description content." ) # # ここで、get_description を使用して、以前に設定した説明を取得し、出力します。 # description = mdl . get_description ( mask ) print ( "Mask description is ' {0} '." . format ( description )) mdl . close_model ()

出力

マスクの説明は「マスクの説明内容」です。
get_flip ( item_handle )

アイテムの反転ステータスを取得します( アイテムハンドル)。

パラメータ:

item_handle ( ItemHandle ) – アイテムハンドル。

戻り値:

いずれか1つ(「flip_none」、「flip_horizontal」、「flip_vertical」、「flip_both」)

戻り値の型:

flip (文字列)

昇給
  • 指定された項目が見つからない場合は SchApiItemNotFoundException が発生します。

  • 指定されたアイテムタイプが有効でない場合、SchApiException が発生します。

例:

#
# Demonstrate use of get_flip and set_flip functions.
#
from typhoon.api.schematic_editor import SchematicAPI
from typhoon.api.schematic_editor import const

mdl = SchematicAPI()
mdl.create_new_model()

# Create one component on model root level.
sub1 = mdl.create_component("core/Subsystem", name="Subsystem1")

print(f"Current rotation: {mdl.get_flip(sub1)}")
mdl.set_flip(sub1, const.FLIP_HORIZONTAL)
print(f"New rotation: {mdl.get_flip(sub1)}")

出力

現在の回転: flip_none 新しい回転: flip_horizontal
get_fqn (アイテムハンドル)

指定された項目の完全修飾名を取得します。 アイテムハンドル.

パラメータ:

item_handle ( ItemHandle ) – アイテムハンドル。

戻り値:

完全修飾名を文字列として指定します。

例:

# # get_fqn API関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () r = mdl . create_component ( "core/Resistor" , name = "R1" ) print ( mdl . get_fqn ( r )) sub = mdl . create_component ( "core/Subsystem" , name = "Sub1" ) l = mdl . create_component ( "core/Inductor" , name = "L1" , parent = sub ) print ( mdl . get_fqn ( l )) # 名前の変更後、fqn も異なる必要があります。 mdl . set_name ( l , "New name" ) print ( "New fqn for component l is ' {0} '." . format ( mdl . get_fqn ( l ))) mdl . close_model ()

出力

R1 Sub1.L1 コンポーネント l の新しい fqn は 'Sub1.New name' です。
get_handler_code ( item_handle , handler_name )

ハンドラのハンドラコードを返します ハンドラー名 指定された項目に定義される アイテムハンドル.

パラメータ:
  • item_handle ( ItemHandle ) – ItemHandle オブジェクト。

  • handler_name ( str ) – ハンドラー名 - Schematic API const モジュールの定数 HANDLER_*。

戻り値:

文字列としてのハンドラー コード。

昇給
  • SchApiItemNotFound アイテムが見つからないハンドラーが見つからない場合 –

  • 名前で見つけられる

  • SchApiException アイテムハンドルが無効、またはハンドラーコードが無効の場合 –

  • 指定された項目から読み取ることができません。

例:

#
# Demonstrate use of set_handler_code() and get_handler_code().
#
from typhoon.api.schematic_editor import SchematicAPI
from typhoon.api.schematic_editor.const import HANDLER_MASK_INIT, \
    HANDLER_PROPERTY_VALUE_CHANGED, WIDGET_COMBO

mdl = SchematicAPI()
mdl.create_new_model()

sub = mdl.create_component("core/Subsystem", name="Subsystem 1")

#
# Create mask and set MASK_INIT handler code.
#
mask_handle = mdl.create_mask(sub)

handler_code = """
import time
# Just display time.
print(f"Current time is '{time.asctime()}'.")
"""

mdl.set_handler_code(mask_handle, HANDLER_MASK_INIT, handler_code)

# Get handler code for the mask mask_handle.
retrieved_handler_code = mdl.get_handler_code(mask_handle, HANDLER_MASK_INIT)
print(f"Retrieved mask init handler code is {retrieved_handler_code}")

#
# Create one property on mask and set its PROPERTY_VALUE_CHANGED handler.
#
prop1 = mdl.create_property(
    mask_handle, name="prop_1", label="Property 1",
    widget=WIDGET_COMBO,
    combo_values=("Choice 1", "Choice 2", "Choice 3"),
    tab_name="First tab"
)

# Set property_value_changed handler on property.
prop_value_changed_handler_code = """
if new_value == "Choice 1":
    print("It's a first choice.")
elif new_value == "Choice 2":
    print("It's a second choice.")
elif new_value == "Choice 3":
    print("It's a third choice")
"""
mdl.set_handler_code(prop1, HANDLER_PROPERTY_VALUE_CHANGED, prop_value_changed_handler_code)

# Get handler code for a property prop1.
retrieved_handler_code = mdl.get_handler_code(prop1, HANDLER_PROPERTY_VALUE_CHANGED)
print(f"Retrieved property value changed handler code for prop1 is {retrieved_handler_code}")

mdl.close_model()

出力

Retrieved mask init handler code is 
import time
# Just display time.
print(f"Current time is '{time.asctime()}'.")

Retrieved property value changed handler code for prop1 is 
if new_value == "Choice 1":
    print("It's a first choice.")
elif new_value == "Choice 2":
    print("It's a second choice.")
elif new_value == "Choice 3":
    print("It's a third choice")
get_hw_property ( prop_name )

指定されたハードウェアプロパティの値を取得します。 プロパティ名 モデルの現在の構成に対して。

パラメータ:

prop_name ( str ) – ハードウェアプロパティの完全修飾名。

戻り値:

指定されたハードウェア プロパティの値。

昇給
  • SchApiItemNotFoundException 指定されたハードウェアプロパティが見つからない場合

  • 存在します。

例:

# # get_hw_property関数の使い方を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () print ( "アナログ入力の数は ' {0} ' です。" . format ( mdl . get_hw_property ( "io.analog_inputs" ))) mdl . close_model ()

出力

アナログ入力の数は「16」です。
get_hw_settings ( )

モデル構成を変更せずにデバイスからハードウェア設定を取得します。

注記

この関数はハンドラーでは使用できません。

パラメータ:

なし

戻り値:

(str, int, int) 型のタプル (hw_product_name, hw_revision, configuration_id)。例えば ('HIL604', 3, 1) の場合、文字列 'HIL604' では文字列 'HIL' とモデル番号の間にスペースがないことに注意してください。

自動検出に失敗した場合は、 間違い が返されます。

例:

#
# Demonstrate use of get_hw_settings.
#
from typhoon.api.schematic_editor import SchematicAPI

mdl = SchematicAPI()
mdl.create_new_model()

hw_sett = mdl.get_hw_settings()

if hw_sett:
    print("Hardware (product, revision, configuration) = {0}.".format(hw_sett))
else:
    print("Hardware settings read failed, maybe HIL device is not connected.")

mdl.close_model()
get_icon_drawing_commands ( item_handle )

指定された項目からアイコン描画コマンドを返します。

パラメータ:

アイテムハンドル

戻り値:

描画コマンド。

昇給
  • アイテムが見つからない場合は SchApiItemNotFoundException が発生します。

  • SchApiException アイテムハンドルが無効の場合、または次の場合

  • 対象アイテムは描画コマンド設定をサポートしていません –

  • 1位。

例:

#
# Demonstrate use of get_icon_drawing_commands and set_icon_drawing_commands.
#

from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()

# Create subsystem and mask it.
sub = mdl.create_component("core/Subsystem", name="Subsystem 1")
mask = mdl.create_mask(sub)

# Define icon drawing commands.
icon_drawing_commands = """
image('my_image.png')
"""

# Set mask icon drawing commands.
mdl.set_icon_drawing_commands(mask, icon_drawing_commands)

# Aquire current icon drawwing commands.
mask_icon_drawing_commands = mdl.get_icon_drawing_commands(mask)
print("Icon drawing commands are: {0}".format(mask_icon_drawing_commands))

mdl.close_model()

出力

アイコン描画コマンドは次のとおりです: image('my_image.png')
get_item ( name , parent = None , item_type = 'unknown' )

名前の付いたアイテムのアイテムハンドルを取得します 名前 親から 親ハンドル.

注記

オプションです。指定されていない場合はルート スキームが使用されます。

注記

アイテムタイプ はオプションパラメータで、ハンドルを取得するアイテムの種類を指定するために使用できます。アイテムの種類を定義する定数を受け入れます( 回路図API定数)

パラメータ:
  • name ( str ) – アイテム名。

  • ( ItemHandle ) – 親ハンドル。

  • item_type ( str ) – アイテムタイプ定数。

戻り値:

見つかった場合はアイテム ハンドル (ItemHandle)、それ以外の場合は None。

昇給
  • SchApiException

  • 1. 複数のアイテムが見つかった場合例えば

  • コンポーネントには、コンポーネントと全く同じ名前のサブコンポーネントがあります

  • ターミナル。その場合は、あいまいさをなくすためにitem_typeを指定してください。

  • 2. ロックされたコンポーネントからのアイテムが要求された場合。

例:

# # get_item関数の使い方を説明します。 #から typhoon.api.schematic_editor SchematicAPIインポートする typhoon.api.schematic_editor import const mdl = SchematicAPI () mdl . create_new_model () # ルート レベルにコンポーネントを 1 つ作成しますr = mdl . create_component ( "core/Subsystem" , name = "R1" ) # get_item を使用してコンポーネントへのハンドルを取得しますr2 = mdl . get_item ( name = "R1" ) # 内部にいくつかの項目を含むサブシステムを作成します sub1 = mdl . create_component ( "core/Subsystem" , name = "Sub 1" ) c = mdl . create_component ( "core/Capacitor" , name = "C1" , parent = sub1 ) port1 = mdl . create_port ( name = "Port 1" , parent = sub1 ) port2 = mdl . create_port ( name = "Port 2" , parent = sub1 ) # # フィルタリングによって get_item を実行します。フィルタリングされていない呼び出しでは例外が発生します。 #サブシステム コンポーネントには、作成されたポートと同じ名前の端末が存在するためです。 # port1_terminal_handle = mdl . get_item ( "Port 1" , parent = sub1 , item_type = const . ITEM_TERMINAL ) print ( port1_terminal_handle ) mdl . close_model ()

出力

端子: サブ1.ポート1
get_item_visual_properties ( item_handle )

指定されたアイテムで利用可能なビジュアルプロパティを返します。サポートされているアイテムタイプと返されるプロパティは次のとおりです。

コンポーネント: 位置、回転、反転、サイズ タグ: 位置、回転、反転、サイズ ポート: 位置、回転、反転、terminal_position、calulated_terminal_position ターミナル: termin_position、calulated_terminal_position

パラメータ:

item_handle ( ItemHandle ) – 回路図アイテムのハンドル。

戻り値:

視覚的な特性を持つ辞書。

昇給
  • アイテムが見つからない場合は SchApiItemNotFoundException が発生します。

  • 渡された item_handle が無効な場合、SchApiException が発生します。

例:

#
# Demonstrate use of get_item_visual_properties and set_item_visual_properties functions.
#
from typhoon.api.schematic_editor import SchematicAPI
from typhoon.api.schematic_editor import const

mdl = SchematicAPI()
mdl.create_new_model()

# Create one component on model root level.
sub1 = mdl.create_component("core/Subsystem", name="Subsystem1")

# Get the handle to port P1 inside Subsystem1
p1 = mdl.get_item(name="P1", parent=sub1, item_type=const.ITEM_PORT)

print("Before changes")
print("--------------")

print(f"Subsystem1 visual properties:")
# Get Subsystem1 visual properties
sub1_visual_props = mdl.get_item_visual_properties(sub1)
for prop_name, prop_value in sub1_visual_props.items():
    print(f" {prop_name} = {prop_value}")

# Get P1 visual properties
print(f"\nPort P1 visual properties:")
p1_visual_props = mdl.get_item_visual_properties(p1)
for prop_name, prop_value in p1_visual_props.items():
    print(f" {prop_name} = {prop_value}")

# Set a new size and rotation for Subsystem1.
sub1_new_props = {"size": (128, 128), "rotation": "right"}
mdl.set_item_visual_properties(sub1, sub1_new_props)

# Set a new terminal_position for port P1.
p1_new_props = {"terminal_position": ("top", "auto")}
mdl.set_item_visual_properties(p1, p1_new_props)

print("\nAfter changes")
print("--------------")

print(f"Subsystem1 visual properties:")
# Get Subsystem1 visual properties
sub1_visual_props = mdl.get_item_visual_properties(sub1)
for prop_name, prop_value in sub1_visual_props.items():
    print(f" {prop_name} = {prop_value}")

# Get P1 visual properties
print(f"\nPort P1 visual properties:")
p1_visual_props = mdl.get_item_visual_properties(p1)
for prop_name, prop_value in p1_visual_props.items():
    print(f" {prop_name} = {prop_value}")

出力

変更前 -------------- サブシステム 1 ビジュアル プロパティ: 位置 = [8192, 8192] 回転 = 上 反転 = flip_none サイズ = [48, 48] ポート P1 ビジュアル プロパティ: 位置 = [7768, 8064] 回転 = 上 反転 = flip_none ターミナル位置 = ['left', 'auto'] computed_terminal_position = [-24, 0] 変更後 -------------- サブシステム 1 ビジュアル プロパティ: 位置 = [8192, 8192] 回転 = 右 反転 = flip_none サイズ = [128, 128] ポート P1 ビジュアル プロパティ: 位置 = [7768, 8064] 回転 = 上 反転 = flip_none ターミナル位置 = ['top', 'auto'] computed_terminal_position = [0, -64]
get_items (= Noneitem_type = None )

指定された親コンポーネントに含まれるすべてのアイテムのハンドルを返します。 ハンドル、オプションでタイプに基づいてアイテムをフィルタリング、 アイテムタイプ. アイテムタイプ 値は定数です。 回路図API定数 詳細については。

注記

プロパティと端子も親コンポーネントの子項目とみなされます。これらのコレクションを取得するには、 アイテムタイプ それぞれの定数に指定されます。

注記

親が指定されていない場合は、最上位スキームが親として使用されます。

注記

アイテムは再帰的に返されません。

パラメータ:
  • ( ItemHandle ) – 親コンポーネントのハンドル。

  • item_type ( str ) – アイテムの種類を指定する定数。指定されていない場合は、すべてのアイテムが含まれます。

戻り値:

アイテムハンドルのリスト。

昇給

SchApiException ロックされたコンポーネントからの項目が要求された場合。

例:

#
# Example demonstrates use of get_items function.
#
from typhoon.api.schematic_editor import SchematicAPI
from typhoon.api.schematic_editor import const

mdl = SchematicAPI()
mdl.create_new_model()

r = mdl.create_component("core/Resistor", name="R1")
vm = mdl.create_component("core/Voltage Measurement", name="vm1")
tag = mdl.create_tag(value="A", name="Tag 1")
sub1 = mdl.create_component("core/Subsystem", name="Subsystem 1")
inner_l = mdl.create_component("core/Inductor", parent=sub1,
                                 name="Inner inductor")
inner_port = mdl.create_port(name="Port 1", parent=sub1)
inner_sub = mdl.create_component("core/Subsystem",
                                   parent=sub1,
                                   name="Inner subsystem")

#
# As get_items was called without parent top level scheme items
# will be returned.
#
items = mdl.get_items()
for item in items:
    print(item)

#
# Following snippet demonstrates use of filtering with get_items
# function.
#
# Get all ports from subsystem referenced by sub1
items = mdl.get_items(parent=sub1, item_type=const.ITEM_PORT)
for item in items:
    print("Item is {0}.".format(item))
    print("Item name part is {0}.".format(mdl.get_name(item)))

#
# Get component terminals and properties.
#
prop_handles = mdl.get_items(parent=r, item_type=const.ITEM_PROPERTY)
print("Component '{0}' property handles are '{1}'.".format(mdl.get_name(r),
                                                         prop_handles))
term_handles = mdl.get_items(parent=r, item_type=const.ITEM_TERMINAL)
print("Component '{0}' terminal handles are '{1}'.".format(mdl.get_name(r),
                                                           term_handles))

mdl.close_model()

出力

コンポーネント: R1 マスクされたコンポーネント: vm1 タグ: タグ1 コンポーネント: サブシステム1 アイテムのポート: サブシステム1.P2。アイテム名部分はP2です。アイテムのポート: サブシステム1.P1。アイテム名部分はP1です。項目はポートです: サブシステム 1.ポート 1。項目名部分はポート 1 です。コンポーネント 'R1' プロパティ ハンドルは '[ItemHandle('property', '6eb193e3-316f-11f0-a2ee-56d8b9d8cbf8.6eb193e6-316f-11f0-b2b6-56d8b9d8cbf8', 'R1.resistance'), ItemHandle('property', '6eb193e3-316f-11f0-a2ee-56d8b9d8cbf8.6eb193e7-316f-11f0-905e-56d8b9d8cbf8', 'R1.param_set')]' です。コンポーネント「R1」の端末ハンドルは「[ItemHandle('terminal', '6eb193e3-316f-11f0-a2ee-56d8b9d8cbf8.6eb193e4-316f-11f0-83e8-56d8b9d8cbf8', 'R1.p_node'), ItemHandle('terminal', '6eb193e3-316f-11f0-a2ee-56d8b9d8cbf8.6eb193e5-316f-11f0-90d2-56d8b9d8cbf8', 'R1.n_node')]」です。
get_label ( item_handle )

指定されたアイテムのラベルを取得します アイテムハンドル.

パラメータ:

item_handle ( ItemHandle ) – アイテムハンドル。

戻り値:

アイテムラベルを文字列として指定します。

昇給
  • アイテムが見つからない場合は SchApiItemNotFoundException が発生します。

  • 指定された項目にラベルがない場合は SchApiException が発生します。

例:

# # get_labelとset_label関数の使い方を説明します。 # from typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () sub = mdl . create_component ( type_name = "core/Subsystem" ) prt = mdl . create_port ( name = "Port 1" , parent = sub ) # ポートラベルを設定します。 mdl . set_label ( prt , "Port 1 label" ) # ポートラベルを取得して出力します。 port_label = mdl . get_label ( prt ) print ( "ポートラベルは ' {0} ' です。" . format ( port_label )) mdl . close_model ()

出力

ポート ラベルは「ポート 1 ラベル」です。
get_library_paths ( )

ライブラリ検索パスのリストを取得します。

パラメータ:

なし

戻り値:

ユーザーライブラリパスのリスト

例:

#
# Demonstrate use of {add,remove}_library_path and reload_library functions.
#
# All the path operations are temporary for the current running session.
#

from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()

#
# Library file is located in directory 'custom_lib' one level above this
# example file.
#
directory, __ = os.path.split(os.path.realpath(__file__))
lib_path = os.path.join(directory, "custom_lib")

# Get all current library paths and remove them
old_paths = mdl.get_library_paths()
for path in old_paths:
    mdl.remove_library_path(path)

# Add library path and reload library to be able to use added library.
mdl.add_library_path(lib_path)
mdl.reload_libraries()

# Create components from loaded libraries.
comp = mdl.create_component("my_lib/CustomComponent")
print("Component is '{0}'.".format(comp))

comp2 = mdl.create_component("archived_user_lib/CustomComponent1")
print("Second component (from archived library) is '{0}'.".format(
    comp2
))

# Remove library from the path.
mdl.remove_library_path(lib_path)

# Add again the previous library paths
for path in old_paths:
    mdl.add_library_path(path)

mdl.close_model()

出力

コンポーネントは「masked_component: CustomComponent1」です。2番目のコンポーネント(アーカイブライブラリから)は「component: CustomComponent11」です。
get_library_resource_dir_path ( item_handle )

ライブラリのリソースファイルが期待される/検索されるディレクトリパスを取得します。パラメータitem_handleには、元のライブラリまで遡ることができる要素を指定します。

パラメータ:

item_handle ( ItemHandle ) – アイテムハンドルオブジェクト。

戻り値:

リソース ファイルが期待/検索されるディレクトリ パスを文字列として指定します。

昇給
  • SchApiException ライブラリが明示的に指定され

  • 存在しません。

例:

#
# Example demonstrates use of get_items function.
#
from typhoon.api.schematic_editor import SchematicAPI

mdl = SchematicAPI()
mdl.create_new_model()

# Core
r = mdl.create_component("core/Resistor")
resistance = mdl.prop(r, "resistance")
core_lib_rsrc_path = mdl.get_library_resource_dir_path(resistance)
print("Resource directory for core component is '{0}'.".format(core_lib_rsrc_path))

#
# Load user library.
# Library file is located in directory 'custom_lib' one level above this
# example file.
#
directory, __ = os.path.split(os.path.realpath(__file__))
lib_path = os.path.join(directory, "custom_lib")

# Add library path and reload library to be able to use added library.
mdl.add_library_path(lib_path)
mdl.reload_libraries()

# Create component from ordinary user library.
user_comp = mdl.create_component("my_lib/CustomComponent")
usr_rsrc_path = mdl.get_library_resource_dir_path(user_comp)
print("Resource directory for user defined library is '{0}'.".format(usr_rsrc_path))

# Create component from archived library.
user_comp2 = mdl.create_component("archived_user_lib/CustomComponent1")
usr2_rsrc_path = mdl.get_library_resource_dir_path(user_comp2)
print("Resource directory for archived user library is '{0}'.".format(usr2_rsrc_path))

# Remove library from the path.
mdl.remove_library_path(lib_path)

mdl.close_model()


出力

コアコンポーネントのリソースディレクトリは「C:\Users\build\AppData\Roaming\typhoon\THCC 2025.2」です。ユーザー定義ライブラリのリソースディレクトリは「C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\sch_api_examples\custom_lib」です。アーカイブされたユーザーライブラリのリソースディレクトリは「C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\sch_api_examples\custom_lib\archived_user_lib_rsrc」です。
get_mask ( item_handle )

指定されたコンポーネントのマスクを返します。 アイテムハンドル.

パラメータ:

item_handle ( ItemHandle ) – コンポーネントのItemHandle

戻り値:

マスク項目ハンドル (コンポーネント上に存在する場合) または [なし]。

昇給
  • SchApiException 渡された item_handle ( ItemHandle )

  • コンポーネントItemHandle 、またはコンポーネントがロックされているかどうか。

例:

# # 例では、get_mask関数の使用方法を示します。 #から typhoon.api.schematic_editor SchematicAPIインポートする typhoon.api.schematic_editor import const mdl = SchematicAPI () model_path = os . path . join ( os . path . dirname ( os . path . realpath ( __file__ )), "get_mask" , "get_mask.tse" ) mdl . load ( model_path ) subsystem_name = "Subsystem1" component_handle = mdl . get_item ( subsystem_name ) mask_handle = mdl . get_mask ( components_handle ) # マスクにプロパティを作成するmdl . create_property ( mask_handle , name = "m_prop_2" , label = "マスクプロパティ2" , widget = const.WIDGET_COMBO , combo_values = ( "選択肢1" , "選択肢2" , "選択肢3" ), tab_name = "最初のタブ" ) mdl.close_model ( )

出力


get_model_dependencies ( )

モデルの依存関係にあるファイル/ディレクトリのリストを返します。ファイルとディレクトリは文字列のリストとして返されます。これはモデルのコンパイルに影響を与えるデータを表します。モデル自体と依存ファイルが2回のコンパイル間で変更されていない場合、2回目のコンパイルはスキップされます。

パラメータ:

なし

戻り値:

ファイルまたはディレクトリ モデルを表す文字列のコレクションが依存します。

例:

#
# Demonstrate use of set_model_dependencies function
#
from typhoon.api.schematic_editor import SchematicAPI
from typhoon.api.schematic_editor.const import KIND_SP


# Create an example dependency files
with open("dependency1.csv", "w") as dependency_file:
    dependency_file.write("1,2,3\n")
    dependency_file.write("2,3,4")

with open("dependency2.csv", "w") as dependency_file:
    dependency_file.write("4,3,2\n")
    dependency_file.write("3,2,1")


# Create new model
mdl = SchematicAPI()
mdl.create_new_model()


# Create scheme.
mdl.create_component("core/Resistor")


# Set list of dependencies for model
mdl.set_model_dependencies(["dependency1.csv", "dependency2.csv"])


# Get list of dependencies for model
dependencies = mdl.get_model_dependencies()
print(f"Dependecies: {dependencies}")


# Remove dependency files to cleanup directory
os.remove("dependency1.csv")
os.remove("dependency2.csv")


# Close model
mdl.close_model()

出力

依存関係: ['dependency1.csv', 'dependency2.csv']
get_model_file_path ( )
パラメータ:

なし

戻り値:

モデルファイルパスを文字列で指定します(

モデルはまだ保存されていません。

例:

# # get_model_file_path関数の使い方を説明します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model ( name = "MyModel" ) # 現在のファイル パスを出力します。 print ( "保存前のモデル ファイル パスは ' {0} ' です。" . format ( mdl . get_model_file_path ())) mdl . save_as ( "model1.tse" ) print ( "保存後のモデル ファイル パスは ' {0} ' です。" . format ( mdl . get_model_file_path ())) mdl . close_model ()

出力

保存前のモデルファイルパスは「C:\Users\build\AppData\Roaming\typhoon\THCC 2025.2\MyModel.tse」です。保存後のモデルファイルパスは「C:\t_sw\build\sw_build\exported_src\api\build\doc_build\api_doc\model1.tse」です。
get_model_information ( )

モデル情報をキー値の形式で返します。

パラメータ:

なし

戻り値:

辞書、可能なキーは「モデル」、対応する値は

モデル名にもう 1 つのキーは「required_toolboxes」で、その値は現在のモデルに必要なツールボックスのリストです。

例:

#
# Demonstrate use of get_model_information function.
#

from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()

mdl.create_new_model(name="My sample model")

# Create some elements in a model.

# Power electronics part.
r = mdl.create_component("core/Resistor", name="Resistor 1")
vs = mdl.create_component("core/Voltage Source", name="Voltage source 1")
con1 = mdl.create_connection(mdl.term(r, "p_node"), mdl.term(vs, "p_node"))
con2 = mdl.create_connection(mdl.term(r, "n_node"), mdl.term(vs, "n_node"))

tph = mdl.create_component("core/Three Phase Inverter")
mdl.set_property_value(mdl.prop(tph, "fvd"), True)


# Signal processing part.
const1 = mdl.create_component("core/Constant", name="Constant 1")
mdl.set_property_value(mdl.prop(const1, "value"), 10)
const2 = mdl.create_component("core/Constant", name="Constant 2")
mdl.set_property_value(mdl.prop(const2, "value"), 20)
sum = mdl.create_component("core/Sum", name="Sum 1")
probe = mdl.create_component("core/Probe", name="Probe 1")
con3 = mdl.create_connection(mdl.term(const1, "out"), mdl.term(sum, "in"))
con4 = mdl.create_connection(mdl.term(const2, "out"), mdl.term(sum, "in1"))
con5 = mdl.create_connection(mdl.term(sum, "out"), mdl.term(probe, "in"))

model_info = mdl.get_model_information()

print("Model name is '{0}'.".format(model_info["model_name"]))
print("Model uses following toolboxes: '{0}'.".format(model_info["required_toolboxes"]))

mdl.close_model()

出力

モデル名は「My sample model」です。モデルは次のツールボックスを使用します: '['Power Loss Calculation']'。
get_model_property_value ( prop_code_name )

指定されたモデルプロパティ(モデル構成)の戻り値。モデルプロパティは、回路図エディタの回路図設定ダイアログで、必要な設定オプションの上にツールヒントが表示されたときに表示されるコード名で識別されます。

パラメータ:

prop_code_name ( str ) – モデルプロパティのコード名。

戻り値:

モデル プロパティの値。

昇給
  • SchApiItemNotFoundException 指定されたモデルプロパティが見つからない場合

  • 見つかった。 -

例:

# # get_model_property_valueとset_model_property_valueの使用方法を示します。 # from typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # 現在の hil デバイスを出力しますprint ( mdl . get_model_property_value ( "hil_device" )) # show_modes モデル プロパティを True に変更しますshow_modes = mdl . get_model_property_value ( "show_modes" ) print ( "変更前の表示モードは{0}です。" . format ( show_modes )) mdl . set_model_property_value ( "show_modes" , True ) show_modes = mdl . get_model_property_value ( "show_modes" ) print ( "変更後の表示モードは{0}です。" . format ( show_modes )) mdl . close_model ()

出力

HIL402 変更前の表示モードはFalseです。変更後の表示モードはTrueです。
get_name (アイテムハンドル)

指定されたアイテムの名前を取得します アイテムハンドル.

パラメータ:

item_handle ( ItemHandle ) – アイテムハンドル。

戻り値:

アイテム名。

例:

# # 例ではget_name関数の使い方を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () sub = mdl . create_component ( "core/Subsystem" , name = "Subsystem 1" ) r = mdl . create_component ( "core/Resistor" , parent = sub , name = "R1" ) print ( r ) r_name = mdl . get_name ( r ) print ( r_name ) # 名前を変更し、新しい名前を印刷します。 print ( "コンポーネント r の新しい名前を 'New name' に設定しています。" ) mdl . set_name ( r , "New name" ) print ( "新しい r の名前は ' {0} ' です。" . format ( mdl . get_name ( r ))) mdl . close_model ()

出力

コンポーネント: サブシステム 1.R1 R1 コンポーネント r の新しい名前を「新しい名前」に設定しています。新しい r の名前は「新しい名前」です。
get_ns_var ( var_name )

名前空間変数の戻り値 変数名.

パラメータ:

var_name ( str ) – 名前空間変数名。

戻り値:

Python オブジェクト。

昇給
  • 指定された名前の変数が存在しない場合は SchApiException が発生します

  • 名前空間。

例:

# # set_ns_var および get_ns_var 関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # 'var1' という名前の変数を作成mdl . set_ns_var ( "var1" , 20 ) print ( mdl . get_ns_var ( "var1" )) # 変数 'var1' の値を更新mdl . set_ns_var ( "var1" , 100 ) print ( mdl . get_ns_var ( "var1" )) mdl . close_model ()

出力

20 100
get_ns_vars ( )

名前空間内のすべての変数の名前を取得します。

パラメータ:

なし

戻り値:

名前空間内の変数名のリスト。

例:

#
# Demonstrate use of get_ns_vars.
#
from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()

# Create some variables
mdl.set_ns_var("var1", 2.71)
mdl.set_ns_var("var2", 100)
mdl.set_ns_var("var3", "Hello")

#
# Print all variable names and their values.
#
for var_name in mdl.get_ns_vars():
    var_value = mdl.get_ns_var(var_name)
    print("Variable name is {0} and its value is {1}.".format(var_name,
                                                             var_value))

mdl.close_model()

出力

変数名はvar1で、その値は2.71です。変数名はvar3で、その値はHelloです。変数名はvar2で、その値は100です。
get_parent ( item_handle )

指定されたハンドルの親ハンドルを返します。

パラメータ:

item_handle ( ItemHandle ) – アイテムハンドルオブジェクト。

戻り値:

親 ItemHandle オブジェクト。

昇給
  • SchApiException 指定されたハンドルが有効でない場合、またはアイテムが

  • ハンドルによって表されるものには親がありません。

例:

# # get_parent関数の使い方を説明します。 #から typhoon.api.schematic_editor SchematicAPIをインポートします。mdl = SchematicAPI () mdl . create_new_model () sub = mdl . create_component ( type_name = "core/Subsystem"  name = "Subsystem 1" ) inner_comp = mdl . create_component ( type_name = "core/Resistor"  parent = sub  name = "R1" ) parent_handle = mdl . get_parent ( inner_comp ) print ( "' {0} ' の親の名前は ' {1} ' です。" . format ( mdl . get_name ( inner_comp )、 mdl . get_name ( parent_handle ))) mdl . close_model ()

出力

'R1' の親の名前は 'サブシステム 1' です。
get_position ( item_handle )

アイテムの位置を取得します。

パラメータ:

item_handle ( ItemHandle ) – アイテムハンドル。

戻り値:

タプル形式 (x, y) の位置。

昇給

指定された項目が見つからない場合は SchApiItemNotFoundException が発生します。

例:

# # get_positionとset_positionの使い方を説明します。 # from typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # タグ項目の位置を取得tag = mdl . create_tag ( name = "タグ 1" , value = "タグ値" , position = ( 160 , 240 )) print ( "タグの位置は{0}です。" . format ( mdl . get_position ( tag ))) # 位置を設定mdl . set_position ( tag , ( 800 , 1600 )) print ( "新しいタグの位置は{0}です。" . format ( mdl . get_position ( tag ))) mdl . close_model ()

出力

タグの位置は[160, 240]です。新しいタグの位置は[800, 1600]です。
get_property_combo_values ( prop_handle )

指定されたプロパティのcombo_valuesリストを返します。 プロップハンドル.

注記

この関数は、ウィジェットがコンボに設定されているプロパティで機能します。

パラメータ:

prop_handle ( ItemHandle ) – プロパティハンドル。

戻り値:

プロパティコンボ値のシーケンス。

昇給

プロパティ ウィジェットがコンボでない場合は SchApiException が発生します。

例:

# # get_property_combo_values および set_property_combo_values関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () tr_line = mdl . create_component ( "core/Transmission Line" , name = "TR Line 1" ) # # model_def という名前のコンポーネント プロパティに新しいコンボ値を追加します# model_def_handle = mdl . prop ( tr_line , "model_def" ) model_def_combo_values = mdl . get_property_combo_values ( model_def_handle ) new_combo_values = model_def_combo_values + [ "New option" ] # 新しいコンボ値を設定しますmdl . set_property_combo_values ( model_def_handle , new_combo_values ) mdl . close_model ()

出力


get_property_default_value ( prop_handle )

プロパティのデフォルト値を返します。

パラメータ:

prop_handle ( ItemHandle ) – プロパティハンドル。

戻り値:

プロパティのデフォルト値を文字列として指定します。

昇給

プロパティが見つからない場合は SchApiItemNotFoundException が発生します。

例:

# # get_property_default_value の使い方を説明します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () r = mdl . create_component ( "core/Resistor" , name = "R1" ) mdl . set_property_value ( mdl . prop ( r , "resistance" ), 12.0 ) res_value = mdl . get_property_value ( mdl . prop ( r , "resistance" )) def_value = mdl . get_property_default_value ( mdl . prop ( r , "resistance" )) print ( "抵抗器 ' {0} ' の抵抗値は ' {1} 'ですが、デフォルト値は ' {2} ' です。" . format ( mdl . get_name ( r ), res_value , def_value )) mdl . close_model ()

出力

抵抗器「R1」の抵抗値は「12.0」ですが、デフォルト値は「1」です。
get_property_disp_value ( prop_handle )

プロパティの表示値を返します。

パラメータ:

prop_handle ( ItemHandle ) – プロパティハンドル。

戻り値:

str

例:

# # set_property_disp_value と get_property_disp_value の使用方法を示します typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # コンポーネントを作成const = mdl . create_component ( "core/Constant" ) # コンポーネントのプロパティ表示値を設定するmdl . set_property_disp_value ( mdl . prop ( const , "value" ), 70 ) # コンポーネントのプロパティ表示値を印刷するprint ( mdl . get_property_disp_value ( mdl . prop ( const , "value" ))) mdl . close_model ()

出力

70
get_property_type_attributes ( prop_handle )

プロパティ タイプの属性を返します。

パラメータ:

prop_handle ( ItemHandle ) – プロパティハンドル。

戻り値: 関数は辞書を返します

プロパティ タイプ属性。

例:

# # get_property_type_attributes の使い方を説明します。 #から typhoon.api.schematic_editor SchematicAPIインポートします。mdl = SchematicAPI () mdl.create_new_model ( ) c = mdl.create_component ( " core /Capacitor "  name = " C1 " ) mdl.set_property_value ( mdl.prop ( c  " capacitance " )  12.0 ) property_type_attributes = mdl.get_property_type_attributes ( mdl.prop ( c  " capacitance " ) ) print ( property_type_attributes ) mdl.close_model ( )

出力

{'name': 'capacitance', 'label': 'Capacitance', 'description': 'Capacitance of the component', 'widget': 'edit', 'type': 'real', 'default_value': '1e-6', 'min_value': None, 'max_value': None, 'unit': 'F', 'evaluate': True, 'combo_values': [], 'tab_name': None, 'visible': True, 'enabled': True, 'supported': True, 'keepline': False, 'skip': False, 'vector': False, 'tunable': False}
get_property_value ( prop_handle )

プロパティの値を返します。

パラメータ:

prop_handle ( ItemHandle ) – プロパティハンドル。

戻り値:

物体

例:

# # set_property_value および get_property_value関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () const = mdl . create_component ( "core/Constant" ) # 現在のプロパティ値を出力しますprint ( mdl . get_property_value ( mdl . prop ( const , "value" ))) # 新しいプロパティ値を設定しますmdl . set_property_value ( mdl . prop ( const , "value" ), 20 ) print ( mdl . get_property_value ( mdl . prop ( const , "value" ))) mdl . close_model ()

出力

[1.0] [20.0]
get_property_value_type ( prop_handle )

プロパティ値の型を返します。

パラメータ:

prop_handle ( ItemHandle ) – プロパティハンドル。

戻り値:

str

昇給

プロパティハンドルが無効な場合はSchApiExceptionが発生します

例:

# # set_property_value_type および get_property_value_type関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () const = mdl . create_component ( "core/Constant" ) # 現在のプロパティ値を出力しますprint ( mdl . get_property_value_type ( mdl . prop ( const , "value" ))) # 新しいプロパティ値を設定しますmdl . set_property_value_type ( mdl . prop ( const , "value" ), "uint" ) print ( mdl . get_property_value_type ( mdl . prop ( const , "value" ))) mdl . close_model ()

出力

実数単位
get_property_values ( item_handle )

指定されたコンポーネント ハンドルのすべてのプロパティ値を (辞書形式で) 返します。

パラメータ:

item_handle ( ItemHandle ) – コンポーネントハンドル。

戻り値:

dict。キーはプロパティ名、値はプロパティ値です。

例:

#
# Demonstrate use of save and save_as functions.
#
from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()

vs = mdl.create_component("core/Voltage Source")
c = mdl.create_component("core/Capacitor", name="C1")
con1 = mdl.create_connection(mdl.term(vs, "n_node"), mdl.term(c, "n_node"))
con2 = mdl.create_connection(mdl.term(vs, "p_node"), mdl.term(c, "p_node"))

def get_and_print(comp_handle):
    """
    Get and print component property values.
    """
    values = mdl.get_property_values(comp_handle)
    print("Component '{0}' property values are '{1}'.".format(
        mdl.get_name(comp_handle), values
    ))

# Get property values from both components and print them.
get_and_print(vs)
get_and_print(c)

# Change capacitor property values.
new_values = {
    "capacitance": 34.2,
    "initial_voltage": 10.3,
}

mdl.set_property_values(c, new_values)

# Print c property values to confirm they are changed.
get_and_print(c)

mdl.close_model()

出力

Component 'Vs1' property values are '{'sig_input': 'False', 'type': 'signal generator', 'param_set': '1phase', 'parent_label': '', 'dtsm_switch_name': '', 'addr': 0, 'spc_nb': 0, 'execution_rate': 0.0001, 'cpd_visible': True, 'enable_snb': False, 'snb_type': 'R2', 'R2': 0.0, 'L1': 0.1, 'override_signal_name': False, 'signal_name': '', 'init_source_nature': 'Constant', 'init_const_value': 0.0, 'init_rms_value': 0.0, 'init_frequency': 50.0, 'init_phase': 0.0}'.
Component 'C1' property values are '{'signal_access': 'inherit', 'capacitance': 1e-06, 'initial_voltage': 0.0, 'pole_shift_ignore': False, 'visible': True}'.
Component 'C1' property values are '{'signal_access': 'inherit', 'capacitance': 34.2, 'initial_voltage': 10.3, 'pole_shift_ignore': False, 'visible': True}'.
get_rotation ( item_handle )

アイテムの回転を取得します( アイテムハンドル)。

パラメータ:

item_handle ( ItemHandle ) – アイテムハンドル。

戻り値:

(「上」、「右」、「左」、「下」のいずれか)

戻り値の型:

回転(文字列)

昇給
  • 指定された項目が見つからない場合は SchApiItemNotFoundException が発生します。

  • 指定されたアイテムタイプが有効でない場合、SchApiException が発生します。

例:

#
# Demonstrate use of get_rotation and set_rotation functions.
#
from typhoon.api.schematic_editor import SchematicAPI
from typhoon.api.schematic_editor import const

mdl = SchematicAPI()
mdl.create_new_model()

# Create one component on model root level.
sub1 = mdl.create_component("core/Subsystem", name="Subsystem1")

print(f"Current rotation: {mdl.get_rotation(sub1)}")
print(f"\nSetting new rotation value: {const.ROTATION_DOWN}\n")
mdl.set_rotation(sub1, const.ROTATION_DOWN)
print("Rotation correctly set?")
print(f"{mdl.get_rotation(sub1) == const.ROTATION_DOWN}")

出力

現在の回転: 上 新しい回転値の設定: 下 回転は正しく設定されていますか? True
get_size ( item_handle )

指定されたアイテムのサイズ(幅/高さ)を取得します。 アイテムハンドル.

パラメータ:

item_handle ( ItemHandle ) – アイテムハンドルオブジェクト。

戻り値:

リスト

例:

# # get_size および set_size 関数の使用方法を示します。 #から typhoon.api.schematic_editor SchematicAPIインポートする typhoon.api.schematic_editor import const mdl = SchematicAPI () mdl . create_new_model () # モデル ルート レベルでコンポーネントを 1 つ作成します。 sub1 = mdl . create_component ( "core/Subsystem"  name = "Subsystem1" ) # コンポーネントの新しいサイズを定義します。 new_width = 70 new_height = 55 # 新しいサイズを設定し、get_size() が新しいサイズを返すかどうかを確認します。 mdl . set_size ( sub1  width = new_width  height = new_height ) print ( mdl . get_size ( sub1 ) == [ new_width  new_height ]) # # コンポーネント サイズ コンポーネントを個別に設定し、get_size() が正しいサイズを返すかどうかを確認します。 # mdl . set_size ( sub1  width = 100 ) print ( mdl . get_size ( sub1 ) == [ 100  new_height ]) mdl . set_size ( sub1 , height = 80 ) print ( mdl . get_size ( sub1 ) == [ 100 , 80 ])

出力

本当だ、本当だ、本当だ
get_sub_level_handle ( item_handle )

指定されたハンドルより1つ下の階層にあるハンドルを返します。 アイテムハンドル.

パラメータ:

item_handle ( ItemHandle ) – ItemHandle オブジェクト。

戻り値:

ItemHandle オブジェクト。

昇給

エラーが発生した場合は SchApiException が発生します。

例:

#
# Demonstrate use of get_sub_level_handle function.
#

from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()

sub = mdl.create_component("core/Subsystem", name="Sub1")
mask = mdl.create_mask(sub)

#
# Calling of this function is not supported from client scripts.
# But, this code demonstrate how it will be called.
#
if False:
    sub_level_handle = mdl.get_sub_level_handle(mask)
    print("Sub-level handle for mask handle is '{0}'.".format(sub_level_handle))

mdl.close_model()

出力


get_terminal_dimension (端末ハンドル)

コンポーネント端子の寸法を返します。

パラメータ:

terminal_handle ( ItemHandle ) – 端末ハンドル。

戻り値:

端子寸法をリストとして表示します。

例:

# # get_terminal_dimension および set_terminal_dimension関数の使用方法を示します。 #から typhoon.api.schematic_editor SchematicAPIインポートします。mdl = SchematicAPI () mdl.create_new_model () const = mdl.create_component ( " core /Constant"  name = "Constant 1" ) print ( mdl.get_terminal_dimension ( mdl.term ( const , " out " ) ) ) mdl.set_terminal_dimension ( mdl.term ( const , " out " ) ) , ( 2 , ) ) print ( mdl.get_terminal_dimension ( mdl.term ( const , " out " ) ) ) mdl.close_model ( )

出力

calc [2]
get_terminal_sp_type (端末ハンドル)

コンポーネント端子SPタイプを戻します。

SP タイプは、SP_TYPE_INHERIT、SP_TYPE_INT、SP_TYPE_UINT、SP_TYPE_REAL、またはそれらの値に評価できる式のいずれかになります。

パラメータ:

terminal_handle ( ItemHandle ) – 端末ハンドル。

戻り値:

端末の SP タイプを文字列として指定します。

例:

# # get_terminal_sp_typeとget_terminal_sp_type_valueの使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # 入力の絶対値を計算するコンポーネントを作成します。 abs = mdl . create_component ( "core/Abs" , name = "Abs 1" ) # # 'calc' を出力します。これは、端末の sp タイプが calc_dimension ハンドラーで計算されることを示します # print ( mdl . get_terminal_sp_type ( mdl . term ( abs , "out" ))) # # 入力 'in' 端末として継承を出力します。接続された出力端末から sp タイプを他のコンポーネントから継承します。 # print ( mdl . get_terminal_sp_type ( mdl . term ( abs , "in" ))) # # get_terminal_sp_type_value は、端末の実際に計算された sp タイプを返します。 # sp タイプはコンパイルの開始後に計算されるため、コンパイルが実行されたときにコンテキストで呼び出されます # # Const 1 は、'out' ターミナルに 'real' sp タイプを持ちます。const1 = mdl . create_component ( "core/Constant"  name = "Constant 1" ) # プローブ 'in' ターミナルは 'inherit' sp タイプを持ちます。probe1 = mdl . create_component ( "core/Probe"  name = "Probe 1" ) con = mdl . create_connection ( mdl . term ( const1  "out" )、 mdl . term ( probe1  "in" )) # コンパイル後... # # プローブ 'in' sp タイプは、実数である const1 コンポーネント 'out' ターミナルから継承されます # print ( mdl . get_terminal_sp_type_value ( mdl . term ( probe1  "in" ))) mdl . close_model ()

出力

継承する 継承する 継承する
get_terminal_sp_type_value (端末ハンドル)

コンポーネント端末の計算された SP タイプを返します (その端末の SP タイプの値に基づいて計算されます)。

計算された場合、返される値はSP_TYPE_INT、SP_TYPE_UINT、SP_TYPE_REALのいずれかになります。SP型値の計算は、回路図のコンパイル時に実行されます。

パラメータ:

terminal_handle ( ItemHandle ) – 端末ハンドル。

戻り値:

端末の SP タイプを文字列として指定します。

例:

# # get_terminal_sp_typeとget_terminal_sp_type_valueの使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # 入力の絶対値を計算するコンポーネントを作成します。 abs = mdl . create_component ( "core/Abs" , name = "Abs 1" ) # # 'calc' を出力します。これは、端末の sp タイプが calc_dimension ハンドラーで計算されることを示します # print ( mdl . get_terminal_sp_type ( mdl . term ( abs , "out" ))) # # 入力 'in' 端末として継承を出力します。接続された出力端末から sp タイプを他のコンポーネントから継承します。 # print ( mdl . get_terminal_sp_type ( mdl . term ( abs , "in" ))) # # get_terminal_sp_type_value は、端末の実際に計算された sp タイプを返します。 # sp タイプはコンパイルの開始後に計算されるため、コンパイルが実行されたときにコンテキストで呼び出されます # # Const 1 は、'out' ターミナルに 'real' sp タイプを持ちます。const1 = mdl . create_component ( "core/Constant"  name = "Constant 1" ) # プローブ 'in' ターミナルは 'inherit' sp タイプを持ちます。probe1 = mdl . create_component ( "core/Probe"  name = "Probe 1" ) con = mdl . create_connection ( mdl . term ( const1  "out" )、 mdl . term ( probe1  "in" )) # コンパイル後... # # プローブ 'in' sp タイプは、実数である const1 コンポーネント 'out' ターミナルから継承されます # print ( mdl . get_terminal_sp_type_value ( mdl . term ( probe1  "in" ))) mdl . close_model ()

出力

継承する 継承する 継承する
hide_name ( item_handle )

回路図アイテムの名前を非表示にします。

パラメータ:

item_handle ( ItemHandle ) – ItemHandle オブジェクト。

戻り値:

なし

昇給
  • SchApiException は、渡されたItemHandleに関連付けられたアイテムの場合に発生します

  • NameableMixin オブジェクトではありません。

例:

#
# Example demonstrates use of the is_name_visible(),
# show_name() and hide_name() functions.
#

from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()


# Initial component creation
const = mdl.create_component(type_name="core/Constant")
print(f"Initial component name visibility: {mdl.is_name_visible(const)}")


# Hiding the component's name
mdl.hide_name(const)
print(f"Component name visibility after calling hide_name():"
      f"{mdl.is_name_visible(const)}")


# Showing the component's name
mdl.show_name(const)
print(f"Component name visibility after calling show_name():"
      f"{mdl.is_name_visible(const)}")


mdl.close_model()

出力

初期のコンポーネント名の可視性: True hide_name() 呼び出し後のコンポーネント名の可視性: False show_name() 呼び出し後のコンポーネント名の可視性: True
hide_property ( prop_handle )

コンポーネントのダイアログでコンポーネントのプロパティを非表示にします。

注記

この機能の効果は、回路図エディターの UI でのみ表示されます。

この関数が呼び出されると、コンポーネントのダイアログでプロパティが非表示になります。プロパティを表示するには、 show_property() 関数。

パラメータ:

prop_handle ( ItemHandle ) – プロパティハンドル。

例:

# # 例では、hide_property、show_property、および# is_property_visible 関数の使用方法を示します。 #から typhoon.api.schematic_editor SchematicAPIインポートします。mdl = SchematicAPI ( ) mdl.create_new_model ( ) const = mdl.create_component ( type_name = " core / Constant " ) print ( mdl.is_property_visible ( mdl.prop ( const , " value " ) ) ) mdl.hide_property ( mdl.prop ( const , " value " ) ) print ( mdl.is_property_visible ( mdl.prop ( const , " value " ) ) ) mdl.show_property ( mdl.prop ( const , " value " ) ) print ( mdl.is_property_visible ( mdl.prop ( const , " value " ) ) ) mdl.close_model ( )

出力

真偽 真
info ( msg , context = None )

関数は情報メッセージを通知します。

パラメータ:
  • msg ( str ) – メッセージ文字列。

  • context ( ItemHandle ) – コンテキスト項目のハンドル。

戻り値:

なし

例:

# # info関数の使い方を説明します。 #から typhoon.api.schematic_editor SchematicAPIをインポートしますmdl = SchematicAPI () mdl . create_new_model () r = mdl . create_component ( "core/Resistor" , name = "R1" ) resistance_prop_handle = mdl . prop ( r , "resistance" ) resistance_value = mdl . get_property_value ( resistance_prop_handle ) mdl . info ( "Resistor resistance is {0} " . format ( resistance_value ), context = resistance_prop_handle ) mdl . close_model ()

出力


is_bypassed ( item_handle )

指定されたコンポーネントがバイパスされるかどうかを返します。

パラメータ:

item_handle ( SchemeItemMixin ) – Scheme アイテム。

戻り値:

ブール

例:

#
# Demonstrates the use of the bypass_component and is_bypassed functions.
#
from typhoon.api.schematic_editor import SchematicAPI

mdl = SchematicAPI()

# Create new model
mdl.create_new_model()

# Starting coordinates
x0 = 8192
y0 = 8192

print("Creating scheme items...")

# Create Voltage Source component
v_in = mdl.create_component(
    "core/Voltage Source",
    name="Vin",
    position=(x0 - 300, y0),
    rotation="right"
)
mdl.set_property_value(mdl.prop(v_in, "init_rms_value"), 100)

# Create Resistor component
r_1 = mdl.create_component(
    "core/Resistor",
    name="R1",
    position=(x0 - 200, y0 - 100)
)
mdl.set_property_value(mdl.prop(r_1, "resistance"), 50)

# Create Resistor component
r_2 = mdl.create_component(
    "core/Resistor",
    name="R2",
    position=(x0 - 100, y0 - 100)
)
mdl.set_property_value(mdl.prop(r_2, "resistance"), 50)

i_meas = mdl.create_component(
    "core/Current Measurement",
    name="I",
    position=(x0, y0),
    rotation="right"
)

mdl.create_connection(mdl.term(v_in, "p_node"), mdl.term(r_1, "p_node"))
mdl.create_connection(mdl.term(r_1, "n_node"), mdl.term(r_2, "p_node"))
mdl.create_connection(mdl.term(r_2, "n_node"), mdl.term(i_meas, "p_node"))
mdl.create_connection(mdl.term(i_meas, "n_node"), mdl.term(v_in, "n_node"))


print("Initial bypass status:")
print(f"{mdl.is_bypassed(r_1)=}")

mdl.bypass_component(r_1)
print("After bypassing component R1:")
print(f"{mdl.is_bypassed(r_1)=}")

mdl.enable_items(r_1)
print("Disabling or enabling a component removes its bypass. After enabling:")
print(f"{mdl.is_bypassed(r_1)=}")

mdl.close_model()

出力

スキーム項目を作成しています... 初期バイパス状態: mdl.is_bypassed(r_1)=False コンポーネントR1をバイパスした後: mdl.is_bypassed(r_1)=True コンポーネントを無効化または有効化すると、バイパスが解除されます。有効化後: mdl.is_bypassed(r_1)=False
is_enabled ( item_handle )

指定された項目が有効かどうかを返します。

パラメータ:

item_handle ( SchemeItemMixin ) – Scheme アイテム。

戻り値:

ブール

例:

#
# Demonstrate the use of the following functions:
# enable_items, disable_items, is_enabled
#
from typhoon.api.schematic_editor import SchematicAPI

mdl = SchematicAPI()

model_path = os.path.join(
    os.path.dirname(os.path.realpath(__file__)),
    "enable_disable",
    "3050_enable_disable_items.tse"
)
mdl.load(model_path)

#
# Names of items that can be disabled
#
item_disable_names = [
    "AI_1"
]

#
# Names of subsystem [0] and item [1] inside subsystem for
# example when an item inside a subsystem is disabled
#
subsystem_get_item_example = ["SS_1", "SM_6"]

#
# Names of items that cannot be disabled
#
# These are not the only items that cannot be disabled ... just an
# example
item_dont_disable_names = [
    "Subsystem1"
]

#
# Fetch all items that can be disabled and that cannot be disabled
#
items_disable = []
items_dont_disable = []
for item_name in item_disable_names:
    items_disable.append(mdl.get_item(item_name))
for item_name in item_dont_disable_names:
    items_dont_disable.append(mdl.get_item(item_name))

#
# Disable, compile, enable - items that can be disabled
#
disabled_items = mdl.disable_items(items_disable)
for item in disabled_items:
    is_enabled = mdl.is_enabled(item)
affected_items = mdl.enable_items(items_disable)
for item in affected_items:
    is_enabled = mdl.is_enabled(item)
mdl.compile()

#
# Disable, compile, enable - items that can not be disabled
#
disabled_items = mdl.disable_items(items_dont_disable)
for item in disabled_items:
    is_enabled = mdl.is_enabled(item)
try:
    mdl.compile()
except Exception as e:
    print(e.args)
affected_items = mdl.enable_items(items_dont_disable)
for item in affected_items:
    is_enabled = mdl.is_enabled(item)
mdl.compile()

#
# Disable, compile, enable - items inside subsystem
#
parent_item = mdl.get_item(subsystem_get_item_example[0])
concrete_item = mdl.get_item(subsystem_get_item_example[1], parent_item)
disabled_items = mdl.disable_items([concrete_item])
for item in disabled_items:
    is_enabled = mdl.is_enabled(item)
try:
    mdl.compile()
except Exception as e:
    print(e.args)
affected_items = mdl.enable_items(concrete_item)
for item in affected_items:
    is_enabled = mdl.disable_items(item)
mdl.compile()

mdl.close_model()

出力

コンポーネントの「SM_4」入力「in1」が接続されていません。コンポーネントの「SS_1.Probe3」入力「in」が接続されていません。コンポーネントの「SS_1.Probe3」入力「in」が接続されていません。
is_model_changed ( )

モデルがロードされた後に何らかの変更が加えられた場合は True を返します。

パラメータ:

なし

戻り値:

モデル変更ステータスを示すブール値。

例:

# # is_model_changed の使い方を説明します。 #から typhoon.api.schematic_editor import SchematicAPI # モデルを作成して保存しますmdl = SchematicAPI () mdl . create_new_model () mdl . create_component ( "core/Capacitor" , name = "C1" ) mdl . save_as ( "model.tse" ) mdl . close_model () # モデルをロードし、変更が加えられていない場合は is_model_changed が False を返すことを確認しますmdl . load ( "model.tse" ) print ( "{mdl.is_model_changed()=}" ) # コンデンサの新しい値を設定し、is_model_changed を再度呼び出しますc = mdl . get_item ( "C1" ) mdl . set_property_value ( mdl . prop ( c , "capacitance" ), 12.0 ) print ( "{mdl.is_model_changed()=}" ) mdl . close_model ()

出力

{mdl.is_model_changed()=} {mdl.is_model_changed()=}
is_name_visible ( item_handle )

回路図アイテムの現在の名前の表示を取得します。:param item_handle: ItemHandle オブジェクト。:type item_handle: ItemHandle

戻り値:

ブール

昇給
  • SchApiException は、渡されたItemHandleに関連付けられたアイテムの場合に発生します

  • NameableMixin オブジェクトではありません。

例:

#
# Example demonstrates use of the is_name_visible(),
# show_name() and hide_name() functions.
#

from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()


# Initial component creation
const = mdl.create_component(type_name="core/Constant")
print(f"Initial component name visibility: {mdl.is_name_visible(const)}")


# Hiding the component's name
mdl.hide_name(const)
print(f"Component name visibility after calling hide_name():"
      f"{mdl.is_name_visible(const)}")


# Showing the component's name
mdl.show_name(const)
print(f"Component name visibility after calling show_name():"
      f"{mdl.is_name_visible(const)}")


mdl.close_model()

出力

初期のコンポーネント名の可視性: True hide_name() 呼び出し後のコンポーネント名の可視性: False show_name() 呼び出し後のコンポーネント名の可視性: True
is_property_enabled ( prop_handle )

プロパティが有効な場合は True を返し、それ以外の場合は False を返します。

パラメータ:

prop_handle ( ItemHandle ) – プロパティハンドル。

戻り値:

ブール

例:

# # disable_property、enable_property、is_property_enabled関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # コンポーネントを作成r = mdl . create_component ( "core/Resistor" ) # プロパティを無効にするmdl . disable_property ( mdl . prop ( r , "resistance" )) # プロパティが有効になっているかどうかを確認します。 print ( mdl . is_property_enabled ( mdl . prop ( r , "resistance" ))) # プロパティを有効にするmdl . enable_property ( mdl . prop ( r , "resistance" )) print ( mdl . is_property_enabled ( mdl . prop ( r , "resistance" ))) mdl . close_model ()

出力

偽 真
is_property_serializable ( prop_handle )

コンポーネント プロパティがシリアル化可能な場合は True を返します。

パラメータ:

prop_handle ( ItemHandle ) – プロパティハンドル。

戻り値:

真実 プロパティがシリアル化可能な場合、 間違い さもないと。

例:

# # 例では、disable_property_serialization、 # enable_property_serialization、およびis_property_serializable関数の使用方法を示します。 #から typhoon.api.schematic_editor SchematicAPIインポートします。mdl = SchematicAPI ( ) mdl.create_new_model ( ) const = mdl.create_component ( type_name = " core / Constant " ) print ( mdl.is_property_serializable ( mdl.prop ( const , " value " ) ) ) mdl.disable_property_serialization ( mdl.prop ( const , " value " ) ) print ( mdl.is_property_serializable ( mdl.prop ( const , " value " ) ) ) mdl.enable_property_serialization ( mdl.prop ( const , " value " ) ) print ( mdl.is_property_serializable ( mdl.prop ( const , " value " ) ) ) mdl.close_model ( )

出力

真偽 真
is_property_visible ( prop_handle )

コンポーネントのプロパティがコンポーネントのダイアログに表示されている場合は True を返し、そうでない場合は False を返します。

パラメータ:

prop_handle ( ItemHandle ) – プロパティハンドル。

戻り値:

真実 プロパティが表示されている場合、 間違い さもないと。

例:

# # 例では、hide_property、show_property、および# is_property_visible 関数の使用方法を示します。 #から typhoon.api.schematic_editor SchematicAPIインポートします。mdl = SchematicAPI ( ) mdl.create_new_model ( ) const = mdl.create_component ( type_name = " core / Constant " ) print ( mdl.is_property_visible ( mdl.prop ( const , " value " ) ) ) mdl.hide_property ( mdl.prop ( const , " value " ) ) print ( mdl.is_property_visible ( mdl.prop ( const , " value " ) ) ) mdl.show_property ( mdl.prop ( const , " value " ) ) print ( mdl.is_property_visible ( mdl.prop ( const , " value " ) ) ) mdl.close_model ( )

出力

真偽 真
is_require_satisfied ( require_string )

提供されているかどうかを確認します 必要な文字列 現在の構成(モデル構成)に対して満たされます。

パラメータ:

require_string ( str ) – 要件文字列。

戻り値:

要件文字列が現在のモデル構成に対して満たされている場合は True、そうでない場合は False。

例:

# # is_require_satisfied() 関数の使い方を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () print ( "モデルの現在の構成で 'sw_sigproc' が使用可能かどうかを確認しています。" ) print ( "有効 = {0} 。" . format ( mdl . is_require_satisfied ( "sw_microgrid" ))) mdl . close_model ()

出力

モデルの現在の構成で 'sw_sigproc' が使用可能かどうかを確認しています。有効 = True。
is_subsystem ( comp_handle )

指定されたコンポーネントが コンピュータハンドル サブシステム(複合)コンポーネントです。

注記

コンポーネントは、複合コンポーネントでない場合はアトミック コンポーネントです。

パラメータ:

comp_handle ( ItemHandle ) – コンポーネントハンドル。

戻り値:

真実 コンポーネントがサブシステムの場合、 間違い さもないと。

昇給

コンポーネントが見つからない場合は SchApiItemNotFoundException が発生します。

例:

# # is_component_composite関数の使い方を示します。 #から typhoon.api.schematic_editor SchematicAPIインポートしますmdl = SchematicAPI ( ) mdl.create_new_model ( ) r = mdl.create_component ( " core /Resistor" ) sub1 = mdl.create_component ( " core / Subsystem " ) vm1 = mdl.create_component ( " core / Voltage Measurement " ) print ( mdl.is_subsystem ( r ) ) print ( mdl.is_subsystem ( sub1 ) ) print ( mdl.is_subsystem ( vm1 ) ) mdl.close_model ( )

出力

偽 真 真
is_terminal_feedthrough (端末ハンドル)

端子がフィードスルーであるかどうかを判断します。

パラメータ:

terminal_handle ( ItemHandle ) – 端末ハンドル。

戻り値:

真実 端子がフィードスルーの場合、 間違い さもないと。

例:

# # 用語関数の使用例を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # アキュムレータ コンポーネントを作成します。その出力端子はフィードスルーですacc = mdl . create_component ( "core/Accumulator" , name = "Accummulator 1" ) print ( mdl . is_terminal_feedthrough ( mdl . term ( acc , "out" ))) # フィードスルーを変更します mdl . set_terminal_feedthrough ( mdl . term ( acc , "out" ), False ) print ( mdl . is_terminal_feedthrough ( mdl . term ( acc , "out" ))) mdl . close_model ()

出力

真偽
is_tunable ( item_handle )

指定された項目が調整可能かどうかを返します。

パラメータ:

item_handle ( ItemHandle ) – コンポーネントハンドルまたはプロパティハンドル

戻り値:

ブール

例:

#
# Demonstrate the use of the following functions:
# enable_items, disable_items, is_enabled
#
from typhoon.api.schematic_editor import SchematicAPI

mdl = SchematicAPI()

model_path = os.path.join(
    os.path.dirname(os.path.realpath(__file__)),
    "enable_disable",
    "3050_enable_disable_items.tse"
)
mdl.load(model_path)

#
# Names of items that can be disabled
#
item_disable_names = [
    "AI_1"
]

#
# Names of subsystem [0] and item [1] inside subsystem for
# example when an item inside a subsystem is disabled
#
subsystem_get_item_example = ["SS_1", "SM_6"]

#
# Names of items that cannot be disabled
#
# These are not the only items that cannot be disabled ... just an
# example
item_dont_disable_names = [
    "Subsystem1"
]

#
# Fetch all items that can be disabled and that cannot be disabled
#
items_disable = []
items_dont_disable = []
for item_name in item_disable_names:
    items_disable.append(mdl.get_item(item_name))
for item_name in item_dont_disable_names:
    items_dont_disable.append(mdl.get_item(item_name))

#
# Disable, compile, enable - items that can be disabled
#
disabled_items = mdl.disable_items(items_disable)
for item in disabled_items:
    is_enabled = mdl.is_enabled(item)
affected_items = mdl.enable_items(items_disable)
for item in affected_items:
    is_enabled = mdl.is_enabled(item)
mdl.compile()

#
# Disable, compile, enable - items that can not be disabled
#
disabled_items = mdl.disable_items(items_dont_disable)
for item in disabled_items:
    is_enabled = mdl.is_enabled(item)
try:
    mdl.compile()
except Exception as e:
    print(e.args)
affected_items = mdl.enable_items(items_dont_disable)
for item in affected_items:
    is_enabled = mdl.is_enabled(item)
mdl.compile()

#
# Disable, compile, enable - items inside subsystem
#
parent_item = mdl.get_item(subsystem_get_item_example[0])
concrete_item = mdl.get_item(subsystem_get_item_example[1], parent_item)
disabled_items = mdl.disable_items([concrete_item])
for item in disabled_items:
    is_enabled = mdl.is_enabled(item)
try:
    mdl.compile()
except Exception as e:
    print(e.args)
affected_items = mdl.enable_items(concrete_item)
for item in affected_items:
    is_enabled = mdl.disable_items(item)
mdl.compile()

mdl.close_model()

出力

調整可能なデフォルト = False。調整可能 = True。調整可能 = False。
load (ファイル名, debug = True )

ファイルからモデルを読み込みます。

注記

この関数はハンドラーでは使用できません。

パラメータ:
  • filename ( str ) – モデルが配置されているファイル名。

  • debug ( bool ) – メッセージを印刷するかどうかを示します。

戻り値:

真実 ロードが成功した場合、 間違い さもないと。

例:

# # ロード機能のデモンストレーション。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # 読み込まれるモデルを作成して保存しますmdl . create_component ( "core/Resistor" ) mdl . save_as ( "new_model.tse" ) # モデルを読み込みmdl . load ( "new_model.tse" ) # tse ファイルを削除してディレクトリをクリーンアップしますos . remove ( "new_model.tse" ) # モデルからアイテムを印刷しますfor item in mdl . get_items (): print ( item ) mdl . close_model ()

出力

コンポーネント: R1
model_to_api (バリアント= ()prop_mappings = None )

モデルの現在の状態を再現する API コマンドを含む文字列を生成します。

注記

この関数はハンドラーでは使用できません。

パラメータ:
  • バリアント(シーケンス) – バリアントコンポーネントのシーケンス (コンポーネントの完全修飾名)。

  • prop_mappings ( dict ) – 指定されたコンポーネントのプロパティ値のマッピング(構成管理で使用されます)。

戻り値:

str

例:

# # create_mask関数の使い方を説明します。 #から typhoon.api.schematic_editor import SchematicAPI # サンプルモデルへのパスmodel_path = os . path . join ( os . path . dirname ( os . path . realpath ( __file__ )), "mdl_to_api" , "example.tse" ) # モデルのロードmdl = SchematicAPI () mdl . load ( model_path ) print ( "モデルの文字列表現:" ) print ( mdl . model_to_api ()) mdl . close_model ()

出力

String representation of model:
from typhoon.api.impl.schematic_editor import model as mdl
mdl.create_new_model()

# Configuration.
mdl.set_model_property_value("hil_device", "HIL402")
mdl.set_model_property_value("hil_configuration_id", 1)
mdl.set_model_property_value("simulation_method", "exact")
mdl.set_model_property_value("simulation_time_step", "auto")
mdl.set_model_property_value("simulation_discret_scaling", "1.0")
mdl.set_model_property_value("dsp_timer_periods", ('100e-6', ' 50e-3'))
mdl.set_model_property_value("ss_calc_method", "systematic elimination")
mdl.set_model_property_value("enb_pole_shift", True)
mdl.set_model_property_value("enb_gds_oversampling", True)
mdl.set_model_property_value("show_modes", False)
mdl.set_model_property_value("device_ao_limit_enable", False)
mdl.set_model_property_value("cpl_stb", False)
mdl.set_model_property_value("enb_dep_sw_detect", False)
mdl.set_model_property_value("code_section", "internal memory")
mdl.set_model_property_value("data_section", "internal memory")
mdl.set_model_property_value("sys_sp_rate_1", 0.0001)
mdl.set_model_property_value("sys_sp_rate_2", 0.05)
mdl.set_model_property_value("sys_real_type_precision", "default")
mdl.set_model_property_value("user_real_type_precision", "default")
mdl.set_model_property_value("sys_cpu_optimization", "high")
mdl.set_model_property_value("user_cpu_optimization", "high")

# Component: Root

# Component: Constant1
_Constant1 = mdl.create_component(
    type_name="core/Constant",
    parent=None,
    name="Constant1",
    rotation="up",
    flip="flip_none",
    position=(8128, 8192),
    hide_name=False,
    size=(None, None)
)


# Component: Subsystem1
_Subsystem1 = mdl.create_component(
    type_name="core/Empty Subsystem",
    parent=None,
    name="Subsystem1",
    rotation="up",
    flip="flip_none",
    position=(8336, 8192),
    hide_name=False,
    size=(48, 48)
)
_Subsystem1_mask = mdl.create_mask(_Subsystem1)
_Subsystem1_mask_gain = mdl.create_property(
    item_handle=_Subsystem1_mask,
    name="gain",
    label="gain",
    widget="edit",
    combo_values=[],
    evaluate=True,
    enabled=True,
    supported=True,
    visible=True,
    tab_name="",
    unit=""
)


_Subsystem1_mask_desc = '''
<html><head><meta name="qrichtext" content="1"></meta><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=""><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br></br></p></body></html>
'''
mdl.set_description(_Subsystem1_mask, _Subsystem1_mask_desc)


# Component: Subsystem1.Sum1
_Subsystem1_Sum1 = mdl.create_component(
    type_name="core/Sum",
    parent=_Subsystem1,
    name="Sum1",
    rotation="up",
    flip="flip_none",
    position=(8192, 8192),
    hide_name=False,
    size=(None, None)
)


# Component: Subsystem1.Gain1
_Subsystem1_Gain1 = mdl.create_component(
    type_name="core/Gain",
    parent=_Subsystem1,
    name="Gain1",
    rotation="up",
    flip="flip_horizontal",
    position=(8264, 8280),
    hide_name=False,
    size=(None, None)
)
mdl.set_property_value(mdl.prop(_Subsystem1_Gain1, "gain"), "gain")


# Component: Subsystem1.Unit Delay1
_Subsystem1_Unit_Delay1 = mdl.create_component(
    type_name="core/Unit Delay",
    parent=_Subsystem1,
    name="Unit Delay1",
    rotation="up",
    flip="flip_horizontal",
    position=(8144, 8280),
    hide_name=False,
    size=(None, None)
)


# Port: Subsystem1.In1
_Subsystem1_In1 = mdl.create_port(
    name="In1",
    parent=_Subsystem1,
    label="",
    kind="sp",
    direction="in",
    dimension=(1,),
    terminal_position=('left', 1),
    rotation="up",
    flip="flip_none",
    hide_name=False,
    position=(8000, 8184)
)

# Port: Subsystem1.Out3
_Subsystem1_Out3 = mdl.create_port(
    name="Out3",
    parent=_Subsystem1,
    label="",
    kind="sp",
    direction="out",
    dimension=(1,),
    terminal_position=('right', 1),
    rotation="up",
    flip="flip_none",
    hide_name=False,
    position=(8344, 8192)
)

# Junction: Subsystem1.Junction1
_Subsystem1_Junction1 = mdl.create_junction(
    name="Junction1",
    parent=_Subsystem1,
    kind="sp",
    position=(8288, 8192)
)

# Component: Probe1
_Probe1 = mdl.create_component(
    type_name="core/Probe",
    parent=None,
    name="Probe1",
    rotation="up",
    flip="flip_none",
    position=(8480, 8192),
    hide_name=False,
    size=(None, None)
)


# Connections
_Subsystem1_Connection1 = mdl.create_connection(
    start=mdl.term(_Subsystem1_Sum1, "in"),
    end=_Subsystem1_In1,
    name="Connection1",
    breakpoints=[],
)
_Subsystem1_Connection4 = mdl.create_connection(
    start=mdl.term(_Subsystem1_Sum1, "out"),
    end=_Subsystem1_Junction1,
    name="Connection4",
    breakpoints=[],
)
_Subsystem1_Connection5 = mdl.create_connection(
    start=_Subsystem1_Junction1,
    end=_Subsystem1_Out3,
    name="Connection5",
    breakpoints=[],
)
_Subsystem1_Connection6 = mdl.create_connection(
    start=mdl.term(_Subsystem1_Gain1, "in"),
    end=_Subsystem1_Junction1,
    name="Connection6",
    breakpoints=[],
)
_Subsystem1_Connection7 = mdl.create_connection(
    start=mdl.term(_Subsystem1_Unit_Delay1, "in"),
    end=mdl.term(_Subsystem1_Gain1, "out"),
    name="Connection7",
    breakpoints=[],
)
_Subsystem1_Connection8 = mdl.create_connection(
    start=mdl.term(_Subsystem1_Unit_Delay1, "out"),
    end=mdl.term(_Subsystem1_Sum1, "in1"),
    name="Connection8",
    breakpoints=[],
)
_Connection1 = mdl.create_connection(
    start=mdl.term(_Constant1, "out"),
    end=mdl.term(_Subsystem1, "In1"),
    name="Connection1",
    breakpoints=[],
)
_Connection3 = mdl.create_connection(
    start=mdl.term(_Subsystem1, "Out3"),
    end=mdl.term(_Probe1, "in"),
    name="Connection3",
    breakpoints=[],
)
precompile_fmu ( fmu_file_path , precompiled_file_path = None , additional_definitions = None )

新しいプリコンパイル済みFMU zipファイルを作成します。ソースファイルはコンパイルされ、静的ライブラリにリンクされます。元のFMU zipファイルからすべてのソースファイルとヘッダーファイルは削除されます。

パラメータ:
  • fmu_file_path – FMUが配置されているパス

  • precompiled_file_path – 新しいFMUを保存するパス。引数が指定されていない場合、ファイルは元のFMUファイルと同じパスに「_precompiled」という接尾辞を付けて保存されます。

  • additional_definitions – コンパイラに渡される追加の定義

戻り値:

なし

print_message (メッセージ)

デバッグ モードが有効な場合は、提供されたメッセージを出力します。

パラメータ:

message ( str ) – 印刷するメッセージ。

戻り値:

なし

prop ( item_handle , prop_name )

プロパティ ハンドルを作成します。

パラメータ:
  • item_handle ( ItemHandle ) – プロパティ コンテナー (マスクやコンポーネントなど) を表すハンドル オブジェクト。

  • prop_name ( str ) – プロパティ名。

戻り値:

プロパティ ハンドル。

例:

# # sch APIプロパティ関数の使用例を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () r = mdl . create_component ( "core/Resistor" , name = "R1" ) resistance_prop = mdl . prop ( r , "resistance" ) # 抵抗器の抵抗値を出力します。 property resistance_value = mdl . get_property_value ( resistance_prop ) print ( "抵抗器 ' {0} ' の抵抗は ' {1} 'です。" . format ( mdl . get_name ( r ), resistance_value )) mdl . close_model ()

出力

抵抗器「R1」の抵抗値は「1.0」です。
refresh_icon ( item_handle )

更新アイコン。

パラメータ:

item_handle ( ItemHandle ) – アイテムハンドル。

戻り値:

なし

例:

# # Schematic APIアイコン関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () tr1 = mdl . create_component ( "core/Three Phase Two Winding Transformer" ) mdl . set_component_icon_image ( tr1 , "/path/to/image.png" ) # テキストを書き込む前に色を赤に設定mdl . set_color ( tr1 , "red" ) mdl . disp_component_icon_text ( tr1 , "Sample text" ) # シーンのコンポーネント ビューの更新を開始mdl . refresh_icon ( tr1 ) mdl . close_model ()

出力


reload_libraries ( )

ライブラリパスにあるライブラリを再読み込みします。ライブラリとは、ユーザーが追加したライブラリ(ソフトウェアインストール時に同梱されたコアライブラリではありません)を指します。

パラメータ:

なし

戻り値:

なし

昇給

ライブラリの再ロード中にエラーが発生した場合の SchApiException。

例:

#
# Demonstrate use of {add,remove}_library_path and reload_library functions.
#
# All the path operations are temporary for the current running session.
#

from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()

#
# Library file is located in directory 'custom_lib' one level above this
# example file.
#
directory, __ = os.path.split(os.path.realpath(__file__))
lib_path = os.path.join(directory, "custom_lib")

# Get all current library paths and remove them
old_paths = mdl.get_library_paths()
for path in old_paths:
    mdl.remove_library_path(path)

# Add library path and reload library to be able to use added library.
mdl.add_library_path(lib_path)
mdl.reload_libraries()

# Create components from loaded libraries.
comp = mdl.create_component("my_lib/CustomComponent")
print("Component is '{0}'.".format(comp))

comp2 = mdl.create_component("archived_user_lib/CustomComponent1")
print("Second component (from archived library) is '{0}'.".format(
    comp2
))

# Remove library from the path.
mdl.remove_library_path(lib_path)

# Add again the previous library paths
for path in old_paths:
    mdl.add_library_path(path)

mdl.close_model()

出力

コンポーネントは「masked_component: CustomComponent1」です。2番目のコンポーネント(アーカイブライブラリから)は「component: CustomComponent11」です。
ライブラリパスを削除します( library_pathpersist = False )

ライブラリ検索パスからパスを削除します。

パラメータ:
  • library_path ( str ) – 削除するライブラリパス。

  • persist ( bool ) – ライブラリパスの変更を永続的にします。

戻り値:

なし

昇給
  • SchApiItemNotFoundException が指定されていない場合

  • 既存のパス内のライブラリ パス。

例:

#
# Demonstrate use of {add,remove}_library_path and reload_library functions.
#
# All the path operations are temporary for the current running session.
#

from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()

#
# Library file is located in directory 'custom_lib' one level above this
# example file.
#
directory, __ = os.path.split(os.path.realpath(__file__))
lib_path = os.path.join(directory, "custom_lib")

# Get all current library paths and remove them
old_paths = mdl.get_library_paths()
for path in old_paths:
    mdl.remove_library_path(path)

# Add library path and reload library to be able to use added library.
mdl.add_library_path(lib_path)
mdl.reload_libraries()

# Create components from loaded libraries.
comp = mdl.create_component("my_lib/CustomComponent")
print("Component is '{0}'.".format(comp))

comp2 = mdl.create_component("archived_user_lib/CustomComponent1")
print("Second component (from archived library) is '{0}'.".format(
    comp2
))

# Remove library from the path.
mdl.remove_library_path(lib_path)

# Add again the previous library paths
for path in old_paths:
    mdl.add_library_path(path)

mdl.close_model()

出力

コンポーネントは「masked_component: CustomComponent1」です。2番目のコンポーネント(アーカイブライブラリから)は「component: CustomComponent11」です。
マスクの削除( item_handle )

指定されたアイテムからマスクを削除します アイテムハンドル.

パラメータ:

item_handle – (ItemHandle): ItemHandle オブジェクト。

戻り値:

なし

昇給
  • SchApiItemNotFoundException アイテムが見つからない場合、またはアイテムが

  • マスクを持っていない。

  • SchApiException の場合

  • 1 )アイテムはマスクの作成をサポートしていませ

  • 2 ) item_handleが無効です。

  • 3 )防護ためマスクは外せません

例:

# # 削除マスク関数の使い方を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # サブシステム コンポーネントを作成します。 sub = mdl . create_component ( "core/Subsystem" , name = "Subsystem 1" ) # サブシステム コンポーネントにマスクを作成します。 mask = mdl . create_mask ( sub ) # サブシステムからマスクを削除します。 mdl .remove_mask ( sub ) mdl . close_model ( )

出力


Remove_property ( item_handle , name )

によって名前が付けられたプロパティを削除します 名前 指定された項目から アイテムハンドル.

パラメータ:
  • item_handle ( ItemHandle ) – ItemHandle オブジェクト。

  • name ( str ) – プロパティ名。

戻り値:

なし

昇給
  • 項目またはプロパティが見つからない場合は SchApiItemNotFound です。

  • アイテムハンドルが無効な場合は SchApiException が発生します。

例:

# # create_property およびremove_property関数の使用方法を示します。 # from typhoon.api.schematic_editor SchematicAPIインポートする typhoon.api.schematic_editor import const mdl = SchematicAPI () mdl . create_new_model () # サブシステム コンポーネントを作成します。 sub = mdl . create_component ( "core/Subsystem"  name = "Sub1" ) # サブシステム 'Sub1' にマスクを作成しますmask = mdl . create_mask ( sub ) # マスクに 2 つのプロパティを作成します。 prop1 = mdl . create_property ( mask  name = "prop_1"  label = "Property 1"  widget = const . WIDGET_COMBO  combo_values = ( "Choice 1"  "Choice 2"  "Choice 3" ) 、 tab_name = "First tab" ) prop2 = mdl . create_property ( mask , name = "prop_2" , label = "プロパティ2" , widget = const.WIDGET_BUTTON , tab_name = " 2番目のタブ" ) # prop2を削除します。 mdl.remove_property ( mask , " prop_2 " ) mdl.close_model ( )

出力


保存

ロードされたモデルを、ロード元と同じファイルに保存します。

注記

この関数はハンドラーでは使用できません。

パラメータ:

なし

戻り値:

真実 モデルが正常に保存された場合、 間違い さもないと。

例:

# # save関数とsave_as関数の使い方を説明します。 # from typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl.create_new_model () r = mdl.create_component ( " core/Resistor"  name = " R1" ) c = mdl.create_component ( " core/Capacitor"  name = " C1 " ) con = mdl.create_connection ( mdl.term ( r  " n_node " )  mdl.term ( c  " p_node " ) ) mdl.save_as ( "save_path.tse " ) mdl.create_junction ( name = " Junction 1 " ) #変更保存mdl.save ( ) mdl.close_model ( )

出力


save_as (ファイル名)

回路図モデルを別の名前で保存します。

注記

この関数はハンドラーでは使用できません。

パラメータ:

filename ( str ) – ファイル名を新しいファイル名として使用して回路図モデルを保存します。

戻り値:

真実 モデルが保存されている場合、または 間違い 何らかのエラーが発生した場合。

例:

# # save関数とsave_as関数の使い方を説明します。 # from typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl.create_new_model () r = mdl.create_component ( " core/Resistor"  name = " R1" ) c = mdl.create_component ( " core/Capacitor"  name = " C1 " ) con = mdl.create_connection ( mdl.term ( r  " n_node " )  mdl.term ( c  " p_node " ) ) mdl.save_as ( "save_path.tse " ) mdl.create_junction ( name = " Junction 1 " ) #変更保存mdl.save ( ) mdl.close_model ( )

出力


set_color ( item_handle , color )

以降のすべてのアイコンAPI操作で使用する色を設定します。色名はQtフレームワークが理解できる形式の文字列で指定します。

パラメータ:
  • item_handle ( ItemHandle ) – アイテムハンドル。

  • color ( str ) – 色の名前。

戻り値:

なし

例:

# # Schematic APIアイコン関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () tr1 = mdl . create_component ( "core/Three Phase Two Winding Transformer" ) mdl . set_component_icon_image ( tr1 , "/path/to/image.png" ) # テキストを書き込む前に色を赤に設定mdl . set_color ( tr1 , "red" ) mdl . disp_component_icon_text ( tr1 , "Sample text" ) # シーンのコンポーネント ビューの更新を開始mdl . refresh_icon ( tr1 ) mdl . close_model ()

出力


set_component_icon_image ( item_handle , image_filename , rotate = 'rotate' )

アイコンに使用する画像を指定します。

パラメータ:
  • item_handle ( ItemHandle ) – アイテムハンドル。

  • image_filename ( str ) – 画像ファイル名。

  • rotate ( str ) – アイコンの回転動作を記述する定数( Schematic API定数を参照)。

戻り値:

なし

例:

# # Schematic APIアイコン関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () tr1 = mdl . create_component ( "core/Three Phase Two Winding Transformer" ) mdl . set_component_icon_image ( tr1 , "/path/to/image.png" ) # テキストを書き込む前に色を赤に設定mdl . set_color ( tr1 , "red" ) mdl . disp_component_icon_text ( tr1 , "Sample text" ) # シーンのコンポーネント ビューの更新を開始mdl . refresh_icon ( tr1 ) mdl . close_model ()

出力


set_component_property (コンポーネント,プロパティ,)

バージョン 2.0 以降では非推奨: 使用 set_property_value() その代わり。

コンポーネントのプロパティ値を指定された値に設定します。

注記

この関数はハンドラーでは使用できません。

パラメータ:
  • コンポーネント( str ) – コンポーネント名。

  • property ( str ) – プロパティ名 (プロパティのコード名、コンポーネントプロパティダイアログのプロパティウィジェットのツールチップに表示されます)。

  • value (オブジェクト) – 新しいプロパティ値。

戻り値:

真実 プロパティ値が正常に適用された場合、 間違い さもないと。

set_description ( item_handle , description )

指定された項目の説明を設定する アイテムハンドル.

パラメータ:
  • item_handle ( ItemHandle ) – ItemHandle オブジェクト。

  • description ( str ) – アイテムの説明。

戻り値:

なし

昇給
  • アイテムが見つからない場合は SchApiItemNotFoundException が発生します。

  • item_handle が指すアイテムが存在しない場合の SchApiException

  • 説明属性がないか、指定されたアイテムハンドルが無効です。

例:

# # set_description関数とget_description関数の使い方を説明します。 # from typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # # コンポーネントにマスクを作成し、 set_description を使用してマスクの説明を設定します。 # sub = mdl . create_component ( "core/Subsystem" , name = "Subsystem 1" ) mask = mdl . create_mask ( sub ) mdl . set_description ( mask , "Mask description content." ) # # ここで、get_description を使用して、以前に設定した説明を取得し、出力します。 # description = mdl . get_description ( mask ) print ( "Mask description is ' {0} '." . format ( description )) mdl . close_model ()

出力

マスクの説明は「マスクの説明内容」です。
set_flip ( item_handle , flip )

アイテムの反転ステータスを取得します( アイテムハンドル)。

パラメータ:
  • item_handle ( ItemHandle ) – アイテムハンドル。

  • flip (文字列) – いずれか1つ (“flip_none”, “flip_horizontal”, “flip_vertical”, “flip_both”)

戻り値:

なし

昇給
  • 指定された項目が見つからない場合は SchApiItemNotFoundException が発生します。

  • 指定された項目タイプまたはフリップ値が無効な場合、SchApiException が発生します。

例:

#
# Demonstrate use of get_flip and set_flip functions.
#
from typhoon.api.schematic_editor import SchematicAPI
from typhoon.api.schematic_editor import const

mdl = SchematicAPI()
mdl.create_new_model()

# Create one component on model root level.
sub1 = mdl.create_component("core/Subsystem", name="Subsystem1")

print(f"Current rotation: {mdl.get_flip(sub1)}")
mdl.set_flip(sub1, const.FLIP_HORIZONTAL)
print(f"New rotation: {mdl.get_flip(sub1)}")

出力

現在の回転: flip_none 新しい回転: flip_horizontal
set_handler_code ( item_handle , handler_name , code )

ハンドラコードを設定する コード ハンドラ名 ハンドラー名 アイテムについて アイテムハンドル.

パラメータ:
  • item_handle ( ItemHandle ) – ItemHandle オブジェクト。

  • handler_name ( str ) – ハンドラー名 - Schematic API const モジュールの定数 HANDLER_*。

  • code ( str ) – ハンドルコード。

戻り値:

なし

昇給
  • SchApiItemNotFound アイテムが見つからないハンドラーが見つからない場合 –

  • 名前で見つけられる

  • SchApiException アイテムハンドルが無効であるかハンドラーを設定できない場合 –

  • 指定された項目に対して例えばハンドラーの設定が禁止されている場合など

例:

#
# Demonstrate use of set_handler_code() and get_handler_code().
#
from typhoon.api.schematic_editor import SchematicAPI
from typhoon.api.schematic_editor.const import HANDLER_MASK_INIT, \
    HANDLER_PROPERTY_VALUE_CHANGED, WIDGET_COMBO

mdl = SchematicAPI()
mdl.create_new_model()

sub = mdl.create_component("core/Subsystem", name="Subsystem 1")

#
# Create mask and set MASK_INIT handler code.
#
mask_handle = mdl.create_mask(sub)

handler_code = """
import time
# Just display time.
print(f"Current time is '{time.asctime()}'.")
"""

mdl.set_handler_code(mask_handle, HANDLER_MASK_INIT, handler_code)

# Get handler code for the mask mask_handle.
retrieved_handler_code = mdl.get_handler_code(mask_handle, HANDLER_MASK_INIT)
print(f"Retrieved mask init handler code is {retrieved_handler_code}")

#
# Create one property on mask and set its PROPERTY_VALUE_CHANGED handler.
#
prop1 = mdl.create_property(
    mask_handle, name="prop_1", label="Property 1",
    widget=WIDGET_COMBO,
    combo_values=("Choice 1", "Choice 2", "Choice 3"),
    tab_name="First tab"
)

# Set property_value_changed handler on property.
prop_value_changed_handler_code = """
if new_value == "Choice 1":
    print("It's a first choice.")
elif new_value == "Choice 2":
    print("It's a second choice.")
elif new_value == "Choice 3":
    print("It's a third choice")
"""
mdl.set_handler_code(prop1, HANDLER_PROPERTY_VALUE_CHANGED, prop_value_changed_handler_code)

# Get handler code for a property prop1.
retrieved_handler_code = mdl.get_handler_code(prop1, HANDLER_PROPERTY_VALUE_CHANGED)
print(f"Retrieved property value changed handler code for prop1 is {retrieved_handler_code}")

mdl.close_model()

出力

Retrieved mask init handler code is 
import time
# Just display time.
print(f"Current time is '{time.asctime()}'.")

Retrieved property value changed handler code for prop1 is 
if new_value == "Choice 1":
    print("It's a first choice.")
elif new_value == "Choice 2":
    print("It's a second choice.")
elif new_value == "Choice 3":
    print("It's a third choice")
set_hw_settings (製品,リビジョン, conf_id )

バージョン 2.0 以降では非推奨: 使用 モデルプロパティ値の設定 その代わり。

注記

この関数はハンドラーでは使用できません。

新しいハードウェア設定を設定します。

パラメータ:
  • product ( str ) – 製品名(HIL 400、HIL 600など)。

  • リビジョン( str ) – 製品のリビジョン (1、2、…)。

  • conf_id ( str ) – 構成ID。

戻り値:

真実 操作が成功した場合、 間違い さもないと。

set_icon_drawing_commands ( item_handle , drawing_commands )

提供されている描画コマンドを設定する(描画コマンド)で示される項目に アイテムハンドル描画コマンドを使用して、対象項目の上にアイコンを描画します。

パラメータ:
  • item_handle ( ItemHandle ) – ItemHandle オブジェクト。

  • drawing_commands ( str ) – 描画コマンドを含む文字列。

戻り値:

なし

昇給
  • アイテムが見つからない場合は SchApiItemNotFoundException が発生します。

  • SchApiException アイテムハンドルが無効の場合、または次の場合

  • 対象項目は描画コマンド設定をサポートしていません。 –

例:

#
# Demonstrate use of get_icon_drawing_commands and set_icon_drawing_commands.
#

from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()

# Create subsystem and mask it.
sub = mdl.create_component("core/Subsystem", name="Subsystem 1")
mask = mdl.create_mask(sub)

# Define icon drawing commands.
icon_drawing_commands = """
image('my_image.png')
"""

# Set mask icon drawing commands.
mdl.set_icon_drawing_commands(mask, icon_drawing_commands)

# Aquire current icon drawwing commands.
mask_icon_drawing_commands = mdl.get_icon_drawing_commands(mask)
print("Icon drawing commands are: {0}".format(mask_icon_drawing_commands))

mdl.close_model()

出力

アイコン描画コマンドは次のとおりです: image('my_image.png')
set_item_visual_properties ( item_handle , prop_dict )

指定されたアイテムのprop_dictで定義されたビジュアルプロパティを設定します。アイテムの種類に応じて、以下のエントリが受け入れられます。

コンポーネント: 位置、回転、反転、サイズ タグ: 位置、回転、反転、サイズ ポート: 位置、回転、反転、terminal_position

パラメータ:

item_handle ( ItemHandle ) – 回路図アイテムのハンドル。

戻り値:

なし。

昇給
  • アイテムが見つからない場合は SchApiItemNotFoundException が発生します。

  • SchApiException 型がサポートされていないか少なくとも 1 つがサポートされていない場合 –

  • プロパティは設定できません。

例:

#
# Demonstrate use of get_item_visual_properties and set_item_visual_properties functions.
#
from typhoon.api.schematic_editor import SchematicAPI
from typhoon.api.schematic_editor import const

mdl = SchematicAPI()
mdl.create_new_model()

# Create one component on model root level.
sub1 = mdl.create_component("core/Subsystem", name="Subsystem1")

# Get the handle to port P1 inside Subsystem1
p1 = mdl.get_item(name="P1", parent=sub1, item_type=const.ITEM_PORT)

print("Before changes")
print("--------------")

print(f"Subsystem1 visual properties:")
# Get Subsystem1 visual properties
sub1_visual_props = mdl.get_item_visual_properties(sub1)
for prop_name, prop_value in sub1_visual_props.items():
    print(f" {prop_name} = {prop_value}")

# Get P1 visual properties
print(f"\nPort P1 visual properties:")
p1_visual_props = mdl.get_item_visual_properties(p1)
for prop_name, prop_value in p1_visual_props.items():
    print(f" {prop_name} = {prop_value}")

# Set a new size and rotation for Subsystem1.
sub1_new_props = {"size": (128, 128), "rotation": "right"}
mdl.set_item_visual_properties(sub1, sub1_new_props)

# Set a new terminal_position for port P1.
p1_new_props = {"terminal_position": ("top", "auto")}
mdl.set_item_visual_properties(p1, p1_new_props)

print("\nAfter changes")
print("--------------")

print(f"Subsystem1 visual properties:")
# Get Subsystem1 visual properties
sub1_visual_props = mdl.get_item_visual_properties(sub1)
for prop_name, prop_value in sub1_visual_props.items():
    print(f" {prop_name} = {prop_value}")

# Get P1 visual properties
print(f"\nPort P1 visual properties:")
p1_visual_props = mdl.get_item_visual_properties(p1)
for prop_name, prop_value in p1_visual_props.items():
    print(f" {prop_name} = {prop_value}")

出力

変更前 -------------- サブシステム 1 ビジュアル プロパティ: 位置 = [8192, 8192] 回転 = 上 反転 = flip_none サイズ = [48, 48] ポート P1 ビジュアル プロパティ: 位置 = [7768, 8064] 回転 = 上 反転 = flip_none ターミナル位置 = ['left', 'auto'] computed_terminal_position = [-24, 0] 変更後 -------------- サブシステム 1 ビジュアル プロパティ: 位置 = [8192, 8192] 回転 = 右 反転 = flip_none サイズ = [128, 128] ポート P1 ビジュアル プロパティ: 位置 = [7768, 8064] 回転 = 上 反転 = flip_none ターミナル位置 = ['top', 'auto'] computed_terminal_position = [0, -64]
set_label ( item_handle , label )

指定された項目のラベルを設定する アイテムハンドル.

パラメータ:
  • item_handle ( ItemHandle ) – アイテムハンドル。

  • label ( str ) – 設定するラベル文字列。

戻り値:

なし

昇給
  • アイテムが見つからない場合は SchApiItemNotFoundException が発生します。

  • 指定されたアイテムにラベル属性がない場合、SchApiException が発生します。

例:

# # get_labelとset_label関数の使い方を説明します。 # from typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () sub = mdl . create_component ( type_name = "core/Subsystem" ) prt = mdl . create_port ( name = "Port 1" , parent = sub ) # ポートラベルを設定します。 mdl . set_label ( prt , "Port 1 label" ) # ポートラベルを取得して出力します。 port_label = mdl . get_label ( prt ) print ( "ポートラベルは ' {0} ' です。" . format ( port_label )) mdl . close_model ()

出力

ポート ラベルは「ポート 1 ラベル」です。
set_model_dependencies ( dependencies_list )

モデルの依存関係としてファイル/ディレクトリのリストを設定します。ファイルとディレクトリは文字列のリストとして渡されます。これはモデルのコンパイルに影響を与えるデータを表します。モデル自体と依存ファイルが2回のコンパイル間で変更されていない場合、2回目のコンパイルはスキップされます。

パラメータ:

dependency_list ( list ) – ファイルまたはディレクトリを表す文字列のリスト。

戻り値:

なし

例:

# # set_model_dependencies関数の使用例# from typhoon.api.schematic_editor SchematicAPIインポートする typhoon.api.schematic_editor.const import KIND_SP # サンプルの依存関係ファイルを作成します。 with open ( " dependency1.csv " , "w" ) as dependency_file : dependency_file.write ( "1,2,3 \n " ) dependency_file.write ( " 2,3,4 " ) with open ( "dependency2.csv" , "w" ) as dependency_file : dependency_file.write ( "4,3,2 \n " ) dependency_file.write ( " 3,2,1" ) # 新しいモデルを作成します mdl = SchematicAPI ( ) mdl.create_new_model ( ) #スキームを作成します。 mdl.create_component ( " core /Resistor" ) #モデルの依存関係のリストを設定します mdl.set_model_dependencies ([ "dependency1.csv" , "dependency2.csv" ]) # 依存関係ファイルを削除してディレクトリをクリーンアップします os . Remove ( "dependency1.csv" ) os .remove ( "dependency2.csv" ) # モデルを閉じるmdl .close_model ( )

出力


set_model_init_code (コード)

モデル初期化コードを設定します。

パラメータ:

code ( str ) – モデルの初期化コードを文字列として表します。

戻り値:

なし

昇給

アクティブなモデルがない場合、SchApiException が発生します。

例:

# # set_model_init_code の使い方を説明します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () model_init_code = """ # 抵抗器 R1 初期抵抗として機能する変数を作成します。 initial_resistance = 100.0 """ mdl . set_model_init_code ( model_init_code ) r = mdl . create_component ( "core/Resistor" , name = "R1" ) c = mdl . create_component ( "core/Capacitor" ) vs = mdl . create_component ( "core/Voltage Source" ) mdl . create_connection ( mdl . term ( vs , "p_node" ), mdl . term ( r , "p_node" )) mdl . create_connection ( mdl . term ( r , "n_node" ), mdl . term ( c , "p_node" )) mdl . create_connection ( mdl . term ( c , "n_node" ), mdl . term ( vs , "n_node" )) mdl . set_property_value ( mdl . prop ( r , "resistance" ), "initial_resistance" ) # モデルを保存します。 mdl . save_as ( "model.tse" ) if mdl . compile (): print ( "コンパイルが成功しました。" ) else : print ( "コンパイルに失敗しました。" ) mdl . close_model ()

出力

コンパイルに成功しました。
set_model_property_value ( prop_code_name , value )

モデル プロパティを指定された値に設定します。

パラメータ:
  • prop_code_name ( str ) – モデルプロパティのコード名。

  • value (オブジェクト) – 設定する値。

戻り値:

なし

昇給
  • 指定されたモデルプロパティが存在しない場合は、SchApiItemNotFoundException が発生します。

  • 存在します。

例:

# # get_model_property_valueとset_model_property_valueの使用方法を示します。 # from typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # 現在の hil デバイスを出力しますprint ( mdl . get_model_property_value ( "hil_device" )) # show_modes モデル プロパティを True に変更しますshow_modes = mdl . get_model_property_value ( "show_modes" ) print ( "変更前の表示モードは{0}です。" . format ( show_modes )) mdl . set_model_property_value ( "show_modes" , True ) show_modes = mdl . get_model_property_value ( "show_modes" ) print ( "変更後の表示モードは{0}です。" . format ( show_modes )) mdl . close_model ()

出力

HIL402 変更前の表示モードはFalseです。変更後の表示モードはTrueです。
set_name (アイテムハンドル,名前)

アイテムの名前を設定します。

パラメータ:
  • item_handle ( ItemHandle ) – アイテムハンドル。

  • name ( str ) – 設定する名前。

戻り値:

なし

昇給
  • SchApiItemNameExistsException すでに別のアイテムが存在する場合

  • 提供された名前。

  • item_handle が指すアイテムが存在しない場合の SchApiException

  • 名前属性がないか、他の項目にすでに名前が指定されている場合。

例:

# # set_nameの使い方を示します。 # from typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () probe = mdl . create_component ( "core/Probe" , name = "Probe 1" ) print ( "初期のプローブ名は ' {0} ' です。" . format ( mdl . get_name ( probe ))) # 名前の変更mdl . set_name ( probe , "プローブの新しい名前" ) print ( "名前変更後のプローブの名前は ' {0} ' です。" . format ( mdl . get_name ( probe ))) mdl . close_model ()

出力

初期プローブ名は「プローブ 1」です。名前変更後のプローブ名は「プローブの新しい名前」です。
set_ns_var ( var_name , value )

名前空間変数を設定する 変数名価値変数が名前空間に存在しない場合は、作成され、値が設定されます。

パラメータ:
  • var_name ( str ) – 名前空間変数名。

  • value (オブジェクト) – 設定する値。

戻り値:

なし

例:

# # set_ns_var および get_ns_var 関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # 'var1' という名前の変数を作成mdl . set_ns_var ( "var1" , 20 ) print ( mdl . get_ns_var ( "var1" )) # 変数 'var1' の値を更新mdl . set_ns_var ( "var1" , 100 ) print ( mdl . get_ns_var ( "var1" )) mdl . close_model ()

出力

20 100
set_port_properties ( item_handleterminal_position = Nonehide_term_label = Noneterm_label = '' )

ポート プロパティを設定します (ポート プロパティ ダイアログに表示されるとおり)。

パラメータ:
  • item_handle ( ItemHandle ) – ポート項目ハンドル。

  • terminal_position (タプル) – このポートに基づいて端末の位置を指定します。

  • hide_term_label ( bool ) – ポート端末ラベルを表示するかどうかを示します。

  • term_label ( str ) – 代替端末ラベルを指定します。

戻り値:

なし

昇給

指定された item_handle がポート用でない場合は SchApiException が発生します。

例:

# # set_port_properties() 関数の使い方を説明します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # コンポーネントを作成しますsub1 = mdl . create_component ( "core/Subsystem" ) prt1 = mdl . create_port ( parent = sub1 , name = "Port 1" ) # ポートのプロパティをいくつか変更します。 mdl . set_port_properties ( prt1 , term_position = ( "auto" , 3 ), hide_term_label = False , term_label = "New label" ) mdl . close_model ()

出力


set_position ( item_handle , position )

項目を設定します( アイテムハンドル) 位置。

注記

位置座標は、グリッド解像度で割り切れる最も近い値に丸められます (これは、スキームのグラフィカル表現では位置がこの動作を尊重すると想定されているため行われます)。

パラメータ:
  • item_handle ( ItemHandle ) – アイテムハンドル。

  • 位置(シーケンス) – 設定する位置。

戻り値:

なし

昇給

指定された項目が見つからない場合は SchApiItemNotFoundException が発生します。

例:

# # get_positionとset_positionの使い方を説明します。 # from typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # タグ項目の位置を取得tag = mdl . create_tag ( name = "タグ 1" , value = "タグ値" , position = ( 160 , 240 )) print ( "タグの位置は{0}です。" . format ( mdl . get_position ( tag ))) # 位置を設定mdl . set_position ( tag , ( 800 , 1600 )) print ( "新しいタグの位置は{0}です。" . format ( mdl . get_position ( tag ))) mdl . close_model ()

出力

タグの位置は[160, 240]です。新しいタグの位置は[800, 1600]です。
set_property_attribute (コンポーネントプロパティ属性)

注意: この関数は非推奨です。この関数を使用するコードが存在するため、ここに残しておきます。

パラメータ:
  • コンポーネント– コンポーネント名。

  • プロパティ– プロパティ名。

  • 属性– 属性名。

  • value – プロパティの新しい値。

戻り値:

成功した場合は True、それ以外の場合は False。

set_property_combo_values ( prop_handle , combo_values )

プロパティコンボ値を指定された値に設定します。

注記

指定されたプロパティ プロップハンドル ウィジェットをコンボに設定する必要があります。

パラメータ:
  • prop_handle ( ItemHandle ) – プロパティハンドル。

  • combo_values (シーケンス) – 新しいコンボ値のシーケンス。

戻り値:

なし

昇給
  • プロパティハンドルで関数が呼び出されたときの SchApiException

  • プロパティウィジェットがコンボではない場合。

例:

# # get_property_combo_values および set_property_combo_values関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () tr_line = mdl . create_component ( "core/Transmission Line" , name = "TR Line 1" ) # # model_def という名前のコンポーネント プロパティに新しいコンボ値を追加します# model_def_handle = mdl . prop ( tr_line , "model_def" ) model_def_combo_values = mdl . get_property_combo_values ( model_def_handle ) new_combo_values = model_def_combo_values + [ "New option" ] # 新しいコンボ値を設定しますmdl . set_property_combo_values ( model_def_handle , new_combo_values ) mdl . close_model ()

出力


set_property_disp_value ( prop_handle , value )

プロパティの表示値を設定します。

パラメータ:
  • prop_handle ( ItemHandle ) – プロパティハンドル。

  • value ( str ) – 値。

戻り値:

なし

例:

# # set_property_disp_value と get_property_disp_value の使用方法を示します typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # コンポーネントを作成const = mdl . create_component ( "core/Constant" ) # コンポーネントのプロパティ表示値を設定するmdl . set_property_disp_value ( mdl . prop ( const , "value" ), 70 ) # コンポーネントのプロパティ表示値を印刷するprint ( mdl . get_property_disp_value ( mdl . prop ( const , "value" ))) mdl . close_model ()

出力

70
set_property_value ( prop_handle , value )

プロパティに新しい値を設定します。

パラメータ:
  • prop_handle ( ItemHandle ) – プロパティハンドル。

  • value (オブジェクト) – 新しい値。

例:

# # set_property_value および get_property_value関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () const = mdl . create_component ( "core/Constant" ) # 現在のプロパティ値を出力しますprint ( mdl . get_property_value ( mdl . prop ( const , "value" ))) # 新しいプロパティ値を設定しますmdl . set_property_value ( mdl . prop ( const , "value" ), 20 ) print ( mdl . get_property_value ( mdl . prop ( const , "value" ))) mdl . close_model ()

出力

[1.0] [20.0]
set_property_value_type ( prop_handle , new_type )

プロパティに新しい値の型を設定します。

パラメータ:

prop_handle ( ItemHandle ) – プロパティハンドル。

戻り値:

なし

昇給

新しい型が無効な場合はSchApiExceptionが発生します

例:

# # set_property_value_type および get_property_value_type関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () const = mdl . create_component ( "core/Constant" ) # 現在のプロパティ値を出力しますprint ( mdl . get_property_value_type ( mdl . prop ( const , "value" ))) # 新しいプロパティ値を設定しますmdl . set_property_value_type ( mdl . prop ( const , "value" ), "uint" ) print ( mdl . get_property_value_type ( mdl . prop ( const , "value" ))) mdl . close_model ()

出力

実数単位
set_property_values ( item_handle , values )

提供されたコンポーネントの複数のプロパティ値を設定します。

パラメータ:
  • item_handle ( ItemHandle ) – コンポーネントハンドル。

  • values ( dict ) – キーがプロパティ名で、値が新しいプロパティ値である辞書。

例:

#
# Demonstrate use of save and save_as functions.
#
from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()

vs = mdl.create_component("core/Voltage Source")
c = mdl.create_component("core/Capacitor", name="C1")
con1 = mdl.create_connection(mdl.term(vs, "n_node"), mdl.term(c, "n_node"))
con2 = mdl.create_connection(mdl.term(vs, "p_node"), mdl.term(c, "p_node"))

def get_and_print(comp_handle):
    """
    Get and print component property values.
    """
    values = mdl.get_property_values(comp_handle)
    print("Component '{0}' property values are '{1}'.".format(
        mdl.get_name(comp_handle), values
    ))

# Get property values from both components and print them.
get_and_print(vs)
get_and_print(c)

# Change capacitor property values.
new_values = {
    "capacitance": 34.2,
    "initial_voltage": 10.3,
}

mdl.set_property_values(c, new_values)

# Print c property values to confirm they are changed.
get_and_print(c)

mdl.close_model()

出力

Component 'Vs1' property values are '{'sig_input': 'False', 'type': 'signal generator', 'param_set': '1phase', 'parent_label': '', 'dtsm_switch_name': '', 'addr': 0, 'spc_nb': 0, 'execution_rate': 0.0001, 'cpd_visible': True, 'enable_snb': False, 'snb_type': 'R2', 'R2': 0.0, 'L1': 0.1, 'override_signal_name': False, 'signal_name': '', 'init_source_nature': 'Constant', 'init_const_value': 0.0, 'init_rms_value': 0.0, 'init_frequency': 50.0, 'init_phase': 0.0}'.
Component 'C1' property values are '{'signal_access': 'inherit', 'capacitance': 1e-06, 'initial_voltage': 0.0, 'pole_shift_ignore': False, 'visible': True}'.
Component 'C1' property values are '{'signal_access': 'inherit', 'capacitance': 34.2, 'initial_voltage': 10.3, 'pole_shift_ignore': False, 'visible': True}'.
set_rotation ( item_handle , rotation )

アイテムの回転を設定します( アイテムハンドル)。

パラメータ:
  • item_handle ( ItemHandle ) – アイテムハンドル。

  • 回転(文字列) – いずれか1つ (「上」、「右」、「左」、「下」)

戻り値:

なし

昇給
  • 指定された項目が見つからない場合は SchApiItemNotFoundException が発生します。

  • 指定されたアイテムタイプが有効でない場合、SchApiException が発生します。

例:

#
# Demonstrate use of get_rotation and set_rotation functions.
#
from typhoon.api.schematic_editor import SchematicAPI
from typhoon.api.schematic_editor import const

mdl = SchematicAPI()
mdl.create_new_model()

# Create one component on model root level.
sub1 = mdl.create_component("core/Subsystem", name="Subsystem1")

print(f"Current rotation: {mdl.get_rotation(sub1)}")
print(f"\nSetting new rotation value: {const.ROTATION_DOWN}\n")
mdl.set_rotation(sub1, const.ROTATION_DOWN)
print("Rotation correctly set?")
print(f"{mdl.get_rotation(sub1) == const.ROTATION_DOWN}")

出力

現在の回転: 上 新しい回転値の設定: 下 回転は正しく設定されていますか? True
set_simulation_method (シミュレーション方法)

バージョン 2.0 以降では非推奨: 使用 モデルプロパティ値の設定 その代わり (シミュレーション方法 構成オブジェクトのフィールド)。

シミュレーション方法を設定します。

注記

この関数はハンドラーでは使用できません。

パラメータ:

Simulation_method ( str ) – シミュレーションに使用する方法。

戻り値:

真実 成功した場合、 間違い さもないと。

例:

# # set_simulation_time および set_simulation_time_step 関数の使用方法を示します。 #から typhoon.api.schematic_editor SchematicAPIインポートする typhoon.api.schematic_editor インポートconst mdl = SchematicAPI ( ) mdl.create_new_model ( ) mdl.set_simulation_method ( const.SIM_METHOD_TRAPEZOIDAL ) mdl.set_simulation_time_step ( 1e - 6 ) mdl.close_model ( )

出力


set_simulation_time_step ( time_step )

バージョン 2.0 以降では非推奨: 使用 モデルプロパティ値の設定 その代わり (シミュレーション時間ステップ 構成オブジェクトのフィールド)。

概略モデルのシミュレーション時間 time_step を設定します。

注記

この関数はハンドラーでは使用できません。

パラメータ:

time_step ( str ) – シミュレーションに使用される時間ステップ。

戻り値:

真実 成功した場合、 間違い さもないと。

例:

# # set_simulation_time および set_simulation_time_step 関数の使用方法を示します。 #から typhoon.api.schematic_editor SchematicAPIインポートする typhoon.api.schematic_editor インポートconst mdl = SchematicAPI ( ) mdl.create_new_model ( ) mdl.set_simulation_method ( const.SIM_METHOD_TRAPEZOIDAL ) mdl.set_simulation_time_step ( 1e - 6 ) mdl.close_model ( )

出力


set_size ( item_handle= None高さ= None )

渡されたアイテムのサイズ (幅/高さ) を設定します。:param item_handle: アイテムハンドルオブジェクト。:type item_handle: アイテムハンドル。:param width: アイテムの新しい幅。:type width: int, float。:param height: アイテムの新しい高さ。:type height: int, float

戻り値:

なし

昇給
  • SchApiException 渡された幅または高さが

  • 最小値を下回っています。

例:

# # get_size および set_size 関数の使用方法を示します。 #から typhoon.api.schematic_editor SchematicAPIインポートする typhoon.api.schematic_editor import const mdl = SchematicAPI () mdl . create_new_model () # モデル ルート レベルでコンポーネントを 1 つ作成します。 sub1 = mdl . create_component ( "core/Subsystem"  name = "Subsystem1" ) # コンポーネントの新しいサイズを定義します。 new_width = 70 new_height = 55 # 新しいサイズを設定し、get_size() が新しいサイズを返すかどうかを確認します。 mdl . set_size ( sub1  width = new_width  height = new_height ) print ( mdl . get_size ( sub1 ) == [ new_width  new_height ]) # # コンポーネント サイズ コンポーネントを個別に設定し、get_size() が正しいサイズを返すかどうかを確認します。 # mdl . set_size ( sub1  width = 100 ) print ( mdl . get_size ( sub1 ) == [ 100  new_height ]) mdl . set_size ( sub1 , height = 80 ) print ( mdl . get_size ( sub1 ) == [ 100 , 80 ])

出力

本当だ、本当だ、本当だ
set_tag_properties ( item_handlevalue = Nonescope = None )

タグのプロパティ (スコープや値など) を設定します。

パラメータ:
  • item_handle ( ItemHandle ) – タグアイテムハンドル。

  • value ( str ) – タグの値。

  • scope ( str ) – タグのスコープ。

戻り値:

なし

昇給

提供された item_handle がタグ用でない場合は SchApiException が発生します。

例:

# # set_tag_properties関数の使い方を説明します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl.create_new_model () r1 = mdl.create_component ( " core /Resistor" , name = " R1" ) tag1 = mdl.create_tag ( name = "Tag 1" , value = " A" ) #タグ変更ます。 mdl.set_tag_properties ( tag1 , value = "B " ) mdl.close_model ( )

出力


set_terminal_dimension (端末ハンドル,寸法)

コンポーネント端子の寸法を設定します。

パラメータ:
  • terminal_handle ( ItemHandle ) – 端末ハンドル。

  • ディメンション(タプル) – 終端の新しいディメンション。

例:

# # get_terminal_dimension および set_terminal_dimension関数の使用方法を示します。 #から typhoon.api.schematic_editor SchematicAPIインポートします。mdl = SchematicAPI () mdl.create_new_model () const = mdl.create_component ( " core /Constant"  name = "Constant 1" ) print ( mdl.get_terminal_dimension ( mdl.term ( const , " out " ) ) ) mdl.set_terminal_dimension ( mdl.term ( const , " out " ) ) , ( 2 , ) ) print ( mdl.get_terminal_dimension ( mdl.term ( const , " out " ) ) ) mdl.close_model ( )

出力

calc [2]
set_terminal_feedthrough (端末ハンドル,フィードスルー)

端子フィードスルー値を設定します。

パラメータ:
  • terminal_handle ( ItemHandle ) – 端末ハンドル。

  • feedthrough ( bool ) – 端子フィードスルー値。

戻り値:

なし

例:

# # 用語関数の使用例を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # アキュムレータ コンポーネントを作成します。その出力端子はフィードスルーですacc = mdl . create_component ( "core/Accumulator" , name = "Accummulator 1" ) print ( mdl . is_terminal_feedthrough ( mdl . term ( acc , "out" ))) # フィードスルーを変更します mdl . set_terminal_feedthrough ( mdl . term ( acc , "out" ), False ) print ( mdl . is_terminal_feedthrough ( mdl . term ( acc , "out" ))) mdl . close_model ()

出力

真偽
set_terminal_sp_type (端末ハンドル, sp_type )

コンポーネント端子のSP(信号処理)タイプを設定します。

SP タイプは、SP タイプの定数 ( Schematic API 定数を参照) のいずれか、またはそれらの値に評価できる式になります。

パラメータ:
  • terminal_handle ( ItemHandle ) – 端末ハンドル。

  • sp_type ( str ) – SP (信号処理) タイプ。

例:

# # set_terminal_sp_type および set_terminal_sp_type_value関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # # set_terminal_sp_type は間接的に端末の sp タイプを設定します。端末の sp タイプ# リゾルバはコンパイル時に sp タイプ値を計算しますが、これはset_terminal_sp_type_value を使用して直接設定することもできます (以下の例を参照) # const1 = mdl . create_component ( "core/Constant" , name = "Constant 1" ) mdl . set_terminal_sp_type ( mdl . term ( const1 , "out" ), "int" ) # set_terminal_sp_type_value は端末の sp_type 値を直接設定しますmdl . set_terminal_sp_type_value ( mdl . term ( const1 , "out" ), "int" ) mdl . close_model ()

出力


set_terminal_sp_type_value (端末ハンドル, sp_type_value )

コンポーネント端子のSPタイプを直接設定します。

パラメータ:
  • terminal_handle ( ItemHandle ) – 端末ハンドル。

  • sp_type_value ( str ) – 新しい SP タイプ値。SP タイプの場合は定数である必要があります ( Schematic API 定数を参照)。

例:

# # set_terminal_sp_type および set_terminal_sp_type_value関数の使用方法を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () # # set_terminal_sp_type は間接的に端末の sp タイプを設定します。端末の sp タイプ# リゾルバはコンパイル時に sp タイプ値を計算しますが、これはset_terminal_sp_type_value を使用して直接設定することもできます (以下の例を参照) # const1 = mdl . create_component ( "core/Constant" , name = "Constant 1" ) mdl . set_terminal_sp_type ( mdl . term ( const1 , "out" ), "int" ) # set_terminal_sp_type_value は端末の sp_type 値を直接設定しますmdl . set_terminal_sp_type_value ( mdl . term ( const1 , "out" ), "int" ) mdl . close_model ()

出力


set_tunable ( item_handle , value )

項目を調整可能に設定します。項目ハンドルはコンポーネントまたはプロパティのいずれかになります。コンポーネントハンドルを指定した場合、調整可能なすべてのプロパティが調整可能になります。

パラメータ:
  • item_handle ( ItemHandle ) – コンポーネントハンドルまたはプロパティハンドル

  • value ( bool ) – True または False

戻り値:

ブール

例:

# # is_component_composite関数の使い方を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () const = mdl . create_component ( "core/Constant" ) print ( "Tunable default = {0} ." . format ( mdl . is_tunable ( const ))) # 調整可能として設定mdl . set_tunable ( const , True ) print ( "Tunable = {0} ." . format ( mdl . is_tunable ( const ))) # 調整不可として設定mdl . set_tunable ( const , False ) print ( "Tunable = {0} ." . format ( mdl . is_tunable ( const )))

出力

調整可能なデフォルト = False。調整可能 = True。調整可能 = False。
show_name ( item_handle )

回路図アイテムの名前を表示します。:param item_handle: ItemHandle オブジェクト。:type item_handle: ItemHandle

戻り値:

なし

昇給
  • SchApiException は、渡されたItemHandleに関連付けられたアイテムの場合に発生します

  • NameableMixin オブジェクトではありません。

例:

#
# Example demonstrates use of the is_name_visible(),
# show_name() and hide_name() functions.
#

from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()


# Initial component creation
const = mdl.create_component(type_name="core/Constant")
print(f"Initial component name visibility: {mdl.is_name_visible(const)}")


# Hiding the component's name
mdl.hide_name(const)
print(f"Component name visibility after calling hide_name():"
      f"{mdl.is_name_visible(const)}")


# Showing the component's name
mdl.show_name(const)
print(f"Component name visibility after calling show_name():"
      f"{mdl.is_name_visible(const)}")


mdl.close_model()

出力

初期のコンポーネント名の可視性: True hide_name() 呼び出し後のコンポーネント名の可視性: False show_name() 呼び出し後のコンポーネント名の可視性: True
show_property ( prop_handle )

コンポーネントのダイアログにコンポーネントのプロパティを表示します。

注記

この機能の効果は、回路図エディターの UI でのみ表示されます。

この関数が呼び出されると、コンポーネントのダイアログにプロパティが表示されます。プロパティを非表示にするには、 非表示プロパティ() 関数。

パラメータ:

prop_handle ( ItemHandle ) – プロパティハンドル。

戻り値:

なし

例:

# # 例では、hide_property、show_property、および# is_property_visible 関数の使用方法を示します。 #から typhoon.api.schematic_editor SchematicAPIインポートします。mdl = SchematicAPI ( ) mdl.create_new_model ( ) const = mdl.create_component ( type_name = " core / Constant " ) print ( mdl.is_property_visible ( mdl.prop ( const , " value " ) ) ) mdl.hide_property ( mdl.prop ( const , " value " ) ) print ( mdl.is_property_visible ( mdl.prop ( const , " value " ) ) ) mdl.show_property ( mdl.prop ( const , " value " ) ) print ( mdl.is_property_visible ( mdl.prop ( const , " value " ) ) ) mdl.close_model ( )

出力

真偽 真
sync_dynamic_terminals ( comp_handle , term_name , term_num , labels = None , sp_types = None , feedthroughs = None )

指定された名前のコンポーネント上の動的端末の数を同期します。

パラメータ:
  • comp_handle ( ItemHandle ) – コンポーネントハンドル。

  • term_name ( str ) – 端末名。

  • term_num ( int ) – 同期する端末の数。

  • labels (リスト) – 新しい端末のラベルのリスト。

  • sp_types ( list ) – 新しい端末のSPタイプのリスト。

  • フィードスルー(リスト) – 新しい端子のフィードスルー値のリスト。

例:

# # sync_dynamic_terminals関数の使い方を示します。 #から typhoon.api.schematic_editor import SchematicAPI mdl = SchematicAPI () mdl . create_new_model () sum = mdl . create_component ( "core/Sum" , name = "Sum 1" ) # 'in' という名前の動的端子の数を 2 から 10 に増やしますmdl . sync_dynamic_terminals ( sum , "in" , 10 ) # 端子の数を 2 に戻しますmdl . sync_dynamic_terminals ( sum , "in" , 2 ) mdl . close_model ()

出力


term ( comp_handle , term_name )

端末固有のIDハンドルを作成します。端末のfqnが期待される場所で使用します。

パラメータ:
  • comp_handle ( ItemHandle ) – コンポーネントハンドル。

  • term_name ( str ) – 端末名。

戻り値:

端末ハンドル。

例:

# # 用語関数の使用例を示します。 #から typhoon.api.schematic_editor SchematicAPIインポートしますmdl = SchematicAPI ( ) mdl.create_new_model ( ) r = mdl.create_component ( " core/Resistor" , name = "R1" ) r_term_id = mdl.term ( r , "n_node" ) print ( r_term_id ) sub = mdl.create_component ( "core / Subsystem" , name = " Subsystem 1" ) c = mdl.create_component ( " core / Capacitor " , name = " C1" ) c_term_id = mdl.term ( c , " p_node " ) print ( c_term_id ) mdl.close_model ( )

出力

端末: R1.n_node 端末: C1.p_node

コンポーネントのリンクを解除し、コンポーネントからライブラリ実装へのリンクを解除します。これにより、コンポーネント実装がライブラリからモデルコンポーネントに転送されるため、特定のライブラリを提供することなく、このコンポーネントを含むモデルを自由に共有できるようになります。

パラメータ:

item_handle ( ItemHandle ) – コンポーネント項目ハンドルオブジェクト。

戻り値:

なし

昇給
  • SchApiException -次のいずれかが発生した場合

  • コンポーネントはアトミックコンポーネントです。

  • コンポーネントはすでにリンク解除されています。

  • 1 つ以上のコンポーネントの親がリンクされています。

  • コンポーネントがロックされているか、一部の親がロックされています。

  • コンポーネントが見つからない場合は SchApiItemNotFoundException が発生します。

例:

# # 用語関数の使用例を示します。 #から typhoon.api.schematic_editor SchematicAPIインポートします。mdl = SchematicAPI ( ) mdl.create_new_model ( ) grid_fault = mdl.create_component ( " core/ Grid Fault " ) mdl.unlink_component ( grid_fault ) mdl.close_model ( )

出力


警告( msgkind = '一般的な警告'context = None )

何らかの警告状態を通知します。

パラメータ:
  • msg ( str ) – メッセージ文字列。

  • kind ( str ) – 警告の種類。

  • context ( ItemHandle ) – コンテキスト項目のハンドル。

戻り値:

なし

昇給

コンテキスト項目が見つからない場合は SchApiItemNotFoundException が発生します。

例:

#
# Demonstrate use of warning.
#
from typhoon.api.schematic_editor import SchematicAPI
mdl = SchematicAPI()
mdl.create_new_model()

r = mdl.create_component("core/Resistor", name="R1")
resistance_prop_handle = mdl.prop(r, "resistance")

if mdl.get_property_value(resistance_prop_handle) < 0.0:
    mdl.warning(msg="Resistance value is negative",
                context=resistance_prop_handle)

mdl.close_model()

出力