hspscannerimpl.h 3.9 KB

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