このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。
入力端子構造体の生成された型と名前の取得
入力端子と出力端子の構造体の生成された型と名前を取得するには、コード記述子 API を使用します。コード ジェネレーターは、コードの生成時にこの情報を DataInterface オブジェクトの DataImplementation オブジェクト フィールド内に保存します。
生成コードとアプリケーションの他のコンポーネントのインターフェイスをとるには、コード記述子 API を使用します。
モデルを開いて作成
モデルを開きます。
myModel = "SumModel";
open_system(myModel);
モデルをビルドします。
evalc("slbuild(myModel)");生成されたコードには入力端子を表す構造体が含まれます。
/* External inputs (root inport signals with default storage) */ ExtU rtU;
コード記述子と入力端子構造体の名前と型の取得
コード記述子オブジェクトを取得します。
codeDescObj = coder.getCodeDescriptor(myModel)
codeDescObj =
CodeDescriptor with properties:
ModelName: 'SumModel'
BuildDir: '/tmp/Bdoc25a_2864802_2939215/tp5505882c/simulinkcoder-ex78186698/SumModel_ert_rtw'
生成されたコードのデータ インターフェイスの種類のリストを取得します。
dataInterfaceTypes = codeDescObj.getDataInterfaceTypes()
dataInterfaceTypes = 2×1 cell
{'Inports' }
{'Outports'}
入力端子を表す DataInterface オブジェクトを取得します。
inports = codeDescObj.getDataInterfaces('Inports')inports =
1×2 DataInterface array with properties:
Type
SID
GraphicalName
VariantInfo
Implementation
Timing
Unit
Range
最初の入力端子を表す Implementation オブジェクトを取得します。この例では、入力端子はそれぞれ DataImplementation のサブクラスである StructExpression として表されます。
impl = inports(1).Implementation
impl =
StructExpression with properties:
Type: [1×1 coder.descriptor.types.Type]
BaseRegion: [1×1 coder.descriptor.TypedRegion]
ElementIdentifier: 'In1'
Variant: ''
最初の入力端子の Type を取得します。この入力端子の Type は real_T です。
implType = impl.Type
implType =
Double with properties:
Identifier: 'real_T'
Name: 'double'
ReadOnly: 0
Volatile: 0
WordLength: 64
Signed: 1
最初の入力端子の BaseRegion を取得します。BaseRegion は入力端子を含む構造体を表します。BaseRegion は rtU です。
baseRegion = impl.BaseRegion
baseRegion =
Variable with properties:
Type: [1×1 coder.descriptor.types.Type]
Identifier: 'rtU'
VarOwner: 'SumModel'
StorageSpecifier: 'extern'
BaseRegion の Type を取得します。BaseRegion の Type は ExtU です。
baseRegionType = baseRegion.Type
baseRegionType =
Struct with properties:
Identifier: 'ExtU'
Name: 'ExtU'
ReadOnly: 0
Volatile: 0
Elements: [1×2 coder.descriptor.types.AggregateElement Sequence]
Checksum: [1×0 Integer Sequence]