function [output] = withoutui(devices,avg_request_time,avg_processing_time,e_request,e_processing,n,maxQueueLength,testRunNo,f)

%global hF
%global hTextField1 hTextField2 hTextField3 hTextField4 hTextField5 hTextField6 hTextField7
%global hEditableLabel1 hEditableLabel2 hEditableLabel3 hEditableLabel4 hEditableLabel5 hEditableLabel6 hEditableLabel7 hEditableLabel8 hEditableLabel9 hEditableLabel10
%global array_system_rn array_line_rn array_csu array_time L_array M_array n

%devices = 2;
%devices = str2num(get(hTextField1,'String')); %количество устройств

%avg_request_time = 10; 
%avg_request_time = str2num(get(hTextField2,'String')); %среднее время поступления требования a_avg

%avg_processing_time = 10;
%avg_processing_time = str2num(get(hTextField3,'String')); %Среднее время обработки требования s_avg

%e_request = 
%e_request = str2num(get(hTextField4,'String')); %начальное значение мультипликативного генератора для времени поступления требований

%e_processing = 250;
%e_processing = str2num(get(hTextField5,'String')); %начальное значение мультипликативного генератора для времени обработки требований

%maxQueueLength = 12;
%maxQueueLength = str2num(get(hTextField7,'String'));
%Квант времени
quant=1;

%n = 500; % сколько нужно прогонов
%n = str2num(get(hTextField6,'String'));

maxQueueLength = 12;
%maxQueueLength = str2num(get(hTextField7,'String'));

time = 0; % системное время
k = 1; % количество прогонов СМО

rejected = 0;

pt_sum = 0; %???
delay = 0; %???
line = 0; %que
line_trn = 0;
%use function
a_time = 0;%rp_gen(e_a, a_avg); время когда придет следующая заявка



% начальное время поступления заявки
request_time = rp_gen(e_request, avg_request_time);

for i=1:1:devices
		device(i) = 0;
		device_processig_request(i) = 0;
		device_processing_time(i) = 0;
		device_bwt(i) = 0;
		device_twt(i) = 0;
	end;
	
	for i=1:1:n
		request_processing_time(i) = 0;
		
		array_system_rn(i) = 0;
		array_line_rn(i) = 0;
		array_time(i) = 0;
	end;
%fprintf('\n\n\nBegin\n\n\n');    

