/****************************************************************************/
/* Copyright (c) 2000 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : WaypointBottom.h                                              */
/* Author   : rsm                                                           */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 2012/10/2                                                     */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
#ifndef _WAYPOINTBOTTOM_H
#define _WAYPOINTBOTTOM_H
#define NTAB 512
#define NCOLS 4

#include "ourTypes.h"
#include "Behavior.h"
#include "MathP.h"
#include "WaypointBottomLog.h"
#include "TerrainAidIF.h"
#include "DynamicControlIF.h"

#define WaypointBottomBehaviorName "waypoint_bottom"

class WaypointBottom : public Behavior {

friend class WaypointBottomLog;

public:

  WaypointBottom();
  virtual ~WaypointBottom();

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

  virtual Boolean shouldBehaviorStart( void );

protected:

  double _northing, _lastNorthing;
  double _easting, _lastEasting;
  double _latitude, _lastLatitude;
  double _longitude, _lastLongitude;
  double _speed;
  double _depth;
  double _bearing;
  double _depthCmd;
  double _thetaFF, _thetaT;
  double _altitudeCmd, _altitude;
  double _maxVertError;
  double _amp;
  double _lambda;
  double _stime;
  double _x0, _y0, _stime0;
  double _avoidRange, _depthHysteresis;
  Boolean _first, _latched, _run, _feedThetaForward, _quarterWave, _initProfile;
  Boolean _nativeAltitudeControl, _stopProp, _maxDepthHold;
  float _profileTab[NTAB][NCOLS];
  FILE *_fpAsc;
  char _fullFileName[128], *_baseName;
  int _indxTab, _lenTab;
  Boolean _depth2AltActive, _avoidRangeActive;
  double _x, _xNext, _pole, _gain, _tau, _Ts, _y;
  double _maxLowerPitch;
  double _driftPitch, _depthLatch;
  Boolean _firstFilter;
  Boolean _useThetaB;
  Boolean _reinitFilter;
  double _deltaNorthing, _deltaEasting;

  //variables to support logging of behavior state
  static int _logFileRefCnt;
  static int _terrainAidIFCnt;
  static int _behaviorCnt;
  static WaypointBottomLog *_log;
  
};



#endif
