function [UAS_index,avail_time] = LEM_EQ_get_UAS(UAS,request_time)
%

LOAD_TIME = 300;

num_UAS = length(UAS);

OK = zeros(num_UAS,1);
min_time = Inf;
min_index = 0;

for u = 1:num_UAS
    if length(UAS(u).schedule(:,1))==1
        u_time = UAS(u).schedule(end,4);
    else
        u_time = UAS(u).schedule(end-1,4);
    end
    if u_time==0
        OK(u) = 1;
    elseif u_time+LOAD_TIME<=request_time
        OK(u) = 1;
    end
    if u_time<min_time
        min_time = u_time;
        min_index = u;
    end
end

indexes = find(OK);
if isempty(indexes)
    UAS_index = min_index;
    avail_time = min_time;
else
    UAS_index = indexes(1);
    avail_time = request_time;
end
