%hlavni spousteci skript experimentu
% !!! potreba pridat pmsm_sim mex soubory sestavene pro pouzivane pc/os

clear all;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%NASTAVENI:
%%%%%%%%%%%

%horizont
T = 120000; 
% T = 12000;

%profil pozadovanych otacek
% ref_profile = [0, -1, 3, 6, 9, 6, 3, 0, 0, 0, 0, 0, 0,-3, -6, -3];%/9*200;
% ref_profile = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
% ref_profile = [0, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 0];
ref_profile = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]*10;
% ref_profile = [1, 10, 50, 200, 200, 30, 0, 0, -1, -10, -50, -200, -200, -30, 0];
% ref_profile = [20, 20, 20, 50, 50, 50, -10, -10, -10, 0, 0, 0, 20, 20, 20];

%pocatecni odhad uhlu natoceni
theta0 = 0;
% theta0 = 0.5;
% theta0 = 1.5;
% theta0 = 1.7;
% theta0 = 3.14;

%simulace
% simulator = 0; %matlab
% simulator = 1; %simulator pmsm bez kompenzace ubytku
simulator = 10; %simulator pmsm s kompenzaci ubytku
% simulator = 2; %matlab s ruznymi indukcnostmi

%vykresleni grafu
% graf = 0; %ne
graf = 1; %ano

%ruzne indukcnosti v osach d-q
inddq = 0; %ne
% inddq = 1; %ano - pro vetsi otacky selze protoze nefunguje kompenzace
% konstantniho clenu - tu je treba dodelat ale je to tezke

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%EXPERIMENT:
%%%%%%%%%%%%

% tic
% ukf_comp(T, ref_profile, theta0, simulator, graf)
% toc

iter = 1;%0;

totalloss1 = 0;
totalloss2 = 0;
totalloss3 = 0;
totalloss4 = 0;


% t1 = tic;
% for i = 1:iter
%     [loss1] = basic_main(T, ref_profile, theta0, simulator, graf, inddq);
%     totalloss1 = totalloss1 + loss1;
% end
% time1 = toc(t1)
% totalloss1

% t2 = tic;
% for i = 1:iter
%     [loss2] = main(T, ref_profile, theta0, simulator, graf, inddq);
%     totalloss2 = totalloss2 + loss2;
% end
% time2 = toc(t2)
% totalloss2
% 
t3 = tic;
for i = 1:iter
    [loss3] = basic_main_lq4(T, ref_profile, theta0, simulator, graf, inddq);
    totalloss3 = totalloss3 + loss3;
end
time3 = toc(t3)
totalloss3
% 
% t4 = tic;
% for i = 1:iter
%     [loss4] = main_lq4(T, ref_profile, theta0, simulator, graf, inddq);
%     totalloss4 = totalloss4 + loss4;
% end
% time4 = toc(t4)
% totalloss4

% %znovu s jinym simulatorem
% simulator = 1;
% 
% 
% totalloss1 = 0;
% totalloss2 = 0;
% totalloss3 = 0;
% totalloss4 = 0;
% 
% 
% t1 = tic;
% for i = 1:iter
%     [loss1] = basic_main(T, ref_profile, theta0, simulator, graf, inddq);
%     totalloss1 = totalloss1 + loss1;
% end
% time1 = toc(t1)
% totalloss1
% 
% t2 = tic;
% for i = 1:iter
%     [loss2] = main(T, ref_profile, theta0, simulator, graf, inddq);
%     totalloss2 = totalloss2 + loss2;
% end
% time2 = toc(t2)
% totalloss2
% 
% t3 = tic;
% for i = 1:iter
%     [loss3] = basic_main_lq4(T, ref_profile, theta0, simulator, graf, inddq);
%     totalloss3 = totalloss3 + loss3;
% end
% time3 = toc(t3)
% totalloss3
% 
% t4 = tic;
% for i = 1:iter
%     [loss4] = main_lq4(T, ref_profile, theta0, simulator, graf, inddq);
%     totalloss4 = totalloss4 + loss4;
% end
% time4 = toc(t4)
% totalloss4
