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

📄 isotalker.h

📁 VHPD1394 V1.15驅動程序源碼
💻 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:       IsoTalker.h
 *  Long name:    Isochronous Talker class definition
 *  Description:  Simple class which handles data transmission over an 
 *                isochronous channel.
 *
 *  Runtime Env.: Win32
 *  Author(s):    Frank Senf
 *  Company:      Thesycon GmbH, Ilmenau
 ************************************************************************/

#if !defined(_ISOTALKER_h_)
#define _ISOTALKER_h_


// get base class definition
#include "CVhpdIsoTalker.h"

//
// CIsoTalker class
// The class is derived from the CVhpdIsoTalker class contained in the
// VHPDLib C++ class library.
// Thus, it has an embeded worker thread that handles data transmission.
// The class mainly implements the PreProcessBuffer and PostProcessBuffer
// functions defined by the base class.
//
class CIsoTalker : public CVhpdIsoTalker {

public:
  // Construction
  CIsoTalker();
  // destructor
  ~CIsoTalker();

  // ----------------
  // interface

  // source 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 source 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

  // function is called before the worker 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:

  // --------------
  // CVhpdIsoTalker overloaded functions
  
  // function that fills buffer with data and sets additional buffer options
  // returns FALSE if buffer processing should be stopped, TRUE to continue
  // if no additional buffer options has to be specified, it is not necessary
  // to access Submit structure
  virtual
  BOOL
  PreProcessBuffer(
    CVhpdBuf* Buf,
    VHPD_ISOCH_SUBMIT_BUFFER* Submit);

  // function is called after a buffer is completed by the driver
  // returns FALSE if buffer processing should be stopped, TRUE to continue
  virtual
  void
  PostProcessBuffer(
    CVhpdBuf* Buf,
    VHPD_ISOCH_SUBMIT_BUFFER* Submit);

  // --------------
  // member variables

  // input file, NULL if not valid
  HANDLE m_File;
  // pattern will be filled to buffer before transferring, only used if m_File==NULL
  unsigned char m_Pattern;

  // storage that can hold one isochronous frame, only used when transferring a file
  unsigned char m_IsoFrame[4096];
  // number of valid bytes placed to m_IsoFrame
  unsigned long m_IsoFrameBytes;

  // flag is set to true if OnThreadExit is called
  bool m_ThreadExited;

  // error 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(_ISOTALKER_h_)

/*************************** EOF **************************************/

⌨️ 快捷键说明

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