/** \file
 *
 *  Contains the VerticalHomogeneityIndexCalculator class declaration.
 *
 *  VerticalHomogeneityIndexCalculator.h should only be included by VerticalHomogeneityIndexCalculator.cpp
 *  Other classes should include VerticalHomogeneityIndexCalculatorIF.h
 *
 *  Copyright (c) 2015 MBARI
 *  MBARI Proprietary Information.  All Rights Reserved
 */

#ifndef VERTICALHOMOGENEITYINDEXCALCULATOR_H_
#define VERTICALHOMOGENEITYINDEXCALCULATOR_H_

#include "VerticalHomogeneityIndexCalculatorIF.h"

#include "component/SyncComponent.h"

class ConfigReader;
class UniversalDataReader;
class DataWriter;

/*
 *
 */
class VerticalHomogeneityIndexCalculator : public SyncDerivationComponent
{
public:
    VerticalHomogeneityIndexCalculator( const Module* module );
    virtual ~VerticalHomogeneityIndexCalculator();

    /// Initialize function
    void initialize( void );

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

private:

    void readConfig();
    bool addSample();
    void calculate();
    void writeData();

#define MAX_MEDIAN_FILTER_LENGTH_SALT 11

    int verbosity_, medianFilterLengthSaltSetting_;
    Timestamp dataTimestamp_;
    float temperature_[4];
    float salinity_[4], saltInWindow_[MAX_MEDIAN_FILTER_LENGTH_SALT];
    float depth_[4];
    int cntrSalt_, n_[4];
    float dz_, meanTemperature_, meanSalinity_, vthi_, vshi_, sigmaTemperature_, sigmaSalinity_;
//    friend class VerticalTemperatureHomogeneityIndexCalculator_Test;

    UniversalDataReader* depthReader_;
    UniversalDataReader* temperatureReader_;
    UniversalDataReader* salinityReader_;

    DataWriter* meanTemperatureWriter_;
    DataWriter* meanSalinityWriter_;
    DataWriter* vthiWriter_;
    DataWriter* vshiWriter_;
    DataWriter* sigmaTemperatureWriter_;
    DataWriter* sigmaSalinityWriter_;

    ConfigReader* verbosityCfgReader_;
    ConfigReader* depth1CfgReader_;
    ConfigReader* depth2CfgReader_;
    ConfigReader* depth3CfgReader_;
    ConfigReader* depth4CfgReader_;
    ConfigReader* depthWindowCfgReader_;
    ConfigReader* medianFilterLengthSaltCfgReader_;

};

#endif /*VERTICALHOMOGENEITYINDEXCALCULATOR_H_*/
