How do I get the harness UUID in Simulink Test

41 Ansichten (letzte 30 Tage)
Taylor
Taylor am 5 Sep. 2023
Kommentiert: Gregg Smith am 10 Nov. 2023
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?

Antworten (1)

Amish
Amish am 11 Sep. 2023
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 Kommentare
Taylor
Taylor am 12 Sep. 2023
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 am 10 Nov. 2023
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

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by