function Wrap;

global numdev
global Devices ValueCount Queue
global systime time alltimeinqueue alltimeatwork TimeCount
global amountinqueue amountinwork amountinsystem dynamicsysusing
global dynamicalltimeinqueue dynamicalltimeatwork dynamicalltimeinqueue

TimeCount = TimeCount + 1;

time(TimeCount) = systime;

%if Queue(1) ~= 0 
    
    counter = 0;
    
    for i=1:length(Queue)
        if Queue(i) ~= 0
            counter = counter+1;
        end;
    end;
    
    amountinqueue(TimeCount) = counter;
    
%else
   % counter = 0;
    
   % amountinqueue(TimeCount) = 0;
    
%end;
if TimeCount ~= 1
    alltimeinqueue = alltimeinqueue + (counter*(time(TimeCount) - time(TimeCount-1)));
else 
    alltimeinqueue = alltimeinqueue + (counter*(time(TimeCount) - 0));
end;
%if max(Devices) ~= 0
    
    counter = 0;
    
    for i= 1:numdev
        if Devices(i) ~= 0
            counter = counter +1;
        end;
    end;
    
    amountinwork(TimeCount) = counter;
    
if TimeCount ~= 1
    alltimeatwork = alltimeatwork + (counter*(time(TimeCount) - time(TimeCount-1)));
else
    alltimeatwork = alltimeatwork + (counter*(time(TimeCount) - 0));
end;
        
%end;
 
dynamicalltimeinqueue(TimeCount) = alltimeinqueue;
dynamicalltimeatwork(TimeCount) = alltimeatwork;

if systime ~= 0
    dynamicsysusing(TimeCount) = alltimeatwork/(numdev*systime);
end;
