% .m file to process all data for locness mission
clear all; close all;
%% Controlls
processShipData = 0;
%% Pull the latest shipboard data, resample, and write to map product
if processShipData == 1
    tic
    handler = ShipDataHandler();
    if handler.downloadData()
        handler.resampleData(10);         % 10
        handler.appendMapProduct(); % waiting for real data
    else
        warning("Download failed. Skipping resample.");
    end
    shipdownload = toc;
end
%%
try
    run C:\Users\spraydata\Documents\GitHub\Spray2_Processing\prelim_plot_spray2pH.m;
catch
    disp('failed to run spray2 processing')
end
%% Pull the latest glider data, convert to Gliderviz file, push to FTP
% Spray2pHProcessor.runMission('25520301', 'Debug', true);
% Basic usage
% processor = Spray2pHProcessor('25520301');
% success = processor.processData();
%% Load latest glider data and write to map product
tic
handler = GliderDataHandler();
handler.processGliderData('25720901');
% handler.processGliderData('25520301');
handler.processGliderData('25706901');
gliderdownload = toc;
%% Copy map product to FTP
tic
outputFile = '\\atlas.shore.mbari.org\ProjectLibrary\901805_Coastal_Biogeochemical_Sensing\Locness\LocnessMapProduct.txt';
glidervizFolder = '\\sirocco\wwwroot\lobo\data\glidervizdata\';
copyfile(outputFile,glidervizFolder)
copy = toc;
%% Convert map product to kml and push latest data to ODSS
tic;
try
    run \\atlas.shore.mbari.org\projectlibrary\901805_Coastal_Biogeochemical_Sensing\Locness\write_ODSS.m;
catch
    disp('could not write ODSS'); % add an email with error code
end
updateODSS = toc;
