/** \file
 *
 *  Contains the PrepareToDive class declaration.
 *
 *  PrepareToDive.h should only be included by PrepareToDive.cpp
 *  Other classes should include PrepareToDiveIF.h
 *
 *  Copyright (c) 2007,2008,2009 MBARI
 *  MBARI Proprietary Information.  All Rights Reserved
 */

#ifndef PREPARETODIVE_H_
#define PREPARETODIVE_H_

#include "component/Behavior.h"

class ConfigReader;
class UniversalDataReader;

/**
 *  Contains the PrepareToDive Behavior/Command.  Simply
 *  sends the vehicle to the surface.  Satisfied when the vehicle
 *  has reached the surface.
 *
 *  PrepareToDive.h should only be included by PrepareToDive.cpp
 *  Other classes should include PrepareToDiveIF.h
 *
 *  \ingroup modules_guidance
 */
class PrepareToDive : public Behavior
{
public:

    PrepareToDive( const Str& prefix, const Module* module );

    virtual ~PrepareToDive();

    /// Initialize function
    void initialize( void );

    /// Read in the parameters for satisfied or runIfUnsatisfied: return true if OK.
    bool readParams( float& massPosition );

    /// Perform the satisfied: return true if envelope "satisfied"
    bool calcSatisfied( const float massPosition );

    /// Just do the run: ignore the results of the satisfied
    void run();

    /// Just do the satisfied: return true if envelope "satisfied"
    bool isSatisfied();

    /// Do the run, and return true if envelope "satisfied"
    bool runIfUnsatisfied();

    /// Uninit function
    void uninitialize( void );

    /// Mission Component factory interface
    static Behavior* CreateBehavior( const Str& prefix, const Module* module );

protected:

    // Configuration
    ConfigReader* massDefaultConfigReader_;
    ConfigReader* massDeviationCfgReader_;

    /// Current depth (in meter from sea surface -- positive down)
    UniversalDataReader* massPositionReader_;

    // Slate output variables

    /// Sets the vertical mode
    DataWriter* verticalModeWriter_;

    /// Sets the mass position
    DataWriter* massPositionCmdWriter_;

    /// Resets Dynamic Control variables
    /// Default is zero.
    DataWriter* speedCmdWriter_;

private:
    // Note that the copy constructor below is private and not given a body.
    // Any attempt to call it will return a compiler error.
    PrepareToDive( const PrepareToDive& old ); // disallow copy constructor

    // indicates whether things are ok to run
    bool ok_;

    ///*------------------- vehicle parameters --------------------------*/
    float massDefault_;
    float massDeviation_;
    ///////////////////////////////////

    // initialize vehicle config variables
    bool readConfig( void );

};

#endif /*PREPARETODIVE_H_*/
