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

#ifndef ABORTDRIFT_H_
#define ABORTDRIFT_H_

#include "component/Behavior.h"

class UniversalDataReader;

/**
 *  Contains the AbortDrift Behavior/Command
 *
 *  Returns statisfied if the elpased time since
 *  last valid acoustic_receive_time (universal variable)
 *  exceeds the allowed duration.
 *
 *  AbortDrift.h should only be included by AbortDrift.cpp
 *  Other classes should include AbortDriftIF.h
 *
 *  \ingroup modules_guidance
 **/

class AbortDrift : public Behavior
{
public:

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

    virtual ~AbortDrift();

    /// Initialize function
    void initialize( void );

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

    /// Runs and returns true if acoustic timer has expired
    /// Otherwise returns false
    bool runIfUnsatisfied( void );

    /// Returns true when acoustic timer has expired
    bool isSatisfied( void );

    /// Uninit function
    void uninitialize( void );

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

protected:

    // XML inputs
    SettingReader *acousticTimeoutSettingReader_;

    // Slate inputs
    UniversalDataReader *acousticReceiveTimeReader_;
    UniversalDataReader *gpsTimeFixReader_;

    // Time keeping variables
    Timestamp abortTimer_;
    float timeoutDuration_;
    bool abortDriftTimeoutReached_;

    // Universal data variables
    bool receivedValidAcousticTime_;
    bool receivedValidGpsTimeFix_;
    float acousticReceiveTime_;
    float gpsTimeFix_;

    // Indicates successful initialization
    bool initialized_;

private:

    bool readSettings( void );

    bool readParams( void );

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

#endif /* ABORTDRIFT_H_ */
