/** \file
 *
 *
 *  Copyright (c) 2007,2008,2009 MBARI
 *  MBARI Proprietary Information.  All Rights Reserved
 */

#ifndef LcmPublisher_H_
#define LcmPublisher_H_

#include "component/AsyncComponent.h"
#include <lcm/lcm-cpp.hpp>
#include "lcmMessages/DoubleItem.hpp"
#include "lcmMessages/DoubleItems.hpp"
#include "data/StrValue.h"

/**
 *  This Component uses an iterative method to calculate pi.
 *  Runs in its own thread, and written to burn cycles.
 *
 *  \ingroup modules_sample
 */
class LcmPublisher : public AsyncComponent
{
public:

    LcmPublisher( const Module* module );

    virtual ~LcmPublisher();

    /// Initialize function
    void initialize( void );

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

    /// Uninit function
    void uninitialize( void );

    void reset();

protected:

    void publish( lcm::LCM *lcm, int nChan, int nItems, char *pubPrefix );

    // Read configuration settings
    bool readConfig( void );

    bool debug_;
    bool redirectStdout_;

    int nDoubleItems_;
    double loopHz_;
    int nChannels_;
    StrValue channelPrefix_;

    lcmMessages::DoubleItems msg_;

    double dummyValue_;

    ConfigReader* nChanCfgReader_;
    ConfigReader* nDoubleItemsCfgReader_;
    ConfigReader* loopHzCfgReader_;
    ConfigReader* publishPrefixCfgReader_;
};

#endif /* LcmPublisher_H_ */
