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

#ifndef DEPTH_KELLER_H_
#define DEPTH_KELLER_H_

#include "component/SyncComponent.h"
#include "io/AnalogToDigital.h"
#include "io/LoadControl.h"

class UniversalDataReader;
class UniversalDataWriter;

/**
 *  Provides software interface to the Keller depth sensor
 *  Can also use SimSlate to provide simulated depth values when
 *  they are available.
 *
 *  Depth_Keller.h should only be included by Depth_Keller.cpp
 *  Other classes should include Depth_KellerIF.h
 *
 *  \ingroup modules_sensor
 */
class Depth_Keller: public SyncSensorComponent
{
public:
    Depth_Keller( const Module* module );
    virtual ~Depth_Keller();

    void initialize();
    void run();
    void uninitialize();

    /// Should return [myNamespace]::SIMULATE_HARDWARE, or [myNamespace]::POWER, etc
    virtual ConfigURI getConfigURI( ConfigOption configOption ) const;

private:

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

    void readConfig();

    UniversalDataReader* latitudeReader_;

    UniversalDataWriter* depthWriter_;
    UniversalDataWriter* pressureWriter_;

    ConfigReader* offsetCfgReader_;
    ConfigReader* scaleCfgReader_;
    ConfigReader* maxPressBoundCfgReader_;
    ConfigReader* minPressBoundCfgReader_;

    // the pressure or depth reading is out of bounds. We only want to report the error once
    int depthPressBoundingErrCnt_;
    // and fail the component after max consecutive out-of-bounds samples
    int boundingErrMaxCnt_;

    float pressureOffset_;
    float scale_;
    float maxPressBound_;
    float minPressBound_;
    float minDepthBound_;

    AnalogToDigital adPressure_;

    // Instance of load controller
    LoadControl loadControl_;

};

#endif /* DEPTH_Keller_H_ */
