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

#ifndef SETSPEED_H_
#define SETSPEED_H_

#include "component/Behavior.h"

class UniversalDataReader;

/**
 *  Contains the SetSpeed Behavior/Command. Passes the selected speed
 *  to speedControl
 *
 *  SetSpeed.h should only be included by SetSpeed.cpp
 *  Other classes should include SetSpeedIF.h
 *
 *  \ingroup modules_guidance
 */
class SetSpeed : public Behavior
{
public:

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

    virtual ~SetSpeed();

    /// Initialize function
    void initialize( void );

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

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

    /// 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:

    /// Read in relevant behavior settings
    void readSettings( void );

    // Slate input setting variables

    /// Desired speed of the vehicle
    SettingReader *speedSettingReader_;

    /// Desired control loop period
    SettingReader *periodSettingReader_;

    // Slate input measurements

    /// Current depth or surrogate for depth
    UniversalDataReader *speedReader_;

    // Slate output variables

    /// Sets the speed specification for SpeedControl
    DataWriter *speedCmdWriter_;

    /// Sets the period specification for LoopControl
    DataWriter *periodCmdWriter_;

    /// The current speed setting
    float speedSetting_;

    /// The current LoopControl Period
    float periodSetting_;

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

};

#endif /*SETSPEED_H_*/
