How do I get the harness UUID in Simulink Test

35 次查看(过去 30 天)
When I merge with git, the UUID of my harness gets out of sync with the XML file. How do I get the current UUID of the test harness without needing to reimport my harness?

回答(1 个)

Amish
Amish 2023-9-11
Hi Taylor,
As I can understand, you need to find a way to get the current UUID of your test harness without reimporting it.
In Simulink, the Universally Unique Identifier (UUID) of a test harness is typically generated when the test harness is created. If the UUID of your test harness gets out of sync with the XML file, you can retrieve the current UUID of the test harness without needing to reimport it by using the Simulink API and MATLAB scripting.
The general way to do this is as follows:
  • Open MATLAB and load your model.
  • Access the test harness object within your model. You can do this by specifying the path to the test harness.
  • Now, you can retrieve its UUID using the get_param function
Here is a sample code for your help:
% Load the Simulink model
load_system('YourModelName');
% Access the test harness
harnessPath = 'YourModelName/MyTestHarness';
harnessObj = Simulink.Harness.getHarness(harnessPath);
% Retrieve the UUID
harnessUUID = get_param(harnessObj, 'UUID');
% Display or use the UUID
disp(['UUID of the test harness: ' harnessUUID]);
Thank you,
Amish
  2 个评论
Taylor
Taylor 2023-9-12
Simulink.Harness.getHarness doesn't seem to exist. I'm aware the UUID is defined in the XML file, but during certain merges, the UUID gets out of sync with the XML and breaks the test case without reimporting it.
There must be a way to simply get the UUID and repair the broken harness.
Gregg Smith
Gregg Smith 2023-11-10
Hi,
I'm not familiar the API given above. I believe the customer should instead use:
% HarnessName - name of the loaded/opened harness block diagram
harnessUUID = get_param(HarnessName, 'HarnessUUID')
If the harness is not opened or loaded, you can access the harness UUID for a give harness name as follows:
% SysName - name of the loaded/opened system block diagram
hInfo = Simulink.harness.find(SysName, 'Name', HarnessName)
There should be a field hInfo.uuid
Thanks
Gregg Smith
Simulink Test Dev

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Inputs 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by