SeparateThreadTwainFeeder.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #pragma once
  2. #include <boost/smart_ptr.hpp>
  3. #include "scan_common.h"
  4. #include "twain\TwainApp.h"
  5. #include "basic_struct.h"
  6. #include "feeder.h"
  7. /************************************************************************/
  8. /* 单独线程TWAIN扫描仪图像送入器 */
  9. /* 2014年12月9日16:04:06 */
  10. /* 作者:唐林 */
  11. /************************************************************************/
  12. class CSeparateThreadTwainFeeder:public IFeeder,private TwainApp
  13. {
  14. public:
  15. static boost::shared_ptr<CSeparateThreadTwainFeeder>Get();
  16. public:
  17. CSeparateThreadTwainFeeder(void);
  18. ~CSeparateThreadTwainFeeder(void);
  19. void SetScannerIndex( const int scanner_index );
  20. //获取扫描仪信息列表
  21. int GetScannerList(vector<SCANNER_INFO> & scannerList);
  22. //获取默认扫描仪信息
  23. int GetDefaultScannerInfo(SCANNER_INFO &scannerInfo);
  24. //显示指定扫描仪设置
  25. int ShowScannerSetting( const unsigned int nId );
  26. //连接扫描仪
  27. int ConnectScanner( const int nIndex );
  28. //断开扫描仪连接
  29. int DisconnectScanner();
  30. //设置事件处理句柄
  31. int SetHandlerWnd(HWND hwnd){m_hWnd = hwnd;return TRUE;}
  32. protected:
  33. int WaitCommand();
  34. virtual ServiceState OnStarting( void );
  35. virtual ServiceState OnRunning( void );
  36. virtual ServiceState OnStoping( void );
  37. void StartScan();
  38. void navtive_graber( PBITMAPINFOHEADER pDIB );
  39. virtual int Stop( void );
  40. virtual BOOL HasStopCommand();
  41. virtual bool GetNext( BOOL wait,IplImage* & img, feeder_param& param );
  42. TW_INT32 m_dataSourceId;
  43. IplImage* m_img;
  44. RTL_CRITICAL_SECTION m_lock;
  45. private:
  46. //扫描仪送入器执行任务类型STTF(SeparateThreadTwainFeeder)_TASK_TYPE
  47. enum STTF_TASK_TYPE{
  48. //默认(STTF_TASK_TYPE_SCAN)
  49. STTF_TASK_TYPE_DEFAULT=0,
  50. //扫描
  51. STTF_TASK_TYPE_SCAN=0,
  52. //连接扫描仪
  53. STTF_TASK_TYPE_CONNECT=1,
  54. //扫描设置
  55. STTF_TASK_TYPE_SETTING=2,
  56. //断开扫描仪连接
  57. STTF_TASK_TYPE_DISCONNECT=3,
  58. } m_current_task_type;
  59. //任务状态
  60. enum STTF_TASK_EXCUTE_STATE{
  61. //任务未开始
  62. STTF_TASK_EXCUTE_STATE_NOTSTART,
  63. //任务执行中
  64. STTF_TASK_EXCUTE_STATE_EXCUTING,
  65. //任务停止中
  66. STTF_TASK_EXCUTE_STATE_STOPING,
  67. //任务已停止
  68. STTF_TASK_EXCUTE_STATE_STOPED,
  69. } m_connect_task_excute_state;
  70. int m_scanner_index;
  71. #define MAX_CONNET_TASK_COUNT 2
  72. //当前正在连接的扫描仪id的索引
  73. int m_current_connect_task_first;
  74. //当前等待连接的扫描仪数量
  75. int m_current_connect_task_count;
  76. //当前等待连接的扫描仪列表
  77. int m_current_connect_task[MAX_CONNET_TASK_COUNT];
  78. HWND m_hWnd;
  79. };