coder.mapping.api.get
説明
は指定されたモデルに対してアクティブなコード マッピングを coderMapObj
= coder.mapping.api.get(simulinkModel
)coderMapObj
オブジェクトとして返します。コード マッピングはモデル データ要素を C または C++ コード生成の構成に関連付けます。モデルに複数のコード マッピングがある場合、アクティブなコード マッピングはアクティブなシステム ターゲット ファイルに関連付けられたマッピングです。
コード マッピングが存在しない場合、エラーが生成されます。モデルの Coder アプリを開くと、Simulink® はコード マッピング オブジェクトを作成します。モデルの Coder アプリを開いていない場合は、関数 coder.mapping.utils.create
を呼び出してコード マッピング オブジェクトを作成できます。
例
Simulink モデルのコード マッピングのプログラムによる作成と使用
プログラム インターフェイスを使用して、Simulink モデルのコード マッピング オブジェクトを作成および使用します。
モデル NoCoderMapping
を読み込みます。
simulinkModel = "NoCoderMapping";
load_system(simulinkModel);
try-catch
ブロックを使用して、モデル用にコード マッピング オブジェクトが存在するかどうかを判別します。try
ブロック内で、関数 coder.mapping.api.get
を使用して既存のオブジェクトの取得を試みます。catch
ブロック内で、関数 coder.mapping.utils.create
を使用して新しいコード マッピング オブジェクトを作成します。コード マッピング オブジェクトを変数 codeMapObj に保存します。
モデルに既存のコード マッピング オブジェクトがあったかどうかを示す出力メッセージを追加します。
try codeMapObj = coder.mapping.api.get(simulinkModel); fprintf("" + ... " ========================================================\n" + ... " The model already had code mappings.\n" + ... " ========================================================\n"); catch fprintf("" + ... " ==========================================\n" + ... " The model does not have code mappings.\n" + ... " Creating new code mappings for the model.\n" + ... " ==========================================\n"); codeMapObj = coder.mapping.utils.create(simulinkModel); end
========================================== The model does not have code mappings. Creating new code mappings for the model. ==========================================
モデルの入力端子 inport_1
のストレージ クラスを取得します。
getInport(codeMapObj,"inport_1","StorageClass")
ans = 'Auto'
入力端子 inport_1
のストレージ クラスを ExportedGlobal
に設定します。
setInport(codeMapObj,"inport_1",StorageClass="ExportedGlobal")
同じ try-catch
ブロックを使用して、関数 coder.mapping.api.get
でモデルの既存のコード マッピングをどのように取得できるようになったかを確認します。
try codeMapObj = coder.mapping.api.get(simulinkModel); fprintf("" + ... " ========================================================\n" + ... " The model already had code mappings.\n" + ... " ========================================================\n"); catch fprintf("" + ... " ==========================================\n" + ... " The model does not have code mappings.\n" + ... " Creating new code mappings for the model.\n" + ... " ==========================================\n"); codeMapObj = coder.mapping.utils.create(simulinkModel); end
======================================================== The model already had code mappings. ========================================================
モデルの入力端子 inport_1
のストレージ クラスを取得します。これは、以前に設定したストレージ クラスであることに注意してください。
getInport(codeMapObj,"inport_1","StorageClass")
ans = 'ExportedGlobal'
モデルを保存せずに閉じます。
close_system(simulinkModel,false)
入力引数
simulinkModel
— Simulink モデル
ハンドル | 文字ベクトル | string スカラー
コード マッピング オブジェクトを返す対象の Simulink モデル。ハンドル、またはモデル名 (.slx
ファイル拡張子なし) あるいはモデル ファイルの相対パスまたは絶対パス (.slx
ファイル拡張子を含む) を含む文字ベクトルまたは string スカラーとして指定します。
メモ
モデルが (たとえば、load_system
を使用して) 読み込まれていなければなりません。
例: "configModel"
データ型: char
| string
| handle
coderDictionary
— コーダー データ インターフェイス ディクショナリ
文字ベクトル | string スカラー | Simulink.data.Dictionary
コード マッピング オブジェクトを返す対象のデータ インターフェイス ディクショナリ。Simulink.data.Dictionary
オブジェクト、またはディクショナリ ファイルの相対パスまたは絶対パス (.sldd
ファイル拡張子を含む) を含む文字ベクトルまたは string スカラーとして指定します。
例: "exCodeDefs.sldd"
データ型: char
| string
| Simulink.data.Dictionary
出力引数
coderMapObj
— コード マッピング
CodeMapping
オブジェクト | CodeMappingCPP
オブジェクト
モデルのコード マッピング オブジェクト。CodeMapping
オブジェクトまたは CodeMappingCPP
として返されます。
出力 | 入力オブジェクト | コード マッピング タイプ |
---|---|---|
coder.mapping.api.CodeMapping | Simulink モデル | "SimulinkCoderC" または "EmbeddedCoderC" |
coder.mapping.api.CodeMappingCPP (Embedded Coder) | Simulink モデル | "EmbeddedCoderCPP" |
coderDataDictObj
— Embedded Coder データ ディクショナリ
CoderDictionary
オブジェクト
Embedded Coder データ ディクショナリ。coder.mapping.api.CoderDictionary
オブジェクトとして返されます。
バージョン履歴
R2020b で導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)