close all
clear all

path(path,'../../ShipBoardSoftware/V8');

dpath = 'X:\707976 EPBuoyPrototypeAndTesting\Deployments\Nov2012 Deployment\134.89.12.189\data\';
results_path = 'X:\707976 EPBuoyPrototypeAndTesting\Deployments\Nov2012 Deployment\DecodedResults\'

dpath = '/mbari/ProjectLibrary/707976 EPBuoyPrototypeAndTesting/Deployments/Nov2012 Deployment/134.89.12.189/data/';
results_path = '/mbari/ProjectLibrary/707976 EPBuoyPrototypeAndTesting/Deployments/Nov2012 Deployment/DecodedResults/'

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))
           SurfaceLogFileDecoderRing(path,filename,[results_path dataDirs(k).name '/'])     
           MakePlots
         end
       end
    end
  end
  pause(10*60)

end