#ifndef _NXWMS_H_
#define _NXWMS_H_

#include "lib_nxwms.h"
#include <pthread.h>
#include <unistd.h>
#include <iostream>

#define CALIB_NUM 50

class NxWMSDev
{
 public:
  NxWMSDev();
  ~NxWMSDev();
  void InitializeNxwms(unsigned char prdct_id, unsigned char tid, int freq);
  void FinalizeNxwms(void);
  void BeginMeasure(void);
  void ResetMeasure(void);
  void EndMeasure(void);
  void CalibGyros(void);
  void CalibAccs(void);
  void GetSensordata(int mode);
  void CopyAccs(double *accsv);
  void CopyGyros(double *gyrosv);
  void CopyMags(double *magsv);
  void OpenNxwms(std::string devname);
  void CloseNxwms(void);
  void SetWirelessFlag(int onoff);

  void setAccsOffset(double *accs_offset);
  void setAccsConvMat(double *accs_cmat);
 private:
  int fd;
  pthread_mutex_t rlock;
  unsigned char id;
  /* double accs[3]; */
  /* double gyros[3];     */
  /* double mags[3];     */
  double accs[15];
  double gyros[15];
  double mags[15];
  double ave_gyros[3];
  double off_accs[3];
  double accs_cmat_[9];

  int mode_;
  // 0 => recent
  // 1 => average
  // 2 => all
  int packet_n_;
  int prdct_id_; //プロダクトID
  bool m_wirelessflag;

};

#endif //_NXWMS_H_