kusage=0;
while k ~= n

    
    
     %   fprintf('\nRun no: %d\n\n\n',k);        
           

       
    %    fprintf('Длина очереди: %d\n',line); 
        
       % ОПРЕДЕЛЕНИЕ СВОБОДНЫХ УСТРОЙСТВ И ПОМЕЩЕНИЕ ЗАЯВКИ НА ОБРАБОТКУ
	flag = 0;
	for i=1:1:devices
		if (device(i) == 0) 
			if ((line == 0) && (request_time == time) && flag == 0)
				device(i) = 1;
				device_bwt(i) = time;
				
				e_processing = initial_v_gen(e_processing);
				new_processing_time = rp_gen(e_processing, avg_processing_time);
				
				pt_sum = pt_sum + new_processing_time;
							
				request_processing_time(k) = new_processing_time;
				device_processig_request(i) = k;
							
				if (new_processing_time <= quant)
					device_processing_time(i) = time + new_processing_time;
				else
					device_processing_time(i) = time + quant;
				end;
				
				device_twt(i) = device_twt(i) + device_processing_time(i) - time;
				
				flag = 1;
			end;
		end;
	end;
	for i=1:1:devices
		if (device(i) == 0)
			if (line ~= 0)
				device(i) = 1;
                kusage=kusage+quant;
				device_bwt(i) = time;
				
				new_processing_time = line_rpt(1);
				device_processig_request(i) = line_rn(1);
				request_processing_time(line_rn(1)) = line_rpt(1);
				
				if (new_processing_time <= quant)
					device_processing_time(i) = time + new_processing_time;
				else
					device_processing_time(i) = time + quant;
				end;
				
				device_twt(i) = device_twt(i) + device_processing_time(i) - time;
				
				line_trn = line_trn + 1;
				line_tlt(line_trn) = time - line_rjt(1);
				
				for j=1:1:line-1
					line_rn(j) = line_rn(j + 1);
					line_rjt(j) = line_rjt(j + 1);
					line_rpt(j) = line_rpt(j + 1);
				end;
				
				line_rn(line) = 0;
				line_rjt(line) = 0;
				line_rpt(line) = 0;
				line = line - 1;
			end;
		end;
	end;
    
      

        % ВЫЧИСЛЕНИЕ ВРЕМЕНИ ПОСТУПЛЕНИЯ ЗАЯВКИ
	if (request_time == time)
        k = k + 1;
      	e_request = initial_v_gen(e_request);
		new_request_time = rp_gen(e_request, avg_request_time);
		request_time = request_time + new_request_time;
	end;
	
	% ВЫЧИСЛЕНИЕ МИНИМАЛЬНОГО ВРЕМЕНИ ОБРАБОТКИ  "time_tick"
	time_tick = 0;
	tmp = 0;

	
	tmp = max(device_processing_time);
	for i=1:1:devices
		if ((device_processing_time(i) < tmp) && (device_processing_time(i) ~= 0))
			tmp = device_processing_time(i);
		end;
	end;
	time_tick = tmp;
	
	if (time_tick > time + quant)
		time_tick = time + quant;
	end;
		
	% ВЫЧИСЛЕНИЕ ВРЕМЕНИ ЗАДЕРЖКИ "delay"
	if ((request_time < time_tick) && (time_tick ~= 0))
		delay = (request_time - time) * line + delay;
	else
		if ((request_time > time_tick) && (time_tick ~= 0))
			delay = (time_tick - time) * line + delay;
		end;
	end;
	
	% ВЫЧИСЛЕНИЕ СИСТЕМНОГО ВРЕМЕНИ "time"
	flag  = 0;
	for i=1:1:devices
		if (device_processing_time(i) ~= 0)
			flag = flag + 1;
		end;
	end;
    
	if ((flag == devices) || ((flag ~= devices) && (line == 0)))
		time = time_tick;
	end;
	if ((flag ~= devices) && (line ~= 0))
		time = time;
	end;
	if (((flag == 0) && (line == 0)) || (request_time <= time_tick))
		time = request_time;
	end;
	
	
	% ФОРМИРОВАНИЕ ОЧЕРЕДИ "line"
	flag = 0;
	
	for i=1:1:devices
		if (device(i) ~= 0)
			flag = flag + 1;
		end;
	end;
       
     if ((flag == devices) && (request_time == time)) 
        if(line <= (maxQueueLength - 3))
		e_processing = initial_v_gen(e_processing);
		
		new_processing_time = rp_gen(e_processing, avg_processing_time);
		
		pt_sum = pt_sum + new_processing_time;
		
		line = line + 1;
		line_rn(line) = k;
		line_rjt(line) = time;
		line_rpt(line) = new_processing_time;
    else
        rejected=rejected+1;
    end;
	end;
	
    

        

    
    
    
    
    
	% СНЯТИЕ ЗАЯВКИ С ОБРАБОТКИ И РЕАЛИЗАЦИЯ ЦИКЛИЧЕСКОЙ ОБРАБОТКИ
	for i=1:1:devices
		if (device(i) == 1)
			if (device_processing_time(i) == time) 
				request_processing_time(device_processig_request(i)) = request_processing_time(device_processig_request(i)) - quant;
				if (request_processing_time(device_processig_request(i)) <= quant)
					time = time + request_processing_time(device_processig_request(i));
					device(i) = 0;
					device_processig_request(i) = 0;
					device_processing_time(i) = 0;
					device_bwt(i) = 0;
                    
				else
					line = line + 1;
					line_rn(line) = device_processig_request(i);
					line_rjt(line) = time;
					line_rpt(line) = request_processing_time(device_processig_request(i));
					
                    
					device(i) = 0;
					device_processig_request(i) = 0;
					device_processing_time(i) = 0;
					device_bwt(i) = 0;
				end;
			end;
		end;
	end;   
        
    

        %console massacre
        
		% среднее число требований в очереди
		M = delay / time;
		M_array(k) = M; 
		%fprintf('\nсреднее число требований в очереди = %f\n', M);
        
       
        
        %коэффициент использования системы
		csu = 0;
		%for i=1:1:devices
			csu = csu + kusage;
            %end;
		csu = csu / (devices * time);
		%fprintf('коэффициент использования системы = %f\n', csu);
		array_csu(k) = csu;
        
      
		% время в очереди
		ld = 0; 
		for i=1:1:line_trn
			ld = ld + line_tlt(i);
		end;

		% средняя задержка в очереди
		av_ld = 0;
		if (line_trn ~= 0)
			av_ld = ld / line_trn;
		end;
		av_ld_array(k) = av_ld;
		%fprintf('средняя задержка в очереди = %f\n', av_ld); 
       
		% среднее время ожидания
		av_wt = pt_sum; 
		for i=1:1:line_trn
			av_wt = av_wt + line_tlt(i);
		end;
		av_wt = av_wt/k; %k or n?????
		av_wt_array(k) = av_wt;
	%	fprintf('среднее время ожидания = %f\n', av_wt);

       
        L = (av_wt * n) / time;	   
		L_array(k) = L;
        
                    % Число требований в системе
	array_system_rn(k) = 0;
	for i=1:1:devices
		if (device(i) == 1)
			array_system_rn(k) = array_system_rn(k) + 1;
		end;
	end;

    
	

        % Число требований в очереди
	    array_line_rn(k) = line;
        

        array_system_rn(k) = array_system_rn(k) + line;
        % Время
	    array_time(k) = time; 

        requestsLeft = n - k;
	
        % Число отказов
	    array_rejected(k) = rejected/k * 100;
        
      %  set(hEditableLabel1,'String, requestsLeft);       
      %  set(hEditableLabel2,'String', rejected);
        
  %  	fprintf('среднее число требований в системе = %f\n', L);
        
        %dynamic output block
      %  set(hEditableLabel7,'String', L);
 %out
       % set(hEditableLabel5,'String', av_wt);
         %out
       % set(hEditableLabel4,'String', av_ld);
         %out
       % set(hEditableLabel3,'String',csu);
         %out
        %set(hEditableLabel6,'String', M);
        
        

        int_obsl = 1/avg_processing_time;
        int_pot = 1/avg_request_time;
        rel_band = int_obsl/(int_pot+int_obsl);
       % set(hEditableLabel8,'String', rel_band);
        abs_band = int_pot*rel_band;
        %set(hEditableLabel9,'String', abs_band); 
        
        %процент отказа
        procent_otkaza = rejected/k * 100;
   %     fprintf('Procent otkazov = %d\n', procent_otkaza, '%'); 
        %set(hEditableLabel10,'String', procent_otkaza); 

        
        
        
end;

%средний коэф использования системы
%for i=1:n
%avg_csu= sum(array_csu(n));
%avg_csu= avg_csu/n
%end

fprintf('\n/np/d/w/q/l/mu/Q/otkaz\n Values: %4.6f  %4.6f  %4.6f  %4.6f  %4.6f  %4.6f  %4.6f  %4.6f \n\n',csu,av_ld,av_wt, M,L,rel_band,abs_band,procent_otkaza);

fprintf(f,'<td>%4.6f</td><td>%4.6f</td><td>%4.6f</td><td>%4.6f</td><td>%4.6f</td><td>%4.6f</td><td>%4.6f</td><td>%4.6f</td></tr>\r\n',csu,av_ld,av_wt, M,L,rel_band,abs_band,procent_otkaza);%fprintf('rejected = %d\n', rejected);  

results (array_system_rn, array_line_rn, array_csu, array_time, L_array, M_array, n,testRunNo,array_rejected);