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

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

#define RotateCarouselBehaviorName "RotateCarousel"

#define NullLegDuration -1.0

class FloatAttribute;
class AngleAttribute;

/*
CLASS 
RotateCarousel

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

public:

  RotateCarousel();

  virtual ~RotateCarousel();

  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 initiating the rotation
  double _initiateRotateDelay;

  // Delay after rotating
  double _rotateDelay;

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

  // Desired pitch if verticalMode is Pitch
  double _pitch;

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

  // 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 *_initiateRotateDelayAttr;
};



#endif
