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

#ifndef MASS_H_
#define MASS_H_

#include "component/Behavior.h"
#include "data/Location.h"

class UniversalDataReader;

/**
 *  Contains the Mass Command
 *
 *  Is not satisfied until the specified mass duration
 *  has passed.
 *
 *  Mass.h should only be included by Mass.cpp
 *  Other classes should include MassIF.h
 *
 *  \ingroup modules_guidance
 */
class Mass : public Behavior
{
public:

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

    virtual ~Mass();

    /// Initialize function
    void initialize( void );

    /// Read in settings
    bool readSettings( void );

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

    /// The actual "payload" of the component
    void run();

    /// Runs and returns false if not in capure radius
    /// Otherwise returns true
    bool runIfUnsatisfied();

    /// Returns true when vehicle has "arrived"
    /// within the captureRadius of the waypoint
    bool isSatisfied();

    /// Uninit function
    void uninitialize( void );

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

protected:

    /// return true if mass time is over
    bool calcSatisfied( void );

    // Positon at which to stop mass
    double massPositionSetting_;

    // Allowable mass position error
    double massDeviation_;

    /// True if mass position reading is active
    int inactivePositionCount_;

    // Servo ConfigReader
    ConfigReader* massDeviationCfgReader_;

    /// Mass position setting
    SettingReader *massPositionSettingReader_;

    // Slate input setting variables
    UniversalDataReader *massPositionReader_;

    /// Mass position command to VerticalControl
    DataWriter* massPositionCmdWriter_;

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

};

#endif /*MASS_H_*/
