Matlab automated testing

Hello guys,

I’m trying to setup a matlab script that automatically load, run and stop the CM4S simulation.

After reading the ProgrammersGuide, i think that all can be done with the following few line of code:

%% Init Simulation

disp(['Load TestRun: ’ TestRunName]);

cmguicmd(['LoadTestRun ’ TestRunName]);

%% Start Sim

disp(‘Start Sim…’);

cmguicmd(‘StartSim’);

disp(‘Waiting…’);

cmguicmd(‘WaitForCondition {$Qu(Time) > 50}’);

disp(‘Sim end. Load data…’);

The problem is that the script get stuck at ‘WaitForCondition’ command. From the CM GUI i see that the SIM status is blocked at ‘Preparation’.

Any suggestion?

Update:
The following code is working, is not optimized becuse it uses pause() function but I didn’t found any other solutions to overcome the deadlock.

%% Init Sim

disp(['Load TestRun: ’ TestRunName]);

cmguicmd(['LoadTestRun ’ TestRunName]);

%% Sim Loop

disp(‘Start Sim…’);

cmguicmd(‘StartSim’, 0);

disp(‘Waiting for simulation to run…’);

sim_status = -1;

while sim_status < 0

sim_status = str2double(cmguicmd('GetSimStatus'));

pause(0.5);

end

disp(‘Simulation is now RUNNING.’);

while sim_status >= 0

sim_status = str2double(cmguicmd('GetSimStatus'));

pause(0.5);

end

disp(‘Sim end. Load data…’);