close all
clear all

path(path,'../../ShipBoardSoftware/V8');

dpath = '/mbari/ProjectLibrary/707976 EPBuoyPrototypeAndTesting/Deployments/April2013/134.89.12.189/data/';
results_path = '/mbari/ProjectLibrary/707976 EPBuoyPrototypeAndTesting/Deployments/April2013/DecodedResults/'
ftp_path = '/mbari/FTP/hamilton/';

while(1)
    
  dataDirs = dir([dpath 'R*']);
  for k = length(dataDirs):-1:1
    if(dataDirs(k).isdir == 1)
       path = [dpath dataDirs(k).name '/'];
       files = dir([path 'D*']);
       files
 
 
       for i = length(files):-1:max(1,length(files)-12)  %To keep from re-checking the same files forever.  Needs to be improved to re-read the D* files every time through.
         filename = files(i).name
         decoded_files = dir([results_path dataDirs(k).name '/' filename '.mat'])
    
         if((length(decoded_files) == 0)  || (decoded_files.datenum < files(i).datenum+(5/(24*60))))  %Decode again if within 5 minutes of raw file date
           SurfaceLogFileDecoderRing(path,filename,[results_path dataDirs(k).name '/'])
           
           MakePlots
         end
       end

    end
  end
  pause(10*60)

end
