// 7KReader.h: interface for the C7KReader class.
//
//////////////////////////////////////////////////////////////////////

#include "6046DryEnd.h"
#include "6046DryEndDlg.h"
#include <math.h>


#if !defined(AFX_7KREADER_H__0A077628_9063_47F0_8A55_25BE201CFD6F__INCLUDED_)
#define AFX_7KREADER_H__0A077628_9063_47F0_8A55_25BE201CFD6F__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

typedef void (*PFN_REMOTECLIENT_CALLBACK)   (   void           *pvParam,                                            // Optional parameter; typically the client's this pointer.
                                                unsigned char  *pbyData,                                            // Pointer to the data.
                                                unsigned long   ulBytes );  

#define EVENT_READ	123


class C7KReader  
{
public:
	void SetParentHWND(HWND hParent);

	C7KReader();
	virtual ~C7KReader();


	void	InitReader(void *pThis, PFN_REMOTECLIENT_CALLBACK myDataCallBack);	//return TRUE if ready

	BOOL	Open7KFile(CString path);
	void	CloseFile();
	BOOL	RewindFile();
	void	Shutdown();

	void	Start(int speed);
	void	Stop();

	BOOL	FileOpen();

	BOOL	GetRecord();

	CString	m_strOpenFile;

private:

	void*					  	 m_ptrThis;
	PFN_REMOTECLIENT_CALLBACK    m_pCallback;
	

	C7kProtocol				m_7kProtocol;
	
	C7kFile					m_7kFile;
	C7kFile::EACCESSMODE	m_AccessMode;
	C7kFile::E7KFILEERROR	m_ErrorCode;

	BOOL					fileOpen;

	PRECORDHEADER7K			m_p7kHeader;							//Filled by 7kProtocol

	HWND					m_hParentWnd;							//Post FILE_READ_DONE message
	UINT					m_dReadErrorCount;

	BYTE*					m_pRecordData;							//The entire record read in by C7KFile
	ULONG					m_ulBytesRead;
	ULONG					m_ulMaxBytes;
	UCHAR					*m_pStartData;
	ULONG					m_ulDataBytes;
	
	UINT					m_timerID;
	static void CALLBACK	TimerProc(HWND hWnd, UINT msg, UINT nTimerId, DWORD dwTimer);
	
};

#endif // !defined(AFX_7KREADER_H__0A077628_9063_47F0_8A55_25BE201CFD6F__INCLUDED_)
