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

#ifndef LBL_H_
#define LBL_H_

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

class UniversalDataReader;

/**
 *  Contains the LBL Behavior/Command.
 *  Drives the vehicle towards a LBL, using crosstrack error correction.
 *
 *  LBL.h should only be included by LBL.cpp
 *  Other classes should include LBLIF.h
 *
 *  \ingroup modules_controller
 */
class LBL : public Behavior
{
public:

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

    virtual ~LBL();

    /// Initialize function
    void initialize( void );

    /// Returns true when vehicle has "arrived" at the LBL
    bool isSatisfied();

    /// runs only if unsatisfied
    bool runIfUnsatisfied();

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

    /// Uninit function
    void uninitialize( void );

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

    class Transponder
    {
    public:
        // Setting variables

        /// Transponder location setting
        Location locationSetting_;
        Location lastLocationSetting_;

        /// Transponder depth setting
        double depthSetting_;
        double lastDepthSetting_;

        // Slate input setting readers

        /// Transponder location setting
        SettingReader *locationSettingReader_;

        /// Transponder depth setting
        SettingReader *depthSettingReader_;

        /// Output to LBLNavigation component
        BlobWriter* lblNavPositionWriter_;

        // Init
        void initialize();
    };

protected:

    /// DataWriters for turning on modems
    static const int NUM_MODEM_VARIANTS = 2;
    DataWriter* pingsRequestedWriters_[NUM_MODEM_VARIANTS];

    // The transponders
    Transponder transponders_[LBLIF::NUM_TRANS];

    /// Indicates initialization success
    bool initialized_;

    // Temporary value for reading/writing BlobValues
    BlobValue value_;

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

};

#endif /*LBL_H_*/
