function [data f_vz f_generator pocet_vzorku] = zmerZotDob(typ_ZotDob, polarizace, vzorku, amp, frekv)
% nastavi rele a zmeri zotavovaci doby

global dev fgen s vps

s.addAnalogOutputChannel(dev, 0:1, 'Voltage');
s.Rate = 1e3;

s.outputSingleScan([0 0]);

s.removeChannel([1 2]);
vps.Vneg = 0;
% ovladani rele
vps.Vpos = 0;

%typ_ZotDob = 2;
if typ_ZotDob == 1
    % propustna zotavovaci doba
    s.addAnalogInputChannel(dev, 6, 'Voltage'); % napeti
    fgen.Function = 'square';
    % vymyslet moznost, jak dat uzivateli moznost nastavit i jine frekvence
    % nez priblizne 100 kHz
    %perioda = 10.01e-6;
    %fgen.Frequency = 1/perioda;
    fgen.Frequency = frekv;
    %amp = 2.5;
    fgen.Amplitude = amp;
    % offset je nastaven podle polarizace zjistene pri mereni VA charakteristiky
    if polarizace == 1
        fgen.Offset = amp;
    else
        fgen.Offset = -amp;
    end
    
    %[polarizace amp fgen.Offset]
    
    s.Rate = 1.25e6;
    s.Channels(1).Range = [-10 10];
    % zmereni 2 period signalu
    %s.NumberOfScans = 2 * s.Rate / fgen.Frequency;
    s.NumberOfScans = vzorku;
    fgen.start;
    %pause(1);
    data = s.startForeground;
    %pause(1);
    fgen.Offset = 0;
    fgen.stop;
    f_vz = s.Rate;
    f_generator = fgen.Frequency;
    pocet_vzorku = s.NumberOfScans;
else
    %disp('zaverna (2)');
    % zaverna zotavovaci doba
    s.addAnalogInputChannel(dev, 7, 'Voltage'); % proud
    
    fgen.Function = 'square';
    %perioda = 10.01e-6;
    %fgen.Frequency = 1/perioda;
    fgen.Frequency = frekv;
    %fgen.Amplitude = 5;
    fgen.Amplitude = amp;
    
    s.Channels(1).Range = [-5 5];
    %s.NumberOfScans = 5000;
    s.NumberOfScans = vzorku;
    s.Rate = 1.25e6;
    
    fgen.start;
    data = s.startForeground ./ 99.2;
    fgen.Offset = 0;
    fgen.stop;
    f_vz = s.Rate;
    f_generator = fgen.Frequency;
    pocet_vzorku = s.NumberOfScans;
end



% nastaveni do vychoziho stavu

vps.Vneg = 0;
vps.Vpos = 0;

s.removeChannel(1);