Is there is a way to convert Signal from Signal Builder Block to Test Sequence code?

11 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Pat Canny
Pat Canny am 2 Jun. 2022
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:
  1. 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 Kommentar
Pat Canny
Pat Canny am 2 Jun. 2022
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Anwin Kushal M
Anwin Kushal M am 3 Jun. 2022
Yes, I am referring automatically generated tests from Simulink Design Verifier
-Thank you.
  3 Kommentare
Pat Canny
Pat Canny am 6 Jun. 2022
Bearbeitet: Pat Canny am 6 Jun. 2022
Thanks @Anwin Kushal M! Could you please send me an email at patcanny@mathworks.com ?

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by