%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% PURPOSE: Plot fuel cell data.
% AUTHOR:  Rob McEwen
% DATE:    01/3/15
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%

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

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


  if exist( 'fuelcellFig1' ) ~= 1
    fuelcellFig1 = figure;
    winpos( position(1,:) );
  else
    figure(fuelcellFig1);
  end
  set( fuelcellFig1, 'Name', 'Fuelcell Plot', 'DeleteFcn', ...
		    'clear fuelcellFig1' );

  nstrips = 2;

  subplot(nstrips,1,1)
  plot(dataFC(:,1), [dataFC(:,anolyte_pump_a_current) ...
		     dataFC(:,anolyte_pump_b_current) ...
		     dataFC(:,catholyte_pump_current) ...
		     dataFC(:,peroxide_pump_current) ]/100 );
  ylabel('Amps')
  title(['Pump Currents and Temperatures ',str]);
  legend('Anolyte A','Anolyte B','Catholyte','Peroxide')
  grid on
  zoom on
  
  subplot(nstrips,1,2)
  plot(dataFC(:,1), [dataFC(:,anolyte_temp) ...
		     dataFC(:,catholyte_temp) ...
		     dataFC(:,fwd_peroxide_temp) ...
		     dataFC(:,aft_peroxide_temp) ...
		    ]/10 );
  ylabel('Centigrade')
  xlabel('Elapsed Time (s)');
  legend('Anolyte','Catholyte','Fwd Peroxide','Aft Peroxide')
  grid on;
  zoom on;


  if exist( 'fuelcellFig2' ) ~= 1
    fuelcellFig2 = figure;
    winpos( position(1,:) );
  else
    figure(fuelcellFig2);
  end
  set( fuelcellFig2, 'Name', 'Fuelcell Plot 2', 'DeleteFcn', ...
		    'clear fuelcellFig2' );

  nstrips = 3;

  subplot(nstrips,1,1)
  plot(dataFC(:,1), [dataFC(:,stack_voltage) ...
		     dataFC(:,battery_voltage) ...
		     dataFC(:,v_setpoint) ]/100 );
  ylabel('Volts')
  title(['Voltages and Currents ',str]);
  legend('Stack','Battery','Setpoint')
  grid on
  zoom on
  
  subplot(nstrips,1,2)
  plot(dataFC(:,1), [dataFC(:,stack_current) ...
		     dataFC(:,battery_current) ...
		    ]/100 );
  ylabel('Amps')
  xlabel('Elapsed Time (s)');
  legend('Stack','Battery');
  grid on;
  zoom on;

  if 0
  subplot(nstrips,1,3)
  plot(dataFC(:,1), dataFC(:,base_injection_duration)/100 );
  ylabel('Seconds')
  xlabel('Elapsed Time (s)');
  grid on;
  zoom on;
  end

  I_pumps =  [dataFC(:,anolyte_pump_a_current) + ...
	      dataFC(:,anolyte_pump_b_current) + ...
	      dataFC(:,catholyte_pump_current) + ...
	      dataFC(:,peroxide_pump_current) ]/100;
  subplot(nstrips,1,3)
  plot(dataFC(:,1), [dataFC(:,stack_current).*dataFC(:,stack_voltage)/10000 ...
		     dataFC(:,stack_voltage).*I_pumps/100 ]);
  ylabel('Watts')
  xlabel('Elapsed Time (s)');
  legend('Stack','Pumps');
  grid on;
  zoom on;


  if exist( 'fuelcellFig3' ) ~= 1
    fuelcellFig3 = figure;
    winpos( position(1,:) );
  else
    figure(fuelcellFig3);
  end
  set( fuelcellFig3, 'Name', 'Fuelcell Plot 3', 'DeleteFcn', ...
		    'clear fuelcellFig3' );

  nstrips = 2;

  subplot(nstrips,1,1)
  plot(dataFC(:,1), dataFC(:,FCC_health) );
  ylabel('Health Flags')
  title(['Health and Status ',str]);
  grid on
  zoom on
  
  subplot(nstrips,1,2)
  plot(dataFC(:,1), dataFC(:,fc_ctrl_state));
  ylabel('Status Count')
  xlabel('Elapsed Time (s)');
  grid on;
  zoom on;

  return




