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

#ifndef NAVIGATIONSIM_H_
#define NAVIGATIONSIM_H_

#include "SimInitStruct.h"
#include "SimResultStruct.h"
#include "SimRunStruct.h"

#include "component/SyncComponent.h"
#include "data/Location.h"
#include "data/Matrix6x6.h"
#include "data/Point3D.h"
#include "data/Point6D.h"
#include "Simulator.h"
#include "utils/AuvMath.h"
#include "utils/Datum.h"

class UniversalDataReader;
class UniversalDataWriter;

/**
 *  NavigationSim provides much of the functionality of "Navigation".
 *  It initializes whenever a location fix is obtained.
 *  \todo The first X seconds of each dive are used to tune the
 *  settings of mass zero position and buoyancy zero gain.
 *
 *  NavigationSim.h should only be included by NavigationSim.cpp
 *  Other classes should include NavigationSimIF.h
 *
 *  \ingroup modules_simulator
 */
class NavigationSim : public SyncDerivationComponent
{

public:
    /// Constructor.
    NavigationSim( const Module* module );

    /// Destructor.
    virtual ~NavigationSim();

    /// Initialize the simulator
    virtual void initialize( void );

    /// Run the simulation
    virtual void run( void );

    /// Uninitialize the simulation
    virtual void uninitialize( void );


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

    /// The actual dynamic simulator
    Simulator simulator_;

    /// Indicates whether the internal sim is running
    bool ok_;

    /// Indicates whether we have an initial position fix
    bool haveFix_;

    // write State to Slate
    virtual void publishState();

    //*------------------- slate variables -----------------------*/

    // Environmental parameters:
    UniversalDataReader* densityReader_;

    // AHRS specific parameters:
    UniversalDataReader* headingReader_;
    UniversalDataReader* pitchReader_;
    UniversalDataReader* rollReader_;

    //----------------------------------------------------------------
    // Depth specific parameters:
    UniversalDataReader *depthReader_;

    //----------------------------------------------------------------
    // Gps specific parameters:
    UniversalDataReader *latitudeFixReader_;
    UniversalDataReader *longitudeFixReader_;
    UniversalDataWriter *latitudeWriter_;
    UniversalDataWriter *longitudeWriter_;
    UniversalDataWriter *speedWriter_;

    //----------------------------------------------------------------
    // Tailcone specific parameters:
    DataReader* propOmegaActionReader_;
    DataReader* elevatorAngleActionReader_;
    DataReader* rudderAngleActionReader_;
    DataReader* massPositionActionReader_;
    UniversalDataReader* propOmegaReader_;
    UniversalDataReader* elevatorAngleReader_;
    UniversalDataReader* rudderAngleReader_;
    UniversalDataReader* massPositionReader_;


    //----------------------------------------------------------------
    // Communications
    SimRunStruct runParams_;
    SimResultStruct results_;

};

#endif /*NAVIGATIONSIM_H_*/
