function [ error ] = MakeQuickViewPlots(path,filename)



%path = '../TestData/'
%filename = '2018.10.09T12.20.05'


LatAnchor = 36.7442;
LonAnchor = -121.8830;


AbsoluteTime = 0;

%disp([path filename '.mat']);

load([path filename '.mat']);

PC_Power = PC_Voltage.*(PC_LoadCurr+PC_BattCurr);
PC_LoadPower = PC_Voltage.*(PC_LoadCurr);
PC_BattPower = PC_Voltage.*(PC_BattCurr);
who


Force = (SC_LowerPressure-1.59)*(8758)/(262.7-1.59);

x = SC_Range;
n = 10;
filtx = filter(ones(1,n)/n,1,x);
x = filtx;

%x = (SC_UpperPressure-18.9)*(71.5-0)/(294.2-18.9);
v = [0 diff(x)/.1];


if(~AbsoluteTime)
Time_DateNum= Time_DateNum-Time_DateNum(1);
end


%addpath('./SpinCalc');
%addpath('./quaternions');

 if(size(TC_Qtn1,1) > size(TC_Qtn1,2))  %Row Major order
  TC_Qtn = [TC_Qtn1 TC_Qtn2 TC_Qtn3 TC_Qtn4];
 else
  TC_Qtn = [TC_Qtn1' TC_Qtn2' TC_Qtn3' TC_Qtn4'];
 end
 TC_Qtn =qmult(TC_Qtn,[sqrt(.5) 0 -sqrt(.5) 0]);  %Rotate sensor 90 degrees about y-axis to make z point up.

 if (0) %(~isnan(TC_Qtn))
    EA = SpinCalc('QtoEA321',TC_Qtn,.001,1);
    
 %   idx = find(EA(:,1) >180);
 %   EA(idx,1) = EA(idx,1)-360;
 EA(:,1) = EA(:,1)-180;
 else
    EA = NaN(size(TC_Qtn1'));
 end


MostRecentLat = NaN; idx = find(~isnan(XB_Lat)); if(~isempty(idx)) MostRecentLat = XB_Lat(idx(end)); end
MostRecentLon = NaN; idx = find(~isnan(XB_Lon)); if(~isempty(idx)) MostRecentLon = XB_Lon(idx(end)); end
Distance = pos2dist(MostRecentLat,MostRecentLon,LatAnchor,LonAnchor,2)*1000;

%fh = figure('Position',[372 61 717 950],'paperposition',[.5 .5 7.5 10],'Visible','off','renderer','opengl');
fh = figure('Position',[372 61 717 950],'paperposition',[.5 .5 7.5 10],'Visible','off','renderer','painter');


ah7 = subplot(7,1,7);
plot(Time_DateNum,XB_YawAng)
hold all
plot(Time_DateNum,EA(:,1));
legend('Buoy','Heave Cone','Location','NorthWest');
ylabel('Yaw Angle (deg)')
datetick('x');
grid on;

idx = find(~isnan(PC_Power));
ah6 = subplot(7,1,6);
plot(Time_DateNum,PC_Power);
ylabel('W');
leg_str = ['Mean = ' num2str(mean(PC_Power(idx)),'%.1f') ' W   (Batt = ' num2str(mean(PC_BattPower(idx)),'%.1f') ' W   Load = ' num2str(mean(PC_LoadPower(idx)),'%.1f') ' W)'];
legend(leg_str,'Location','NorthWest');
datetick('x');
grid on

ah5 = subplot(7,1,5);
plot(Time_DateNum,PC_BattCurr,Time_DateNum,PC_LoadCurr)
ylabel('Current (A)');
legend('Battery Current','Load Current','Location','NorthWest');
datetick('x');
grid on;

ah4 = subplot(7,1,4);
plot(Time_DateNum,BC_GroundFault,Time_DateNum,PC_DiffPress)

legend('Ground Fault (mA)','PTO Comp Pressure (psi)','Location','NorthWest')
ylim([0 5]);
set(gca,'YTick',[0:1:5]);
grid on;
datetick('x');

ah3 = subplot(7,1,3);
plot(Time_DateNum,PC_Voltage)
hold all
plot(Time_DateNum,BC_Voltage)
ylim([260 330]);
legend('Bus Voltage','Batt Voltage','Location','NorthWest');
ylabel('Voltage (V)');
datetick('x');
grid on;

idx = find(~isnan(PC_RPM));
ah2 = subplot(7,1,2);
plot(Time_DateNum,SC_LoadCell);
hold all
plot(Time_DateNum,PC_RPM);
ylim([-6000 12000]);
datetick('x')
legend('Load Cell (lbs)',['RPM (stdDev = ' num2str(std(PC_RPM(idx)),'%.f') ' RPM)'],'Location','NorthWest');
grid on;

idx = find((SC_Range < 80) & (SC_Range > 0));
if(round(mean(TC_StatusFields.ActualPos(round(3*end/4):end))))
  DoorPos = 'Doors Closed';
else
  DoorPos = 'Doors Open';
end

  AnchorPos = ['Distance to Anchor = ' num2str(Distance,'%.f') ' m'];

ah1 = subplot(7,1,1);
if(exist('SC_Range_Smooth'))
        plot(Time_DateNum,SC_Range_Smooth);
else
    plot(Time_DateNum(idx),SC_Range(idx));
end
grid on;
datetick('x')
ylabel('Piston Position (in)');
title([filename '  -  ' AnchorPos '  -  ' DoorPos]);


print([path filename '.pdf'],'-dpdf')
close all;

end

