Is there is a way to convert Signal from Signal Builder Block to Test Sequence code?
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Anwin Kushal M
le 2 Juin 2022
Modifié(e) : Pat Canny
le 6 Juin 2022
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 commentaire
Pat Canny
le 2 Juin 2022
Are you referring to automatically generated tests from Simulink Design Verifier?
Thanks.
Réponse acceptée
Pat Canny
le 2 Juin 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:
- 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 commentaire
Pat Canny
le 2 Juin 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.
Plus de réponses (1)
Anwin Kushal M
le 3 Juin 2022
Voir également
Catégories
En savoir plus sur Inputs dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!