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

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

#define RotateToLaunchPositionBehaviorName "RotateToLaunchPosition"

#define NullLegDuration -1.0

class FloatAttribute;
class AngleAttribute;

/*
CLASS 
RotateToLaunchPosition

DESCRIPTION

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 RotateToLaunchPosition : public Behavior {

public:

  RotateToLaunchPosition();

  virtual ~RotateToLaunchPosition();

  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;

  // Vertical mode 
  DynamicControlIF::VerticalMode _verticalMode;

  // Desired depth if verticalMode is Depth
  double _depth;

  // Delay before rotating
  double _rotateDelay;

  // Delay before checking status
  double _statusDelay;

  // When this is zero, rotate a dummy buoy. One? Rotate a real buoy
  long _realBuoy;

  // When this is false, rotate a dummy buoy. True? Rotate a real buoy
  Boolean _rotateRealBuoy;

  // True when the rotate command was issued
  Boolean _initiate;

  // True when a good buoy has rotated to the data position
  Boolean _rotated;

  // When this is zero, turn status calls off, otherwise  on
  long _statusCalls;
  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 *_rotateDelayAttr;
  FloatAttribute *_statusDelayAttr;
};



#endif
