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

#ifndef TERMINALGUIDANCE_H_
#define TERMINALGUIDANCE_H_

#include <vector>
#include "component/Behavior.h"
#include "sensorModule/DDMIF.h"

class UniversalDataReader;

/**
 *  Contains the TerminalGuidance Behavior/Command.
 *
 *  TerminalGuidance.h should only be included by TerminalGuidance.cpp
 *  Other classes should include TerminalGuidanceIF.h
 *
 *  \ingroup modules_guidance
 */
class TerminalGuidance : public Behavior
{
public:

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

    virtual ~TerminalGuidance();

    /// Initialize function
    void initialize();

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

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

    /// 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();

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

protected:

    // Slate input setting variables

    /// Range objective for terminal guidace
    SettingReader *targetRangeSettingReader_;


    // Slate input measurements

    /// Current orientation of the vehicle
    UniversalDataReader *orientationReader_;

    /// Heading to target in North-East-Down coordinate frame
    DataReader *headingToContactReader_;

    /// Slant range to target
    DataReader *rangeToContactReader_;


    // Slate output variables

    /// Sets the mode for HorizontalControl
    DataWriter *horizontalModeWriter_;

    /// Sets the specified bearing for HorizontalControl
    DataWriter *headingCmdWriter_;


    // Settings

    /// Objective range for terminal guidace
    float targetRangeSetting_;

    /// Vehicle heading to contact
    float headingToContact_;

    /// Vehicle range to contact
    float rangeToContact_;

    /// Vehicle heading to command
    float headingCmd_;

    bool initialized_;

    bool debug_;

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

};

#endif /*TERMINALGUIDANCE_H_*/
