%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% PURPOSE: Plot Modtronix data.
% AUTHOR:  Rob McEwen
% DATE:    2015/6/17
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  

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

  startDateTime = datetime(startTime,'convertfrom','posixtime');
  
  if( exist('thisTitleStr') ~= 1 )
    thisTitleStr = ['; Data Set: ', DirName];
    startStr = sprintf(';  Start time = %.1f (Sec Unix) = %s Z', startTime, ...
                       datestr(startDateTime));
    thisTitleStr = [thisTitleStr,startStr]
  end

  if( exist( 'LightsFig' ) ~= 1 )
      LightsFig = figure;
      figure(LightsFig);
      set(gcf,'position',position)
  else 
      figure( LightsFig ); 
  end
  set( LightsFig, 'name', ...
      'Temp, Humidity, fStop',...
      'DeleteFcn', 'clear LightsFig')
  %     'paperorientation','landscape','paperposition',[.25 .25 10.5 8.0]);
  clf
  lights1=subplot(4,1,1);
  plot( datenum(datetime(ModtronixLog.data(:,end),'convertfrom','posixtime')), ...
        ModtronixLog.data(:,6) );
  grid on
  set(gca,'fontsize',15)
  set(gca,'ylim',[0 1.2])
  title(['Light On/Off',thisTitleStr]);
  ylabel('Light 1');
  set(gca,'xminorgrid','on','xminortick','on');
  datetick('x',13)
  
  lights2=subplot(4,1,2);
  plot( datenum(datetime(ModtronixLog.data(:,end),'convertfrom','posixtime')), ...
        ModtronixLog.data(:,7) );
  grid on
  set(gca,'fontsize',15)
  set(gca,'ylim',[0 1.2])
  ylabel('Light 2');
  set(gca,'xminorgrid','on','xminortick','on');
  datetick('x',13)
  
  lights3=subplot(4,1,3);
  plot( datenum(datetime(ModtronixLog.data(:,end),'convertfrom','posixtime')), ...
        ModtronixLog.data(:,8) );
  grid on
  set(gca,'fontsize',15)
  set(gca,'ylim',[0 1.2])
  ylabel('Light 3')
  set(gca,'xminorgrid','on','xminortick','on');
  datetick('x',13)
  
  lights4=subplot(4,1,4);
  plot( datenum(datetime(ModtronixLog.data(:,end),'convertfrom','posixtime')), ...
        ModtronixLog.data(:,9) );
  grid on
  set(gca,'fontsize',15)
  set(gca,'ylim',[0 1.2])
  ylabel('Light 4')
  set(gca,'xminorgrid','on','xminortick','on');
  datetick('x',13)

  xlabel('Hours:Minutes:Seconds Zulu');
  linkaxes(get(gcf,'children'),'x')
