ImgBrd.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #pragma once
  2. #include <conio.h>
  3. #include <stdlib.h>
  4. #include <vector>
  5. using namespace std;
  6. //=========================================
  7. //add by song 2016-1-27 for eBus
  8. #include <PvSampleUtils.h>
  9. #include <PvStream.h>
  10. #include <PvDevice.h>
  11. #include <PvPipeline.h>
  12. #include <PvBuffer.h>
  13. #include <PvStreamGEV.h>
  14. #define PV_GUI_NOT_AVAILABLE
  15. #ifdef PV_GUI_NOT_AVAILABLE
  16. #include <PvSystem.h>
  17. #else
  18. #include <PvDeviceFinderWnd.h>
  19. #endif // PV_GUI_NOT_AVAILABLE
  20. //==========================================
  21. #include "LogFile.h"
  22. #include "CommonData.h"
  23. #include "EComRFParam_i.h"
  24. #define BUFFERING_SIZE_MAX 3
  25. class PipelineEventSink : public PvPipelineEventSink
  26. {
  27. protected:
  28. void OnBufferTooSmall( PvPipeline *aPipeline, bool *aReallocAll, bool *aResetStats )
  29. {
  30. *aReallocAll = true;
  31. *aResetStats = true;
  32. cout << "Buffers reallocated by the pipeline" << endl;
  33. }
  34. };
  35. // CImgBrd
  36. class CShareMem;
  37. class CImgBrd : public CWnd
  38. {
  39. DECLARE_DYNAMIC(CImgBrd)
  40. public:
  41. CImgBrd();
  42. virtual ~CImgBrd();
  43. //=======================================
  44. //add by song 2016-1-27 for eBus
  45. bool SelectDevice( PvString &aIP );
  46. bool StartSlave();
  47. bool SaveImage(const WORD* pRawImg, const char* pImgName,int nWidth, int nHeight);
  48. //=======================================
  49. bool InitBrd(HWND hWnd);
  50. bool CloseBrd();
  51. bool SetFrameValid();
  52. bool SetAcqMode(int nMode); //1: 1000x1000,2: 500x500, 3:1000x500;
  53. bool ChangeActiveMode(CString ExamType, int nPUMode,int nSzieX,int nSizeY, int nCropLeft = 0, int nCropTop = 0, int nCropRight = 0, int nCropBottom = 0);
  54. bool StartGrab(void);
  55. bool StopGrab(int nXRayOnNum = 0);
  56. bool SetGrabMode(int nmode);
  57. bool GetImageInfo(ZSKK_ACQ_INFO &imgInfo);
  58. //bool ExitCaptureThread();
  59. HANDLE m_Mutext_Buff;
  60. WORD *m_pImgBuffer;
  61. DWORD m_pImgBufferSize;
  62. WORD *m_pwData;
  63. ZSKK_IMAGE_INFO m_ImgInfo; //save image data
  64. ZSKK_ACQ_INFO m_ACQInfo; //Save image information
  65. //static UINT __stdcall CaptureThread(LPVOID para);
  66. // 消息(不包含数据)的处理; nMSGOutMode(0-异步,1-同步);
  67. bool MSGControl(CWnd *Wnd, int nMSGType, int nMSGwParam, int nMSGpParam,int nMSGOutMode = ZSKK_MSG_TYPE_SYNC_NO,int nTargetPosition = ZSKK_MSG_TARGETHANDLE_NULL);
  68. bool SetPixelSpacing(int nPixelSpacing);
  69. int m_nXRayOnNum; //记录曝光次数
  70. public:
  71. CString m_SubConfigPath;
  72. //=========================================================================
  73. //add by song 2016-1-28 get image thread,avoid block main thread.
  74. HANDLE m_hEventGrab;
  75. HANDLE m_IsInGrabPeriod;
  76. HANDLE m_IsLeaveSlave;
  77. HANDLE m_hEventExitGrapThd;
  78. CWinThread* m_pGrapThdPro;
  79. bool m_bExitGrapThdPro;
  80. UINT IniGrabThread();
  81. UINT ExitGrabThread();
  82. static UINT GrabThread( LPVOID pParam );
  83. bool LogInfo( LPCSTR strLog );
  84. bool LogError( LPCSTR strLog );
  85. bool LogWarn( LPCSTR strLog );
  86. WORD* ReadyImgBuff(DWORD ImgSize);
  87. //=========================================================================
  88. private:
  89. int m_nPixelSpacing;
  90. int m_nMode;
  91. CString m_strDCFFile;
  92. bool m_IsValid;
  93. bool m_IsGrab;
  94. int m_nBuf;
  95. HWND m_hWnd;
  96. CLogFile *m_pLog;
  97. int m_nGrabMode; //1 single shot mode, 2 Sequence rad mode, 3 pulse flu mode, 4, continue flu mode;
  98. void Pausetime(DWORD dwSpan);
  99. //去掉四周坏线部分
  100. int CropImageMargin(LPVOID pDstData, int& nDstWidth, int& nDstHeight,
  101. LPVOID pScrData, int nSrcWidth, int nSrcHeight, int nBits,
  102. int nLeftMargin,int nTopMargin,int nRightMargin,int nBottomMargin);
  103. protected:
  104. CShareMem* m_pDataBuffer;
  105. int m_nCurrentFrame;
  106. int m_nTotalFrameGrab;
  107. double m_fCurAcqFrameRate;
  108. CString m_strLog;
  109. CString m_strExamType;
  110. bool WriteFrame(WORD* pImgData,int nWidth,int nHeight);
  111. void trimipstr(string &trimtarget);
  112. bool InitConnection();
  113. int OpenEbusDevice();
  114. int CloseEbusDevice();
  115. static long ProcessingFunction(/*long HookType, MIL_ID HookId, void MPTYPE *HookDataPtr*/);
  116. static CImgBrd* m_pCab;
  117. protected:
  118. long SizeX; // Buffer Size X
  119. long SizeY; // Buffer Size Y
  120. //bool m_bExitCaptureThread;
  121. int m_nCropLeft, m_nCropTop, m_nCropRight, m_nCropBottom;
  122. protected:
  123. DECLARE_MESSAGE_MAP()
  124. };