Simulink.CodeImporter クラス
名前空間: Simulink
説明
Simulink.CodeImporter
クラスを使用して、カスタム C/C++ コードをモデル化、検証、および妥当性確認するために Simulink® にインポートします。このクラスのインスタンスは、Simulink にインポートするカスタム コードを指定するために使用されます。
Simulink.CodeImporter
クラスは handle
クラスです。
作成
説明
obj = Simulink.CodeImporter()
は、LibraryFileName
プロパティが "untitled"
に設定されている CodeImporter
のインスタンスを作成します。
obj = Simulink.CodeImporter(
(LibName
)LibName
はユーザーによって選択され、string または文字ベクトルとして指定されるファイル名) は、LibraryFileName
プロパティが LibName
に設定されている CodeImporter
のインスタンスを作成します。
プロパティ
LibraryFileName
— Simulink ライブラリ ファイルおよび生成されるアーティファクトの名前
"untitled"
(既定値) | string | 文字ベクトル
インポートされるコード用に作成される Simulink ライブラリ ファイルおよび生成されるアーティファクトの名前。string または文字ベクトルとして指定します。名前は、有効な MATLAB® 変数名でなければなりません。コードがインポートされる場合、生成されるデータ ディクショナリとその他のアーティファクトには、拡張子が異なる、同じファイル名が使用されます。
例: "pumpController"
データ型: string
| character vector
OutputFolder
— 生成されるライブラリ ファイルと生成されるアーティファクトの場所
"" (既定値) | string | 文字ベクトル
生成されるライブラリ ファイルと生成されるアーティファクトの場所。string または文字ベクトルとして指定します。空白のままにすると、現在の MATLAB フォルダーが使用されます。
CustomCode
プロパティの一部であるファイルの場所は、このフォルダーを基準にして指定できます。
例: "C:\HeatPump\Controller"
データ型: string
| character vector
CustomCode
— インポートするカスタムの C または C++ コードおよび関連付けられているプロパティ
CustomCode
オブジェクト
インポートする C または C++ コード ファイルおよび関連付けられているプロパティ。クラス Simulink.CodeImporter.CustomCode
のオブジェクトとして指定します。このプロパティを使用して、ソース ファイルとヘッダー ファイル、フォルダー パス、ライブラリ、およびコンパイラとリンカー フラグなど、コード インポート オプションを指定します。詳細については、Simulink.CodeImporter.CustomCode
を参照してください。
obj = Simulink.CodeImporter; obj.CustomCode.InterfaceHeaders = ["pumpController.h"]; obj.CustomCode.IncludePaths = ["./include"]; obj.CustomCode.SourceFiles = ["src/pumpController.c" "src/utils.c"]; obj.CustomCode
ans = CustomCode with properties: SourceFiles: ["src/pumpController.c" "src/utils.c"] InterfaceHeaders: "pumpController.h" IncludePaths: "./include" Libraries: [1×0 string] Defines: [1×0 string] Language: "C" CompilerFlags: [1×0 string] LinkerFlags: [1×0 string] GlobalVariableInterface: 0 FunctionArrayLayout: NotSpecified
ParseInfo
— 解析されるカスタム コードに関する情報
Simulink.CodeImporter.ParseInfo
オブジェクト
解析されるカスタム コードに関する情報。クラス Simulink.CodeImporter.ParseInfo
のオブジェクトとして指定します。このプロパティは読み取り専用です。カスタム コードに関する情報を取得するためには解析が成功する必要があります。詳細については、Simulink.CodeImporter.ParseInfo
を参照してください。
s = parse(obj); obj.ParseInfo
ans = ParseInfo with properties: Success: 1 AvailableFunctions: ["Controller" "setFanTempThreshold" "setPumpTempThreshold"] EntryFunctions: ["Controller" "setFanTempThreshold" "setPumpTempThreshold"] AvailableTypes: "pump_control_bus" Errors: []
Options
— ライブラリ作成用にインポートしているときにコード インポーターによって使用される追加のオプション
Options
オブジェクト
ライブラリ作成用にインポートしているときにコード インポーターによって使用される追加のオプション。クラス Simulink.CodeImporter.Options
のオブジェクトとして指定します。このオブジェクトを使用して、関数を指すポインターで渡された引数のサイズの既定値、および Simulink ライブラリ ブラウザーの名前を変更します。詳細については、Simulink.CodeImporter.Options
を参照してください。
obj.Options
ans = Options with properties: PassByPointerDefaultSize: "-1" CreateTestHarness: 0 LibraryBrowserName: "" SimulateInSeparateProcess: 0 UndefinedFunctionHandling: "FilterOut"
obj.Options.LibraryBrowserName = "Controller Library";
obj.Options
ans = Options with properties: PassByPointerDefaultSize: "-1" CreateTestHarness: 0 LibraryBrowserName: "Controller Library" SimulateInSeparateProcess: 0 UndefinedFunctionHandling: "FilterOut"
メソッド
パブリック メソッド
parse | カスタム コードの関数、型、グローバル変数、依存関係を解析する |
import | Import custom code, functions, and types into Simulink |
addToProject | Add custom code and imported artifacts to MATLAB project |
view | Simulink コード インポーター ウィザードを起動する |
save | Save import settings to JSON format text file |
load | Load import settings from saved import settings file |
computeInterfaceHeaders | Compute interface headers from specified source files |
例
カスタム コードのインポート
カスタム コードの場所とオプションを指定します。
コード インポーター オブジェクトを作成します。
obj = Simulink.CodeImporter('PumpController');
インポートするカスタム コードを指定します。
obj.CustomCode.InterfaceHeaders = ["pumpController.h"]; obj.CustomCode.IncludePaths = ["./include"]; obj.CustomCode.SourceFiles = ["src/pumpController.c" "src/utils.c"];
ライブラリ ブラウザーで使用する名前を指定します。
obj.Options.LibraryBrowserName = "Controller Library";
カスタム コードを解析します。
s = parse(obj); obj.ParseInfo
ans = ParseInfo with properties: Success: 1 AvailableFunctions: ["Controller" "setFanTempThreshold" "setPumpTempThreshold"] EntryFunctions: ["Controller" "setFanTempThreshold" "setPumpTempThreshold"] AvailableTypes: "pump_control_bus" Errors: []
解析したコードをインポートします。
s = import(obj);
バージョン履歴
R2021a で導入
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)