% iGp_read          - Script to read out data and plot mean/RMS/spectrum
%
% Copyright (c) 2006 Dimtel, Inc., All Rights Reserved
%
% $Id: iGp_read.m,v 1.1.1.1 2010/10/05 16:43:02 dim Exp $
% $Date: 2010/10/05 16:43:02 $
% $Author: dim $
% $Revision: 1.1.1.1 $
% $Log: iGp_read.m,v $
% Revision 1.1.1.1  2010/10/05 16:43:02  dim
% Initial import of iGp12
%
% Revision 1.1  2008/01/05 19:53:38  dim
% Changes to avoid reliance on sort_bunches and rms() from the LFB suite
%
% Revision 1.1  2007/03/14 08:35:58  dim
% Matlab tools for data acquisition and testing with file-based data exchange
%
%

vars=who;
for k=1:length(vars)
  if (~strcmp(vars{k}, 'sys') && ~strcmp(vars{k}, 'acq') && ...
      ~strcmp(vars{k}, 'acq_cnt'))
    clear(vars{k});
  end
end

prm.debug = 1;
if (exist('sys', 'var'))
  prm.sys = sys;
else
  prm.sys = input('iGp device name [TEST]: ', 's');
end
if (isempty(prm.sys))
  prm.sys = 'TEST';
end

% Figure out the directory
prm.tm = datestr(now, 'HH:MM:SS');
prm.tm(3:4)=prm.tm(4:5); prm.tm(5:6)=prm.tm(7:8); prm.tm = prm.tm(1:6);
unix(['mkdir ', prm.tm]);

[status, prm] = iGp_gd(prm);

if (status && ~exist('acq_cnt', 'var'))
  disp(['Created data set [', prm.tm, ']. Plotting...']);
  eval(['cd ', prm.tm]);
  iGp_plt
  cd ..
end
