//=========================================================================
// Summary  :
// Filename : MMDepthSensor.h
// Author   : paley
// Project  :
// Revision : 1
// Created  : 2001/06/12
// Modified : 2001/06/12
//=========================================================================
// Description :  Depth sensor message
//=========================================================================
#ifndef _MMDEPTHSENSOR_H
#define _MMDEPTHSENSOR_H

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

#define DepthSensorMessageTimeOut 30

//////////////////////////////////////////////
class MMDepthSensor : public MMConvertible
{

public:
	MMDepthSensor(const ModemMessage *pMM);
	MMDepthSensor(float depth, float temperature, float pressure, int updateTime);

	virtual const char* pcRead(const char* sourceBuffer);
	virtual char* pcWrite(char* destBuffer) const;
	virtual ModemMessage::Type tGetMessageType() const
		{ return ModemMessage::tMMDepthSensor; };

	void setDepth(float depth)
		{ m_depth = MMUtil::double2short(depth,MIN_DEPTH,MAX_DEPTH); };
	void setTemperature(float temperature)
		{ m_temperature = MMUtil::double2char(temperature,MIN_TEMP,MAX_TEMP); };
	void setPressure(float pressure)
		{ m_pressure = MMUtil::double2short(pressure,MIN_PRESSURE,MAX_PRESSURE); };
	void setUpdateTime(int updateTime)
		{ m_updateTime = updateTime; };

	float getDepth()
		{ return MMUtil::short2double(m_depth,MIN_DEPTH,MAX_DEPTH); };
	float getTemperature()
		{ return MMUtil::char2double(m_temperature,MIN_TEMP,MAX_TEMP); };
	float getPressure()
		{ return MMUtil::short2double(m_pressure,MIN_PRESSURE,MAX_PRESSURE); };
	int getUpdateTime()
	    { return m_updateTime; };

	void toString(char* str);
	virtual int iGetDefaultTimeout() const { return DepthSensorMessageTimeOut; };
	static int size() { return 9; };

protected:
	//WARNING! m_depth resolution will be limited to
	// (MAX_DEPTH - MIN_DEPTH)/65535 meters
	ushort m_depth;
	//WARNING! m_temperature resolution will be limited to
	// (MAX_TEMP - MIN_TEMP)/255 degrees
	uchar m_temperature;
	//WARNING! m_pressure resolution will be limited to
	// (MAX_PRESSURE - MIN_PRESSURE)/65535 psi
	ushort m_pressure;
	int m_updateTime;
};

#endif
