Files
Work/aladin/hold/divelog.cpp
2024-08-07 09:12:07 -04:00

96 lines
1.9 KiB
C++

#include <aladin/divelog.hpp>
#include <aladin/divetime.hpp>
DiveLog::DiveLog()
{
mExtraInfo=0;
mBottomTime=0;
mMaxDepthHi=0;
mMaxDepthLo=0;
mSurfaceTimeHi=0;
mSurfaceTimeLo=0;
mTotalAirConsumption=0;
mEntryTime1=0;
mEntryTime2=0;
mEntryTime3=0;
mEntryTime4=0;
mWaterTemperature=0;
}
DiveLog::~DiveLog()
{
}
bool DiveLog::operator<(const DiveLog &diveLog)const
{
return getEntryTime()<diveLog.getEntryTime();
}
bool DiveLog::operator==(const DiveLog &diveLog)const
{
return getEntryTime()==diveLog.getEntryTime();
}
bool DiveLog::operator>(const DiveLog &diveLog)const
{
return getEntryTime()>diveLog.getEntryTime();
}
int DiveLog::getBottomTime(void)const
{
int bottomTime=(((mBottomTime>>4)*10))+(mBottomTime&0x0F);
if(mExtraInfo&0x04)bottomTime+=100;
return bottomTime;
}
int DiveLog::getMaxDepth(void)const
{
double maxDepth(((double)((mMaxDepthHi*256)+mMaxDepthLo)*10.00)/4096.00);
return int((maxDepth*3.281)+.5);
}
int DiveLog::getAltitude(void)const
{
return 0;
}
int DiveLog::getWaterTemperature(void)const
{
return mWaterTemperature/4;
}
SystemTime DiveLog::getEntryTime(void)const
{
return DiveTime(mEntryTime1,mEntryTime2,mEntryTime3,mEntryTime4).getTime();
}
Time DiveLog::getSurfaceTime(void)const
{
return Time(mSurfaceTimeHi,mSurfaceTimeLo);
}
bool DiveLog::readFrom(Array<BYTE> &array,int &index)
{
try
{
mExtraInfo=array[index++];
mBottomTime=array[index++];
mMaxDepthHi=array[index++];
mMaxDepthLo=array[index++];
mSurfaceTimeHi=array[index++];
mSurfaceTimeLo=array[index++];
mTotalAirConsumption=array[index++];
mEntryTime1=array[index++];
mEntryTime2=array[index++];
mEntryTime3=array[index++];
mEntryTime4=array[index++];
mWaterTemperature=array[index++];
}
catch(ArrayIndexOutOfBoundsException exception)
{
::OutputDebugString(exception.toString()+String("\n"));
return false;
}
return true;
}