MATLAB Answers

sl_customization - Update Lookup Table Data (Non-Standard Format)

5 ビュー (過去 30 日間)
William Curry
William Curry 2020 年 1 月 9 日
コメント済み: William Curry 2020 年 1 月 9 日
-In the link below, section "Propagate Nonstandard Format Lookup Table Data", an example is given on how to propogate non-standard lookup table data to the workspace. Is there a way to propogate this to a data dictonary variable instead? The data that is propogated is just the table data and not the breakpoint data, can the breakpoints be accessed as well?
If this isn't possible is there a way to access the table editor data programmatically?

  0 件のコメント

サインイン to comment.

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2020 年 1 月 9 日
As far as propagating modified data back to its source variable, it doesn't matter whether the source variable is in the base workspace or a SLDD. Try it and it works when the variable is in a SLDD.

  3 件のコメント

William Curry
William Curry 2020 年 1 月 9 日
I'm still not sure how to prevent a worspace variable from being created using the example provided. The line of code in the example " blkInfo.tableWorkSpaceVarName = 'table3d_map_custom';" makes a workspace variable once the "myConvertTableFcn" is called. How do I set a SLDD variable instead? Also do you know how to access the breakpoints as well?
Fangjun Jiang
Fangjun Jiang 2020 年 1 月 9 日
Migrate your model with base workspace data to using a SLDD. All the changes will be reflected to the SLDD. Use a 2d table example so you will be able to view and change the table data and propagate it back to SLDD.
William Curry
William Curry 2020 年 1 月 9 日
-My Model is already using a data dictonary. The code I'm using below. You can see in the function "myConvertTableFcn" I had to access the SLDD in order to get anything to be saved to the SLDD. I believe the issue is in tableWorkSpaceVarName class below (Next to the ISSUE HERE? comment). Is there a different class call for the data dictonary?
function sl_customization(cm)
cm.LookupTableEditorCustomizer.getTableConvertToCustomInfoFcnHandle{end+1} = ...
@myGetTableConvertInfoFcn;
end
function blkInfo = myGetTableConvertInfoFcn(blk,tableStr)
global currentSystem block
block = blk;
currentSystem = gcs;
nameOfTable = lower(get_param(block,'Name'));
blkInfo.allowTableConvertLocal = true;
blkInfo.tableWorkSpaceVarName = nameOfTable; %%%%%%%%%%%%%%%%%ISSUE HERE????
blkInfo.tableConvertFcnHandle = @myConvertTableFcn;
end
% Converts 3-dimensional lookup table from Simulink format to
% nonstandard format used in workspace variable
function cMap = myConvertTableFcn(data)
global currentSystem block nameOfTable
nameOfTable = lower(get_param(block,'Name'));
tableDimensions = get_param(block,'NumberOfTableDimensions');
dataDictonary = Simulink.data.dictionary.open(get_param(currentSystem,'DataDictionary'));
dDataSectObj = getSection(dataDictonary,'Design Data');
tableEntry = getEntry(dDataSectObj,nameOfTable);
oldTableVal = getValue(tableEntry);
if(strcmp(tableDimensions,'1'))%if this table has 1 dimension set y val
oldTableVal.Value.y = data;
setValue(tableEntry,oldTableVal);
elseif(strcmp(tableDimensions,'2'))%if this table has 2 dimension set z val
oldTableVal.Value.z = data;
setValue(tableEntry,oldTableVal);
end
cMap = data;
end

サインイン to comment.

サインイン してこの質問に回答します。

製品


リリース

R2019b

Translated by