coder.asap2.CompuMethod
R2026b説明
計算方法オブジェクトを作成して計算方法要素を定義し、それを ASAP2 ファイルにエクスポートします。
作成
は compu = coder.asap2.CompuMethodcomputation method オブジェクトを作成します。このオブジェクトを使用して計算方法を定義し、ASAP2 ファイルにエクスポートできます。
プロパティ
カスタム計算方法の名前を指定します。
例: "CustomCompuMethod_1"
計算方法のコメントと説明を指定します。
例: "Description of the computation method"
キャリブレーション ツールに表示される計算方法の表示形式を指定します。
例: %3.4
計算方法の物理単位を指定します。
例: "sec"
有理分数関数の係数を指定します。
例: 0 100 0 0 1 1
内部のソース値から物理値への変換タイプを指定します。
例: LINEAR
ConversionType を TAB_VERB とする計算方法の値を指定します。
例: struct with literals and values
計算方法に追加で記述する必要のある説明を指定します。
例: "additional information"
例
この例では、計算方法、特性、測定値、およびルックアップ テーブル パラメーターの追加、変更、および削除を行うことで、ASAP2 ファイルの ECU 説明をプログラムからカスタマイズする方法を説明します。
関数を使用してビルドされたモデルから ECU 説明オブジェクトを作成し、その内容の検索やフィルタリングを行った後、カスタマイズした ASAP2 ファイルとしてエクスポートします。
この例では次を行います。
モデルをビルドし、ECU 説明オブジェクトを作成する
計算方法を検索してプロパティによってフィルターを適用する
カスタム計算方法を追加および変更する
カスタムの特性および測定を追加および変更する
軸情報とともにルックアップ テーブル パラメーターを追加する
カスタマイズした ASAP2 ファイルをエクスポートする
モデルを開いてビルド
モデル例 ASAP2Demo を開いて、そこからコードを生成します。モデルのビルドは、ECU 説明オブジェクトを作成するための前提条件です。
open_system("ASAP2Demo");
slbuild("ASAP2Demo");### Searching for referenced models in model 'ASAP2Demo'. ### Total of 2 models to build. ### Starting serial code generation build. ### Starting model reference code generation target build for: ASAP2DemoModelRef ### Successfully updated the model reference code generation target for: ASAP2DemoModelRef ### Starting top model code generation target build for: ASAP2Demo ### Successful completion of build procedure for: ASAP2Demo Build Summary Model reference code generation targets: Model Build Reason Status Build Duration ============================================================================================================ ASAP2DemoModelRef Target (ASAP2DemoModelRef.c) did not exist. Code generated and compiled. 0h 0m 8.5322s Top model targets: Model Build Reason Status Build Duration ============================================================================================ ASAP2Demo Target (ASAP2Demo.c) did not exist. Code generated and compiled. 0h 0m 16.383s 2 of 2 models built (0 models already up to date) Build duration: 0h 0m 27.316s
ECU の説明の作成と確認
ビルドされたモデルの ECU 説明オブジェクトを作成します。find 関数を使用して、使用可能な計算方法を一覧表示します。
descObj = coder.asap2.getEcuDescriptions("ASAP2Demo");Export duration: 0h 0m 0s 227ms
find(descObj, "CompuMethod")ans = 1×9 string
"CM_double" "CM_double_m_per_U0028_s_U005E_2_U0029" "CM_double_rpm" "CM_int16_rpm" "CM_int32" "CM_single" "CM_single_m_per_U0028_s_U005E_2_U0029" "CM_single_rpm" "CM_uint8"
単位として rpm を使用する計算方法のみを取得するようにフィルターを適用します。
find(descObj, "CompuMethod", Units="rpm")
ans = 1×3 string
"CM_double_rpm" "CM_int16_rpm" "CM_single_rpm"
カスタム計算方法の追加
線形変換タイプの計算方法を作成し、ECU 説明オブジェクトに追加します。
CompuMethod_1 = coder.asap2.CompuMethod; CompuMethod_1.Name = 'CompuMethod_1'; CompuMethod_1.ConversionType = "LINEAR"; CompuMethod_1.Coefficients = [2 3]; CompuMethod_1.LongIdentifier = "longIdentifierTest"; CompuMethod_1.Format = "%2.3"; CompuMethod_1.Units = "s"; add(descObj, CompuMethod_1);
新規に追加された計算方法のプロパティを確認します。
get(descObj, "CompuMethod", "CompuMethod_1")
ans =
CompuMethod with properties:
Name: 'CompuMethod_1'
LongIdentifier: "longIdentifierTest"
Format: "%2.3"
Units: "s"
Coefficients: [2 3]
ConversionType: "LINEAR"
CompuVTabValues: [1×1 struct]
CustomData: ""
変換タイプを TAB_VERB に更新し、対応する CompuVTabValues を定義します。既存の説明のプロパティを変更するには、set 関数を使用します。
set(descObj, "CompuMethod", "CompuMethod_1", ConversionType="TAB_VERB"); set(descObj, "CompuMethod", "CompuMethod_1", CompuVTabValues=struct("Literals", ["false" "true"], "Values", [0 1]));
変更されたフィールドを確認します。
modifiedProp = get(descObj, "CompuMethod", "CompuMethod_1")
modifiedProp =
CompuMethod with properties:
Name: 'CompuMethod_1'
LongIdentifier: "longIdentifierTest"
Format: "%2.3"
Units: "s"
Coefficients: [2 3]
ConversionType: "TAB_VERB"
CompuVTabValues: [1×1 struct]
CustomData: ""
modifiedProp.CompuVTabValues
ans = struct with fields:
Literals: ["false" "true"]
Values: [0 1]
カスタム特性の追加
キャリブレーション パラメーターを表す特性を作成し、ECU 説明オブジェクトに追加します。次に、UpperLimit プロパティを更新します。
param1 = coder.asap2.Characteristic; param1.Name = "Custom_parameter1"; param1.LongIdentifier = "longIdentifierParam"; param1.UpperLimit = 255; param1.LowerLimit = 0; add(descObj, param1); get(descObj, "Characteristic", "Custom_parameter1")
ans =
Characteristic with properties:
Name: "Custom_parameter1"
LongIdentifier: "longIdentifierParam"
Type: 'VALUE'
EcuAddress: '0x0000'
CompuMethodName: 'NO_COMPU_METHOD'
LowerLimit: 0
UpperLimit: 255
EcuAddressComment: ""
EcuAddressExtension: []
CalibrationAccess: 'Calibration'
DisplayIdentifier: ""
Format: ""
BitMask: []
AxisInfo: []
RecordLayout: ""
Dimensions: []
Export: 1
MaxRefresh: [1×1 struct]
SymbolLink: [1×1 struct]
CustomData: ""
set(descObj, "Characteristic", "Custom_parameter1", UpperLimit=128)
カスタム測定の追加
信号を表す測定を作成し、ECU 説明オブジェクトに追加します。次に、CalibrationAccess プロパティを更新します。
signal1 = coder.asap2.Measurement; signal1.Name = "Custom_signal1"; signal1.LongIdentifier = "longIdentifierSignal"; signal1.UpperLimit = 255; signal1.LowerLimit = 0; add(descObj, signal1); get(descObj, "Measurement", "Custom_signal1")
ans =
Measurement with properties:
Name: "Custom_signal1"
LongIdentifier: "longIdentifierSignal"
DataType: 'UBYTE'
EcuAddress: '0x0000'
CompuMethodName: ""
LowerLimit: 0
UpperLimit: 255
Raster: [1×1 struct]
EcuAddressComment: ""
EcuAddressExtension: []
CalibrationAccess: 'NoCalibration'
DisplayIdentifier: ""
Format: ""
BitMask: []
Dimensions: []
Export: 1
MaskData: [1×1 struct]
MaxRefresh: [1×1 struct]
SymbolLink: [1×1 struct]
CustomData: ""
set(descObj, "Measurement", "Custom_signal1", CalibrationAccess="Calibration")
ルックアップ テーブル パラメーターの追加
2 つの座標軸をもつ、タイプが MAP のルックアップ テーブル パラメーターを作成します。各軸には、名前、計算方法、軸の点の最大数、および軸のタイプが必要です。
lutParam = coder.asap2.Characteristic; lutParam.Name = "custom_lookup_table"; lutParam.Type = "MAP"; axisData = coder.asap2.AxisInfo; axisData(1).Name = "BP3"; axisData(2).Name = "Bp4"; axisData(1).CompuMethodName = "ASAP2Demo_CM_double"; axisData(2).CompuMethodName = "ASAP2Demo_CM_double"; axisData(1).MaxAxisPoints = "3"; axisData(2).MaxAxisPoints = "3"; axisData(1).AxisType = "STD_AXIS"; axisData(2).AxisType = "STD_AXIS"; lutParam.AxisInfo = axisData; add(descObj, lutParam)
カスタマイズした ASAP2 ファイルのエクスポート
更新された ECU 説明オブジェクトを使用して、ASAP2 ファイルをエクスポートします。生成されたファイルに、カスタム計算方法、特性、測定値、およびルックアップ テーブル パラメーターが含まれていることを確認します。
coder.asap2.export("ASAP2Demo", CustomEcuDescriptions=descObj);カスタム説明の削除
ECU 説明オブジェクトからカスタム説明を削除します。
delete(descObj, "CompuMethod", "CompuMethod_1"); delete(descObj, "Characteristic", "Custom_parameter1"); delete(descObj, "Measurement", "Custom_signal1");
バージョン履歴
R2022b で導入
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- 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)