%----------------------------------------------------------------------
%                      Copyright (C) 1994-1997
%               Massachussetts Institute of Technology
%              Sea Grant Underwater Vehicles Laboratory
%----------------------------------------------------------------------
%     $Revision: 1.1 $			$Date: 1996/07/16 16:18:22 $
%----------------------------------------------------------------------

set( gcf, 'Name', 'Thruster Current and Propeller Speed' );

spdplot = (exist( 'm_propeller_speed' ) == 1) | ...
    (exist( 'm_thruster_rot' ) == 1);

if exist('m_thruster_current') == 1 & exist('cc_speed_0') == 1
    
    if spdplot
	subplot( 2, 1, 1 )
    end
    cla
    o2_thamp( time, data(:,cc_speed_0), data(:,m_thruster_current) );

    if spdplot
	subplot( 2, 1, 2 )
    end
end

if exist( 'm_propeller_speed' ) == 1

    cla
    o2_thspd( time, data(:,m_propeller_speed) );

elseif exist( 'm_thruster_rot' ) == 1

    special = [848444807 848449068 853949532 853951566 853952146 ...
	       853952757 853952920 853958621 853963328 853965002 853965119 ...
	       853966364 853967280 854038306 854048996 854049836 854051471 ...
	       854052026 854054062];
	
    if any( start == special )
	disp( ['Using special case: ' num2str(start)] );
	m_rot = hex2dec('ffff') - round(2e6*pi./data(:,m_thruster_rot));
	ind = find(m_rot == 0);
	m_rot(ind) = Inf*ones(size(ind));
	clear ind
    else
	m_rot = data(:,m_thruster_rot);
	if any( m_rot >= hex2dec('8000') & finite(m_rot) )
	    disp( 'Using pre 11/96 thruster rotation' );
	    bad = find( m_rot >= hex2dec('8000') );
	    m_rot(bad) = hex2dec('10000') - m_rot(bad);
	end
    end
    prop = (60./(16e-6*m_rot))/5.54;

    o2_thspd( time, prop );
end

clear spdplot
