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

#include "Behavior.h"
#include "MissionClock.h"
#include "MathP.h"

#define NoAbortDepth -99999.
#define NoMinimumAltitude -99999.
#define NoAbortAltitude -999999.
#define NoHardDeck -99999.
#define NoDeltaDepth -99999.
#define NoMaxLowerPitch -99999.
#define NoPitchLimitAlt -99999.
#define NoAltSuspendPitch -99999.
#define NoAltTimeOut -99999.

#define DepthEnvelopeBehaviorName "depthEnvelope"

/*
CLASS 
DepthEnvelope

DESCRIPTION
This behavior prevents the vehicle from decending below the "maxDepth"
or ascending above the "minDepth".  If "minAltitude" != NoMinimumAltitude, 
then it also prevents the vehicle from approaching closer to the bottom than
"minAltitude".  If "abortDepth" != NoAbortDepth, then the
mission is aborted if the "abortDepth" is reached.

Attribute       Type               Meaning
---------       ----               -------
minDepth        Float              Minimum depth
maxDepth        Float              Maximum depth
minAltitude     Float              Minimum altitude
abortDepth      Float              Abort when below this depth
abortAltitude   Float              Abort when below this altitude
abortLockoutDepth Float		   Ignore altitude aborts when
				     shallower than this depth
AUTHORS
Tom O'Reilly, Hans Thomas, Rob McEwen
*/
class DepthEnvelope : public Behavior {

public:

  ///////////////////////////////////////////////////////////////////
  // Constructor
  DepthEnvelope();

  virtual ~DepthEnvelope();

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

protected:

  double _maxDepth;
  double _minDepth;
  double _minAltitude;
  double _abortDepth;
  double _abortAltitude;
  Boolean _altitudeStop;
  Boolean _depthStop;
  double _hardDeck;
  double _deltaDepth;
  double _restartDepth;
  double _elevator;
  double _maxLowerPitch;
  double _maxLowerPitchDepth;
  double _pitchLimitAlt;
  double _minFlsHorzRange;
  double _altSuspendPitch;
  double _altTimeOut, _lastTime;
  Boolean _altSuspendDepthControl, _latchData, _indirectAltCntrl;
  double _lastDepth;
};

#endif
