123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- #pragma once
- #include <conio.h>
- #include <stdlib.h>
- #include <vector>
- using namespace std;
- //=========================================
- //add by song 2016-1-27 for eBus
- #include <PvSampleUtils.h>
- #include <PvStream.h>
- #include <PvDevice.h>
- #include <PvPipeline.h>
- #include <PvBuffer.h>
- #include <PvStreamGEV.h>
- #define PV_GUI_NOT_AVAILABLE
- #ifdef PV_GUI_NOT_AVAILABLE
- #include <PvSystem.h>
- #else
- #include <PvDeviceFinderWnd.h>
- #endif // PV_GUI_NOT_AVAILABLE
- //==========================================
- #include "LogFile.h"
- #include "CommonData.h"
- #include "EComRFParam_i.h"
- #define BUFFERING_SIZE_MAX 3
- class PipelineEventSink : public PvPipelineEventSink
- {
- protected:
- void OnBufferTooSmall( PvPipeline *aPipeline, bool *aReallocAll, bool *aResetStats )
- {
- *aReallocAll = true;
- *aResetStats = true;
- cout << "Buffers reallocated by the pipeline" << endl;
- }
- };
- // CImgBrd
- class CShareMem;
- class CImgBrd : public CWnd
- {
- DECLARE_DYNAMIC(CImgBrd)
- public:
- CImgBrd();
- virtual ~CImgBrd();
- //=======================================
- //add by song 2016-1-27 for eBus
- bool SelectDevice( PvString &aIP );
- bool StartSlave();
- bool SaveImage(const WORD* pRawImg, const char* pImgName,int nWidth, int nHeight);
- //=======================================
- bool InitBrd(HWND hWnd);
- bool CloseBrd();
- bool SetFrameValid();
- bool SetAcqMode(int nMode); //1: 1000x1000,2: 500x500, 3:1000x500;
-
- bool ChangeActiveMode(CString ExamType, int nPUMode,int nSzieX,int nSizeY, int nCropLeft = 0, int nCropTop = 0, int nCropRight = 0, int nCropBottom = 0);
- bool StartGrab(void);
- bool StopGrab(int nXRayOnNum = 0);
- bool SetGrabMode(int nmode);
- bool GetImageInfo(ZSKK_ACQ_INFO &imgInfo);
- //bool ExitCaptureThread();
- HANDLE m_Mutext_Buff;
- WORD *m_pImgBuffer;
- DWORD m_pImgBufferSize;
- WORD *m_pwData;
-
- ZSKK_IMAGE_INFO m_ImgInfo; //save image data
- ZSKK_ACQ_INFO m_ACQInfo; //Save image information
- //static UINT __stdcall CaptureThread(LPVOID para);
- // 消息(不包含数据)的处理; nMSGOutMode(0-异步,1-同步);
- bool MSGControl(CWnd *Wnd, int nMSGType, int nMSGwParam, int nMSGpParam,int nMSGOutMode = ZSKK_MSG_TYPE_SYNC_NO,int nTargetPosition = ZSKK_MSG_TARGETHANDLE_NULL);
- bool SetPixelSpacing(int nPixelSpacing);
- int m_nXRayOnNum; //记录曝光次数
- public:
- CString m_SubConfigPath;
- //=========================================================================
- //add by song 2016-1-28 get image thread,avoid block main thread.
- HANDLE m_hEventGrab;
- HANDLE m_IsInGrabPeriod;
- HANDLE m_IsLeaveSlave;
- HANDLE m_hEventExitGrapThd;
- CWinThread* m_pGrapThdPro;
- bool m_bExitGrapThdPro;
- UINT IniGrabThread();
- UINT ExitGrabThread();
- static UINT GrabThread( LPVOID pParam );
- bool LogInfo( LPCSTR strLog );
- bool LogError( LPCSTR strLog );
- bool LogWarn( LPCSTR strLog );
- WORD* ReadyImgBuff(DWORD ImgSize);
- //=========================================================================
- private:
-
- int m_nPixelSpacing;
- int m_nMode;
- CString m_strDCFFile;
- bool m_IsValid;
- bool m_IsGrab;
- int m_nBuf;
- HWND m_hWnd;
- CLogFile *m_pLog;
- int m_nGrabMode; //1 single shot mode, 2 Sequence rad mode, 3 pulse flu mode, 4, continue flu mode;
- void Pausetime(DWORD dwSpan);
- //去掉四周坏线部分
- int CropImageMargin(LPVOID pDstData, int& nDstWidth, int& nDstHeight,
- LPVOID pScrData, int nSrcWidth, int nSrcHeight, int nBits,
- int nLeftMargin,int nTopMargin,int nRightMargin,int nBottomMargin);
- protected:
- CShareMem* m_pDataBuffer;
- int m_nCurrentFrame;
- int m_nTotalFrameGrab;
- double m_fCurAcqFrameRate;
- CString m_strLog;
- CString m_strExamType;
- bool WriteFrame(WORD* pImgData,int nWidth,int nHeight);
- void trimipstr(string &trimtarget);
- bool InitConnection();
- int OpenEbusDevice();
- int CloseEbusDevice();
- static long ProcessingFunction(/*long HookType, MIL_ID HookId, void MPTYPE *HookDataPtr*/);
- static CImgBrd* m_pCab;
- protected:
- long SizeX; // Buffer Size X
- long SizeY; // Buffer Size Y
- //bool m_bExitCaptureThread;
- int m_nCropLeft, m_nCropTop, m_nCropRight, m_nCropBottom;
- protected:
- DECLARE_MESSAGE_MAP()
- };
|