/* * me4GrabberGS.h * * Created on: 7. dec. 2012 * Author: Viacheslav Isaev * * GrabberGS is a child from CPco_me4_edge_GS class. * CPco_me4_edge_GS originally provided by PCO, in the project used modified, * because it is impossible to reuse class as is. * */ #ifndef ME4GRABBERGS_H_ #define ME4GRABBERGS_H_ #include #include #include #include #include "Cpco_me4_GS.h" namespace me4 { //typedef int(*ProcessImageCallback)(WORD*, size_t); typedef boost::function ProcessImageCallback; /** Implementation of microEnabled4 board for PCO Global Shutter Camera * * This class derives PCO proprietary class with purpose make it compatible with * asynDriver. * * This class includes internal buffer to store images. * Buffer write/read operations split by different threads. * This splits expenses on image conversion. * * */ class GrabberGS : public CPco_me4_edge_GS { public: /** C-tor of the class * * */ GrabberGS(); virtual ~GrabberGS(); /** It's grabbing single image to provided buffer. * */ DWORD grabSingle(WORD* buff); /** Thread body to read images from board's buffer. * */ void processingImages(); /** Thread body to process local buffer with converted images. * */ void processingLocalBuffer(); /** Set continues acquisition mode * */ bool setContinues(bool); /** Starting acquire with requested numbers of frames. * */ int startAcquire(const frameindex_t imgNum); /** Star continues mode of image acquisition * */ int startAcquire(); /** Stopping acquisition process * */ int stopAcquire(); /** It register callbacks to read out images from local buffer * */ int registerCallback(const ProcessImageCallback &processImageCallback); /** It sets internal buffer size * */ size_t setBufferSize(int bufferSize); /** It returns internal buffer size * */ size_t getBufferSize(); /** It returns number of lost images in last acquisition * */ size_t getNumLostImages(); /** It returns minimum camera wait time to get image. * */ clock_t getMinCameraWaitTime(); /** It returns maximum camera wait time to get image. * */ clock_t getMaxCameraWaitTime(); protected: epicsThreadId _thrImageAcquisition; epicsThreadId _thrImageProcessing; size_t _bufferSize; bool _exitRequested; bool _acquisition_processing; epicsEvent _acquisition; bool _continuesMode; frameindex_t _currentPicNum; //< Number of current picture frameindex_t _expectedPicNum; //< Number of current picture volatile unsigned int _actualWidth; volatile unsigned int _actualHeight; /// Number of images in the buffer. If number of the images exceed ... int _timeout; //< Picture waiting timeout size_t _countImgInBuffPrev; bool _bufferAlarm; size_t _numLostImages; int _deltaImgBuff; size_t _rawDataSize; ProcessImageCallback _processImageCallback; dma_mem* _pMem; epicsMutex *_queueLock; std::queue _queue; //< There are a links on the buffer frameindex_t _totalImgNumbers; clock_t _cameraWaitTime; clock_t _minCameraWaitTime; clock_t _maxCameraWaitTime; /** * */ int selectingDMABuffer(); /** * */ void prepareAcquire(); /** Function blocks till next image is ready * */ int waitNextImage(); /** Function reads image in given number * */ int readImage(WORD* buff); /** Function writes logging information. * * It overrides original function to support IOC logging engine */ virtual void writelog(DWORD lev,PCO_HANDLE hdriver,const char *str,...); }; } /* namespace me4 */ #endif /* ME4GRABBERGS_H_ */