function UR_USS_17
% UR_USS_17 - behavior for USS 17
% On input:
%     t (float): current time
% On output:
%     N/A
% Call:
%     UR_USS_17(23);
% Author:
%     T. Henderson
%     University of Utah
%     Summer 2019
%

global g_USS_info

PLAN_FILE = 'plan_17_';

display('USS_17');

% Generate new flight requests

% create flight files given flight plan  (plan_<USS_id>_<req_no>)

files = dir('.');
num_files = length(files);
num_g_USS_info = length(g_USS_info);
for f = 1:num_files
    f_name = files(f).name;
    if length(f_name)>8&strcmp(PLAN_FILE,f_name(1:8))
        id = 17;
        u = 0;
        for e = 1:num_g_USS_info
            if g_USS_info(e).id==id
                u = e;
            end
        end
        if u<1
            display('UR_USS_17 Error: no USS id match');
        end
        index = 9;
        s = [];
        while f_name(index)~=DOT
            s = [s,f_name(index)];
            index = index + 1;
        end
        req_num = str2num(s);
        if isempty(find(req_num==g_USS_info(u).requests))
            fid = fopen(f_name,'r');
            params = fscanf('%d');
            params(1) = id;
            ff_name = [FLIGHT,f_name(5:end)];
            fid = fopen(ff_name,'w');
            num_params = length(params);
            for p = 1:num_params
                fprintf(fid,'%d\n',params(p));
            end
            fclose(fid);
        end
    end
end
