1 Star 1 Fork 2

今夜无眠/GNSS_Viewer_V2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
SaveBinaryNoParsingDlg.h 2.62 KB
一键复制 编辑 原始数据 按行查看 历史
Alex Lin 提交于 2018-07-18 16:21 . 2.0.326
#pragma once
class BufferBlock
{
public:
BufferBlock()
{
for(int i = 0; i < BlockSize; ++i)
{
bufferBlcok[i] = new U08[BufferSize];
bufferIndex[i] = 0;
}
writePtr = 0;
readPtr = 0;
timeTick = 0;
maxWriteSize = 0;
maxBlockSize = 0;
totalWriteSize = 0;
maxReadSize = 0;
alreadyAck = FALSE;
sleepCount = 0;
readCount = 0;
}
~BufferBlock()
{
for(int i = 0; i < BlockSize; ++i)
{
delete [] bufferBlcok[i];
bufferIndex[i] = 0;
}
}
enum { BufferSize = 128 * 1024 };
enum { BlockSize = 4 };
bool WriteBlock(U08* ptr, int size);
const U08* ReadBlock(int index, int* size) { *size = bufferIndex[index]; return bufferBlcok[index]; };
int GetWritePtr() { return writePtr; }
int GetReadPtr() { return readPtr; }
bool NeedWrite() { return writePtr != readPtr; }
void NextWritePtr() { if(++writePtr == BlockSize) writePtr = 0; }
void NextReadPtr()
{
if(bufferIndex[readPtr] > maxWriteSize)
maxWriteSize = bufferIndex[readPtr];
totalWriteSize += bufferIndex[readPtr];
bufferIndex[readPtr] = 0;
if(++readPtr == BlockSize)
readPtr = 0;
int gap = writePtr - readPtr;
if(gap < 0) gap += BlockSize;
if(gap >= maxBlockSize) maxBlockSize = gap + 1;
}
ULONGLONG totalWriteSize;
BOOL alreadyAck;
//For debug
int bufferIndex[BlockSize];
int maxWriteSize;
int maxBlockSize;
int maxReadSize;
int sleepCount;
int readCount;
protected:
U08 *bufferBlcok[BlockSize];
int writePtr;
int readPtr;
DWORD timeTick;
};
class SaveBinaryNoParsingDlg : public CDialog
{
DECLARE_DYNAMIC(SaveBinaryNoParsingDlg)
public:
enum Type
{
Default,
Telit,
};
SaveBinaryNoParsingDlg(CWnd* pParent = NULL); //
virtual ~SaveBinaryNoParsingDlg();
virtual BOOL OnInitDialog();
void SetFilePath(LPCSTR s) { filePath = s; };
void SetComPort(int c) { comPort = c; };
void SetBaudRate(int b) { baudrate = b; };
void SetType(Type t) { type = t; }
protected:
BufferBlock buffer;
Type type;
CString filePath;
int comPort;
int baudrate;
BOOL stopThreadBufferWrite;
BOOL stopThreadComRead;
CWinThread* threadBufferWrite;
CWinThread* threadComRead;
CTime startTime;
int noAckAlerm;
static UINT ThreadBufferWrite(LPVOID pParam);
static UINT ThreadComRead(LPVOID pParam);
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV
virtual void OnOK();
virtual void OnDestroy();
afx_msg void OnTimer(UINT_PTR nIDEvent);
UINT ComRead();
UINT BufferWrite();
void ShowSize(ULONGLONG size, UINT id);
void ShowDuration(CTimeSpan ts, UINT id);
DECLARE_MESSAGE_MAP()
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/null_130_5865/GNSS_Viewer_V2.git
[email protected]:null_130_5865/GNSS_Viewer_V2.git
null_130_5865
GNSS_Viewer_V2
GNSS_Viewer_V2
master

搜索帮助