//=========================================================================
// Summary  :
// Filename : MMLN250.h
// Author   : Gil Jones
// Project  :
// Revision : 1
// Created  : 2002/01/21
// Modified : 2002/01/21
//=========================================================================
// Description :  LN250 information
//=========================================================================

#ifndef _MMLN250_H
#define _MMLN250_H

#include "ModemMessage.h"
#include "MMUtils.h"
#include "MMAhrs.h"

#define LN250TimeOut 60 //seconds

#define MIN_VEL -10.0
#define MAX_VEL 10.0

class MMLN250 : public MMAhrs
{

 public:
    
    enum LN250types {
	InsOnly,
	Hybrid
    };

    MMLN250(const ModemMessage *pMM);
    MMLN250(int ln250type, float sysTime, char valid, float lat, float lon, float alt, float nvel,
	    float evel, float vvel, float biasx, float biasy, float head, float pitch, float roll, float yaw,
	    float pRate, float rRate, float yRate, short mode, short type, int updateTime);

    virtual const char* pcRead(const char* sourceBuffer);
    virtual char* pcWrite(char* destBuffer) const;
    virtual ModemMessage::Type tGetMessageType() const
	{ return ModemMessage::tMMLN250; };
    virtual int iGetDefaultTimeout() const
	{ return LN250TimeOut; };
    
    void setLN250type(int t)
	{ _hyOrIns = MMUtil::char2int(t); };
    int getLN250type()
	{ return MMUtil::char2int(_hyOrIns); };
    void setNvel(float nvel) 
	{ _nvel = MMUtil::double2char(nvel, MIN_VEL, MAX_VEL); };
    void setEvel(float evel) 
	{ _evel = MMUtil::double2char(evel, MIN_VEL, MAX_VEL); };
    void setVvel(float vvel) 
	{ _vvel = MMUtil::double2char(vvel, MIN_VEL, MAX_VEL); };
    void setXbias(float biasx)
	{
	    //fprintf(stdout, "biasx: %g\n", biasx);
	    float convbias = MMUtil::radToDeg(biasx);
	    _biasX = convbias * 3600.0;
	}

    void setYbias(float biasy)
	{
	    //fprintf(stdout, "biasy: %g\n", biasy);
	    float convbias = MMUtil::radToDeg(biasy);
	    _biasY = convbias * 3600.0;
	}
    
    float getSysTime()
	{ return _sysTime; };
    char getValid()
	{ return _valid; };
    float getLat()
	{ return _lat; };
    float getLon()
	{ return _lon; };
    float getAlt()
	{ return _alt; };
    float getNvel()
	{ return MMUtil::char2double(_nvel, MIN_VEL, MAX_VEL); };
    float getEvel()
	{ return MMUtil::char2double(_evel, MIN_VEL, MAX_VEL); };
    float getVvel()
	{ return MMUtil::char2double(_vvel, MIN_VEL, MAX_VEL); };
    float getBiasX()
	{ return _biasX; };
    float getBiasY()
	{ return _biasY; };
    char getMode()
	{ return _mode; };
    char getType()
	{ return _type; };

    //one for each chars
    static int size() { return MMAhrs::size()+ 6 + 6*sizeof(float); };  
			    //note that valid and head not included in MM			    

 protected:

    uchar _hyOrIns;
    char _mode,_type;
    float _sysTime;
    char _valid;
    float _lat, _lon, _alt;
    float _head;
    float _biasX, _biasY;
    uchar _nvel, _evel, _vvel;
};

#endif

