12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- #pragma once
- #include <boost/smart_ptr.hpp>
- #include "scan_common.h"
- #include "twain\TwainApp.h"
- #include "basic_struct.h"
- #include "feeder.h"
- /************************************************************************/
- /* 单独线程TWAIN扫描仪图像送入器 */
- /* 2014年12月9日16:04:06 */
- /* 作者:唐林 */
- /************************************************************************/
- class CSeparateThreadTwainFeeder:public IFeeder,private TwainApp
- {
- public:
- static boost::shared_ptr<CSeparateThreadTwainFeeder>Get();
- public:
- CSeparateThreadTwainFeeder(void);
- ~CSeparateThreadTwainFeeder(void);
- void SetScannerIndex( const int scanner_index );
- //获取扫描仪信息列表
- int GetScannerList(vector<SCANNER_INFO> & scannerList);
- //获取默认扫描仪信息
- int GetDefaultScannerInfo(SCANNER_INFO &scannerInfo);
- //显示指定扫描仪设置
- int ShowScannerSetting( const unsigned int nId );
- //连接扫描仪
- int ConnectScanner( const int nIndex );
- //断开扫描仪连接
- int DisconnectScanner();
- //设置事件处理句柄
- int SetHandlerWnd(HWND hwnd){m_hWnd = hwnd;return TRUE;}
- protected:
- int WaitCommand();
- virtual ServiceState OnStarting( void );
- virtual ServiceState OnRunning( void );
- virtual ServiceState OnStoping( void );
- void StartScan();
- void navtive_graber( PBITMAPINFOHEADER pDIB );
- virtual int Stop( void );
- virtual BOOL HasStopCommand();
- virtual bool GetNext( BOOL wait,IplImage* & img, feeder_param& param );
- TW_INT32 m_dataSourceId;
- IplImage* m_img;
- RTL_CRITICAL_SECTION m_lock;
- private:
- //扫描仪送入器执行任务类型STTF(SeparateThreadTwainFeeder)_TASK_TYPE
- enum STTF_TASK_TYPE{
- //默认(STTF_TASK_TYPE_SCAN)
- STTF_TASK_TYPE_DEFAULT=0,
- //扫描
- STTF_TASK_TYPE_SCAN=0,
- //连接扫描仪
- STTF_TASK_TYPE_CONNECT=1,
- //扫描设置
- STTF_TASK_TYPE_SETTING=2,
- //断开扫描仪连接
- STTF_TASK_TYPE_DISCONNECT=3,
- } m_current_task_type;
- //任务状态
- enum STTF_TASK_EXCUTE_STATE{
- //任务未开始
- STTF_TASK_EXCUTE_STATE_NOTSTART,
- //任务执行中
- STTF_TASK_EXCUTE_STATE_EXCUTING,
- //任务停止中
- STTF_TASK_EXCUTE_STATE_STOPING,
- //任务已停止
- STTF_TASK_EXCUTE_STATE_STOPED,
- } m_connect_task_excute_state;
- int m_scanner_index;
- #define MAX_CONNET_TASK_COUNT 2
- //当前正在连接的扫描仪id的索引
- int m_current_connect_task_first;
- //当前等待连接的扫描仪数量
- int m_current_connect_task_count;
- //当前等待连接的扫描仪列表
- int m_current_connect_task[MAX_CONNET_TASK_COUNT];
- HWND m_hWnd;
- };
|