/** \file
 *
 *  Specifies the interface details for the HFRCMSurfaceCurrentAtVehicleLocation
 *  component in the EstimationModule.
 *
 *  HFRCMSurfaceCurrentAtVehicleLocation.h should only be included by
 *  HFRCMSurfaceCurrentAtVehicleLocation.cpp
 *  Other classes should include HFRCMSurfaceCurrentAtVehicleLocationIF.h
 *
 *  Copyright (c) 2013, 2014 MBARI
 *  MBARI Proprietary Information.  All Rights Reserved
 */

#ifndef HFRCMSURFACECURRENTATVEHICLELOCATION_H_
#define HFRCMSURFACECURRENTATVEHICLELOCATION_H_

#include "component/SyncComponent.h"
#include "data/Mtx.h"

#include "HFRadarCompactModelForecasterIF.h" // for TOTAL_HOURS, etc.

class UniversalDataReader;
class BlobReader;
class ConfigReader;

/**
 *  Specifies the interface details for the HFRCMSurfaceCurrentAtVehicleLocation
 *  component in the EstimationModule.
 *
 *  HFRCMSurfaceCurrentAtVehicleLocation.h should only be included by
 *  HFRCMSurfaceCurrentAtVehicleLocation.cpp
 *  Other classes should include HFRCMSurfaceCurrentAtVehicleLocationIF.h
 *
 *  \ingroup modules_estimation
 */

class HFRCMSurfaceCurrentAtVehicleLocation : public SyncEstimationComponent
{
public:
    HFRCMSurfaceCurrentAtVehicleLocation( const Module* module );
    virtual ~HFRCMSurfaceCurrentAtVehicleLocation();

    /// Initialize function
    void initialize( void );

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

protected:
    const bool debug_;
    int verbosity_;
    // space components
    Mtx eastEmpiricalOrthogonalFunctionsHere_;
    Mtx northEmpiricalOrthogonalFunctionsHere_;
    float eastEnsembleMeanHere_;
    float northEnsembleMeanHere_;
    float eastScalingFactor_;
    float northScalingFactor_;
    // time components
    Mtx expansionCoefficients_; // TODO: Would it be better to have a lookup component for the ECs like for the EOFs?
    Mtx expansionCoefficientsNow_;
    double forecastEpochSeconds_[ HFRadarCompactModelForecasterIF::TOTAL_HOURS ]; // TODO: Would go into time interpolator component
    // results
    float eastVelocity_, northVelocity_, velocityAccuracy_;
    bool haveValidForecast_;
    // readers & writers
    UniversalDataReader* latitudeReader_;
    UniversalDataReader* longitudeReader_;
    UniversalDataWriter* eastVelocityWriter_;
    UniversalDataWriter* northVelocityWriter_;
    // Configuration readers
    ConfigReader* velocityAccuracyConfigReader_;

    /// Look up the expansion coefficients at the current time.
    bool lookupExpansionCoefficients( void );

    /// Look up the empirical orthogonal functions at the current location.
    bool lookupEmpiricalOrthogonalFunctions( void );

    /// Calculate the estimated velocities at the current location and time.
    void reproject( 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.
    HFRCMSurfaceCurrentAtVehicleLocation( const HFRCMSurfaceCurrentAtVehicleLocation& old ); // disallow copy constructor

};

#endif /* HFRCMSURFACECURRENTATVEHICLELOCATION_H_ */
