⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recordfile.h

📁 一款不错的关于绘制波形编程的软件源代码
💻 H
字号:
#ifndef _RECORDFILE_H
#define _RECORDFILE_H


#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

struct CDataPage
{
	BOOL isValid;			// 表示此结构存储的数据值是否有效
	BYTE* pageAddr;			// 数据页的起始地址
	UINT dataOffset;		// 数据记录在数据页中的字节偏移长度
	UINT gpsOffset;			// GPS定位数据在数据页中的字节偏移长度
	UINT bcdTimeOffset;		// BCD日期时间在数据页中的字节偏移长度
	UINT pageSize;			// 数据页字节大小
	UINT pageIndex;			// 数据页在文件中的序号,0表示第一页
	UINT dataCount;			// 数据页包含的数据记录个数
	UINT dataSize;			// 数据页包含的数据记录字节大小
	UINT interval;			// 数据记录时间间隔(s)
	UINT indexInBlock;		// 数据页在Flash块中的索引值
	UINT status;			// 数据页存储的状态信息

	void Clear() { isValid = FALSE; }
};

typedef struct tagTime_t
{
	int year;
	char month;
	char day;
	char hour;
	char min;
	char sec;
}Time_t;

typedef struct _FileDataDateTimeInfo
{
	int idealMonths;
	int actualMonths;
	int idealDays;
	int actualDays;
	int idealHours;
	int actualHours;
	int idealMinutes;
	int actualMinutes;
} FILEDATA_DATETIMEINFO;

class CRecordFile  
{
public:
	CRecordFile();
	CRecordFile(LPCTSTR filePath);
	CRecordFile(LPCTSTR filePath, const COleDateTime& startTime);
	CRecordFile(LPCTSTR filePath, const COleDateTime& startTime, const COleDateTime& endTime);
	virtual ~CRecordFile();
	
	long GetDataPageCount() const;
	
	void GetHeadDataPage(CDataPage* pOutPage);
	void GetTailDataPage(CDataPage* pOutPage);
	
	void GetDataPageAt(UINT index, CDataPage* pOutPage);
	void GetDataPageAt(COleDateTime time, CDataPage* pOutPage);
	
	void GetNextDataPage(CDataPage* pCurPage, CDataPage* pOutPage);
	void GetPrevDataPage(CDataPage* pCurPage, CDataPage* pOutPage);
	void GetDataPageRelativeTo(CDataPage* pCurPage, int offset, CDataPage* pOutPage);
	
	void GetDataPageMiddleOf(UINT start, UINT end, CDataPage* pOutPage);
	
	void GetHeadDataPageTime(COleDateTime& time);
	void GetTailDataPageTime(COleDateTime& time);

	void GetFileDataDateTimeInfo(FILEDATA_DATETIMEINFO& info);

protected:
//	CRecordFile();

private:
	HANDLE m_hFile;
	HANDLE m_hFileMapping; 
	BYTE* m_pvFile;
	
	DWORD m_fileSize;
	UINT m_pageCount;

	CString m_filePath;

	void FindDataPageAfter(const COleDateTime& time, CDataPage* pOutPage, UINT* recordIndex);
	void FindDataPageBefore(const COleDateTime& time, CDataPage* pOutPage, UINT* recordIndex);
	
	DWORD MapRecordFile(LPCTSTR filePath);
	void UnmapRecordFile();

public:
	UINT m_startPageIndex;
	UINT m_endPageIndex;
	
	UINT m_startRecordIndex;
	UINT m_endRecordIndex;
};

class CRecordException: public CException
{
	DECLARE_DYNAMIC(CRecordException);
	
public:
	enum
	{
		none = 0,
		fileOpenFailed,
		invalidFormat,
		timeOutOfRange,
		invalidFileLength,
		invalidParameter,
	};
	
	CRecordException(int cause = CRecordException::none, 
		DWORD osError = 0, LPCTSTR fileName = NULL);
	virtual ~CRecordException();
	
	CString GetErrorDecription();
	
	int m_cause;
	DWORD m_osError;
	CString m_fileName;
	
protected:
	
};

class CRecordHelper
{
public:
	CRecordHelper() {}
	virtual ~CRecordHelper() {}

	static void GetDateTime(COleDateTime& dt, const BYTE* pBcddt);
};

#endif // _RECORDFILE_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -