// XTFReader.h: interface for the CXTFReader class.
//
//////////////////////////////////////////////////////////////////////
#pragma pack(1)
#include "FileHeaders/Xtf.h"
#pragma pack()

#include <math.h>

#if !defined(AFX_XTFREADER_H__CFEE3A5D_0BC0_4B3F_805E_CC1DCA467689__INCLUDED_)
#define AFX_XTFREADER_H__CFEE3A5D_0BC0_4B3F_805E_CC1DCA467689__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


//APP MESSAGES
/////////////////////////////////////////
#define  FILE_READ_DONE		WM_APP
/////////////////////////////////////////

class CXTFReader  
{
public:
	CXTFReader();
	virtual ~CXTFReader();
	
	BOOL	InitReader(CString path, HWND parent);			//return TRUE if file opens & ping ready
	BOOL	Shutdown();										//return TRUE if...

	BYTE*	GetPing();										//Return NULL if BAD DATA
	DWORD	GetSamples();									//

	DWORD   GetRoll();
	DWORD   GetPitch();
	DWORD   GetHeave();
	DWORD   GetHeading();

	void	CloseFile();

	void	ResetFile();

private:
	
	BOOL	fileOpen;
	CString requestedFile;									//input path
	
	void OpenXTF_File();	
	

	BOOL AnalyzeFile();
	int	 GetChanNumber();
	int  numChannels;

	CFile				 m_File;
	CFileException		 ex ;

	//XTF STRUCTURES
	SXtfFileHeader		 *fileHeader;
	SXtfCommonPartHeader *commonHeader;
	SXtfPingHeader		 *pingHeader;
	SXtfPingChanHeader	 *pingChanHeader;
	unsigned char		 *m_pCIma;
	unsigned short		 *m_pSIma;

	UINT currOff;
	int  ip;
	long startPos ;
	int  nSamplesPerChan ;
	int  m_BytesPerSamples;

	HWND m_hParentWnd;									//Send EOF message

};

#endif // !defined(AFX_XTFREADER_H__CFEE3A5D_0BC0_4B3F_805E_CC1DCA467689__INCLUDED_)
