function [zbytproud stdodchylka] = zmerZbytProud(smer_VA, pocet_vzorku, Ud)
% nastavi rele a zmeri zbytkovy proud (dioda neni Zenerova)

global dev s vps

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

if smer_VA == 1
    % propustna cast
    s.outputSingleScan([0 5]);
else
    % zaverna cast
    s.outputSingleScan([0 0]);
end

s.removeChannel([1 2]);

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

s.addAnalogInputChannel(dev, 7, 'Voltage'); % proud
s.Rate = 5e3;
s.Channels(1).Range = [-0.1 0.1];
s.NumberOfScans = pocet_vzorku;

if Ud < 1.0
    % neni LED, mozno dat plnych 10 V
    vps.Vneg = -10;
else
    % snizene napeti, abych nezpusobil pruraz
    vps.Vneg = -5;
end

data = s.startForeground;
proud = abs(data / 99.2);
%close all;
%figure(1);
%plot(proud)
zbytproud = mean(proud);
stdodchylka = std(proud);


% nastaveni do vychoziho stavu
vps.Vneg = 0;
vps.Vpos = 0;

s.removeChannel(1);
