/****************************************************************************/
/* Copyright (c) 2000 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : SetDepth.cc                                                   */
/* Author   :                                                               */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 02/07/2000                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
#include "SetDepth.h"
#include "FloatAttribute.h"
#include "AngleAttribute.h"
#include "IntegerAttribute.h"
#include "VerticalModeAttribute.h"
#include "MissionTimeAttribute.h"
#include "MathP.h"
#include "Syslog.h"

#define NotSpecified -100000.0

SetDepth::SetDepth()
  : Behavior(SetDepthBehaviorName, NonSequential)
{
  Boolean debug = False;

  attributes.add(new FloatAttribute("speed", "Commanded speed", &_speed,
				    NotSpecified ));

  attributes.add(new FloatAttribute("depth",
				    "Commanded depth if verticalMode "
				    "is \"depth\"",
				    &_depth ) );

}


SetDepth::~SetDepth()
{
}


Boolean SetDepth::shouldBehaviorStart( void ) {
     return verticalSequence();
}

void SetDepth::execute()
{

     Boolean debug = True;

     if( _speed != NotSpecified ) 
	  setSpeed(DynamicControlIF::Speed, _speed);
     
     setVertical(DynamicControlIF::Depth, _depth);
}


Boolean SetDepth::validInput()
{
  Boolean valid = True;
  Boolean debug = True;

  if ( ( _speed != NotSpecified) && 
       (_speed < 0.)) {
    printError("Speed is less than zero");
    valid = False;
  }

  if (_depth < 0) {
       printError("Depth is less than zero");
       valid = False;
  }

  return valid;
}

