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

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

#define DownloadDataBehaviorName "DownloadData"

#define NullLegDuration -1.0

class FloatAttribute;
class AngleAttribute;

/*
CLASS 
DownloadData

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

public:

  DownloadData();

  virtual ~DownloadData();

  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 launching
  double _downloadDelay;

  // Delay before checking status
  double _statusDelay;

  // True when the download has been initiated
  Boolean _initiateDownload;

  // True when the data has been downloaded
  Boolean _downloaded;

  // 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 *_downloadDelayAttr;
  FloatAttribute *_statusDelayAttr;
};



#endif
