function o2_remctl( time, rawlbl, chead, res )

% O2_REMCTL      Plots remote control commanded heading
%   Plots the raw LBL channel times after validation and the rounded values
%   that commanded the vehicle (both decoded) superimposed on the commanded
%   heading.
%
%   B. A. Moran, 1996

%----------------------------------------------------------------------
%                      Copyright (C) 1994-1996
%               Massachussetts Institute of Technology
%              Sea Grant Underwater Vehicles Laboratory
%----------------------------------------------------------------------
%     $Revision: 1.1 $			$Date: 2000/01/10 19:08:19 $
%----------------------------------------------------------------------

global run_name;

if nargin < 4, res = 30; end

[xx,yy] = stairs( time, 180/pi*chead );

plot( xx, yy, 'c' );

mask = find( 1 <= rawlbl & rawlbl <= 4.6 );

valid_r = 100*(rawlbl(mask)-1);
valid_p = round(valid_r/res)*res;
line( time(mask), valid_r, 'color', 'r', 'linestyle', 'x' );
line( time(mask), valid_p, 'color', [0 .7 0], 'linestyle', 'o' );

for i=1:length(mask)
    line( time(mask(i))*[1 1], [valid_r(i) valid_p(i)], 'color', 'y' );
end

title( ['Commanded Heading by Remote Delay: ' run_name] );
xlabel( 'elapsed time (s)' );
ylabel( 'commanded heading (deg)' );
zoom on
