nass-micro-station-measurem.../speedgoat-measurement/run_test.m

51 lines
1.3 KiB
Matlab

%%
Tsim = 100; % [s]
%%
tg = slrt;
%% TODO - Build this application if updated
%%
if tg.Connected == "Yes"
if tg.Status == "running"
disp('Target is Running, Stopping...');
tg.stop;
while tg.Status == "running"
pause(1);
end
disp('Target is Stopped');
end
if tg.Status == "stopped"
disp('Load the Application');
tg.load('measure_channels');
%% Get the current date for the filename
% Get the current date and time
date_str = erase(cellstr(num2str(clock')), ' ');
% Don't take the seconds and add some "_"
date_str = strjoin(date_str(1:5), '_');
%% Run the application
disp('Starting the Application');
tg.start;
pause(Tsim);
tg.stop;
%% Get the data from the speedgoat
f = SimulinkRealTime.openFTP(tg);
cd(f, 'data/measure_channels/');
mget(f, 'data_001.dat', 'data');
close(f);
% Convert the data to a Matlab object
data = SimulinkRealTime.utils.getFileScopeData('data/data_001.dat').data;
%% Save the new data into one mat file
save(['mat/data_', date_str, '.mat'], 'data');
else
error("The target computer is running");
end
else
error("The target computer is not connected");
end