facing out of range error on Simulink.harness.create for SeparateAssessment value given as a true
2 views (last 30 days)
Show older comments
Description: While creating test harness i am facing this error on "create.m" default script at this line
>> Simulink.harness.create(harnessOwner, varargin{:}); and when i am trying to go inside this it is telling it is .p script so unable to debug it. so, after run the script it is giving me this error "At least one value is out of range for rectangle or position. All x values must be within -32786..32767 range, all y values must be within -32786..32767 range
>> due to confidentiality i am unable to give u all the details but i came with more info regarding errror. i am running this command line "sltest.harness.create(ti_name,'Name', th_name, 'Source', 'Test Sequence', 'SeparateAssessment', true, 'SaveExternally', true, 'ScheduleInitTermReset', false, 'SchedulerBlock','None', 'HarnessPath', th_pfad);" so, as u can see here i am using "sltest.harness.create" function where 'SeparateAssessment' value is true. so, if i false that value so, i am able to generate the harness but it is without Assessment block but actually i need Assessment block also and if i give 'Separate'Assessment' true then it will error " "At least one value is out of range for rectangle or position. All x values must be within -32786..32767 range, all y values must be within -32786..32767 range" so, now how to resolve this issue while giving 'SeparateAssessment' as a true
0 Comments
Answers (1)
Namnendra
on 24 Jul 2024
Hi Vivek,
It sounds like you're encountering an issue related to the positioning of blocks within the test harness when using the `sltest.harness.create` function with the `SeparateAssessment` option set to `true`. The error message indicates that the position values of some blocks are out of the acceptable range.
Here are some steps to troubleshoot and potentially resolve the issue:
1. Check Initial Block Positions
Ensure that the initial positions of blocks in your model are within the acceptable range. If any block has a position outside the range of `[-32786, 32767]`, it could cause this error. Verify the positions of blocks in your model using the following command:
blocks = find_system('your_model_name', 'Type', 'Block');
positions = get_param(blocks, 'Position');
Inspect the `positions` array to ensure all values are within the specified range.
2. Adjust Block Positions
If you find any block positions out of range, adjust them to be within the acceptable limits. You can use the `set_param` function to update block positions:
set_param('your_model_name/block_path', 'Position', [x1, y1, x2, y2]);
Ensure that the new positions are within the range `[-32786, 32767]`.
3. Create a Custom Script to Adjust Positions
You can create a custom script to automatically adjust block positions if they are out of range. Here is an example script:
blocks = find_system('your_model_name', 'Type', 'Block');
for i = 1:length(blocks)
pos = get_param(blocks{i}, 'Position');
if any(pos < -32786) || any(pos > 32767)
% Adjust positions to be within range
pos(pos < -32786) = -32786;
pos(pos > 32767) = 32767;
set_param(blocks{i}, 'Position', pos);
end
end
4. Use a Try-Catch Block
You can use a `try-catch` block to handle errors and provide more information about the block causing the issue:
try
sltest.harness.create(ti_name, 'Name', th_name, 'Source', 'Test Sequence', ...
'SeparateAssessment', true, 'SaveExternally', true, ...
'ScheduleInitTermReset', false, 'SchedulerBlock', 'None', ...
'HarnessPath', th_pfad);
catch ME
disp('Error creating test harness:');
disp(ME.message);
% Additional debugging or logging can be done here
end
5. Update MATLAB
Ensure you are using the latest version of MATLAB and Simulink Test, as updates may contain bug fixes and improvements that could resolve this issue.
Example Script to Create Test Harness
Here is an example script that incorporates some of the suggestions above:
try
% Adjust block positions if necessary
blocks = find_system(ti_name, 'Type', 'Block');
for i = 1:length(blocks)
pos = get_param(blocks{i}, 'Position');
if any(pos < -32786) || any(pos > 32767)
pos(pos < -32786) = -32786;
pos(pos > 32767) = 32767;
set_param(blocks{i}, 'Position', pos);
end
end
% Create test harness
sltest.harness.create(ti_name, 'Name', th_name, 'Source', 'Test Sequence', ...
'SeparateAssessment', true, 'SaveExternally', true, ...
'ScheduleInitTermReset', false, 'SchedulerBlock', 'None', ...
'HarnessPath', th_pfad);
catch ME
disp('Error creating test harness:');
disp(ME.message);
end
By following these steps, you should be able to identify and resolve the issue with block positions, allowing you to create the test harness with the `SeparateAssessment` option set to `true`.
I hope the above information helps you in resolving the issue.
Thank you.
0 Comments
See Also
Categories
Find more on Inputs in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!