2022-07-13 10:22:31 +00:00
# include " hg_scanner_402.h "
# include "../wrapper/hg_log.h"
# include "filetools.h"
2022-07-18 08:56:03 +00:00
# if defined(WIN32) || defined(_WIN64)
2022-07-13 10:22:31 +00:00
# include "scanner_manager.h"
# endif
# include <map>
//#define SAVE_TO_FILE
# define USB_REQ_GET_FPGA_REGS 0x40
# define USB_REQ_SET_FPGA_REGS 0x41
# define USB_REQ_GET_MOTOR_REGS 0x42
# define USB_REQ_SET_MOTOR_REGS 0x43
# define USB_REQ_GET_DEV_STATUS 0x60
# define USB_REQ_GET_DEV_CONFIGURATION 0x61
# define USB_REQ_SET_DEV_CONFIGURATION 0x62
# define USB_REQ_GET_DEV_REGS 0x63
# define USB_REQ_SET_DEV_REGS 0x64
2022-07-23 10:01:44 +00:00
# ifdef OEM_LISICHENG
2022-10-11 01:00:46 +00:00
static std : : string jsontext1 ( " { \" device_type \" : \" G402-lsc \" , \" option_count \" :62, \" 1 \" :{ \" category \" : \" base \" , \" name \" : \" restore \" , \" title \" : \" \\ u6062 \\ u590d \\ u9ed8 \\ u8ba4 \\ u8bbe \\ u7f6e \" , \" desc \" : \" \\ u6062 \\ u590d \\ u9ed8 \\ u8ba4 \\ u8bbe \\ u7f6e \" , \" type \" : \" button \" , \" cur \" : \" button \" , \" default \" : \" button \" , \" size \" :0}, \" 2 \" :{ \" category \" : \" advanced \" , \" name \" : \" help \" , \" title \" : \" \\ u5e2e \\ u52a9 \" , \" desc \" : \" \\ u663e \\ u793a \\ u8f6f \\ u4ef6 \\ u5e2e \\ u52a9 \\ u6587 \\ u6863 \" , \" type \" : \" button \" , \" cur \" : \" true \" , \" default \" : \" true \" , \" size \" :4}, \" 3 \" :{ \" category \" : \" base \" , \" name \" : \" grp-1 \" , \" title \" : \" \\ u57fa \\ u672c \\ u8bbe \\ u7f6e \" , \" type \" : \" group \" }, \" 4 \" :{ \" category \" : \" base \" , \" name \" : \" is-multiout \" , \" title \" : \" \\ u591a \\ u6d41 \\ u8f93 \\ u51fa \" , \" desc \" : \" \\ u540c \\ u65f6 \\ u8f93 \\ u51fa \\ u591a \\ u79cd \\ u989c \\ u8272 \\ u6a21 \\ u5f0f \\ u7684 \\ u56fe \\ u50cf \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4}, \" 5 \" :{ \" category \" : \" base \" , \" name \" : \" multiout-type \" , \" title \" : \" \\ u591a \\ u6d41 \\ u8f93 \\ u51fa \\ u7c7b \\ u578b \" , \" desc \" : \" \\ u9009 \\ u62e9 \\ u591a \\ u6d41 \\ u8f93 \\ u51fa \\ u7684 \\ u7c7b \\ u578b \" , \" type \" : \" string \" , \" cur \" : \" \\ u5f69 \\ u8272+ \\ u7070 \\ u5ea6+ \\ u9ed1 \\ u767d \" , \" default \" : \" \\ u5f69 \\ u8272+ \\ u7070 \\ u5ea6+ \\ u9ed1 \\ u767d \" , \" size \" :32, \" range \" :[ \" \\ u5f69 \\ u8272+ \\ u7070 \\ u5ea6+ \\ u9ed1 \\ u767d \" , \" \\ u5f69 \\ u8272+ \\ u7070 \\ u5ea6 \" , \" \\ u5f69 \\ u8272+ \\ u9ed1 \\ u767d \" , \" \\ u7070 \\ u5ea6+ \\ u9ed1 \\ u767d \" ], \" depend_or \" :[ \" 4==true \" ]}, \" 6 \" :{ \" category \" : \" base \" , \" name \" : \" mode \" , \" title \" : \" \\ u989c \\ u8272 \\ u6a21 \\ u5f0f \" , \" desc \" : \" \\ u9009 \\ u62e9 \\ u8272 \\ u5f69 \\ u6a21 \\ u5f0f \" , \" type \" : \" string \" , \" cur \" : \" 24 \\ u4f4d \\ u5f69 \\ u8272 \" , \" default \" : \" 24 \\ u4f4d \\ u5f69 \\ u8272 \" , \" size \" :32, \" range \" :[ \" 24 \\ u4f4d \\ u5f69 \\ u8272 \" , \" 256 \\ u7ea7 \\ u7070 \\ u5ea6 \" , \" \\ u9ed1 \\ u767d \" , \" \\ u989c \\ u8272 \\ u81ea \\ u52a8 \\ u8bc6 \\ u522b \" ], \" depend_or \" :[ \" 4==false \" ]}, \" 7 \" :{ \" category \" : \" base \" , \" name \" : \" binary-threshold \" , \" title \" : \" \\ u9ed1 \\ u767d \\ u56fe \\ u50cf \\ u9608 \\ u503c \" , \" desc \" : \" \\ u9ad8 \\ u4e8e \\ u8be5 \\ u9608 \\ u503c \\ u4e3a1 \\ uff08 \\ u767d \\ uff09 \\ uff0c \\ u4f4e \\ u4e8e \\ u8be5 \\ u9608 \\ u503c \\ u4e3a0 \\ uff08 \\ u9ed1 \\ uff09 \" , \" type \" : \" int \" , \" cur \" :127, \" default \" :127, \" size \" :4, \" range \" :{ \" min \" :0, \" max \" :255}, \" depend_or \" :[ \" 4==true \" , \" 6== \\ u9ed1 \\ u767d \" ]}, \" 8 \" :{ \" category \" : \" base \" , \" name \" : \" reverse-bw \" , \" title \" : \" \\ u9ed1 \\ u767d \\ u56fe \\ u50cf \\ u53cd \\ u8272 \\ u8f93 \\ u51fa \" , \" desc \" : \" \\ u8f93 \\ u51fa \\ u7684 \\ u9ed1 \\ u767d \\ u56fe \\ u50cf \\ u4ee5 \\ u201c1 \\ u201d \\ u4ee3 \\ u8868 \\ u9ed1 \\ u8272 \\ uff0c \\ u201c0 \\ u201d \\ u4ee3 \\ u8868 \\ u767d \\ u8272 \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4, \" depend_or \" :[ \" 4==true \" , \" 6== \\ u9ed1 \\ u767d \" ]}, \" 9 \" :{ \" category \" : \" base \" , \" name \" : \" filter \" , \" title \" : \" \\ u7070 \\ u5ea6 \\ u6216 \\ u9ed1 \\ u767d \\ u56fe \\ u50cf - \\ u9664 \\ u8272 \\ u4e0e \\ u589e \\ u5f3a \" , \" desc \" : \" \\ u6d88 \\ u9664 \\ u6216 \\ u589e \\ u5f3a \\ u6307 \\ u5b9a \\ u8272 \\ u5f69 \" , \" type \" : \" string \" , \" cur \" : \" \\ u4e0d \\ u9664 \\ u8272 \" , \" default \" : \" \\ u4e0d \\ u9664 \\ u8272 \" , \" size \" :24, \" range \" :[ \" \\ u4e0d \\ u9664 \\ u8272 \" , \" \\ u9664 \\ u7ea2 \\ u8272 \" , \" \\ u9664 \\ u7eff \\ u8272 \" , \" \\ u9664 \\ u84dd \\ u8272 \" , \" \\ u7ea2 \\ u8272 \\ u589e \\ u5f3a \" , \" \\ u7eff \\ u8272 \\ u589e \\ u5f3a \" , \" \\ u84dd \\ u8272 \\ u589e \\ u5f3a \" ], \" depend_and \" :[ \" 4!=true \" , \" 6!=24 \\ u4f4d \\ u5f69 \\ u8272 \" , \" 6!= \\ u989c \\ u8272 \\ u81ea \\ u52a8 \\ u8bc6 \\ u522b \" ]}, \" 10 \" :{ \" category \" : \" base \" , \" name \" : \" is-rid-multiout-red \" , \" title \" : \" 24 \\ u4f4d \\ u5f69 \\ u8272 \\ u56fe \\ u50cf - \\ u591a \\ u6d41 \\ u8f93 \\ u51fa \\ u9664 \\ u7ea2 \" , \" desc \" : \" \\ u540c \\ u65f6 \\ u8f93 \\ u51fa \\ u5f69 \\ u8272 \\ u56fe \\ u50cf \\ u548c \\ u7070 \\ u5ea6 \\ u9664 \\ u7ea2 \\ u56fe \\ u50cf \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4, \" depend_and \" :[ \" 4!=true \" , \" 6!=256 \\ u7ea7 \\ u7070 \\ u5ea6 \" , \" 6!= \\ u9ed1 \\ u767d \" , \" 6!= \\ u989c \\ u8272 \\ u81ea \\ u52a8 \\ u8bc6 \\ u522b \" ]}, \" 11 \" :{ \" category \" : \" base \" , \" name \" : \" is-rid-answer-sheet-red \" , \" title \" : \" 24 \\ u4f4d \\ u5f69 \\ u8272 \\ u56fe \\ u50cf - \\ u7b54 \\ u9898 \\ u5361 \\ u9664 \\ u7ea2 \" , \" desc \" : \" \\ u8f93 \\ u51fa \\ u9664 \\ u7ea2 \\ u5f69 \\ u8272 \\ u56fe \\ u50cf \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4, \" depen
2022-10-07 09:50:28 +00:00
static std : : string jsontext2 ( " 626b \\ u63cf \\ u533a \\ u57df \\ u53f3 \\ u4e0b \\ u89d2y \\ u5750 \\ u6807 \" , \" type \" : \" float \" , \" cur \" :297.000000, \" default \" :297.000000, \" size \" :4, \" range \" :{ \" min \" :0.000000, \" max \" :297.000000}, \" depend_and \" :[ \" 21==true \" ]}, \" 26 \" :{ \" category \" : \" base \" , \" name \" : \" is-size-check \" , \" title \" : \" \\ u5c3a \\ u5bf8 \\ u68c0 \\ u6d4b \" , \" desc \" : \" \\ u68c0 \\ u6d4b \\ u7eb8 \\ u5f20 \\ u5b9e \\ u9645 \\ u5c3a \\ u5bf8 \\ u4e0e \\ u8bbe \\ u7f6e \\ u662f \\ u5426 \\ u5339 \\ u914d \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4, \" depend_or \" :[ \" 20==A3 \" , \" 20==A4 \" , \" 20==A4 \\ u6a2a \\ u5411 \" , \" 20==A5 \" , \" 20==A6 \" , \" 20==A6 \\ u6a2a \\ u5411 \" , \" 20==B4 \" , \" 20==B5 \" , \" 20==B5 \\ u6a2a \\ u5411 \" , \" 20==B6 \" , \" 20==B6 \\ u6a2a \\ u5411 \" , \" 20==Double Letter \" , \" 20==LEGAL \" , \" 20==Letter \" , \" 20==Letter \\ u6a2a \\ u5411 \" ]}, \" 27 \" :{ \" category \" : \" base \" , \" name \" : \" page \" , \" title \" : \" \\ u626b \\ u63cf \\ u9875 \\ u9762 \" , \" desc \" : \" \\ u8bbe \\ u7f6e \\ u9875 \\ u9762 \\ u626b \\ u63cf \\ u65b9 \\ u5f0f \" , \" type \" : \" string \" , \" cur \" : \" \\ u53cc \\ u9762 \" , \" default \" : \" \\ u53cc \\ u9762 \" , \" size \" :50, \" range \" :[ \" \\ u5355 \\ u9762 \" , \" \\ u53cc \\ u9762 \" , \" \\ u8df3 \\ u8fc7 \\ u7a7a \\ u767d \\ u9875 \\ uff08 \\ u901a \\ u7528 \\ uff09 \" , \" \\ u8df3 \\ u8fc7 \\ u7a7a \\ u767d \\ u9875 \\ uff08 \\ u53d1 \\ u7968 \\ u7eb8 \\ uff09 \" , \" \\ u5bf9 \\ u6298 \" ]}, \" 28 \" :{ \" category \" : \" base \" , \" name \" : \" blank-sensitivity \" , \" title \" : \" \\ u8df3 \\ u8fc7 \\ u7a7a \\ u767d \\ u9875 \\ u7075 \\ u654f \\ u5ea6 \" , \" desc \" : \" \\ u6570 \\ u503c \\ u8d8a \\ u5927 \\ uff0c \\ u5219 \\ u8d8a \\ u5bb9 \\ u6613 \\ u8df3 \\ u8fc7 \" , \" type \" : \" int \" , \" cur \" :50, \" default \" :50, \" size \" :4, \" range \" :{ \" min \" :1, \" max \" :100}, \" depend_or \" :[ \" 27== \\ u8df3 \\ u8fc7 \\ u7a7a \\ u767d \\ u9875 \\ uff08 \\ u53d1 \\ u7968 \\ u7eb8 \\ uff09 \" , \" 27== \\ u8df3 \\ u8fc7 \\ u7a7a \\ u767d \\ u9875 \\ uff08 \\ u901a \\ u7528 \\ uff09 \" ]}, \" 29 \" :{ \" category \" : \" base \" , \" name \" : \" resolution \" , \" title \" : \" \\ u5206 \\ u8fa8 \\ u7387 \" , \" desc \" : \" \\ u8bbe \\ u7f6e \\ u626b \\ u63cf \\ u56fe \\ u50cf \\ u7684 \\ u5206 \\ u8fa8 \\ u7387 \" , \" type \" : \" int \" , \" cur \" :200, \" default \" :200, \" size \" :4, \" range \" :[100,150,200,300]}, \" 30 \" :{ \" category \" : \" base \" , \" name \" : \" is-exchange \" , \" title \" : \" \\ u4ea4 \\ u6362 \\ u6b63 \\ u53cd \\ u9762 \" , \" desc \" : \" \\ u4ea4 \\ u6362 \\ u6bcf \\ u5f20 \\ u6587 \\ u7a3f \\ u7684 \\ u6b63 \\ u53cd \\ u9762 \\ u51fa \\ u56fe \\ u987a \\ u5e8f \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4, \" depend_and \" :[ \" 27!= \\ u5355 \\ u9762 \" ]}, \" 31 \" :{ \" category \" : \" base \" , \" name \" : \" grp-2 \" , \" title \" : \" \\ u4eae \\ u5ea6 \" , \" type \" : \" group \" }, \" 32 \" :{ \" category \" : \" base \" , \" name \" : \" is-custom-gamma \" , \" title \" : \" \\ u542f \\ u7528 \\ u8272 \\ u8c03 \\ u66f2 \\ u7ebf \" , \" desc \" : \" \\ u81ea \\ u5b9a \\ u4e49 \\ u56fe \\ u50cf \\ u8272 \\ u8c03 \\ u6548 \\ u679c \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4}, \" 33 \" :{ \" category \" : \" base \" , \" name \" : \" brightness \" , \" title \" : \" \\ u4eae \\ u5ea6 \\ u503c \" , \" desc \" : \" \\ u8c03 \\ u6574 \\ u56fe \\ u50cf \\ u4eae \\ u5ea6 \" , \" type \" : \" int \" , \" cur \" :128, \" default \" :128, \" size \" :4, \" range \" :{ \" min \" :1, \" max \" :255}}, \" 34 \" :{ \" category \" : \" base \" , \" name \" : \" contrast \" , \" title \" : \" \\ u5bf9 \\ u6bd4 \\ u5ea6 \" , \" desc \" : \" \\ u8c03 \\ u6574 \\ u56fe \\ u50cf \\ u5bf9 \\ u6bd4 \\ u5ea6 \" , \" type \" : \" int \" , \" cur \" :4, \" default \" :4, \" size \" :4, \" range \" :{ \" min \" :1, \" max \" :7}}, \" 35 \" :{ \" category \" : \" base \" , \" name \" : \" gamma \" , \" title \" : \" \\ u4f3d \\ u9a6c \\ u503c \" , \" desc \" : \" \\ u8c03 \\ u6574 \\ u56fe \\ u50cf \\ u4f3d \\ u739b \\ u503c \" , \" type \" : \" float \" , \" cur \" :1.000000, \" default \" :1.000000, \" size \" :4, \" range \" :{ \" min \" :0.010000, \" max \" :5.000000}}, \" 36 \" :{ \" category \" : \" base \" , \" name \" : \" grp-3 \" , \" title \" : \" \\ u56fe \\ u50cf \\ u5904 \\ u7406 \" , \" type \" : \" group \" }, \" 37 \" :{ \" category \" : \" base \" , \" name \" : \" is-anti-skew \" , \" title \" : \" \\ u81ea \\ u52a8 \\ u7ea0 \\ u504f \" , \" desc \" : \" \\ u81ea \\ u52a8 \\ u7ea0 \\ u6b63 \\ u6b6a \\ u659c \\ u9001 \\ u5165 \\ u7684 \\ u6587 \\ u7a3f \\ u56fe \\ u50cf \" , \" type \" : \" bool \" , \" cur \" :true, \" default \" :true, \" size \" :4, \" depend_or \" :[ \" 27!= \\ u5bf9 \\ u6298 \" ]}, \" 38 \" :{ \" category \" : \" base \" , \" name \" : \" is-split \" , \" title \" : \" \\ u56fe \\ u50cf \\ u62c6 \\ u5206 \" , \" desc \" : \" \\ u81ea \\ u52a8 \\ u62c6 \\ u5206 \\ u56fe \\ u50cf \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4, \" depend_or \" :[ \" 27!= \\ u5bf9 \\ u6298 \" ]}, \" 39 \" :{ \" category
2022-07-23 10:01:44 +00:00
# else
2022-08-12 09:18:38 +00:00
# ifdef x86_64
2022-10-11 01:00:46 +00:00
static std : : string jsontext1 ( " { \" device_type \" : \" G402-x86 \" , \" option_count \" :61, \" 1 \" :{ \" category \" : \" base \" , \" name \" : \" restore \" , \" title \" : \" \\ u6062 \\ u590d \\ u9ed8 \\ u8ba4 \\ u8bbe \\ u7f6e \" , \" desc \" : \" \\ u6062 \\ u590d \\ u9ed8 \\ u8ba4 \\ u8bbe \\ u7f6e \" , \" type \" : \" button \" , \" cur \" : \" button \" , \" default \" : \" button \" , \" size \" :0}, \" 2 \" :{ \" category \" : \" advanced \" , \" name \" : \" help \" , \" title \" : \" \\ u5e2e \\ u52a9 \" , \" desc \" : \" \\ u663e \\ u793a \\ u8f6f \\ u4ef6 \\ u5e2e \\ u52a9 \\ u6587 \\ u6863 \" , \" type \" : \" button \" , \" cur \" : \" true \" , \" default \" : \" true \" , \" size \" :4}, \" 3 \" :{ \" category \" : \" base \" , \" name \" : \" grp-1 \" , \" title \" : \" \\ u57fa \\ u672c \\ u8bbe \\ u7f6e \" , \" type \" : \" group \" }, \" 4 \" :{ \" category \" : \" base \" , \" name \" : \" is-multiout \" , \" title \" : \" \\ u591a \\ u6d41 \\ u8f93 \\ u51fa \" , \" desc \" : \" \\ u540c \\ u65f6 \\ u8f93 \\ u51fa \\ u591a \\ u79cd \\ u989c \\ u8272 \\ u6a21 \\ u5f0f \\ u7684 \\ u56fe \\ u50cf \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4}, \" 5 \" :{ \" category \" : \" base \" , \" name \" : \" multiout-type \" , \" title \" : \" \\ u591a \\ u6d41 \\ u8f93 \\ u51fa \\ u7c7b \\ u578b \" , \" desc \" : \" \\ u9009 \\ u62e9 \\ u591a \\ u6d41 \\ u8f93 \\ u51fa \\ u7684 \\ u7c7b \\ u578b \" , \" type \" : \" string \" , \" cur \" : \" \\ u5f69 \\ u8272+ \\ u7070 \\ u5ea6+ \\ u9ed1 \\ u767d \" , \" default \" : \" \\ u5f69 \\ u8272+ \\ u7070 \\ u5ea6+ \\ u9ed1 \\ u767d \" , \" size \" :32, \" range \" :[ \" \\ u5f69 \\ u8272+ \\ u7070 \\ u5ea6+ \\ u9ed1 \\ u767d \" , \" \\ u5f69 \\ u8272+ \\ u7070 \\ u5ea6 \" , \" \\ u5f69 \\ u8272+ \\ u9ed1 \\ u767d \" , \" \\ u7070 \\ u5ea6+ \\ u9ed1 \\ u767d \" ], \" depend_or \" :[ \" 4==true \" ]}, \" 6 \" :{ \" category \" : \" base \" , \" name \" : \" mode \" , \" title \" : \" \\ u989c \\ u8272 \\ u6a21 \\ u5f0f \" , \" desc \" : \" \\ u9009 \\ u62e9 \\ u8272 \\ u5f69 \\ u6a21 \\ u5f0f \" , \" type \" : \" string \" , \" cur \" : \" 24 \\ u4f4d \\ u5f69 \\ u8272 \" , \" default \" : \" 24 \\ u4f4d \\ u5f69 \\ u8272 \" , \" size \" :32, \" range \" :[ \" 24 \\ u4f4d \\ u5f69 \\ u8272 \" , \" 256 \\ u7ea7 \\ u7070 \\ u5ea6 \" , \" \\ u9ed1 \\ u767d \" , \" \\ u989c \\ u8272 \\ u81ea \\ u52a8 \\ u8bc6 \\ u522b \" ], \" depend_or \" :[ \" 4==false \" ]}, \" 7 \" :{ \" category \" : \" base \" , \" name \" : \" binary-threshold \" , \" title \" : \" \\ u9ed1 \\ u767d \\ u56fe \\ u50cf \\ u9608 \\ u503c \" , \" desc \" : \" \\ u9ad8 \\ u4e8e \\ u8be5 \\ u9608 \\ u503c \\ u4e3a1 \\ uff08 \\ u767d \\ uff09 \\ uff0c \\ u4f4e \\ u4e8e \\ u8be5 \\ u9608 \\ u503c \\ u4e3a0 \\ uff08 \\ u9ed1 \\ uff09 \" , \" type \" : \" int \" , \" cur \" :127, \" default \" :127, \" size \" :4, \" range \" :{ \" min \" :0, \" max \" :255}, \" depend_or \" :[ \" 4==true \" , \" 6== \\ u9ed1 \\ u767d \" ]}, \" 8 \" :{ \" category \" : \" base \" , \" name \" : \" reverse-bw \" , \" title \" : \" \\ u9ed1 \\ u767d \\ u56fe \\ u50cf \\ u53cd \\ u8272 \\ u8f93 \\ u51fa \" , \" desc \" : \" \\ u8f93 \\ u51fa \\ u7684 \\ u9ed1 \\ u767d \\ u56fe \\ u50cf \\ u4ee5 \\ u201c1 \\ u201d \\ u4ee3 \\ u8868 \\ u9ed1 \\ u8272 \\ uff0c \\ u201c0 \\ u201d \\ u4ee3 \\ u8868 \\ u767d \\ u8272 \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4, \" depend_or \" :[ \" 4==true \" , \" 6== \\ u9ed1 \\ u767d \" ]}, \" 9 \" :{ \" category \" : \" base \" , \" name \" : \" filter \" , \" title \" : \" \\ u7070 \\ u5ea6 \\ u6216 \\ u9ed1 \\ u767d \\ u56fe \\ u50cf - \\ u9664 \\ u8272 \\ u4e0e \\ u589e \\ u5f3a \" , \" desc \" : \" \\ u6d88 \\ u9664 \\ u6216 \\ u589e \\ u5f3a \\ u6307 \\ u5b9a \\ u8272 \\ u5f69 \" , \" type \" : \" string \" , \" cur \" : \" \\ u4e0d \\ u9664 \\ u8272 \" , \" default \" : \" \\ u4e0d \\ u9664 \\ u8272 \" , \" size \" :24, \" range \" :[ \" \\ u4e0d \\ u9664 \\ u8272 \" , \" \\ u9664 \\ u7ea2 \\ u8272 \" , \" \\ u9664 \\ u7eff \\ u8272 \" , \" \\ u9664 \\ u84dd \\ u8272 \" , \" \\ u7ea2 \\ u8272 \\ u589e \\ u5f3a \" , \" \\ u7eff \\ u8272 \\ u589e \\ u5f3a \" , \" \\ u84dd \\ u8272 \\ u589e \\ u5f3a \" ], \" depend_and \" :[ \" 4!=true \" , \" 6!=24 \\ u4f4d \\ u5f69 \\ u8272 \" , \" 6!= \\ u989c \\ u8272 \\ u81ea \\ u52a8 \\ u8bc6 \\ u522b \" ]}, \" 10 \" :{ \" category \" : \" base \" , \" name \" : \" is-rid-multiout-red \" , \" title \" : \" 24 \\ u4f4d \\ u5f69 \\ u8272 \\ u56fe \\ u50cf - \\ u591a \\ u6d41 \\ u8f93 \\ u51fa \\ u9664 \\ u7ea2 \" , \" desc \" : \" \\ u540c \\ u65f6 \\ u8f93 \\ u51fa \\ u5f69 \\ u8272 \\ u56fe \\ u50cf \\ u548c \\ u7070 \\ u5ea6 \\ u9664 \\ u7ea2 \\ u56fe \\ u50cf \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4, \" depend_and \" :[ \" 4!=true \" , \" 6!=256 \\ u7ea7 \\ u7070 \\ u5ea6 \" , \" 6!= \\ u9ed1 \\ u767d \" , \" 6!= \\ u989c \\ u8272 \\ u81ea \\ u52a8 \\ u8bc6 \\ u522b \" ]}, \" 11 \" :{ \" category \" : \" base \" , \" name \" : \" is-rid-answer-sheet-red \" , \" title \" : \" 24 \\ u4f4d \\ u5f69 \\ u8272 \\ u56fe \\ u50cf - \\ u7b54 \\ u9898 \\ u5361 \\ u9664 \\ u7ea2 \" , \" desc \" : \" \\ u8f93 \\ u51fa \\ u9664 \\ u7ea2 \\ u5f69 \\ u8272 \\ u56fe \\ u50cf \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4, \" depen
2022-10-07 09:50:28 +00:00
static std : : string jsontext2 ( " : \" tl-y \" , \" title \" : \" \\ u626b \\ u63cf \\ u533a \\ u57df \\ u4e0a \\ u4fa7 \\ uff08mm \\ uff09 \" , \" desc \" : \" \\ u81ea \\ u5b9a \\ u4e49 \\ u626b \\ u63cf \\ u533a \\ u57df \\ u5de6 \\ u4e0a \\ u89d2y \\ u5750 \\ u6807 \" , \" type \" : \" float \" , \" cur \" :0.000000, \" default \" :0.000000, \" size \" :4, \" range \" :{ \" min \" :0.000000, \" max \" :297.000000}, \" depend_and \" :[ \" 21==true \" ]}, \" 25 \" :{ \" category \" : \" base \" , \" name \" : \" br-y \" , \" title \" : \" \\ u626b \\ u63cf \\ u533a \\ u57df \\ u4e0b \\ u4fa7 \\ uff08mm \\ uff09 \" , \" desc \" : \" \\ u81ea \\ u5b9a \\ u4e49 \\ u626b \\ u63cf \\ u533a \\ u57df \\ u53f3 \\ u4e0b \\ u89d2y \\ u5750 \\ u6807 \" , \" type \" : \" float \" , \" cur \" :297.000000, \" default \" :297.000000, \" size \" :4, \" range \" :{ \" min \" :0.000000, \" max \" :297.000000}, \" depend_and \" :[ \" 21==true \" ]}, \" 26 \" :{ \" category \" : \" base \" , \" name \" : \" page \" , \" title \" : \" \\ u626b \\ u63cf \\ u9875 \\ u9762 \" , \" desc \" : \" \\ u8bbe \\ u7f6e \\ u9875 \\ u9762 \\ u626b \\ u63cf \\ u65b9 \\ u5f0f \" , \" type \" : \" string \" , \" cur \" : \" \\ u53cc \\ u9762 \" , \" default \" : \" \\ u53cc \\ u9762 \" , \" size \" :40, \" range \" :[ \" \\ u5355 \\ u9762 \" , \" \\ u53cc \\ u9762 \" , \" \\ u8df3 \\ u8fc7 \\ u7a7a \\ u767d \\ u9875 \\ uff08 \\ u901a \\ u7528 \\ uff09 \" , \" \\ u8df3 \\ u8fc7 \\ u7a7a \\ u767d \\ u9875 \\ uff08 \\ u53d1 \\ u7968 \\ u7eb8 \\ uff09 \" , \" \\ u5bf9 \\ u6298 \" ]}, \" 27 \" :{ \" category \" : \" base \" , \" name \" : \" blank-sensitivity \" , \" title \" : \" \\ u8df3 \\ u8fc7 \\ u7a7a \\ u767d \\ u9875 \\ u7075 \\ u654f \\ u5ea6 \" , \" desc \" : \" \\ u6570 \\ u503c \\ u8d8a \\ u5927 \\ uff0c \\ u5219 \\ u8d8a \\ u5bb9 \\ u6613 \\ u8df3 \\ u8fc7 \" , \" type \" : \" int \" , \" cur \" :50, \" default \" :50, \" size \" :4, \" range \" :{ \" min \" :1, \" max \" :100}, \" depend_or \" :[ \" 26== \\ u8df3 \\ u8fc7 \\ u7a7a \\ u767d \\ u9875 \\ uff08 \\ u53d1 \\ u7968 \\ u7eb8 \\ uff09 \" , \" 26== \\ u8df3 \\ u8fc7 \\ u7a7a \\ u767d \\ u9875 \\ uff08 \\ u901a \\ u7528 \\ uff09 \" ]}, \" 28 \" :{ \" category \" : \" base \" , \" name \" : \" resolution \" , \" title \" : \" \\ u5206 \\ u8fa8 \\ u7387 \" , \" desc \" : \" \\ u8bbe \\ u7f6e \\ u626b \\ u63cf \\ u56fe \\ u50cf \\ u7684 \\ u5206 \\ u8fa8 \\ u7387 \" , \" type \" : \" int \" , \" cur \" :200, \" default \" :200, \" size \" :4, \" range \" :[100,150,200,300]}, \" 29 \" :{ \" category \" : \" base \" , \" name \" : \" is-exchange \" , \" title \" : \" \\ u4ea4 \\ u6362 \\ u6b63 \\ u53cd \\ u9762 \" , \" desc \" : \" \\ u4ea4 \\ u6362 \\ u6bcf \\ u5f20 \\ u6587 \\ u7a3f \\ u7684 \\ u6b63 \\ u53cd \\ u9762 \\ u51fa \\ u56fe \\ u987a \\ u5e8f \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4, \" depend_and \" :[ \" 26!= \\ u5355 \\ u9762 \" ]}, \" 30 \" :{ \" category \" : \" base \" , \" name \" : \" grp-2 \" , \" title \" : \" \\ u4eae \\ u5ea6 \" , \" type \" : \" group \" }, \" 31 \" :{ \" category \" : \" base \" , \" name \" : \" is-custom-gamma \" , \" title \" : \" \\ u542f \\ u7528 \\ u8272 \\ u8c03 \\ u66f2 \\ u7ebf \" , \" desc \" : \" \\ u81ea \\ u5b9a \\ u4e49 \\ u56fe \\ u50cf \\ u8272 \\ u8c03 \\ u6548 \\ u679c \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4}, \" 32 \" :{ \" category \" : \" base \" , \" name \" : \" brightness \" , \" title \" : \" \\ u4eae \\ u5ea6 \\ u503c \" , \" desc \" : \" \\ u8c03 \\ u6574 \\ u56fe \\ u50cf \\ u4eae \\ u5ea6 \" , \" type \" : \" int \" , \" cur \" :128, \" default \" :128, \" size \" :4, \" range \" :{ \" min \" :1, \" max \" :255}}, \" 33 \" :{ \" category \" : \" base \" , \" name \" : \" contrast \" , \" title \" : \" \\ u5bf9 \\ u6bd4 \\ u5ea6 \" , \" desc \" : \" \\ u8c03 \\ u6574 \\ u56fe \\ u50cf \\ u5bf9 \\ u6bd4 \\ u5ea6 \" , \" type \" : \" int \" , \" cur \" :4, \" default \" :4, \" size \" :4, \" range \" :{ \" min \" :1, \" max \" :7}}, \" 34 \" :{ \" category \" : \" base \" , \" name \" : \" gamma \" , \" title \" : \" \\ u4f3d \\ u9a6c \\ u503c \" , \" desc \" : \" \\ u8c03 \\ u6574 \\ u56fe \\ u50cf \\ u4f3d \\ u739b \\ u503c \" , \" type \" : \" float \" , \" cur \" :1.000000, \" default \" :1.000000, \" size \" :4, \" range \" :{ \" min \" :0.010000, \" max \" :5.000000}}, \" 35 \" :{ \" category \" : \" base \" , \" name \" : \" grp-3 \" , \" title \" : \" \\ u56fe \\ u50cf \\ u5904 \\ u7406 \" , \" type \" : \" group \" }, \" 36 \" :{ \" category \" : \" base \" , \" name \" : \" is-anti-skew \" , \" title \" : \" \\ u81ea \\ u52a8 \\ u7ea0 \\ u504f \" , \" desc \" : \" \\ u81ea \\ u52a8 \\ u7ea0 \\ u6b63 \\ u6b6a \\ u659c \\ u9001 \\ u5165 \\ u7684 \\ u6587 \\ u7a3f \\ u56fe \\ u50cf \" , \" type \" : \" bool \" , \" cur \" :true, \" default \" :true, \" size \" :4, \" depend_or \" :[ \" 26!= \\ u5bf9 \\ u6298 \" ]}, \" 37 \" :{ \" category \" : \" base \" , \" name \" : \" is-split \" , \" title \" : \" \\ u56fe \\ u50cf \\ u62c6 \\ u5206 \" , \" desc \" : \" \\ u81ea \\ u52a8 \\ u62c6 \\ u5206 \\ u56fe \\ u50cf \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4, \" depend_or \" :[ \" 26!= \\ u5bf9 \\ u6298 \" ]}, \" 38 \" :{ \" category \" : \" base \" , \" name \" : \" is-erase-black-frame \" , \" title \" : \" \\ u6d88 \\ u9
2022-08-12 09:18:38 +00:00
# else
2022-10-11 01:00:46 +00:00
static std : : string jsontext1 ( " { \" device_type \" : \" G402 \" , \" option_count \" :61, \" 1 \" :{ \" category \" : \" base \" , \" name \" : \" restore \" , \" title \" : \" \\ u6062 \\ u590d \\ u9ed8 \\ u8ba4 \\ u8bbe \\ u7f6e \" , \" desc \" : \" \\ u6062 \\ u590d \\ u9ed8 \\ u8ba4 \\ u8bbe \\ u7f6e \" , \" type \" : \" button \" , \" cur \" : \" button \" , \" default \" : \" button \" , \" size \" :0}, \" 2 \" :{ \" category \" : \" advanced \" , \" name \" : \" help \" , \" title \" : \" \\ u5e2e \\ u52a9 \" , \" desc \" : \" \\ u663e \\ u793a \\ u8f6f \\ u4ef6 \\ u5e2e \\ u52a9 \\ u6587 \\ u6863 \" , \" type \" : \" button \" , \" cur \" : \" true \" , \" default \" : \" true \" , \" size \" :4}, \" 3 \" :{ \" category \" : \" base \" , \" name \" : \" grp-1 \" , \" title \" : \" \\ u57fa \\ u672c \\ u8bbe \\ u7f6e \" , \" type \" : \" group \" }, \" 4 \" :{ \" category \" : \" base \" , \" name \" : \" is-multiout \" , \" title \" : \" \\ u591a \\ u6d41 \\ u8f93 \\ u51fa \" , \" desc \" : \" \\ u540c \\ u65f6 \\ u8f93 \\ u51fa \\ u591a \\ u79cd \\ u989c \\ u8272 \\ u6a21 \\ u5f0f \\ u7684 \\ u56fe \\ u50cf \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4}, \" 5 \" :{ \" category \" : \" base \" , \" name \" : \" multiout-type \" , \" title \" : \" \\ u591a \\ u6d41 \\ u8f93 \\ u51fa \\ u7c7b \\ u578b \" , \" desc \" : \" \\ u9009 \\ u62e9 \\ u591a \\ u6d41 \\ u8f93 \\ u51fa \\ u7684 \\ u7c7b \\ u578b \" , \" type \" : \" string \" , \" cur \" : \" \\ u5f69 \\ u8272+ \\ u7070 \\ u5ea6+ \\ u9ed1 \\ u767d \" , \" default \" : \" \\ u5f69 \\ u8272+ \\ u7070 \\ u5ea6+ \\ u9ed1 \\ u767d \" , \" size \" :32, \" range \" :[ \" \\ u5f69 \\ u8272+ \\ u7070 \\ u5ea6+ \\ u9ed1 \\ u767d \" , \" \\ u5f69 \\ u8272+ \\ u7070 \\ u5ea6 \" , \" \\ u5f69 \\ u8272+ \\ u9ed1 \\ u767d \" , \" \\ u7070 \\ u5ea6+ \\ u9ed1 \\ u767d \" ], \" depend_or \" :[ \" 4==true \" ]}, \" 6 \" :{ \" category \" : \" base \" , \" name \" : \" mode \" , \" title \" : \" \\ u989c \\ u8272 \\ u6a21 \\ u5f0f \" , \" desc \" : \" \\ u9009 \\ u62e9 \\ u8272 \\ u5f69 \\ u6a21 \\ u5f0f \" , \" type \" : \" string \" , \" cur \" : \" 24 \\ u4f4d \\ u5f69 \\ u8272 \" , \" default \" : \" 24 \\ u4f4d \\ u5f69 \\ u8272 \" , \" size \" :32, \" range \" :[ \" 24 \\ u4f4d \\ u5f69 \\ u8272 \" , \" 256 \\ u7ea7 \\ u7070 \\ u5ea6 \" , \" \\ u9ed1 \\ u767d \" , \" \\ u989c \\ u8272 \\ u81ea \\ u52a8 \\ u8bc6 \\ u522b \" ], \" depend_or \" :[ \" 4==false \" ]}, \" 7 \" :{ \" category \" : \" base \" , \" name \" : \" binary-threshold \" , \" title \" : \" \\ u9ed1 \\ u767d \\ u56fe \\ u50cf \\ u9608 \\ u503c \" , \" desc \" : \" \\ u9ad8 \\ u4e8e \\ u8be5 \\ u9608 \\ u503c \\ u4e3a1 \\ uff08 \\ u767d \\ uff09 \\ uff0c \\ u4f4e \\ u4e8e \\ u8be5 \\ u9608 \\ u503c \\ u4e3a0 \\ uff08 \\ u9ed1 \\ uff09 \" , \" type \" : \" int \" , \" cur \" :127, \" default \" :127, \" size \" :4, \" range \" :{ \" min \" :0, \" max \" :255}, \" depend_or \" :[ \" 4==true \" , \" 6== \\ u9ed1 \\ u767d \" ]}, \" 8 \" :{ \" category \" : \" base \" , \" name \" : \" reverse-bw \" , \" title \" : \" \\ u9ed1 \\ u767d \\ u56fe \\ u50cf \\ u53cd \\ u8272 \\ u8f93 \\ u51fa \" , \" desc \" : \" \\ u8f93 \\ u51fa \\ u7684 \\ u9ed1 \\ u767d \\ u56fe \\ u50cf \\ u4ee5 \\ u201c1 \\ u201d \\ u4ee3 \\ u8868 \\ u9ed1 \\ u8272 \\ uff0c \\ u201c0 \\ u201d \\ u4ee3 \\ u8868 \\ u767d \\ u8272 \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4, \" depend_or \" :[ \" 4==true \" , \" 6== \\ u9ed1 \\ u767d \" ]}, \" 9 \" :{ \" category \" : \" base \" , \" name \" : \" filter \" , \" title \" : \" \\ u7070 \\ u5ea6 \\ u6216 \\ u9ed1 \\ u767d \\ u56fe \\ u50cf - \\ u9664 \\ u8272 \\ u4e0e \\ u589e \\ u5f3a \" , \" desc \" : \" \\ u6d88 \\ u9664 \\ u6216 \\ u589e \\ u5f3a \\ u6307 \\ u5b9a \\ u8272 \\ u5f69 \" , \" type \" : \" string \" , \" cur \" : \" \\ u4e0d \\ u9664 \\ u8272 \" , \" default \" : \" \\ u4e0d \\ u9664 \\ u8272 \" , \" size \" :24, \" range \" :[ \" \\ u4e0d \\ u9664 \\ u8272 \" , \" \\ u9664 \\ u7ea2 \\ u8272 \" , \" \\ u9664 \\ u7eff \\ u8272 \" , \" \\ u9664 \\ u84dd \\ u8272 \" , \" \\ u7ea2 \\ u8272 \\ u589e \\ u5f3a \" , \" \\ u7eff \\ u8272 \\ u589e \\ u5f3a \" , \" \\ u84dd \\ u8272 \\ u589e \\ u5f3a \" ], \" depend_and \" :[ \" 4!=true \" , \" 6!=24 \\ u4f4d \\ u5f69 \\ u8272 \" , \" 6!= \\ u989c \\ u8272 \\ u81ea \\ u52a8 \\ u8bc6 \\ u522b \" ]}, \" 10 \" :{ \" category \" : \" base \" , \" name \" : \" is-rid-multiout-red \" , \" title \" : \" 24 \\ u4f4d \\ u5f69 \\ u8272 \\ u56fe \\ u50cf - \\ u591a \\ u6d41 \\ u8f93 \\ u51fa \\ u9664 \\ u7ea2 \" , \" desc \" : \" \\ u540c \\ u65f6 \\ u8f93 \\ u51fa \\ u5f69 \\ u8272 \\ u56fe \\ u50cf \\ u548c \\ u7070 \\ u5ea6 \\ u9664 \\ u7ea2 \\ u56fe \\ u50cf \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4, \" depend_and \" :[ \" 4!=true \" , \" 6!=256 \\ u7ea7 \\ u7070 \\ u5ea6 \" , \" 6!= \\ u9ed1 \\ u767d \" , \" 6!= \\ u989c \\ u8272 \\ u81ea \\ u52a8 \\ u8bc6 \\ u522b \" ]}, \" 11 \" :{ \" category \" : \" base \" , \" name \" : \" is-rid-answer-sheet-red \" , \" title \" : \" 24 \\ u4f4d \\ u5f69 \\ u8272 \\ u56fe \\ u50cf - \\ u7b54 \\ u9898 \\ u5361 \\ u9664 \\ u7ea2 \" , \" desc \" : \" \\ u8f93 \\ u51fa \\ u9664 \\ u7ea2 \\ u5f69 \\ u8272 \\ u56fe \\ u50cf \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4, \" depend_an
2022-10-07 09:50:28 +00:00
static std : : string jsontext2 ( " 8mm \\ uff09 \" , \" desc \" : \" \\ u81ea \\ u5b9a \\ u4e49 \\ u626b \\ u63cf \\ u533a \\ u57df \\ u5de6 \\ u4e0a \\ u89d2y \\ u5750 \\ u6807 \" , \" type \" : \" float \" , \" cur \" :0.000000, \" default \" :0.000000, \" size \" :4, \" range \" :{ \" min \" :0.000000, \" max \" :297.000000}, \" depend_and \" :[ \" 21==true \" ]}, \" 25 \" :{ \" category \" : \" base \" , \" name \" : \" br-y \" , \" title \" : \" \\ u626b \\ u63cf \\ u533a \\ u57df \\ u4e0b \\ u4fa7 \\ uff08mm \\ uff09 \" , \" desc \" : \" \\ u81ea \\ u5b9a \\ u4e49 \\ u626b \\ u63cf \\ u533a \\ u57df \\ u53f3 \\ u4e0b \\ u89d2y \\ u5750 \\ u6807 \" , \" type \" : \" float \" , \" cur \" :297.000000, \" default \" :297.000000, \" size \" :4, \" range \" :{ \" min \" :0.000000, \" max \" :297.000000}, \" depend_and \" :[ \" 21==true \" ]}, \" 26 \" :{ \" category \" : \" base \" , \" name \" : \" page \" , \" title \" : \" \\ u626b \\ u63cf \\ u9875 \\ u9762 \" , \" desc \" : \" \\ u8bbe \\ u7f6e \\ u9875 \\ u9762 \\ u626b \\ u63cf \\ u65b9 \\ u5f0f \" , \" type \" : \" string \" , \" cur \" : \" \\ u53cc \\ u9762 \" , \" default \" : \" \\ u53cc \\ u9762 \" , \" size \" :40, \" range \" :[ \" \\ u5355 \\ u9762 \" , \" \\ u53cc \\ u9762 \" , \" \\ u8df3 \\ u8fc7 \\ u7a7a \\ u767d \\ u9875 \\ uff08 \\ u901a \\ u7528 \\ uff09 \" , \" \\ u8df3 \\ u8fc7 \\ u7a7a \\ u767d \\ u9875 \\ uff08 \\ u53d1 \\ u7968 \\ u7eb8 \\ uff09 \" , \" \\ u5bf9 \\ u6298 \" ]}, \" 27 \" :{ \" category \" : \" base \" , \" name \" : \" blank-sensitivity \" , \" title \" : \" \\ u8df3 \\ u8fc7 \\ u7a7a \\ u767d \\ u9875 \\ u7075 \\ u654f \\ u5ea6 \" , \" desc \" : \" \\ u6570 \\ u503c \\ u8d8a \\ u5927 \\ uff0c \\ u5219 \\ u8d8a \\ u5bb9 \\ u6613 \\ u8df3 \\ u8fc7 \" , \" type \" : \" int \" , \" cur \" :50, \" default \" :50, \" size \" :4, \" range \" :{ \" min \" :1, \" max \" :100}, \" depend_or \" :[ \" 26== \\ u8df3 \\ u8fc7 \\ u7a7a \\ u767d \\ u9875 \\ uff08 \\ u53d1 \\ u7968 \\ u7eb8 \\ uff09 \" , \" 26== \\ u8df3 \\ u8fc7 \\ u7a7a \\ u767d \\ u9875 \\ uff08 \\ u901a \\ u7528 \\ uff09 \" ]}, \" 28 \" :{ \" category \" : \" base \" , \" name \" : \" resolution \" , \" title \" : \" \\ u5206 \\ u8fa8 \\ u7387 \" , \" desc \" : \" \\ u8bbe \\ u7f6e \\ u626b \\ u63cf \\ u56fe \\ u50cf \\ u7684 \\ u5206 \\ u8fa8 \\ u7387 \" , \" type \" : \" int \" , \" cur \" :200, \" default \" :200, \" size \" :4, \" range \" :[100,150,200,300]}, \" 29 \" :{ \" category \" : \" base \" , \" name \" : \" is-exchange \" , \" title \" : \" \\ u4ea4 \\ u6362 \\ u6b63 \\ u53cd \\ u9762 \" , \" desc \" : \" \\ u4ea4 \\ u6362 \\ u6bcf \\ u5f20 \\ u6587 \\ u7a3f \\ u7684 \\ u6b63 \\ u53cd \\ u9762 \\ u51fa \\ u56fe \\ u987a \\ u5e8f \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4, \" depend_and \" :[ \" 26!= \\ u5355 \\ u9762 \" ]}, \" 30 \" :{ \" category \" : \" base \" , \" name \" : \" grp-2 \" , \" title \" : \" \\ u4eae \\ u5ea6 \" , \" type \" : \" group \" }, \" 31 \" :{ \" category \" : \" base \" , \" name \" : \" is-custom-gamma \" , \" title \" : \" \\ u542f \\ u7528 \\ u8272 \\ u8c03 \\ u66f2 \\ u7ebf \" , \" desc \" : \" \\ u81ea \\ u5b9a \\ u4e49 \\ u56fe \\ u50cf \\ u8272 \\ u8c03 \\ u6548 \\ u679c \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4}, \" 32 \" :{ \" category \" : \" base \" , \" name \" : \" brightness \" , \" title \" : \" \\ u4eae \\ u5ea6 \\ u503c \" , \" desc \" : \" \\ u8c03 \\ u6574 \\ u56fe \\ u50cf \\ u4eae \\ u5ea6 \" , \" type \" : \" int \" , \" cur \" :128, \" default \" :128, \" size \" :4, \" range \" :{ \" min \" :1, \" max \" :255}}, \" 33 \" :{ \" category \" : \" base \" , \" name \" : \" contrast \" , \" title \" : \" \\ u5bf9 \\ u6bd4 \\ u5ea6 \" , \" desc \" : \" \\ u8c03 \\ u6574 \\ u56fe \\ u50cf \\ u5bf9 \\ u6bd4 \\ u5ea6 \" , \" type \" : \" int \" , \" cur \" :4, \" default \" :4, \" size \" :4, \" range \" :{ \" min \" :1, \" max \" :7}}, \" 34 \" :{ \" category \" : \" base \" , \" name \" : \" gamma \" , \" title \" : \" \\ u4f3d \\ u9a6c \\ u503c \" , \" desc \" : \" \\ u8c03 \\ u6574 \\ u56fe \\ u50cf \\ u4f3d \\ u739b \\ u503c \" , \" type \" : \" float \" , \" cur \" :1.000000, \" default \" :1.000000, \" size \" :4, \" range \" :{ \" min \" :0.010000, \" max \" :5.000000}}, \" 35 \" :{ \" category \" : \" base \" , \" name \" : \" grp-3 \" , \" title \" : \" \\ u56fe \\ u50cf \\ u5904 \\ u7406 \" , \" type \" : \" group \" }, \" 36 \" :{ \" category \" : \" base \" , \" name \" : \" is-anti-skew \" , \" title \" : \" \\ u81ea \\ u52a8 \\ u7ea0 \\ u504f \" , \" desc \" : \" \\ u81ea \\ u52a8 \\ u7ea0 \\ u6b63 \\ u6b6a \\ u659c \\ u9001 \\ u5165 \\ u7684 \\ u6587 \\ u7a3f \\ u56fe \\ u50cf \" , \" type \" : \" bool \" , \" cur \" :true, \" default \" :true, \" size \" :4, \" depend_or \" :[ \" 26!= \\ u5bf9 \\ u6298 \" ]}, \" 37 \" :{ \" category \" : \" base \" , \" name \" : \" is-split \" , \" title \" : \" \\ u56fe \\ u50cf \\ u62c6 \\ u5206 \" , \" desc \" : \" \\ u81ea \\ u52a8 \\ u62c6 \\ u5206 \\ u56fe \\ u50cf \" , \" type \" : \" bool \" , \" cur \" :false, \" default \" :false, \" size \" :4, \" depend_or \" :[ \" 26!= \\ u5bf9 \\ u6298 \" ]}, \" 38 \" :{ \" category \" : \" base \" , \" name \" : \" is-erase-black-frame \" , \" title \" : \" \\ u6d88 \\ u9664 \\ u9ed1 \\ u6846 \" , \" desc \" : \" \\ u6d88 \\ u9664 \\ u6587 \\ u7a3f \\ u8303 \\ u5
2022-07-23 10:01:44 +00:00
# endif
2022-08-12 09:18:38 +00:00
# endif
2022-10-18 08:23:22 +00:00
2022-07-13 10:22:31 +00:00
enum hg_239_setting_item
{
HG_239_SETTING_RESTORE = 1 , // 恢复默认设置
HG_239_SETTING_HELP , // 帮助
HG__239_SETTING_GROUP_1 ,
HG_239_SETTING_COLOR_MODE , // 颜色模式
2022-10-18 08:23:22 +00:00
2022-07-13 10:22:31 +00:00
HG_239_SETTING_ERASE_COLOR , // 除色
HG_239_SETTING_ERASE_MULTI_RED , // 多流输出除红
HG_239_SETTING_ERASE_ANSWER_RED , // 答题卡除红
HG_239_SETTING_ERASE_BACKGROUND , // 移除背景
HG_239_SETTING_ERASE_BKG_RANGE , // 移除背景范围
HG_239_SETTING_NOISE , // 黑白图像噪点优化
HG_239_SETTING_NOISE_SIZE , // 噪点优化尺寸
HG_239_SETTING_PAPER_SIZE , // 纸张尺寸
HG_239_SETTING_CUSTOM_AREA , // 自定义扫描区域
HG_239_SETTING_CUSTOM_AREA_LEFT , // 扫描区域左侧( mm)
HG_239_SETTING_CUSTOM_AREA_RIGHT , // 扫描区域右侧( mm)
HG_239_SETTING_CUSTOM_AREA_TOP , // 扫描区域上侧( mm)
HG_239_SETTING_CUSTOM_AREA_BOTTOM , // 扫描区域下侧( mm)
HG_239_SETTING_PAPER_SIZE_CHECK , // 尺寸检测
HG_239_SETTING_PAGE , // 扫描页面
HG_239_SETTING_SKIP_NILL , // 跳过空白页灵敏度
HG_239_SETTING_RESOLUTION , // 分辨率
HG_239_SETTING_IMG_QUALITY , // 画质
HG_239_SETTING_REVERSE , // 交换正反面
HG_239_SETTING_SPLIT , // 图像拆分
HG_239_SETTING_CORRECT , // 自动纠偏
HG_239_SETTING_ERASE_HOLE , // 穿孔移除
HG_239_SETTING_HOLE_SEARCH , // 穿孔搜索范围
HG__239_SETTING_GROUP_2 ,
HG_239_SETTING_CUSTOM_GAMMA , // 启用色调曲线
HG_239_SETTING_LIGHT , // 亮度
HG_239_SETTING_CONTRAST , // 对比度
HG_239_SETTING_GAMMA , // 伽玛
HG__239_SETTING_GROUP_3 ,
HG_239_SETTING_SHARP , // 锐化与模糊
HG_239_SETTING_ERASE_BLACK_BORDER , // 消除黑框
HG_239_SETTING_SAMPLE , // 深色样张
HG_239_SETTING_THRESHOLD , // 阈值
HG_239_SETTING_ANTI_NOISE , // 背景抗噪等级
HG_239_SETTING_MARGIN , // 边缘缩进
HG_239_SETTING_FILLING , // 背景填充方式
HG_239_SETTING_PERMEATE , // 防止渗透
HG_239_SETTING_PERMEATE_lv , // 防止渗透等级
HG_239_SETTING_REMOVE_MORR , // 去除摩尔纹
HG_239_SETTING_ERROR_EXTENTION , // 错误扩散
HG_239_SETTING_REMOVE_TXTTURE , // 除网纹
HG__239_SETTING_GROUP_4 ,
HG_239_SETTING_ULTRASONIC , // 超声波检测
HG_239_SETTING_STAPLE , // 装订检测
HG_239_SETTING_SCAN_METHOD , // 连续扫描或扫描指定张数
HG_239_SETTING_SCAN_COUNT , // 扫描指定数量
HG_239_SETTING_DIRECTION , // 文稿方向 删除文稿自动识别
HG_239_SETTING_ROTATE , // 背面旋转180°
HG_239_SETTING_FRACTATE , // 折角检测
HG_239_SETTING_FRACTATE_COMPLEX , // 折角检测复杂度
HG_239_SETTING_SCREW , // 歪斜检测
HG_239_SETTING_SCREW_COMPLEX , // 歪斜检测复杂度
2022-10-18 08:23:22 +00:00
2022-07-13 10:22:31 +00:00
HG_239_SETTING_END ,
//暂时屏蔽
HG_239_SETTING_MULTI_OUT = 500 , // 多流输出
} ;
2022-10-18 08:23:22 +00:00
2022-07-13 10:22:31 +00:00
namespace settings402
{
// device status to scanner_err
2022-10-18 08:23:22 +00:00
scanner_err device_status_to_hg_err ( setting3399 : : HGEIntInfo * ds )
2022-07-13 10:22:31 +00:00
{
scanner_err code = SCANNER_ERR_OK ;
2022-10-18 08:23:22 +00:00
if ( ds - > From = = setting3399 : : HGType : : FPGA )
2022-07-13 10:22:31 +00:00
code = SCANNER_ERR_OK ;
2022-10-18 08:23:22 +00:00
else if ( ds - > From = = setting3399 : : HGType : : MtBoard )
2022-07-13 10:22:31 +00:00
{
switch ( ds - > Code )
{
case 0x00002 :
code = SCANNER_ERR_DEVICE_NO_PAPER ;
break ;
case 0x00004 :
code = SCANNER_ERR_DEVICE_COVER_OPENNED ;
break ;
case 0x00008 :
code = SCANNER_ERR_DEVICE_FEEDING_PAPER ;
break ;
case 0x00010 :
code = SCANNER_ERR_DEVICE_PAPER_JAMMED ;
break ;
case 0x00020 :
code = SCANNER_ERR_DEVICE_DOUBLE_FEEDING ;
break ;
case 0x00040 :
code = SCANNER_ERR_DEVICE_STAPLE_ON ;
break ;
case 0x00080 :
code = SCANNER_ERR_DEVICE_PAPER_SKEW ;
break ;
case 0x10000 :
case 0x80000 :
code = SCANNER_ERR_TIMEOUT ;
break ;
case 0x20000 :
code = SCANNER_ERR_DEVICE_SIZE_CHECK ;
break ;
default :
break ;
}
}
2022-10-18 08:23:22 +00:00
else if ( ds - > From = = setting3399 : : HGType : : IMG )
2022-07-13 10:22:31 +00:00
{
if ( ds - > Code = = 1 )
code = SCANNER_ERR_DEVICE_DOGEAR ;
else if ( ds - > Code = = 2 )
code = SCANNER_ERR_DEVICE_SIZE_CHECK ;
}
2022-10-18 08:23:22 +00:00
else if ( ds - > From = = setting3399 : : HGType : : V4L2 )
2022-07-13 10:22:31 +00:00
{
if ( ds - > Code = = 0 )
code = SCANNER_ERR_DEVICE_SCANN_ERROR ;
else if ( ds - > Code = = 1 )
code = SCANNER_ERR_DEVICE_NO_IMAGE ;
}
2022-10-18 08:23:22 +00:00
else if ( ds - > From = = setting3399 : : HGType : : STOPSCAN )
2022-07-13 10:22:31 +00:00
code = SCANNER_ERR_DEVICE_STOPPED ;
return code ;
}
// resolution
static struct
{
float resolution ;
int dev_value ;
} resolution_map [ ] =
{
{ 100.0f , 1 } ,
{ 150.0f , 1 } ,
{ 200.0f , 1 } ,
{ 240.0f , 1 } ,
{ 300.0f , 0 } ,
{ 600.0f , 1 } //临时版本发1 原来发2
} ;
bool is_equal ( float l , float r )
{
return fabs ( l - r ) < .000001f ;
}
int match_best_resolution ( int resolution , bool * exact )
{
int rsl = resolution ,
ind = 0 ;
bool good = true , * r = exact ? exact : & good ;
if ( rsl < = resolution_map [ 0 ] . resolution )
{
ind = 0 ;
}
else if ( rsl > = resolution_map [ ARRAY_SIZE ( resolution_map ) - 1 ] . resolution )
{
ind = ARRAY_SIZE ( resolution_map ) - 1 ;
}
else
{
for ( int i = 1 ; i < ARRAY_SIZE ( resolution_map ) ; + + i )
{
if ( is_equal ( rsl , resolution_map [ i ] . resolution ) )
{
ind = i ;
break ;
}
if ( rsl < resolution_map [ i ] . resolution )
{
float dif_l = rsl - resolution_map [ i - 1 ] . resolution ,
dif_r = resolution_map [ i ] . resolution - rsl ;
if ( dif_l > dif_r )
ind = i ;
else
ind = i - 1 ;
break ;
}
}
}
* r = is_equal ( rsl , resolution_map [ ind ] . resolution ) ;
return ind ;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// class ...
hg_scanner_402 : : hg_scanner_402 ( const char * dev_name , int pid , usb_io * io ) : hg_scanner ( G20039Serial , dev_name , io )
2022-10-17 10:15:29 +00:00
, rewrite_conf_ ( false ) , reset_ ( false )
2022-07-13 10:22:31 +00:00
{
2022-10-17 10:15:29 +00:00
pid_ = pid ;
2022-07-13 10:22:31 +00:00
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " hg_scanner_402(%s) constructing ... \n " , hg_log : : format_ptr ( this ) . c_str ( ) ) ;
dev_conf_ . value = 0 ;
# ifndef MAPPING_FUNCTION_IN_BASE
init_setting_map ( setting_map_ , ARRAY_SIZE ( setting_map_ ) ) ;
# endif
2022-08-13 01:29:00 +00:00
if ( init_settings ( 0x402 ) )
2022-10-07 09:50:28 +00:00
init_settings ( ( jsontext1 + jsontext2 ) . c_str ( ) ) ;
2022-07-13 10:22:31 +00:00
writedown_device_configuration ( ) ; // initialize the hardware settings
init_version ( ) ;
}
hg_scanner_402 : : ~ hg_scanner_402 ( )
{
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " hg_scanner_402(%s) destroyed. \n " , hg_log : : format_ptr ( this ) . c_str ( ) ) ;
}
int hg_scanner_402 : : read_register ( int addr , int * val )
{
std : : lock_guard < std : : mutex > lock ( io_lock_ ) ;
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 50 ) ) ;
int l = sizeof ( * val ) ,
ret = io_ - > control_io ( 0x0c0 , USB_REQ_GET_DEV_REGS , addr , 0 , val , & l ) ;
if ( ret )
status_ = ret ;
return ret ;
}
int hg_scanner_402 : : write_register ( int addr , int val )
{
std : : lock_guard < std : : mutex > lock ( io_lock_ ) ;
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 50 ) ) ;
int l = sizeof ( val ) ,
ret = io_ - > control_io ( 0x040 , USB_REQ_SET_DEV_REGS , addr , 0 , & val , & l ) ;
if ( ret )
status_ = ret ;
return ret ;
}
int hg_scanner_402 : : write_command ( int cmd )
{
return write_register ( 0 , cmd ) ;
}
std : : string hg_scanner_402 : : control_fetch ( int addr , int val , int size )
{
int l = sizeof ( val ) ,
ret = 0 ;
std : : string data ( " " ) ;
ret = write_register ( addr , val ) ;
if ( ret = = SCANNER_ERR_OK )
{
std : : lock_guard < std : : mutex > lock ( io_lock_ ) ;
l = size + 1 ;
data . resize ( size + 2 ) ;
bzero ( & data [ 0 ] , size + 2 ) ;
ret = io_ - > read_bulk ( & data [ 0 ] , & l ) ;
2022-07-14 06:21:53 +00:00
if ( ret = = SCANNER_ERR_OK )
{
VLOG_MINI_3 ( LOG_LEVEL_DEBUG_INFO , " control_fetch(%d, %d) - read_bulk %d bytes \n " , addr , val , l ) ;
}
else
2022-07-13 10:22:31 +00:00
{
VLOG_MINI_3 ( LOG_LEVEL_DEBUG_INFO , " control_fetch(%d, %d) - read_bulk = %s \n " , addr , val , hg_scanner_err_name ( ret ) ) ;
data . clear ( ) ;
}
}
else
VLOG_MINI_3 ( LOG_LEVEL_DEBUG_INFO , " control_fetch(%d, %d) = %s \n " , addr , val , hg_scanner_err_name ( ret ) ) ;
return data ;
}
std : : string hg_scanner_402 : : get_fpga ( void )
{
int val = 0 ,
2022-10-18 08:23:22 +00:00
ret = read_register ( setting3399 : : SR_GET_MBVERSION_LENGHT , & val ) ;
2022-07-13 10:22:31 +00:00
std : : string fpga ( " " ) ;
if ( ret = = SCANNER_ERR_OK )
{
fpga . resize ( val + 2 ) ;
bzero ( & fpga [ 0 ] , val + 2 ) ;
2022-10-18 08:23:22 +00:00
return control_fetch ( setting3399 : : SR_GET_MBVERSION , 0 , val ) ;
2022-07-13 10:22:31 +00:00
}
return fpga ;
}
int hg_scanner_402 : : clr_roller_num ( void )
{
int val = 0 ,
2022-10-18 08:23:22 +00:00
ret = read_register ( setting3399 : : SR_CLR_ROLLER_NUM , & val ) ;
2022-07-13 10:22:31 +00:00
if ( ret = = SCANNER_ERR_OK )
return val ;
else
{
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " clr_roller_num = %s \n " , hg_scanner_err_name ( ret ) ) ;
return - 1 ;
}
}
int hg_scanner_402 : : get_sleep_time ( void )
{
int val = 0 ,
2022-10-18 08:23:22 +00:00
ret = read_register ( setting3399 : : SR_GET_SLEEPTIME , & val ) ;
2022-07-13 10:22:31 +00:00
if ( ret = = SCANNER_ERR_OK )
return val ;
else
{
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " get_sleep_time = %s \n " , hg_scanner_err_name ( ret ) ) ;
return - 1 ;
}
}
int hg_scanner_402 : : get_scan_mode ( void )
{
int val = 0 ,
2022-10-18 08:23:22 +00:00
ret = read_register ( setting3399 : : SR_OS , & val ) ;
2022-07-13 10:22:31 +00:00
if ( ret )
{
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " get scan mode error: %s \n " , hg_scanner_err_name ( ret ) ) ;
status_ = ret ;
return - 1 ;
}
else
return val ;
}
int hg_scanner_402 : : get_status ( void )
{
int val = 0 ,
2022-10-18 08:23:22 +00:00
ret = read_register ( setting3399 : : SR_STATUS , & val ) ;
2022-07-13 10:22:31 +00:00
if ( ret )
{
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " get status error: %s \n " , hg_scanner_err_name ( ret ) ) ;
status_ = ret ;
return - 1 ;
}
else
return val ;
}
bool hg_scanner_402 : : is_dev_tx ( void )
{
int val = 0 ,
2022-10-18 08:23:22 +00:00
ret = read_register ( setting3399 : : SR_STATUS , & val ) ;
2022-07-13 10:22:31 +00:00
if ( ret )
{
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " is_dev_tx() error: %s \n " , hg_scanner_err_name ( ret ) ) ;
status_ = ret ;
return false ;
}
else
return val ;
}
bool hg_scanner_402 : : is_dev_image_process_done ( void )
{
int val = 0 ,
2022-10-18 08:23:22 +00:00
ret = read_register ( setting3399 : : SR_GET_IMAGEPROCESSDONE , & val ) ;
2022-07-13 10:22:31 +00:00
if ( ret )
{
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " is_dev_image_process_done() error: %s \n " , hg_scanner_err_name ( ret ) ) ;
status_ = ret ;
return true ;
}
else
return val ;
}
bool hg_scanner_402 : : is_dev_image_keep_last_paper ( void )
{
int val = 0 ,
2022-10-18 08:23:22 +00:00
ret = read_register ( setting3399 : : SR_GET_KEEP_LAST_PAPER , & val ) ;
2022-07-13 10:22:31 +00:00
if ( ret )
{
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " is_dev_image_keep_last_paper() error: %s \n " , hg_scanner_err_name ( ret ) ) ;
status_ = ret ;
return true ;
}
else
return val ;
}
int hg_scanner_402 : : get_scanned_count ( void )
{
int val = 0 ,
2022-10-18 08:23:22 +00:00
ret = read_register ( setting3399 : : SR_GET_SCANN_NUM , & val ) ;
2022-07-13 10:22:31 +00:00
if ( ret = = SCANNER_ERR_OK )
return val ;
else
{
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " get_scanned_count = %s \n " , hg_scanner_err_name ( ret ) ) ;
return - 1 ;
}
}
int hg_scanner_402 : : get_image_count ( void )
{
int val = 0 ,
2022-10-18 08:23:22 +00:00
ret = read_register ( setting3399 : : SR_IM_COUNT , & val ) ;
2022-07-13 10:22:31 +00:00
VLOG_MINI_2 ( LOG_LEVEL_DEBUG_INFO , " get_image_count() = %d, error: %s \n " , val , hg_scanner_err_name ( ret ) ) ;
if ( ret = = SCANNER_ERR_OK )
return val ;
else
return - 1 ;
}
int hg_scanner_402 : : get_front_data_size ( void )
{
int val = 0 ,
2022-10-18 08:23:22 +00:00
ret = read_register ( setting3399 : : SR_IM_FRONT_SIZE , & val ) ;
2022-07-13 10:22:31 +00:00
if ( ret = = SCANNER_ERR_OK )
return val ;
else
{
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " get_front_data_size = %s \n " , hg_scanner_err_name ( ret ) ) ;
return - 1 ;
}
}
void hg_scanner_402 : : init_version ( void )
{
std : : string fv ( get_firmware_version ( ) ) ,
sn ( get_serial_num ( ) ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " HG3399 firmware version: %s \n " , fv . c_str ( ) ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " HG3399 serial number: %s \n " , sn . c_str ( ) ) ;
//VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, " HG3399 IP: %s\n", get_ip().c_str());
if ( fv . length ( ) > = 10 & & ( fv [ 5 ] > ' A ' | | atoi ( fv . substr ( 6 , 4 ) . c_str ( ) ) > = 1209 ) )
{
is_kernelsnap_211209_ = atoi ( get_fpga ( ) . c_str ( ) ) > = 35211210 ;
}
else
is_kernelsnap_211209_ = false ;
}
void hg_scanner_402 : : image_process ( std : : shared_ptr < tiny_buffer > & buff )
{
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " Process image with %u bytes content ... \n " , buff - > size ( ) ) ;
2022-07-15 08:04:09 +00:00
hg_imgproc : : HIMGPRC handle = get_image_process_object ( pid_ ) ;
2022-07-13 10:22:31 +00:00
hg_imgproc : : IMGHEAD ih ;
int err = SCANNER_ERR_OK ,
index = 0 ;
void * buf = NULL ;
err = hg_imgproc : : load_buffer ( handle , buff ) ;
err = hg_imgproc : : decode ( handle , pid_ ) ;
2022-07-14 06:21:53 +00:00
VLOG_MINI_3 ( LOG_LEVEL_DEBUG_INFO , " Image process parameter: 0x%x%08x, multi out: %s \n " , ( ( unsigned int * ) & image_prc_param_ . value ) [ 1 ] , ( ( unsigned int * ) & image_prc_param_ . value ) [ 0 ] , is_multiout ? " true " : " false " ) ;
2022-09-19 03:50:40 +00:00
2022-09-11 15:56:27 +00:00
if ( isremove_left_hole | | isremove_right_hole | | isremove_top_hole | | isremove_low_hole )
{
err = hg_imgproc : : fillhole ( handle , isremove_top_hole_threshold , isremove_low_hole_threshold , isremove_left_hole_threshold , isremove_right_hole_threshold ) ;
2022-07-14 06:21:53 +00:00
}
/////////////////////////////////////111111111111111111111111111//////////////////////////////////
err = hg_imgproc : : auto_crop ( handle ) ;
if ( img_conf_ . is_autodiscradblank_normal | | img_conf_ . is_autodiscradblank_vince )
{
err = hg_imgproc : : discardBlank ( handle ) ;
printf ( " 丢弃空白页开启 \r \n " ) ;
//VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "丢弃空白页开启:%s\n",hg_scanner_err_name(ret));
}
if ( img_conf_ . fadeback )
{
2022-10-20 06:58:26 +00:00
hg_imgproc : : fadeback ( handle ) ;
2022-07-14 06:21:53 +00:00
//printf("背景除色开启\r\n");
//VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "背景除色开启:%s\n",hg_scanner_err_name(ret));
}
if ( img_conf_ . resolution_dst ! = img_conf_ . resolution_native )
{
hg_imgproc : : resolution_change ( handle ) ;
//printf("dpi改变开启\r\n");
//VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "dpi改变开启:%s\n",hg_scanner_err_name(ret));
}
if ( img_conf_ . cropRect . enable & & ! img_conf_ . is_autocrop )
{
hg_imgproc : : croprect ( handle ) ;
//printf("手动裁图开启\r\n");
//VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "手动裁图开启:%s\n",hg_scanner_err_name(ret));
}
if ( img_conf_ . filter ! = ColorFilter : : FILTER_NONE & & ( img_conf_ . pixtype = = COLOR_MODE_BLACK_WHITE | | img_conf_ . pixtype = = COLOR_MODE_256_GRAY ) )
{
printf ( " 除色开启 \r \n " ) ;
hg_imgproc : : channel ( handle ) ;
//VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "除色开启:%s\n",hg_scanner_err_name(ret));
}
/////////////////////////////////////2222222222222222222222222222222222222//////////////////////////////////
2022-07-15 08:04:09 +00:00
adjust_color ( handle ) ;
2022-07-14 06:21:53 +00:00
if ( img_conf_ . pixtype = = COLOR_MODE_24_BITS & & img_conf_ . hsvcorrect )
{
hg_imgproc : : answerSheetFilterRed ( handle ) ;
//printf("答题卡出红开启\r\n");
//VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "答题卡出红开启:%s\n",hg_scanner_err_name(ret));
}
if ( img_conf_ . refuseInflow )
{
int lv = 5 ;
if ( image_prc_param_ . bits . is_permeate_lv_ = = 0 )
lv = 5 ;
else if ( image_prc_param_ . bits . is_permeate_lv_ = = 1 )
lv = 15 ;
else if ( image_prc_param_ . bits . is_permeate_lv_ = = 2 )
lv = 25 ;
else if ( image_prc_param_ . bits . is_permeate_lv_ = = 3 )
lv = 35 ;
else if ( image_prc_param_ . bits . is_permeate_lv_ = = 4 )
lv = 45 ;
hg_imgproc : : antiInflow ( handle , lv ) ;
}
if ( img_conf_ . colorCorrection & & img_conf_ . pixtype ! = COLOR_MODE_BLACK_WHITE )
{
hg_imgproc : : colorCorrection ( handle ) ;
//printf("颜色校正开启\r\n");
//VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "颜色校正开启:%s\n",hg_scanner_err_name(ret));
}
if ( ( img_conf_ . imageRotateDegree ! = TEXT_DIRECTION_0 | | img_conf_ . is_backrotate180 ) & & ( ! img_conf_ . is_autotext ) )
{
printf ( " 手动旋转开启 \r \n " ) ;
hg_imgproc : : orentation ( handle ) ;
}
if ( img_conf_ . removeMorr )
{
hg_imgproc : : textureRemove ( handle ) ;
//printf("除摩尔纹开启\r\n");
//VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "除摩尔纹开启:%s\n",hg_scanner_err_name(ret));
}
if ( img_conf_ . detachnoise . is_detachnoise )
{
hg_imgproc : : nosieDetach ( handle ) ;
//printf("噪点优化开启\r\n");
//VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "噪点优化开启:%s\n",hg_scanner_err_name(ret));
}
if ( img_conf_ . pixtype = = COLOR_MODE_BLACK_WHITE )
{
hg_imgproc : : errorextention ( handle ) ;
//printf("黑白图处理开启\r\n");
//VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "黑白图处理开启:%s\n",hg_scanner_err_name(ret));
}
if ( img_conf_ . en_fold )
{
hg_imgproc : : fold ( handle ) ;
//printf("对折开启\r\n");
//VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "对折开启:%s\n",hg_scanner_err_name(ret));
}
///////////////////////////////////
2022-08-20 03:18:34 +00:00
if ( img_conf_ . multi_output_red & & img_conf_ . pixtype = = COLOR_MODE_24_BITS )
2022-07-14 06:21:53 +00:00
{
err = hg_imgproc : : multi_out_red ( handle ) ;
//printf("多流出红开启\r\n");
//VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "多流出红开启:%s\n",hg_scanner_err_name(ret));
}
if ( img_conf_ . sharpen )
{
hg_imgproc : : sharpenType ( handle ) ;
}
2022-08-20 03:18:34 +00:00
if ( img_conf_ . fadeback )
2022-07-13 10:22:31 +00:00
{
2022-10-20 06:58:26 +00:00
err = hg_imgproc : : fadeback ( handle ) ;
2022-07-13 10:22:31 +00:00
}
2022-08-20 03:18:34 +00:00
if ( img_conf_ . multi_output_red & & img_conf_ . pixtype = = COLOR_MODE_24_BITS )
2022-07-13 10:22:31 +00:00
err = hg_imgproc : : multi_out_red ( handle ) ;
2022-08-20 03:18:34 +00:00
if ( img_conf_ . splitImage )
2022-07-13 10:22:31 +00:00
{
2022-08-04 07:01:27 +00:00
//split3399_++;
2022-07-13 10:22:31 +00:00
int colormode = 1 ;
if ( img_conf_ . filter = = RID_COLOR_NONE )
colormode = img_conf_ . pixtype ;
2022-10-20 06:58:26 +00:00
err = hg_imgproc : : split ( handle , - 1 ) ;
2022-07-13 10:22:31 +00:00
VLOG_MINI_5 ( LOG_LEVEL_DEBUG_INFO , " img split-> multiOutput is:%d splitImage is:%d multi_output_red is:%d pixtype is:%d is_duplex:%d \r \n "
, img_conf_ . multiOutput
, img_conf_ . splitImage
, img_conf_ . multi_output_red
, img_conf_ . pixtype
, img_conf_ . is_duplex ) ;
}
2022-08-20 03:18:34 +00:00
if ( ! img_conf_ . splitImage | | ! img_conf_ . multi_output_red | | ! is_multiout )
2022-07-13 10:22:31 +00:00
{
if ( img_conf_ . automaticcolor )
{
hg_imgproc : : auto_matic_color ( handle , img_conf_ . automaticcolortype ) ;
}
}
if ( img_conf_ . is_autotext )
{
printf ( " 文本方向自动识别 \r \n " ) ;
hg_imgproc : : ocr_auto_txtdirect ( handle ) ;
}
if ( is_quality_ = = IMG_SPEED & & resolution_ > = 300 )
{
err = hg_imgproc : : quality ( handle , resolution_ ) ;
}
//多流输出最后处理
if ( is_multiout )
{
2022-08-20 03:18:34 +00:00
int multi_out = img_conf_ . multiOutput ;
2022-07-13 10:22:31 +00:00
err = hg_imgproc : : multi_out ( handle , multi_out ) ;
}
hg_imgproc : : final ( handle ) ;
2022-08-04 01:36:46 +00:00
while ( hg_imgproc : : get_final_data ( handle , & ih , & buf , index + + ) = = SCANNER_ERR_OK )
2022-07-13 10:22:31 +00:00
{
VLOG_MINI_5 ( LOG_LEVEL_DEBUG_INFO , " Final picture %d (%d * %d * %d) with %u bytes! \n " , index
, ih . width , ih . height , ih . bits * ih . channels , ih . total_bytes ) ;
if ( ! img_type_ . empty ( ) )
{
std : : vector < unsigned char > bmpdata ;
hg_imgproc : : imgtypechange ( handle , img_type_ , buf , bmpdata ) ;
//cv::imencode(img_type_,*((cv::Mat*)buf),bmpdata);
if ( bmpdata . empty ( ) )
{
status_ = SCANNER_ERR_NO_DATA ;
return ;
}
buf = bmpdata . data ( ) ;
ih . total_bytes = bmpdata . size ( ) ;
VLOG_MINI_6 ( LOG_LEVEL_DEBUG_INFO , " Set img type is:%s Final picture %d (%d * %d * %d) with %u bytes! \n " , img_type_ . c_str ( ) , index
, ih . width , ih . height , ih . bits * ih . channels , ih . total_bytes ) ;
}
save_final_image ( & ih , buf ) ;
}
hg_imgproc : : release ( handle ) ;
}
int hg_scanner_402 : : get_device_sleep_stautus ( void )
{
2022-10-18 08:23:22 +00:00
int ret = read_register ( setting3399 : : SR_GET_SLEEP_STAUTUS , 0 ) ;
2022-07-13 10:22:31 +00:00
return ret ;
}
int hg_scanner_402 : : get_device_paperon_stautus ( void )
{
2022-10-18 08:23:22 +00:00
int ret = read_register ( setting3399 : : SR_GET_PAPERON , 0 ) ;
2022-07-13 10:22:31 +00:00
return ret ;
}
// int hg_scanner_402::writedown_device_configuration()
// {
// int ret = SCANNER_ERR_OK;
// ret = write_register(SR_CONFIG_SCAN_PARAM, dev_conf_.value);
// VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Writedown scanner configuration(0x%x) = %s\n", dev_conf_.value, hg_scanner_err_name(ret));
// return ret;
// }
2022-10-18 08:23:22 +00:00
int hg_scanner_402 : : writedown_device_configuration ( setting_hardware : : HGSCANCONF_3399 * dev_conf )
2022-07-13 10:22:31 +00:00
{
int ret = SCANNER_ERR_OK ;
2022-07-25 02:38:20 +00:00
if ( ! dev_conf )
{
2022-10-18 08:23:22 +00:00
dev_conf_ . params_3399 . is_textcorrect = ! keep_watermark_ ;
2022-07-13 10:22:31 +00:00
dev_conf = & dev_conf_ ;
2022-07-25 02:38:20 +00:00
}
2022-07-13 10:22:31 +00:00
2022-10-18 08:23:22 +00:00
ret = write_register ( setting3399 : : SR_CONFIG_SCAN_PARAM , dev_conf - > value ) ;
2022-07-13 10:22:31 +00:00
VLOG_MINI_2 ( LOG_LEVEL_DEBUG_INFO , " Writedown scanner configuration(0x%x) = %s \n " , dev_conf - > value , hg_scanner_err_name ( ret ) ) ;
return ret ;
}
int hg_scanner_402 : : writedown_image_configuration ( void )
{
2022-07-14 06:21:53 +00:00
//int ret = write_register(SR_CONFIF_IMGPROCPARAM, sizeof(SCANCONF));
//if (ret != SCANNER_ERR_OK)
// return ret;
2022-07-13 10:22:31 +00:00
2022-07-14 06:21:53 +00:00
int ret = SCANNER_ERR_OK ;
2022-07-13 10:22:31 +00:00
SCANCONF ic ;
2022-07-14 06:21:53 +00:00
int len = sizeof ( ic ) ;
2022-07-13 10:22:31 +00:00
bzero ( & ic , len ) ;
ic . papertype = paper_size_ ;
2022-07-14 06:21:53 +00:00
if ( is_lateral ( image_prc_param_ . bits . paper ) )
ic . paperAlign = Rot270 ;
// else if (image_prc_param_.bits.text_direction == TEXT_DIRECTION_AUTO)
// ic.paperAlign = AutoTextOrientation;
else
ic . paperAlign = Rot0 ;
2022-07-13 10:22:31 +00:00
2022-10-18 08:23:22 +00:00
ic . en_sizecheck = dev_conf_ . params_3399 . enable_sizecheck ;
2022-07-13 10:22:31 +00:00
2022-07-14 06:21:53 +00:00
if ( image_prc_param_ . bits . text_direction ! = TEXT_DIRECTION_AUTO )
ic . imageRotateDegree = ( float ) image_prc_param_ . bits . text_direction ;
else
ic . imageRotateDegree = 0 ;
2022-07-13 10:22:31 +00:00
2022-07-14 06:21:53 +00:00
ic . is_duplex = ( image_prc_param_ . bits . page = = PAGE_DOUBLE
| | image_prc_param_ . bits . page = = PAGE_OMIT_EMPTY
| | image_prc_param_ . bits . page = = PAGE_OMIT_EMPTY_RECEIPT
| | image_prc_param_ . bits . page = = PAGE_FOLIO ) ;
2022-07-13 10:22:31 +00:00
2022-07-14 06:21:53 +00:00
ic . en_fold = ( image_prc_param_ . bits . page = = PAGE_FOLIO ) ;
ic . pixtype = image_prc_param_ . bits . color_mode = = COLOR_MODE_AUTO_MATCH ? 2 : image_prc_param_ . bits . color_mode ;
ic . automaticcolor = is_auto_matic_color ;
2022-07-13 10:22:31 +00:00
2022-07-14 06:21:53 +00:00
ic . automaticcolortype = 1 ; // ic.pixtype; //存疑
if ( resolution_ > = 300 )
2022-07-13 10:22:31 +00:00
{
2022-07-14 06:21:53 +00:00
if ( is_quality_ = = IMG_SPEED )
{
ic . resolution_dst = 200 ;
}
else if ( is_quality_ = = IMG_QUALITY )
{
ic . resolution_dst = resolution_ ;
}
2022-08-05 01:30:51 +00:00
else
{
ic . resolution_dst = resolution_ ;
}
2022-07-13 10:22:31 +00:00
}
2022-07-14 06:21:53 +00:00
else
2022-07-13 10:22:31 +00:00
{
ic . resolution_dst = resolution_ ;
}
ic . resolution_native = 200.0f ;
ic . gamma = ( float ) gamma_ ;
ic . contrast = ( contrast_ - 4 ) * 333.0 ;
ic . brightness = ( bright_ - 128 ) * ( 2000.0 / 254.0 ) ;
ic . threshold = threshold_ ;
ic . is_autocontrast = 0 ; //无参数
ic . is_autocrop = ( ic . papertype = = TwSS : : None | | ic . papertype = = TwSS : : USStatement ) ;
ic . is_autodiscradblank_normal = image_prc_param_ . bits . page = = PAGE_OMIT_EMPTY ;
ic . discardblank_percent = omit_empty_level_ > = 70 ? 70 : omit_empty_level_ ;
ic . is_autodiscradblank_vince = image_prc_param_ . bits . page = = PAGE_OMIT_EMPTY_RECEIPT ;
ic . is_switchfrontback = image_prc_param_ . bits . exchange ;
ic . autodescrew = image_prc_param_ . bits . automatic_skew ;
2022-08-20 03:18:34 +00:00
ic . multi_output_red = image_prc_param_ . bits . rid_red ;
2022-07-13 10:22:31 +00:00
ic . hsvcorrect = image_prc_param_ . bits . rid_answer_red ;
ic . sharpen = image_prc_param_ . bits . sharpen ;
ic . enhance_color = image_prc_param_ . bits . rid_color ;
ic . fillbackground = image_prc_param_ . bits . erase_black_frame ;
ic . is_convex = ( image_prc_param_ . bits . fill_background = = FILL_BKG_CONVEX_POLYGON ) ;
ic . noise = image_prc_param_ . bits . noise_optimize ;
ic . indent = margin_ ;
ic . AutoCrop_threshold = threshold_ ;
if ( test_1_paper_ )
{
LOG_INFO ( LOG_LEVEL_DEBUG_INFO , " scanning mode: testing ONE paper ... \n " ) ;
2022-08-12 03:16:21 +00:00
ic . scannum = /*ic.is_duplex ? 2 :*/ 1 ;
2022-07-13 10:22:31 +00:00
}
else
{
2022-08-22 06:32:02 +00:00
if ( scan_count_ = = - 1 )
ic . scannum = - 1 ;
else
ic . scannum = scan_count_ ; // (ic.is_duplex ? scan_count_ * 2 : scan_count_);
2022-07-13 10:22:31 +00:00
}
ic . is_backrotate180 = image_prc_param_ . bits . rotate_back_180 ;
ic . is_dogeardetection = image_prc_param_ . bits . fractate_check ;
2022-10-18 08:23:22 +00:00
ic . hardwarecaps . en_skrewdetect = dev_conf_ . params_3399 . screw_detect_enable ;
ic . hardwarecaps . en_doublefeed = dev_conf_ . params_3399 . ultrasonic_enable ;
ic . hardwarecaps . en_stapledetect = dev_conf_ . params_3399 . staple_enbale ;
ic . hardwarecaps . skrewdetectlevel = dev_conf_ . params_3399 . screw_detect_level ;
// ic.hardwarecaps.is_autopaper = dev_conf_.params_3399.is_autopaper;
2022-07-13 10:22:31 +00:00
ic . hardwarecaps . capturepixtype = 0 ; //暂无参数 获取图像类型
ic . hardwarecaps . lowpowermode = LowPowerMode : : Min_None ; //暂无参数 设置休眠时间 两个参数3399未使用
ic . fillhole . is_fillhole = image_prc_param_ . bits . rid_hole ;
ic . fillhole . fillholeratio = rid_hole_range_ ;
2022-09-12 04:27:25 +00:00
adjust_filling_hole ( & ic ) ;
2022-07-13 10:22:31 +00:00
ic . detachnoise . is_detachnoise = image_prc_param_ . bits . noise_optimize ;
ic . detachnoise . detachnoise = noise_range_ ;
ic . is_autotext = image_prc_param_ . bits . text_direction = = TEXT_DIRECTION_AUTO ? 1 : 0 ;
ic . isfillcolor = is_color_fill ;
ic . refuseInflow = image_prc_param_ . bits . is_permeate ;
ic . colorCorrection = 0 ;
ic . removeMorr = image_prc_param_ . bits . remove_morr ;
ic . errorExtention = image_prc_param_ . bits . error_extention ; //
ic . textureRemove = image_prc_param_ . bits . remove_txtture ; //
ic . splitImage = image_prc_param_ . bits . split ;
{
ic . cropRect . enable = custom_area_ ;
int height = ( custom_area_br_y_ * ic . resolution_dst ) / 25.4 - ( custom_area_lt_y_ * ic . resolution_dst / 25.4 ) ;
int width = ( custom_area_br_x_ * ic . resolution_dst ) / 25.4 - ( custom_area_lt_x_ * ic . resolution_dst / 25.4 ) ;
ic . cropRect . height = height ;
ic . cropRect . width = width ;
ic . cropRect . x = custom_area_lt_x_ * ic . resolution_dst / 25.4 ;
ic . cropRect . y = custom_area_lt_y_ * ic . resolution_dst / 25.4 ;
}
ic . multiOutput = ( MultiOutput ) image_prc_param_ . bits . multi_out ;
2022-08-20 03:18:34 +00:00
if ( ! is_multiout )
{
ic . multiOutput = MultiOutput : : Unused ;
}
2022-07-13 10:22:31 +00:00
ic . normalCrop = image_prc_param_ . bits . dark_sample ;
ic . dogeardistabce = fractate_level_ ;
ic . fadeback = image_prc_param_ . bits . erase_bakground ;
ic . fadebackrange = erase_bkg_range_ ;
2022-07-28 06:03:20 +00:00
ic . isuoloadexceptionimage = ( double_paper_handle_ & DOUBLE_PAPER_SAVE_IMG ) = = DOUBLE_PAPER_SAVE_IMG ;
2022-07-13 10:22:31 +00:00
int filter_clr [ ] = { 3 , 0 , 1 , 2 , 5 , 6 , 7 } ;
if ( image_prc_param_ . bits . color_mode = = COLOR_MODE_24_BITS | | image_prc_param_ . bits . color_mode = = COLOR_MODE_AUTO_MATCH )
ic . filter = 3 ;
else
{
2022-08-20 03:18:34 +00:00
ic . filter = filter_clr [ ic . enhance_color ] ;
2022-07-13 10:22:31 +00:00
// if(ic.filter != 3)
// ic.pixtype = 2;
ic . hsvcorrect = 0 ;
ic . multi_output_red = 0 ;
ic . multiOutput = MultiOutput : : Unused ;
}
//多留输出的处理
2022-08-20 03:18:34 +00:00
if ( ic . multiOutput = = MULTI_GRAY_AND_BW & & is_multiout )
2022-07-13 10:22:31 +00:00
{
ic . pixtype = 1 ;
}
2022-08-20 03:18:34 +00:00
else if ( ( ic . multiOutput = = MULTI_OUT_ALL | | ic . multiOutput = = MULTI_COLOR_AND_GRAY | | ic . multiOutput = = MULTI_COLOR_AND_BW ) & & is_multiout )
2022-07-13 10:22:31 +00:00
{
ic . pixtype = 2 ;
}
if ( is_multiout )
{
ic . hsvcorrect = 0 ;
ic . multi_output_red = 0 ;
ic . fadeback = false ;
ic . sharpen = 0 ;
ic . removeMorr = 0 ;
ic . textureRemove = 0 ;
ic . errorExtention = 0 ;
ic . detachnoise . is_detachnoise = 0 ;
}
if ( ic . pixtype = = 0 )
{
ic . hsvcorrect = 0 ;
ic . multi_output_red = 0 ;
ic . fadeback = false ;
ic . sharpen = 0 ;
ic . removeMorr = 0 ;
ic . textureRemove = 0 ;
}
//自定义裁切
if ( image_prc_param_ . bits . paper = = PAPER_AUTO_MATCH
| | image_prc_param_ . bits . paper = = PAPER_MAX_SIZE
| | image_prc_param_ . bits . paper = = PAPER_MAX_SIZE_CLIP
| | image_prc_param_ . bits . paper = = PAPER_TRIGEMINY
)
{
ic . cropRect . enable = false ;
}
2022-07-14 06:21:53 +00:00
//{
// std::lock_guard<std::mutex> lock(io_lock_);
//
// ret = io_->write_bulk(&ic, &len);
//
// this_thread::sleep_for(chrono::milliseconds(500));
// io_->set_timeout(2000);//必要延时
//}
2022-07-13 10:22:31 +00:00
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " Write-down 0x%x bytes image process parameters \n " , len ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.pixtype=%d " , ic . pixtype ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.papertype=%d " , ic . papertype ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.AutoCrop_threshold=%d " , ic . AutoCrop_threshold ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.autodescrew=%d " , ic . autodescrew ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.automaticcolor=%d " , ic . automaticcolor ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.brightness=%f " , ic . brightness ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.contrast=%f " , ic . contrast ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.en_fold=%d " , ic . en_fold ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.en_sizecheck=%d " , ic . en_sizecheck ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.enhance_color=%d " , ic . enhance_color ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.fillbackground=%d " , ic . fillbackground ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.filter=%d " , ic . filter ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.gamma=%f " , ic . gamma ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.hardwarecaps.capturepixtype=%d " , ic . hardwarecaps . capturepixtype ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.hardwarecaps.en_doublefeed=%d " , ic . hardwarecaps . en_doublefeed ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.hsvcorrect=%d " , ic . hsvcorrect ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.imageRotateDegree=%f " , ic . imageRotateDegree ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.indent=%d " , 5 ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.is_autocontrast=%d " , ic . is_autocontrast ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.is_autocrop=%d " , ic . is_autocrop ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.is_autodiscradblank_normal=%d " , ic . is_autodiscradblank_normal ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.is_autodiscradblank_vince=%d " , ic . is_autodiscradblank_vince ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.is_autotext=%d " , ic . is_autotext ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.is_backrotate180=%d " , ic . is_backrotate180 ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.is_convex=%d " , ic . is_convex ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.is_duplex=%d " , ic . is_duplex ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.is_switchfrontback=%d " , ic . is_switchfrontback ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.is_dogeardetection=%d " , ic . is_dogeardetection ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.fillhole.multi_output_red=%d " , ic . multi_output_red ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.noise=%d " , 8 ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.pixtype=%d " , ic . pixtype ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.resolution_dst=%f " , ic . resolution_dst ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.resolution_native=%f " , ic . resolution_native ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.scannum=%d " , ic . scannum ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.sharpen=%d " , ic . sharpen ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.discardblank_percent=%d " , ic . discardblank_percent ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.detachnoise.is_detachnoise=%d " , ic . detachnoise . is_detachnoise ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.detachnoise.detachnoise=%d \r " , ic . detachnoise . detachnoise ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.detachnoise.refuseInflow=%d \r " , ic . refuseInflow ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.detachnoise.refuseInflow=%d \r " , ic . refuseInflow ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.removeMorr=%d \r " , ic . removeMorr ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.errorExtention=%d \r " , ic . errorExtention ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.textureRemove=%d \r \n " , ic . refuseInflow ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.fillhole.is_fillhole=%d \r \n " , ic . fillhole . is_fillhole ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.ic.fillhole.fillholeratio=%d \r \n " , ic . fillhole . fillholeratio ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.fadeback=%d \r \n " , ic . fadeback ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.cropRect.enable=%d \r " , ic . cropRect . enable ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.cropRect.width=%d \r \n " , ic . cropRect . width ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.cropRect.height=%d \r \n " , ic . cropRect . height ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.cropRect.x=%f \r \n " , ic . cropRect . x ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " \n ic.cropRect.y=%d \r \n " , ic . cropRect . y ) ;
img_conf_ = ic ;
return ret ;
}
int hg_scanner_402 : : pop_first_image ( void )
{
2022-10-18 08:23:22 +00:00
int ret = write_register ( setting3399 : : SR_IM_POP , 1 ) ;
2022-07-13 10:22:31 +00:00
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " popup first image = %s \n " , hg_scanner_err_name ( ret ) ) ;
return ret ;
}
2022-08-02 08:32:46 +00:00
int hg_scanner_402 : : read_one_image_from_usb ( SANE_Image_Statu statu )
2022-07-13 10:22:31 +00:00
{
int r = 0 ,
total = get_front_data_size ( ) ,
off = 0 ,
ret = SCANNER_ERR_OK ;
2022-07-14 06:21:53 +00:00
VLOG_MINI_1 ( LOG_LEVEL_ALL , " New image size: %u \n " , total ) ;
2022-07-13 10:22:31 +00:00
if ( ! waiting_for_memory_enough ( total ) )
{
status_ = SCANNER_ERR_INSUFFICIENT_MEMORY ;
return status_ ;
}
2022-08-04 01:36:46 +00:00
//if (user_cancel_)
//return SCANNER_ERR_USER_CANCELED;
2022-07-13 10:22:31 +00:00
if ( total = = - 1 )
ret = status_ ;
else
{
std : : shared_ptr < tiny_buffer > buf ( aquire_memory ( total ) ) ;
if ( ! buf . get ( ) )
return SCANNER_ERR_INSUFFICIENT_MEMORY ;
// write reading command
2022-08-02 08:32:46 +00:00
buf - > set_image_statu ( statu ) ;
2022-10-18 08:23:22 +00:00
ret = write_register ( setting3399 : : SR_IM_TX , 1 ) ;
2022-07-13 10:22:31 +00:00
if ( ret = = SCANNER_ERR_OK )
{
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 10 ) ) ;
r = total ;
{
std : : lock_guard < std : : mutex > lock ( io_lock_ ) ;
2022-07-14 06:21:53 +00:00
void * buff = buf - > data ( off , ( unsigned int * ) & r ) ;
2022-07-13 10:22:31 +00:00
2022-07-14 06:21:53 +00:00
ret = SCANNER_ERR_INSUFFICIENT_MEMORY ;
while ( buff )
2022-07-13 10:22:31 +00:00
{
2022-07-14 06:21:53 +00:00
ret = io_ - > read_bulk ( buff , & r ) ;
if ( ret ! = SCANNER_ERR_OK )
break ;
2022-07-13 10:22:31 +00:00
2022-07-14 06:21:53 +00:00
off + = r ;
if ( off > = total )
break ;
r = total - off ;
buff = buf - > data ( off , ( unsigned int * ) & r ) ;
2022-07-13 10:22:31 +00:00
}
}
2022-07-14 06:21:53 +00:00
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " Read image from USB = %s \n " , hg_scanner_err_name ( ret ) ) ;
2022-07-13 10:22:31 +00:00
if ( ret = = SCANNER_ERR_OK )
{
2022-07-19 09:12:06 +00:00
//{
// char f[128] = { 0 };
// sprintf(f, "/tmp/usb_%02d.jpg", usb_img_index_);
// buf->to_file(f);
//}
2022-07-13 10:22:31 +00:00
ret = save_usb_data ( buf ) ;
if ( ret = = SCANNER_ERR_OK )
{
pop_first_image ( ) ;
2022-07-14 06:21:53 +00:00
}
else
{
VLOG_MINI_1 ( LOG_LEVEL_FATAL , " save usb data failed: %s \n " , hg_scanner_err_name ( ret ) ) ;
2022-07-13 10:22:31 +00:00
}
}
else
{
2022-07-14 06:21:53 +00:00
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " Read image data from USB err: %s \n " , hg_scanner_err_name ( ret ) ) ;
2022-07-13 10:22:31 +00:00
}
}
2022-07-14 06:21:53 +00:00
else
{
VLOG_MINI_1 ( LOG_LEVEL_FATAL , " write command SR_IM_TX failed: %s \n " , hg_scanner_err_name ( ret ) ) ;
}
2022-07-13 10:22:31 +00:00
}
return ret ;
}
void hg_scanner_402 : : discard_all_images ( void )
{
2022-08-06 06:18:53 +00:00
char buf [ 32 ] ;
2022-10-18 08:23:22 +00:00
setting3399 : : HGEIntInfo * info = ( setting3399 : : HGEIntInfo * ) buf ;
2022-07-13 10:22:31 +00:00
int size = sizeof ( buf ) ,
oto = 0 ,
pre_img = 0 ,
pre_int = 0 ,
ret = SCANNER_ERR_OK ;
{
std : : lock_guard < std : : mutex > lock ( io_lock_ ) ;
oto = io_ - > get_timeout ( ) ;
io_ - > set_timeout ( 100 ) ;
ret = io_ - > read_interrupt ( buf , & size ) ;
}
while ( ret = = SCANNER_ERR_OK )
{
pre_int + + ;
2022-10-18 08:23:22 +00:00
if ( info - > From = = setting3399 : : IMG )
2022-07-13 10:22:31 +00:00
{
while ( get_image_count ( ) > 0 )
{
pop_first_image ( ) ;
pre_img + + ;
}
}
size = sizeof ( buf ) ;
{
std : : lock_guard < std : : mutex > lock ( io_lock_ ) ;
ret = io_ - > read_interrupt ( buf , & size ) ;
}
}
{
std : : lock_guard < std : : mutex > lock ( io_lock_ ) ;
io_ - > set_timeout ( oto ) ;
}
if ( pre_int )
VLOG_MINI_2 ( LOG_LEVEL_DEBUG_INFO , " prev-connection has left %d interrupt packet(s) && %d image(s). \n " , pre_int , pre_img ) ;
}
//color_mode =-1 除色选项
int hg_scanner_402 : : on_color_mode_changed ( int & color_mode )
{
int ret = SCANNER_ERR_OK ;
2022-10-18 08:23:22 +00:00
if ( ( ( ( color_mode = = COLOR_MODE_24_BITS | | color_mode = = COLOR_MODE_AUTO_MATCH ) & & ! dev_conf_ . params_3399 . color ) | |
( ( color_mode ! = COLOR_MODE_24_BITS & & color_mode ! = COLOR_MODE_AUTO_MATCH ) & & dev_conf_ . params_3399 . color ) ) & & color_mode ! = - 1 )
2022-07-13 10:22:31 +00:00
{
2022-10-18 08:23:22 +00:00
dev_conf_ . params_3399 . color ^ = 1 ;
2022-07-13 10:22:31 +00:00
ret = writedown_device_configuration ( ) ;
if ( ret )
2022-10-18 08:23:22 +00:00
dev_conf_ . params_3399 . color ^ = 1 ;
2022-07-13 10:22:31 +00:00
}
if ( color_mode = = COLOR_MODE_AUTO_MATCH )
{
2022-10-18 08:23:22 +00:00
dev_conf_ . params_3399 . color = 1 ;
2022-07-13 10:22:31 +00:00
}
2022-10-18 08:23:22 +00:00
setting_hardware : : HGSCANCONF_3399 d = dev_conf_ ;
2022-07-13 10:22:31 +00:00
if ( image_prc_param_ . bits . rid_color ! = RID_COLOR_NONE
& & ( image_prc_param_ . bits . color_mode = = COLOR_MODE_256_GRAY | | image_prc_param_ . bits . color_mode = = COLOR_MODE_BLACK_WHITE )
)
{
2022-10-18 08:23:22 +00:00
d . params_3399 . color = 1 ;
2022-07-13 10:22:31 +00:00
ret = writedown_device_configuration ( & d ) ;
}
if ( image_prc_param_ . bits . rid_color ! = RID_COLOR_NONE
& & ( image_prc_param_ . bits . color_mode = = COLOR_MODE_256_GRAY | | image_prc_param_ . bits . color_mode = = COLOR_MODE_BLACK_WHITE )
& & color_mode = = - 1 )
{
2022-10-18 08:23:22 +00:00
d . params_3399 . color = 1 ;
2022-07-13 10:22:31 +00:00
}
else if ( image_prc_param_ . bits . rid_color = = RID_COLOR_NONE
& & ( image_prc_param_ . bits . color_mode = = COLOR_MODE_256_GRAY | | image_prc_param_ . bits . color_mode = = COLOR_MODE_BLACK_WHITE )
& & color_mode = = - 1 )
{
2022-10-18 08:23:22 +00:00
d . params_3399 . color = 0 ;
2022-07-13 10:22:31 +00:00
}
if ( color_mode = = - 1 )
ret = writedown_device_configuration ( & d ) ;
return ret ;
}
int hg_scanner_402 : : on_paper_changed ( int & paper )
{
bool exact = true ;
2022-10-18 08:23:22 +00:00
int ind = hgpaper_to_devspaper ( paper_map_3399 , ARRAY_SIZE ( paper_map_3399 ) , paper , & exact , & paper_size_ ) ,
2022-07-13 10:22:31 +00:00
ret = exact ? SCANNER_ERR_OK : SCANNER_ERR_NOT_EXACT ;
2022-10-18 08:23:22 +00:00
if ( dev_conf_ . params_3399 . paper ! = paper_map_3399 [ ind ] . dev_value )
2022-07-13 10:22:31 +00:00
{
2022-10-18 08:23:22 +00:00
int old = dev_conf_ . params_3399 . paper ;
2022-07-13 10:22:31 +00:00
2022-10-18 08:23:22 +00:00
dev_conf_ . params_3399 . paper = paper_map_3399 [ ind ] . dev_value ;
2022-07-13 10:22:31 +00:00
ret = writedown_device_configuration ( ) ;
if ( ret )
{
2022-10-18 08:23:22 +00:00
dev_conf_ . params_3399 . paper = old ;
for ( int i = 0 ; i < ARRAY_SIZE ( paper_map_3399 ) ; + + i )
2022-07-13 10:22:31 +00:00
{
2022-10-18 08:23:22 +00:00
if ( paper_map_3399 [ i ] . dev_value = = old )
2022-07-13 10:22:31 +00:00
{
2022-10-18 08:23:22 +00:00
paper = paper_map_3399 [ i ] . paper ;
2022-07-13 10:22:31 +00:00
break ;
}
}
}
else if ( ! exact )
ret = SCANNER_ERR_NOT_EXACT ;
}
return ret ;
}
int hg_scanner_402 : : on_paper_check_changed ( bool & check )
{
int ret = SCANNER_ERR_OK ;
2022-10-18 08:23:22 +00:00
if ( dev_conf_ . params_3399 . enable_sizecheck ^ check )
2022-07-13 10:22:31 +00:00
{
2022-10-18 08:23:22 +00:00
dev_conf_ . params_3399 . enable_sizecheck = check ;
2022-07-13 10:22:31 +00:00
ret = writedown_device_configuration ( ) ;
if ( ret )
{
2022-10-18 08:23:22 +00:00
dev_conf_ . params_3399 . enable_sizecheck = ! check ;
check = dev_conf_ . params_3399 . enable_sizecheck ;
2022-07-13 10:22:31 +00:00
}
}
if ( image_prc_param_ . bits . paper = = PAPER_AUTO_MATCH
| | image_prc_param_ . bits . paper = = PAPER_MAX_SIZE
| | image_prc_param_ . bits . paper = = PAPER_MAX_SIZE_CLIP
| | image_prc_param_ . bits . paper = = PAPER_TRIGEMINY
| | image_prc_param_ . bits . paper = = PAPER_16K
| | image_prc_param_ . bits . paper = = PAPER_8K
| | image_prc_param_ . bits . paper = = PAPER_16K_LATERAL
)
{
2022-10-18 08:23:22 +00:00
setting_hardware : : HGSCANCONF_3399 * d = & dev_conf_ ;
d - > params_3399 . enable_sizecheck = false ;
2022-07-13 10:22:31 +00:00
ret = writedown_device_configuration ( d ) ;
}
return ret ;
}
int hg_scanner_402 : : on_resolution_changed ( int & dpi )
{
bool exact = true ;
int ind = settings402 : : match_best_resolution ( dpi , & exact ) ,
ret = exact ? SCANNER_ERR_OK : SCANNER_ERR_NOT_EXACT ;
2022-10-18 08:23:22 +00:00
if ( dev_conf_ . params_3399 . dpi ! = settings402 : : resolution_map [ ind ] . dev_value )
2022-07-13 10:22:31 +00:00
{
2022-10-18 08:23:22 +00:00
int old = dev_conf_ . params_3399 . dpi ;
dev_conf_ . params_3399 . dpi = settings402 : : resolution_map [ ind ] . dev_value ;
dev_conf_ . params_3399 . dpi = 1 ;
2022-07-13 10:22:31 +00:00
ret = writedown_device_configuration ( ) ;
if ( ret )
{
2022-10-18 08:23:22 +00:00
dev_conf_ . params_3399 . dpi = old ;
2022-07-13 10:22:31 +00:00
}
else if ( ! exact )
ret = SCANNER_ERR_NOT_EXACT ;
}
if ( ret = = SCANNER_ERR_NOT_EXACT )
dpi = settings402 : : resolution_map [ ind ] . resolution ;
return ret ;
}
int hg_scanner_402 : : on_ultrasonic_check_changed ( bool & check )
{
int ret = SCANNER_ERR_OK ;
2022-10-18 08:23:22 +00:00
if ( dev_conf_ . params_3399 . ultrasonic_enable ^ check )
2022-07-13 10:22:31 +00:00
{
2022-10-18 08:23:22 +00:00
dev_conf_ . params_3399 . ultrasonic_enable = check ;
2022-07-13 10:22:31 +00:00
ret = writedown_device_configuration ( ) ;
if ( ret )
{
2022-10-18 08:23:22 +00:00
dev_conf_ . params_3399 . ultrasonic_enable = ! check ;
check = dev_conf_ . params_3399 . ultrasonic_enable ;
2022-07-13 10:22:31 +00:00
}
}
return ret ;
}
int hg_scanner_402 : : on_staple_check_changed ( bool & check )
{
int ret = SCANNER_ERR_OK ;
2022-10-18 08:23:22 +00:00
if ( dev_conf_ . params_3399 . staple_enbale ^ check )
2022-07-13 10:22:31 +00:00
{
2022-10-18 08:23:22 +00:00
dev_conf_ . params_3399 . staple_enbale = check ;
2022-07-13 10:22:31 +00:00
ret = writedown_device_configuration ( ) ;
if ( ret )
{
2022-10-18 08:23:22 +00:00
dev_conf_ . params_3399 . staple_enbale = ! check ;
check = dev_conf_ . params_3399 . staple_enbale ;
2022-07-13 10:22:31 +00:00
}
}
return ret ;
}
int hg_scanner_402 : : on_skew_check_changed ( bool & check )
{
int ret = SCANNER_ERR_OK ;
2022-10-18 08:23:22 +00:00
if ( dev_conf_ . params_3399 . screw_detect_enable ^ check )
2022-07-13 10:22:31 +00:00
{
2022-10-18 08:23:22 +00:00
dev_conf_ . params_3399 . screw_detect_enable = check ;
2022-07-13 10:22:31 +00:00
ret = writedown_device_configuration ( ) ;
if ( ret )
{
2022-10-18 08:23:22 +00:00
dev_conf_ . params_3399 . screw_detect_enable = ! check ;
check = dev_conf_ . params_3399 . screw_detect_enable ;
2022-07-13 10:22:31 +00:00
}
}
return ret ;
}
int hg_scanner_402 : : on_skew_check_level_changed ( int & check )
{
int ret = SCANNER_ERR_OK ,
val = check ,
2022-10-18 08:23:22 +00:00
old = dev_conf_ . params_3399 . screw_detect_level ;
setting_hardware : : HGSCANCONF_3399 cf ;
2022-07-13 10:22:31 +00:00
2022-10-18 08:23:22 +00:00
cf . params_3399 . screw_detect_level = - 1 ;
2022-07-13 10:22:31 +00:00
if ( val < 0 )
{
val = 0 ;
ret = SCANNER_ERR_NOT_EXACT ;
}
2022-10-18 08:23:22 +00:00
else if ( val > cf . params_3399 . screw_detect_level )
2022-07-13 10:22:31 +00:00
{
2022-10-18 08:23:22 +00:00
val = cf . params_3399 . screw_detect_level ;
2022-07-13 10:22:31 +00:00
ret = SCANNER_ERR_NOT_EXACT ;
}
2022-10-18 08:23:22 +00:00
if ( val ! = dev_conf_ . params_3399 . screw_detect_level )
2022-07-13 10:22:31 +00:00
{
2022-10-18 08:23:22 +00:00
dev_conf_ . params_3399 . screw_detect_level = val ;
2022-07-13 10:22:31 +00:00
ret = writedown_device_configuration ( ) ;
if ( ret )
2022-10-18 08:23:22 +00:00
check = dev_conf_ . params_3399 . screw_detect_level = old ;
2022-07-13 10:22:31 +00:00
}
if ( ret = = SCANNER_ERR_OK & & val ! = check )
{
check = val ;
ret = SCANNER_ERR_NOT_EXACT ;
}
return ret ;
}
2022-07-23 10:01:44 +00:00
int hg_scanner_402 : : on_get_feedmode ( int & feedmode ) //获取分纸强度
{
int ret = SCANNER_ERR_OK ,
val = 0 ;
2022-10-18 08:23:22 +00:00
ret = read_register ( setting3399 : : SR_GET_FEEDMODE , & feedmode ) ;
2022-07-23 10:01:44 +00:00
return ret ;
}
int hg_scanner_402 : : on_set_feedmode ( int feedmode ) //设置分纸强度
{
int ret = SCANNER_ERR_OK ,
val = 0 ;
2022-10-18 08:23:22 +00:00
ret = write_register ( setting3399 : : SR_SET_FEEDMODE , feedmode ) ;
2022-07-23 10:01:44 +00:00
return ret ;
}
2022-07-13 10:22:31 +00:00
void hg_scanner_402 : : on_device_reconnected ( void )
{
int ret = writedown_device_configuration ( ) ;
init_version ( ) ;
rewrite_conf_ = ret ! = SCANNER_ERR_OK ;
if ( reset_ )
{
reset_ = false ;
start ( ) ;
}
}
int hg_scanner_402 : : on_scanner_closing ( bool force )
{
return SCANNER_ERR_OK ;
}
void hg_scanner_402 : : thread_handle_usb_read ( void )
{
char buf [ 32 ] = { 0 } ;
2022-10-18 08:23:22 +00:00
setting3399 : : HGEIntInfo * info = ( setting3399 : : HGEIntInfo * ) buf ;
2022-07-13 10:22:31 +00:00
int size = sizeof ( buf ) ,
ret = SCANNER_ERR_OK ,
to_cnt = 0 ,
count = 0 ;
bool go = true ;
//status_ = SCANNER_ERR_DEVICE_BUSY;
while ( run_ & & go )
{
size = sizeof ( buf ) ;
2022-07-19 09:12:06 +00:00
memset ( buf , 0 , size ) ;
2022-07-13 10:22:31 +00:00
{
std : : lock_guard < std : : mutex > lock ( io_lock_ ) ;
ret = io_ - > read_interrupt ( buf , & size ) ;
2022-08-05 02:56:16 +00:00
// io_->set_timeout(1000);
2022-07-13 10:22:31 +00:00
}
2022-07-14 06:21:53 +00:00
VLOG_MINI_5 ( LOG_LEVEL_DEBUG_INFO , " read-INT = %s: From(%d), Code(%d), Index(%d), size = %d \n " , hg_scanner_err_name ( ret ) ,
info - > From , info - > Code , info - > Img_Index , size ) ;
2022-07-13 10:22:31 +00:00
if ( ret ! = SCANNER_ERR_OK )
{
if ( ret = = SCANNER_ERR_TIMEOUT )
{
if ( to_cnt + + < 30 )
{
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 500 ) ) ;
2022-07-14 06:21:53 +00:00
//int statu = get_status();
//if ((statu & 0x03) == 0)
//{
// VLOG_MINI_1(LOG_LEVEL_FATAL, "USB thread over with status: 0x%x\n", statu);
// status_ = SCANNER_ERR_OK;
// break;
//}
2022-07-13 10:22:31 +00:00
continue ;
}
}
status_ = ret ;
break ;
}
to_cnt = 0 ;
if ( size = = sizeof ( buf ) )
{
2022-08-02 08:32:46 +00:00
ret = settings402 : : device_status_to_hg_err ( info ) ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " status from interrupt point is '%s' \n " , hg_scanner_err_name ( status_ ) ) ;
if ( ret ! = SCANNER_ERR_OK & & ret ! = SCANNER_ERR_TIMEOUT & & ret ! = SCANNER_ERR_DEVICE_STOPPED )
{
2022-08-04 09:01:58 +00:00
//if (!is_dev_image_process_done())
2022-08-02 08:32:46 +00:00
{
int st = ret , count = 0 , statu = last_usb_image_statu ( st ) ;
2022-08-04 09:01:58 +00:00
//while (!is_dev_image_process_done())
2022-08-04 09:23:56 +00:00
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 1000 ) ) ;
2022-08-02 08:32:46 +00:00
while ( ( count = get_image_count ( ) ) > 0 )
{
int s = SANE_Image_Statu_OK ;
if ( count < = 2 )
{
if ( image_prc_param_ . bits . page = = PAGE_SINGLE )
s = count = = 1 ? statu : s ;
else
s = statu ;
}
ret = read_one_image_from_usb ( ( SANE_Image_Statu ) s ) ;
count + + ;
if ( ret ! = SCANNER_ERR_OK
& & ret ! = SCANNER_ERR_CREATE_FILE_FAILED
& & ret ! = SCANNER_ERR_WRITE_FILE_FAILED )
break ;
}
2022-08-05 02:56:16 +00:00
status_ = st ;
2022-08-02 08:32:46 +00:00
}
2022-08-04 09:47:57 +00:00
2022-08-02 08:32:46 +00:00
VLOG_MINI_1 ( LOG_LEVEL_WARNING , " \346 \211 \253 \346 \217 \217 \345 \244 \261 \350 \264 \245 , read interrupt \350 \277 \224 \345 \233 \236 \347 \212 \266 \346 \200 \201 \344 \270 \272 \357 \274 \232 %s \n " , hg_scanner_err_description ( status_ ) ) ;
break ;
}
2022-07-13 10:22:31 +00:00
switch ( info - > From )
{
2022-10-18 08:23:22 +00:00
case setting3399 : : IMG :
2022-07-13 10:22:31 +00:00
if ( get_image_count ( ) > 0 )
{
read_one_image_from_usb ( ) ;
}
2022-07-14 06:21:53 +00:00
else
{
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " receive IMG event but no image count(%d)! " , get_image_count ( ) ) ;
}
2022-07-13 10:22:31 +00:00
break ;
2022-10-18 08:23:22 +00:00
case setting3399 : : V4L2 :
2022-07-13 10:22:31 +00:00
VLOG_MINI_1 ( LOG_LEVEL_FATAL , " V4L2 error: %d \n " , info - > Code ) ;
{
bool cancel = user_cancel_ ;
stop ( ) ;
user_cancel_ = cancel ;
go = false ;
}
break ;
2022-10-18 08:23:22 +00:00
case setting3399 : : STOPSCAN :
2022-07-14 06:21:53 +00:00
go = false ;
LOG_INFO ( LOG_LEVEL_ALL , " Received STOPSCAN event ... \n " ) ;
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 500 ) ) ;
2022-08-05 02:56:16 +00:00
while ( get_image_count ( ) > 0 ) // lost IMG message, check image count to receive rest images (BUG-228)...
2022-07-14 06:21:53 +00:00
{
2022-08-05 02:56:16 +00:00
ret = read_one_image_from_usb ( ) ;
if ( ret ! = SCANNER_ERR_OK )
2022-07-14 06:21:53 +00:00
{
2022-08-05 02:56:16 +00:00
status_ = ret ;
break ;
2022-07-14 06:21:53 +00:00
}
}
break ;
2022-07-13 10:22:31 +00:00
default :
break ;
}
2022-07-14 06:21:53 +00:00
if ( ! go )
break ;
2022-07-13 10:22:31 +00:00
}
else
VLOG_MINI_2 ( LOG_LEVEL_DEBUG_INFO , " read %d bytes, sizeof(buf) = %d \n " , size , sizeof ( buf ) ) ;
this_thread : : sleep_for ( chrono : : milliseconds ( 10 ) ) ;
}
VLOG_MINI_2 ( LOG_LEVEL_DEBUG_INFO , " USB thread exit with code: %s, status = %s \n " , hg_scanner_err_name ( ret ) , hg_scanner_err_name ( status_ ) ) ;
}
int hg_scanner_402 : : start ( void )
{
2022-10-12 09:09:11 +00:00
2022-07-13 10:22:31 +00:00
bool handled = false ;
int ret = try_third_app_handle_start ( handled ) ,
val = 0 ;
// for third-sane-app invoking, added on 2022-05-19
if ( handled )
return ret ;
2022-10-12 09:09:11 +00:00
split3399_ = 0 ;
2022-07-13 10:22:31 +00:00
user_cancel_ = false ;
cb_mem_ = true ;
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " scanner status: 0x%x \n " , get_status ( ) ) ;
notify_ui_working_status ( STATU_DESC_PREPARE_START ) ;
reset ( ) ;
get_roller_num ( ) ;
2022-10-18 08:23:22 +00:00
read_register ( setting3399 : : SR_GET_PAPERON , & val ) ;
2022-07-19 09:12:06 +00:00
if ( ! val )
{
VLOG_MINI_1 ( LOG_LEVEL_WARNING , " start failed: %s \n " , hg_scanner_err_name ( SCANNER_ERR_DEVICE_NO_PAPER ) ) ;
return SCANNER_ERR_DEVICE_NO_PAPER ;
}
2022-07-13 10:22:31 +00:00
notify_ui_working_status ( STATU_DESC_REWRITE_CONFIGURATION ) ;
writedown_device_configuration ( ) ;
2022-07-14 06:21:53 +00:00
writedown_image_configuration ( ) ;
2022-07-19 09:12:06 +00:00
val = 0 ;
2022-07-13 10:22:31 +00:00
ret = read_register ( /*SR_GET_ANDROID_STATE*/ 0x1001 , & val ) ;
2022-08-02 10:00:17 +00:00
2022-07-19 09:12:06 +00:00
while ( val )
2022-07-13 10:22:31 +00:00
{
if ( val = = 1 )
ret = status_ = SCANNER_ERR_DEVICE_COVER_OPENNED ;
else if ( val = = 2 )
ret = status_ = SCANNER_ERR_DEVICE_PAPER_JAMMED ;
else if ( val = = 3 )
ret = status_ = SCANNER_ERR_DEVICE_NO_PAPER ;
else
2022-07-19 09:12:06 +00:00
{
VLOG_MINI_2 ( LOG_LEVEL_WARNING , " consider as success on SR_GET_ANDROID_STATE(%d) result: %s \n " , val , hg_scanner_err_name ( ret ) ) ;
break ;
}
2022-07-13 10:22:31 +00:00
2022-07-19 09:12:06 +00:00
VLOG_MINI_2 ( LOG_LEVEL_WARNING , " failed on SR_GET_ANDROID_STATE(%d) result: %s \n " , val , hg_scanner_err_name ( ret ) ) ;
2022-07-13 10:22:31 +00:00
return ret ;
}
2022-08-12 03:16:21 +00:00
int count = scan_count_ ;
if ( test_1_paper_ )
count = 1 ;
write_register ( 0x1000 , count ) ;
2022-10-18 08:23:22 +00:00
ret = write_command ( setting3399 : : SC_START ) ;
2022-07-13 10:22:31 +00:00
VLOG_MINI_1 ( LOG_LEVEL_WARNING , " start result: %s \n " , hg_scanner_err_name ( ret ) ) ;
2022-08-05 02:56:16 +00:00
// io_->set_timeout(1000);
2022-07-13 10:22:31 +00:00
if ( ret = = SCANNER_ERR_OK )
{
//status_ = SCANNER_ERR_DEVICE_BUSY;
wait_usb_ . notify ( ) ;
this_thread : : sleep_for ( chrono : : milliseconds ( 100 ) ) ;
ret = try_third_app_after_start ( ret ) ;
}
else
{
status_ = ret ;
VLOG_MINI_3 ( LOG_LEVEL_WARNING , " (%s)[Thread %s]Send start command = %s \n " , hg_log : : current_time ( ) . c_str ( ) , hg_log : : format_current_thread_id ( ) . c_str ( ) , hg_scanner_err_name ( ret ) ) ;
}
return ret ;
}
int hg_scanner_402 : : stop ( void )
{
int ret = SCANNER_ERR_OK ;
user_cancel_ = true ;
2022-10-18 08:23:22 +00:00
ret = write_command ( setting3399 : : SC_STOP ) ;
2022-08-05 02:56:16 +00:00
// io_->set_timeout(500);
2022-08-04 01:36:46 +00:00
//final_imgs_.clear();
2022-07-13 10:22:31 +00:00
return status_ ;
}
int hg_scanner_402 : : reset ( void )
{
final_imgs_ . clear ( ) ;
2022-07-19 09:12:06 +00:00
discard_all_images ( ) ;
2022-07-13 10:22:31 +00:00
return status_ ;
}
int hg_scanner_402 : : device_io_control ( unsigned long code , void * data , unsigned * len )
{
int ret = SCANNER_ERR_OUT_OF_RANGE ;
if ( HG_CONTROL_CODE_OPTION_ENABLE = = code )
{
OPTEN * opten = ( OPTEN * ) data ;
ret = SCANNER_ERR_OK ;
if ( opten - > opt_num = = HG_239_SETTING_CORRECT & & ! opten - > enabled ) // for BUG-20 modified by Gongbing on 2022-03-12
{
bool enable = true ;
setting_automatic_skew ( opten - > opt_num , & enable ) ;
}
}
else if ( IO_CTRL_CODE_TEST_SINGLE = = code )
{
test_1_paper_ = true ;
ret = start ( ) ;
}
else
ret = hg_scanner : : device_io_control ( code , data , len ) ;
return ret ;
}
std : : string hg_scanner_402 : : get_firmware_version ( void )
{
2022-10-18 08:23:22 +00:00
return control_fetch ( setting3399 : : SR_GET_FWVERSION , 0 , 512 ) ;
2022-07-13 10:22:31 +00:00
}
std : : string hg_scanner_402 : : get_serial_num ( void )
{
2022-10-18 08:23:22 +00:00
return control_fetch ( setting3399 : : SR_GET_SERIALNUM , 0 , 512 ) ;
2022-07-13 10:22:31 +00:00
}
std : : string hg_scanner_402 : : get_ip ( void )
{
2022-10-18 08:23:22 +00:00
return control_fetch ( setting3399 : : SR_GET_IPADDR , 0 , 512 ) ;
2022-07-13 10:22:31 +00:00
}
int hg_scanner_402 : : get_roller_num ( void )
{
2022-08-13 07:06:32 +00:00
int val = 0 ,
2022-10-18 08:23:22 +00:00
ret = read_register ( setting3399 : : SR_GET_ROLLER_NUM , & val ) ;
2022-07-13 10:22:31 +00:00
if ( ret = = SCANNER_ERR_OK )
return val ;
else
{
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " get_roller_num = %s \n " , hg_scanner_err_name ( ret ) ) ;
2022-08-13 07:06:32 +00:00
return - 2 ;
}
// return -2;
}
int hg_scanner_402 : : get_history_count ( void )
{
2022-08-11 01:36:19 +00:00
return - 2 ;
2022-07-13 10:22:31 +00:00
}
int hg_scanner_402 : : clear_roller_num ( void )
{
int val = 0 ,
2022-10-18 08:23:22 +00:00
ret = read_register ( setting3399 : : SR_CLR_ROLLER_NUM , & val ) ;
2022-07-13 10:22:31 +00:00
return ret ;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int hg_scanner_402 : : set_leaflet_scan ( void )
{
int ret = SCANNER_ERR_OK ;
test_1_paper_ = true ;
ret = start ( ) ;
return ret ;
}
int hg_scanner_402 : : get_abuot_info ( void )
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT ;
}
int hg_scanner_402 : : restore_default_setting ( void )
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT ;
}
int hg_scanner_402 : : set_final_image_format ( SANE_FinalImgFormat * fmt )
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT ;
}
int hg_scanner_402 : : get_compression_format ( void )
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT ;
}
int hg_scanner_402 : : set_compression_format ( void )
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT ;
}
int hg_scanner_402 : : set_auto_color_type ( void )
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT ;
}
int hg_scanner_402 : : get_device_code ( void )
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT ;
}
int hg_scanner_402 : : get_sleep_time ( SANE_Power * getime )
{
int val = 0 ,
2022-10-18 08:23:22 +00:00
ret = read_register ( setting3399 : : SR_GET_SLEEPTIME , & val ) ;
2022-07-13 10:22:31 +00:00
if ( ret = = SCANNER_ERR_OK )
* getime = ( SANE_Power ) val ;
else
{
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " get_sleep_time = %s \n " , hg_scanner_err_name ( ret ) ) ;
return - 1 ;
}
}
int hg_scanner_402 : : set_sleep_time ( int setsleepime )
{
2022-10-18 08:23:22 +00:00
int ret = write_register ( setting3399 : : SR_SET_SLEEPTIME , setsleepime ) ;
2022-07-13 10:22:31 +00:00
VLOG_MINI_2 ( LOG_LEVEL_DEBUG_INFO , " set sleep time to %d = %s \n " , setsleepime , hg_scanner_err_name ( ret ) ) ;
return ret ;
}
int hg_scanner_402 : : get_dogear_distance ( void )
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT ;
}
int hg_scanner_402 : : set_dogear_distance ( void )
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT ;
}
int hg_scanner_402 : : get_scanner_paperon ( SANE_Bool * paperon )
{
int val = 0 ,
2022-10-18 08:23:22 +00:00
ret = read_register ( setting3399 : : SR_GET_PAPERON , & val ) ;
2022-07-13 10:22:31 +00:00
if ( ret = = SCANNER_ERR_OK )
{
if ( ! val )
{
ret = SCANNER_ERR_DEVICE_NO_PAPER ;
if ( paperon )
{
* paperon = true ;
}
}
else
{
ret = SCANNER_ERR_OK ;
if ( paperon )
{
* paperon = false ;
}
}
}
else
{
VLOG_MINI_1 ( LOG_LEVEL_DEBUG_INFO , " get_scanner_paperon = %s \n " , hg_scanner_err_name ( ret ) ) ;
return - 1 ;
}
return ret ;
}
int hg_scanner_402 : : set_scan_when_paper_on ( void )
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT ;
}
int hg_scanner_402 : : get_scan_when_paper_on ( void )
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT ;
}
int hg_scanner_402 : : get_scan_with_hole ( void )
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT ;
}
int hg_scanner_402 : : set_scan_with_hole ( void )
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT ;
}
int hg_scanner_402 : : get_scan_is_sleep ( )
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT ;
}
2022-07-23 10:01:44 +00:00
int hg_scanner_402 : : get_device_log ( string & log )
{
int ret = SCANNER_ERR_OK ;
int len = log . size ( ) ;
2022-10-18 08:23:22 +00:00
ret = write_register ( setting3399 : : SR_SET_JSON_PATH , len ) ;
2022-07-23 10:01:44 +00:00
if ( ret = = SCANNER_ERR_OK )
ret = io_ - > write_bulk ( & log [ 0 ] , & len ) ;
VLOG_MINI_2 ( LOG_LEVEL_DEBUG_INFO , " log path:%s ret:%s \n " , log . c_str ( ) , hg_scanner_err_name ( ret ) ) ;
return ret ;
}
int hg_scanner_402 : : notify_sleep ( )
{
int val = 0 ,
2022-10-18 08:23:22 +00:00
ret = write_register ( setting3399 : : SR_NOTIFY_SLEEP , val ) ;
2022-07-23 10:01:44 +00:00
return ret ;
}