hspscannerimpl.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #ifndef LIBFRAMEWORK_HSPS_IMPL_H
  2. #define LIBFRAMEWORK_HSPS_IMPL_H
  3. #include "HSPScannerClass.h"
  4. #include "cmb.h"
  5. #define FILE_VERSION 1
  6. typedef struct{
  7. INT64 iTime; //心跳时间
  8. short iX,iY,iW,iH; //窗口位置
  9. char bGrey; //灰度
  10. BYTE iRotate; //旋转角度
  11. BYTE iScanSz; //尺寸
  12. BYTE iCamIdx; //摄像头编号
  13. }HspsState;
  14. typedef int (*pHSPSCall)(const char *data, size_t len, int& iRet);
  15. class HSPSClassImpl : public CHSPSClass
  16. {
  17. public:
  18. HSPSClassImpl();
  19. ~HSPSClassImpl();
  20. //DeviceBaseClass
  21. ErrorCodeEnum GetDevCategory(DevCategoryInfo &devCategory);
  22. ErrorCodeEnum Reset();
  23. ErrorCodeEnum DevClose();
  24. ErrorCodeEnum GetLastErr(DevErrorInfo &devErrInfo);
  25. virtual ErrorCodeEnum DevOpen();
  26. //
  27. // Set param, more detail please to see ParamType and its according ParamTypeValue.
  28. //
  29. virtual ErrorCodeEnum SetParam(ParamType type, ParamTypeValue value);
  30. //
  31. // Command the device to start to preview or stop previewing.
  32. // -nValue[in] set 1 means StartPreview while 0 means StopPreview.
  33. // If the device' state had been setted before what the nValue commanded, ignore it and
  34. // return Error_Succeed.
  35. // The function returns only the specified behavior is done completely, StartPreview in special.
  36. // 更新20161117: nValue值为 1 时打开预览,确保当前打开预览过程执行结束且窗口处于显示状态才返回Error_Succeed,
  37. // nValue值为 0 时关闭预览并隐藏窗口
  38. virtual ErrorCodeEnum SetPreview(short nValue);
  39. // Scan Image from device and store the image.
  40. // -pszFileName[in] Store the path and name using suffix ".jpg"
  41. // specifies that where the image will be located and what it would be named.
  42. // 拍摄照片,传入的文件名已带绝对路径,无需再进行拼接处理
  43. //
  44. virtual ErrorCodeEnum ScanImage(const char* pszFileName);
  45. //
  46. // Scan Image from device and return the image data in byte format.
  47. // -pBtImg[out] The buffer used to store the scanned image data.
  48. // 存储图片字节流的缓冲区,大小为 nBtLen 字节
  49. // -nBtLen[in,out] Indicate the max byte-type size of pBtImg could be stored
  50. // and Store the real byte-type size of pBtImg had used when returned.
  51. // when detect value of nBtLen is 0 or smaller that necessary size, please
  52. // set nBtlen with real byte-type size and return Error_TooSmallBuffer.
  53. // 如果nBtLen指定的字节数过小,那么对nBtLen赋值实际所需的大小并返回 Error_TooSmallBuffer,此操作仅允许一次
  54. // -pszFileName[in] Store the path and name where the image file should be located
  55. // while "" indicates that the image file shouldn't be stored at locate.
  56. // 文件名长度为零表示不在本地生成图片文件
  57. virtual ErrorCodeEnum ScanImageEx(BYTE* pBtImg, int& nBtLen, const char* pszFileName = "");
  58. //
  59. // Set position and width of preview dialog with the rate of length to width: 16:9.
  60. // -nX[in] The X coordinate of leftTop point.
  61. // -nY[in] The Y coordinate of leftTop point.
  62. // -nWidth[in] The Width of Preview Dialog .
  63. // 传入预览窗口显示的坐标,左上角的横坐标nX,左上角的纵坐标nY,以及预览窗口的宽,宽与高的比例为 16:9
  64. //
  65. virtual ErrorCodeEnum SetViewPos(int nX, int nY, int nWidth);
  66. //
  67. // Show property dialog of HSPS of LiangTian.
  68. // If there is no property dialog function, ignore it and return Error_NotImpl(更新20161117).
  69. // 更新20161117:用于打开良田高拍仪设备的设置属性页,可能用不到
  70. //
  71. virtual ErrorCodeEnum SetProperty()
  72. {
  73. return Error_NotImpl;
  74. }
  75. //
  76. // Get current status of device.
  77. virtual ErrorCodeEnum GetDevStatus(HspsDevStatus& status);
  78. ////////////////////////////////////
  79. public:
  80. void ThreadRun();
  81. pthread_t m_hThreadID;
  82. static void* Proc(void* inPara);
  83. bool m_bThreadExit;
  84. void StartTimer();
  85. void CloseThread(pthread_t& h);
  86. pHSPSCall HSPSCall;
  87. protected:
  88. ErrorCodeEnum GetErrorInfo(int iCode, char* sErr, ...);
  89. DevErrorInfo m_DevErrInfo;
  90. bool m_bIsOpen;
  91. char m_sLibPath[260];
  92. SShareMem m_ShereMem;
  93. };
  94. #endif //LIBFRAMEWORK_HSPS_IMPL_H