%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% PURPOSE: Plot items related to the battery - Metrabyte.
% AUTHOR:  rsm
% DATE:    00/6/5
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%

  if exist('metrabyte') ~= 1, return, end

  str = [' ',titleStr,' Plotted on ',myDate];
  PaperPosn = [.5 .5 3.75 2.5];
  FigurePosn = [5 30 815 760];
  i = 0;


  if exist( 'battFig' ) ~= 1
    battFig = figure;
    figure(battFig);
  else
    figure(battFig);
  end
  set( battFig, 'Name', 'Metrabyte Battery Plot', 'DeleteFcn', 'clear battFig' );
  set(gcf,'position',position)

  %nstrips = 2;
  %if exist('dataTC') == 1, nstrips = 3; end
  nstrips = 3;

  subplot(nstrips,1,1)
  plot(metrabyte(:,1), metrabyte(:,voltage));
  ylabel('Volts')
%  xlabel('Seconds');
  title(['Metrabyte Voltage ',str]);
  grid on
  zoom on
  subplot(nstrips,1,2)
  plot(metrabyte(:,1), metrabyte(:,current));
  ylabel('Amperes')
  title(['Metrabyte Current',str]);
%  xlabel('Seconds');
  grid on;
  zoom on;
  subplot(nstrips,1,3)
  Powt = metrabyte(:,current).*metrabyte(:,voltage);
  plot(metrabyte(:,1), Powt );
  if exist('dataTC') == 1,
    interpVolts = spline( metrabyte(:,1), metrabyte(:,voltage), dataTC(:,1) );
    interpAmps  = spline( metrabyte(:,1), metrabyte(:,current),dataTC(:,1) );
    Powp = dataTC(:,propCurrent1).*interpVolts;
    Powh = (interpAmps-dataTC(:,propCurrent1)).*interpVolts;
    line(dataTC(:,1), Powp, 'color','red');
    line(dataTC(:,1), Powh, 'color','green');
    legend('Total','Propulsion','Hotel')

    if 0
    %
    % There is some issue with the endpoint slopes that cause huge endpoint
    % values, thus necessitating fancy plot scaling.  Skip it for now.
    %
    interpAmps = spline( dataTC(:,1), dataTC(:,propCurrent1), metrabyte(:,1) );
    line(metrabyte(:,1), metrabyte(:,voltage).*interpAmps, 'color','red');
    Ylim = get(gca,'YLim');
    ymax = max(abs(Ylim));
    set(gca,'YLim',[0 ymax])
    end

  end
  ylabel('Watts')
  title(['Metrabyte Power',str]);
  xlabel('Elapsed Time (s)');
  grid on;
  zoom on;



return
  if exist('dataTC') ~= 1, return, end

  subplot(nstrips,1,3)
  plot(dataTC(:,1), dataTC(:,propRpm));
  ylabel('Rev/Min')
  title(['Propeller Speed',str]);
  xlabel('Seconds');
  grid on;




