📄 asyncreceiver.h
字号:
/************************************************************************
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
* PURPOSE.
************************************************************************/
/************************************************************************
*
* Module: AsyncReceiver.h
* Long name: CAsyncReceiver class definition
* Description: Simple class that continuously receives data transferred
* by asynchronous WRITE requests (based on CVhpdDataSlave).
*
* Runtime Env.: Win32
* Author(s): Frank Senf
* Company: Thesycon GmbH, Ilmenau
************************************************************************/
#if !defined(_AsyncReceiver_h_)
#define _AsyncReceiver_h_
// get base class definition
#include "CVhpdDataSlave.h"
class CAsyncReceiver : public CVhpdDataSlave {
public:
// Construction
CAsyncReceiver();
// destructor
~CAsyncReceiver();
// ----------------
// interface
// output file handling
// opens the specified file
// returns 0 for success, 1 if a file was already opened or an specific
// error code if opening the file failed
unsigned long
OpenFile(const char *Filename);
// closes the output file, no-op if no file is currently opened
void CloseFile();
// return current number of buffers completed with error
unsigned long
GetErrorCount() { return m_BufferError; }
// return status code of last buffer completed with error
unsigned long
GetLastError() { return m_LastError; }
// returns true if the thread is about to terminate
bool
ThreadExited() { return m_ThreadExited; }
// ----------------
// CVhpdThread overloaded functions
// This notification handler is called in the context of
// the worker thread before the thread terminates itself.
// NOTE: It is called in the context of the worker thread.
virtual
void OnThreadExit();
// overloaded CVhpdThread::TerminateThread() function
// NOTE 1: called in the context of the main thread
// NOTE 2: TerminateThread() is overloaded to ensure that the
// thread will exit. This is done by trying to terminate the
// thread until it really terminates. For future version of VHPDLib
// this will be implemented by the base class
virtual
void
TerminateThread();
// implementation
protected:
// --------------
// CVhpdDataSlave overloaded functions
// function is called after a buffer is completed by the driver
// returns FALSE if buffer processing should be stopped, TRUE to continue
// function is called with every buffer, even if it was completed with error
virtual
BOOL
PostProcessBuffer(CVhpdBuf* Buf);
// --------------
// member variables
// output file, NULL if not valid
HANDLE m_File;
// flag is set to true if OnThreadExit is called
bool m_ThreadExited;
// error handling
// counter increases every time a buffer is completed with an error status
unsigned long m_BufferError;
// last error received from the Buf->mStatus member, only valid if
// m_BufferError != 0
unsigned long m_LastError;
};
#endif // !defined(_AsyncReceiver_h_)
/*************************** EOF **************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -