#if !defined(AFX_THREADMAG_H__F00AB1A4_2AAB_47DC_A905_EAC811DB2240__INCLUDED_)
#define AFX_THREADMAG_H__F00AB1A4_2AAB_47DC_A905_EAC811DB2240__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// threadMag.h : header file
//

typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;


/////////////////////////////////////////////////////////////////////////////
// CthreadMag thread

class CthreadMag : public CWinThread
{
	DECLARE_DYNAMIC(CthreadMag)
public:
				
	CthreadMag
		(CWnd* pWnd,
		int *mesage_to,
		unsigned char *DataIn,
		unsigned char *DataOut,
		int *NScans,
		double *Spectra,
		double *Spectra1,
		bool *SpecToGet,
		bool *DevDetT,
		unsigned __int16 *startPixT,
		unsigned __int16 *endPixT,
		bool *FastT,
		bool *test1T,
		unsigned __int16 *tot_startPixT,
		unsigned __int16 *tot_endPixT,
		bool *SclDir,
		double *NormSpec,
		bool *applyNorm,
		double *RefSpec,
		int *HowToApplyRef,
		double *Bck,
		bool *applBck,
		int *ExpN,
		double *bck_a,
		double *bck_b,
		unsigned char *BoxCarN,
		bool *Average,
		int *conn_Dev,
		int *SpectrToSelect,
		bool *Log,
		bool *AllClbrToFLASH,
		double *ColorNorm,
		double *Xscl_lmbd,
		char *InfoString,
		double *slopeIndex,
		bool *reset,
		int *Blank,
		unsigned char	*TrigEnableMode,
		unsigned char	*TrigSignalFrontMode,
		unsigned char	*enableMode,
		unsigned __int16 *pixel,
		unsigned __int16 *threshold
		);
	
	virtual ~CthreadMag();

// Attributes
public:

	void ShapeData(double *ShapeData);
	void BoxCarF(int start_pix, int end_pix, double *DataArray, unsigned char param1);
	void WriteToFlash(int address3bytes, char* ArrayToWrite, bool SectorEraised, int lengthToWrite);


	unsigned char	*InputReport;//[100];
	ULONG			Length;
	LPOVERLAPPED	lpOverLap;
	DWORD			NumberOfBytesRead;
	HANDLE			ReadHandle;
	ULONG			Required;
	CString			ValueToDisplay;
	unsigned char	*OutputReport;//[MAXREPORTSIZE];	
	double			*SpectraT;
	double			*Spectra1T;
	bool			*SpecToGetT;
	bool			*DevDet;
	unsigned __int16 *startPix;
	unsigned __int16 *endPix;
	bool			*Fast;
	bool			*test1;
	unsigned __int16 *tot_startPix;
	unsigned __int16 *tot_endPix;
	int				*mesage_toT;
	int				RLn;
	int				TransNmb;
	int				*NScansT;
	unsigned __int16 ShiftAddress;
	bool			*SclDirT;

	double			*NormSpecT;
	bool			*applyNormT;
	bool			*LogT;
	double			*RefSpecT;
	int				*HowToApplyRefT;
	double			*BckT;
	bool			*applBckT;
	int				*ExpNT;
	double			*bck_aT;
	double			*bck_bT;
	unsigned char	*BoxCarNT;
	bool			*AverageT;
	int				*conn_DevT;
	int				*SpectrToSelectT;
	bool			*AllClbrToFLASHT;
	double			*ColorNormT;
	double			*Xscl_lmbdT;
	char			*InfoStringT;
	double			*slopeIndexT;
	bool			*resetT;
	int				*BlankT;
	unsigned char	*TrigEnableModeT;
	unsigned char	*TrigSignalFrontModeT;
	unsigned char	*enableModeT;
	unsigned __int16 *pixelT;
	unsigned __int16 *thresholdT;


	DWORD			ActualBytesRead;
	DWORD			BytesRead;
	DWORD			dwError;
	DWORD			cbBytesRead;
	int SpecNmb;
	int tmp;
	double tmp_dbl1;
	int ByteNumber;
	unsigned __int16 tmp1;
	unsigned __int16 tmp2;
	unsigned short	InputSpec_loc[4096];
	unsigned char startTrans;
	unsigned char endTrans;
	unsigned __int16 startPTshift;
	unsigned __int16 endPTshift;
	unsigned __int16 startPix1;
	unsigned __int16 endPix1;
	int devd, devd2;
	int cnt1;
	bool flag1;
	unsigned __int16 address_flash;
	unsigned __int16 address_buffer;
	int writings;
	unsigned char t2;
	int length;
	bool			DeviceDetected;

	double bckArr[11][2];
	int bckInd;
	int ExpOld;
	int NScansOld;
	bool AverageOld;
	bool send_message;
	double slopeRemoval[3686];
	unsigned char scanMode;
	unsigned char	TrigEnableModeOld;
	unsigned char	TrigSignalFrontModeOld;
	unsigned char	enableModeOld;
	unsigned __int16 pixelOld;
	unsigned __int16 thresholdOld;


// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CthreadMag)
	public:
	virtual BOOL InitInstance();
	virtual int ExitInstance();
	//}}AFX_VIRTUAL

// Implementation
public:


	// Generated message map functions
	//{{AFX_MSG(CthreadMag)
//	afx_msg LRESULT Mes_Anal(WPARAM,LPARAM);
	afx_msg void Mes_Anal(WPARAM,LPARAM);
		// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_THREADMAG_H__F00AB1A4_2AAB_47DC_A905_EAC811DB2240__INCLUDED_)
