% Simulation model of a single server queue
% Adapted from Law and Kelton (1991)
% T.Trani and H. Baik (March 99)

% Update function

% Purpose: 	Updates simulation clock, server status function (busy function), and 
%			area under queue function

% Q_LIMIT				= queue limit to terminate the simulation
% mean_interarrival		= interarrival time in units of time
% mean_service			= service time in time units
% mean_delays_required 	= numbers of entities simulated

% Function calls: 	none

% Called from:		sim_queue.m (main function)

function update

%Update area accumulate for time-average statistics

global Q_LIMIT  mean_interarrival  mean_service mean_delays_required 
global next_event_type num_custs_delayed num_delays_required...
       num_events num_in_q server_status
global area_num_in_q area_server_status mean_interarrival...
       mean_service time time_arrival...
       time_last_event time_next_event total_of_delays std_interarrival

  
   time_since_last_event = time - time_last_event;
   time_last_event = time;

   area_num_in_q = area_num_in_q + num_in_q * time_since_last_event ;
   area_server_status = area_server_status + server_status * time_since_last_event ;
 
