// -*- C++ -*-
/*!
 * @file  NxWMSReader.h
 * @brief Sequence InPort component
 *
 */

#ifndef NxWMSREADER_H
#define NxWMSREADER_H

#include <iostream>
#include <iomanip>
#include <exception>
#include <stdexcept>
#include <rtm/idl/BasicDataTypeSkel.h>
#include <rtm/Manager.h>
#include <rtm/DataFlowComponentBase.h>
#include <rtm/CorbaPort.h>
#include <rtm/DataInPort.h>
#include <rtm/DataOutPort.h>
#include <utils/UtilTimer.h>
#include <Extended3DdataTypes.hh>
#include "NxWMS.h"

using namespace RTC;
using namespace std;

class NxWMSReader
  : public RTC::DataFlowComponentBase
{
public:
  NxWMSReader(RTC::Manager* manager);
  ~NxWMSReader();

  /* RTC function */
  virtual RTC::ReturnCode_t onInitialize();
  virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id);
  virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id);
  virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id);


protected:
  /* Configuration variable declaration */
  std::string m_componentconf_file;
  std::string m_config;

  /* DataOutPort declaration */
  //RTC::TimedFloatSeq m_outResult;
  //OutPort<RTC::TimedFloatSeq> m_outResultPort;

  Extended3DdataTypes::TimedMotion3DSensorData m_outResult;
  OutPort<Extended3DdataTypes::TimedMotion3DSensorData> m_outResultPort;

private:
  bool setState();
  int getInertiaAxis(string str);
  double getInertiaPM(string str);

  UtilTimer m_timer;
  NxWMSDev nxwmsd;

  unsigned char prdct_id_;
  unsigned char module_id_;
  int freq_;
  std::string devicename_;

  double accs_offset_[3];
  double accs_cmat_[9];
  /* axis order and plusminus */
  int axis_ord_[3];
  double axis_pm_[3];
};


extern "C"
{
  void NxWMSReaderInit(RTC::Manager* manager);
};

#endif // NxWMSREADER_H
