function m_lookDlinfo(id, numDays)

% Brian Schlining
% 26 Oct 2004

%%
% Prompt for input if no input arguments are specified
if nargin < 2
    numDays = 7;
end

%% Read File
file = fullfile(getOasisPath, 'raw', 'dlinfo.log');

fprintf(1, '[%s] Reading %s\n', mfilename, file)
fid = fopen(file);

% n the number of lines of data so we allocate memory
n = 0;
while ~feof(fid)
    line = fgetl(fid);
    if ~isempty(strmatch(id, line))
        n = n + 1;
    end
end

% Allocate memory
startDate = ones(n, 1) * NaN;
endDate = startDate;
bytes = startDate;
exitCode = startDate;

% Rewind the file
fseek(fid, 0, -1);

% Read only the lines of the mooring we're interested in
n = 0;
%pattern = sprintf('^%s.+', id);
acceptDate = now - numDays;
while ~feof(fid)
    line = fgetl(fid);
    if ~isempty(strmatch(id, line))
    %if ~isempty(regexp(line, pattern, 'match'));
        testDate = datenum(stringtokenizer(line, 2, ','));
        if testDate >= acceptDate
            n = n + 1;
            startDate(n) = testDate;
            endDate(n) = datenum(stringtokenizer(line, 3, ','));
            bytes(n) = str2double(stringtokenizer(line, 4, ','));
            exitCode(n) = str2double(stringtokenizer(line, 5, ','));    
        end
    end
end

fclose(fid);
fprintf(1, '[%s] Reading completed\n', mfilename)

% Truncate by Date. Tack on placholders for the exitCodes so 
% that the legend draws correctly.
good = find(startDate >= now - numDays);
startDate = [ones(6, 1) * (min(startDate) - 1); startDate(good)];
endDate = [ones(6, 1) * NaN; endDate(good)];
bytes = [ones(6, 1) * NaN; bytes(good)];
exitCode = [[0:5]'; exitCode(good)];

% Calculate values
duration = (endDate - startDate)*24*60; % in minutes
kb = bytes ./ 1024; % in kilobytes
rate = kb ./ (duration*60); % kilobytes / sec

% Get some mooring specific information
prop = readProperties(fullfile(getOasisPath, 'cfg', 'mooring.properties'));
lat = sscanf(getProperty(prop, [id '.latitude']), '%f');
lon = sscanf(getProperty(prop, [id '.longitude']), '%f');
if isempty(lat) | isempty(lon)
    loc = [];
else
    loc = getLocationString(lat, lon);
end
XLim = [now-numDays now];

fprintf(1, '[%s] Found %i data points since %s\n', mfilename, length(good), datestr(now - numDays, 31));

%%
% Generate the plots
figure(1)
Color1 = [0 0 .5];
plot(startDate, duration, 'Color', Color1);
set(gca, 'YColor', Color1, 'Xgrid', 'on', 'XLim', XLim)
daytick('x');
title(['\bf{Download Duration from ' upper(id) ' (' loc{1} ')}'])
ylabel('\bf{Minutes}', 'Color', Color1)
xlabel('\bf{Date}')
setfontsize(7)
set(gcf, 'PaperPosition', [0 0 3.75 3.25])

%%
figure(2)
Color1 = [0 .5 0];
plot(startDate, kb, 'Color', Color1);
set(gca, 'YColor', Color1, 'Xgrid', 'on', 'XLim', XLim)
daytick('x');
title(['\bf{Download Size from ' upper(id) ' (' loc{1} ')}'])
ylabel('\bf{Kilobytes}', 'Color', Color1)
xlabel('\bf{Date}')
setfontsize(7)
set(gcf, 'PaperPosition', [0 0 3.75 3.25])

%%
figure(3)
Color1 = [.5 0 .5];
plot(startDate, rate, 'Color', Color1);
set(gca, 'YColor', Color1, 'Xgrid', 'on', 'XLim', XLim)
daytick('x');
title(['\bf{Download Rate from ' upper(id) ' (' loc{1} ')}'])
ylabel('\bf{Kilobytes sec^{-1}}', 'Color', Color1)
xlabel('\bf{Date}')
setfontsize(7)
set(gcf, 'PaperPosition', [0 0 3.75 3.25])

%%
figure(4)
Color1 = [0 0 0];
c0 = find(exitCode == 0);
c1 = find(exitCode == 1);
c2 = find(exitCode == 2);
c3 = find(exitCode == 3);
c4 = find(exitCode == 4);
c5 = find(exitCode == 5);
plot(startDate(c0), exitCode(c0), 'g.');
hold on
plot(startDate(c1), exitCode(c1), 'r.');
plot(startDate(c2), exitCode(c2), 'rx');
plot(startDate(c3), exitCode(c3), 'r^');
plot(startDate(c4), exitCode(c4), 'rs');
plot(startDate(c5), exitCode(c5), 'rv');
set(gca, 'YColor', Color1, 'Xgrid', 'on', 'XLim', XLim, 'YLim', [0 5], 'YTick', [0:5])
daytick('x');
title(['\bf{Exit Code from ' upper(id) ' (' loc{1} ')}'])
ylabel('\bf{Exit Code}', 'Color', Color1)
xlabel('\bf{Date}')
legend('Success', 'Argument Error', 'Could Not Acquire TNC Port', 'Could Not Connect to OASIS', 'Download Error', 'Abort Error');
%set(legendH, 'Location', 'Best')
setfontsize(7)

%%
set(gcf, 'PaperPosition', [0 0 3.75 3.25])