/****************************************************************************/
/* Copyright (c) 2000 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : BuoyLaunch.h                                                    */
/* Author   :                                                               */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 02/07/2000                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
#ifndef _BuoyLaunch_H
#define _BuoyLaunch_H

#include "ourTypes.h"
#include "Behavior.h"
#include "DynamicControlIF.h"
#include "BuoyLauncherIF.h"

#define BuoyLaunchBehaviorName "BuoyLaunch"

#define NullLegDuration -1.0

class FloatAttribute;
class AngleAttribute;

/*
CLASS 
BuoyLaunch

DESCRIPTION
This behavior sets heading, depth or pitch, and speed of the vehicle.
Vertical mode can be either Pitch or Depth. Behavior is active for
specified number of "legs"; each leg has a specified duration, and
heading is incremented by specified amount after each leg.

Attribute       Type               Meaning
---------       ----               -------
heading         angle              Commanded heading
speed           double             Commanded speed
verticalMode    VerticalMode       Either "depth" or "pitch"
depth           double             Commanded depth if verticalMode is "depth"
pitch           angle              Commanded pitch if verticalMode is "pitch"
legDuration     integer            Duration of each leg 
maxLegs         integer            Maximum number of legs
headingInc      angle              Increment heading by this amount after 
                                   each leg
AUTHOR
Tom O'Reilly
*/
class BuoyLaunch : public Behavior {

public:

  BuoyLaunch();

  virtual ~BuoyLaunch();

  virtual void execute();
  Boolean shouldBehaviorStart( void );
  virtual Boolean validInput();

protected:

  //
  // Open an interface to the Buoy Launcher:
  //
  BuoyLauncherIF *_buoyLauncher;


  // Desired heading; will get incremented after each leg
  double _heading;

  // Desired speed
  double _speed;
  double _launchSpeed;

  // Vertical mode 
  DynamicControlIF::VerticalMode _verticalMode;

  // Desired depth if verticalMode is Depth
  double _depth;

  // Delay before launching
  double _launchDelay;

  // True when the buoy has been launched
  Boolean _initiateLaunch;

  // True when the buoy has been launched
  Boolean _launched;

  // When this is zero, turn status calls off, otherwise  on
  long _statusCalls;
  long _fake;
  Boolean _statusSet;

  // Desired pitch if verticalMode is Pitch
  double _pitch;

  // Maximumm number of legs to do
  long _maxLegs;

  // Duration (secs) of each leg
  long _legDuration;

  // Increment heading by this amount after each leg
  double _headingIncrement;

  // Number of legs completed
  int _legsCompleted;

  // Starting time of current leg
  double _legStartTime;

  FloatAttribute *_depthAttribute;
  AngleAttribute *_pitchAttribute;
  FloatAttribute *_launchDelayAttr;
};



#endif
