Is there is a way to convert Signal from Signal Builder Block to Test Sequence code?
6 ビュー (過去 30 日間)
古いコメントを表示
The MATLAB automatically generate test harness using the signal builder block. i need to convert the all the signals from signal builder block to test sequence code , Please Help
1 件のコメント
Pat Canny
2022 年 6 月 2 日
Are you referring to automatically generated tests from Simulink Design Verifier?
Thanks.
採用された回答
Pat Canny
2022 年 6 月 2 日
Assuming you need to use a Signal Builder instead of a Signal Editor (Signal Editor is the recommended approach; look here for a utility to convert from Signal Builder to Signal Editor), you can author a Test Sequence block programmatically.
To do this, try using the following functions:
- Select the Signal Builder block in the model and use the signalbuilder function to retrieve the signal data for each group in the Signal Builder. Example code:
[time,data,signames,groupnames] = signalbuilder(gcb);
new_system('example_model')
blockName = 'example_model/Test Sequence';
sltest.testsequence.newBlock(blockName);
3. You can then start creating Test Sequence steps (starting with sltest.testsequence.addStep). The number of steps could be based on the number of elements in the Signal Builder data. Here is just some starter code for one of the signals:
numSteps = numel(data{1})-1; %assumes all signal data vectors are of equal length
numsignals = numel(signames);
for i=1:numsignals
sltest.testsequence.addSymbol(blockName,...
signames{i},'Data','Output');
end
actionDesc1 = [signames(1) + " = " + string(data{1}(1)) + ";"]; %just defines Action for first signal
stepNames = "Step" + string(1:numSteps);
sltest.testsequence.addStep(blockName,stepNames(1),'Action',actionDesc1)
% You could then use string concatenation to define Action for all signals in
% Step1
for k=2:numSteps-1
actionDesc = [signames(1) + " = " + string(data{1}(k)) + ";"]; %just defines Action for first signal
sltest.testsequence.addStepAfter(blockName,stepNames(k),stepNames(k-1),'Action',actionDesc);
transitionDuration = time{1}(k) - time{1}(k-1);
transitionCondition = "after(" + string(transitionDuration)+")";
sltest.testsequence.addTransition(blockName,stepNames(k-1),transitionCondition,stepNames(k))
end
1 件のコメント
Pat Canny
2022 年 6 月 2 日
Just a quick follow-up on my answer: the "Action Description" is just a string. My "starter code" would need to be updated to include data type casting and other considerations. The code above simply sets each signal to a double. My goal was to demonstrate the general workflow and show which functions to consider.
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Inputs についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!