#pragma once #include #include #include #define FWVersionEN #define G100 #ifdef G200 #define FWVersion "G2393C0322" #define SERIALNUM "G2396021071101" #else #define FWVersion "G1393C0322" #define SERIALNUM "G1396021071101" #endif //#ifdef FWVersionEN //#pragma warnning("WARNNING! current fareware version is :" FWVersion) //#endif typedef unsigned int u32; typedef unsigned char u8; typedef unsigned char byte; typedef unsigned short u16; typedef struct Size { long x; long y; }; typedef enum Error_Status : uint32_t { NO_error = 0, Dog_error = 1, Size_error = 2, Img_Detecting = 0xffff, }; typedef struct ImgStatus { Error_Status status; uint32_t sannum; }; typedef union HG_ScanConfig { unsigned int value; struct { unsigned int paper : 5; unsigned int color : 1; unsigned int dpi : 2; unsigned int double_feed_enbale : 1; unsigned int stable_enbale : 1; unsigned int screw_detect_enable : 1; unsigned int screw_detect_level : 3; //第十四位 unsigned int iscorrect_mode : 1; unsigned int is_autopaper : 1; unsigned int is_textcorrect : 1; unsigned int is_fixedpaper : 1; unsigned int en_anlogic_key : 1; unsigned int en_autosize : 1; unsigned int pc_correct : 1; unsigned int enable_sizecheck : 1; unsigned int enabledsp_cache : 1; unsigned int sizeerror_errorratio : 9; } g200params; struct { unsigned int pageSize : 5; unsigned int isColor : 1; unsigned int dpi : 2; unsigned int doubleFeeded : 1; unsigned int enableStable : 1; unsigned int enableLed : 1; unsigned int reversed1 : 6; unsigned int isCorrect : 1; unsigned int dstHeight : 8; unsigned int reversed2 : 6; } g400params; } HGScanConfig; typedef enum SCAN_STATUS { SCAN_NORMAL, SCAN_SCANNING, SCAN_COVEROPEN, SCAN_FEEDERROR, SCAN_PAPERJAM, SCAN_DOUBLEFEED, SCAN_AQUIREIMGTIMEOUT, SCAN_AQUIREIMGSIZEERROR, SCAN_DETECTSKREW, SCAN_DETECTSTABLE, SCAN_COUNTMODE, SCAN_NOFEED, SCAN_AUTOCORRECT_DONE, SCAN_STOPED } SCAN_STATUS; struct MotorBoardGlue { MotorBoardGlue(const std::function error_call, const std::function scan_done_call, const std::function os_mode_call, const std::function set_sleepmode_call, const std::function mltop_call, std::function auto_paper, const std::function coveropen) : m_error_call(error_call), m_scan_done_call(scan_done_call), m_os_mode_call(os_mode_call), m_set_sleepmode_call(set_sleepmode_call), m_mltop_call(mltop_call), m_auto_paper(auto_paper), m_coveropen_call(coveropen) { } std::function m_error_call; std::function m_scan_done_call; std::function m_os_mode_call; std::function m_set_sleepmode_call; std::function m_mltop_call; std::function m_auto_paper; std::function m_coveropen_call; }; struct ScannerNativeParam { u32 TotalScanned; //扫描总计�? u32 RollerNum; //滚轴计数 u32 H_ratio; //横向修正系数 u32 V_ratio; //纵向修正系数 u32 JamTimes; //卡纸次数 u32 FeedErrorTimes; //搓纸失败次数 u32 DoubleFeedTimes; //双张次数 u32 ScanSessionsCount; //总计扫描次数 u16 gray_sp; //灰度sp�? u16 color_sp; //彩色sp�? int sleeptime; //休眠模式时间 -1 不休�? std::string SerialNum; //序列�? std::string Token; //识别�? u32 clr_maxbright; //彩色平场校正最大亮�? u32 gray_maxbright; //灰度平场校正最大亮�? u32 speedmode; //速度模式 G100 0->70 1->80 2->90 3->100 G200 0->100 1->110 2->120 3->130 u16 Vid; //USB vid u16 Pid; //USB Pid std::uint32_t chu_motor_speed_200; // G100 G200 出纸电机速度 std::uint32_t chu_motor_speed_300; // G100 G200 出纸电机速度 std::uint32_t chu_motor_speed_600; // G100 G200 出纸电机速度 }; enum TwSS : unsigned short { None = 0, A4Letter = 1, A4 = 1, B5Letter = 2, JISB5 = 2, B5 = 2, USLetter = 3, USLegal = 4, A5 = 5, B4 = 6, ISOB4 = 6, B6 = 7, ISOB6 = 7, USLedger = 9, USExecutive = 10, A3 = 11, B3 = 12, ISOB3 = 12, A6 = 13, C4 = 14, C5 = 15, C6 = 16, _4A0 = 17, _2A0 = 18, A0 = 19, A1 = 20, A2 = 21, A7 = 22, A8 = 23, A9 = 24, A10 = 25, ISOB0 = 26, ISOB1 = 27, ISOB2 = 28, ISOB5 = 29, ISOB7 = 30, ISOB8 = 31, ISOB9 = 32, ISOB10 = 33, JISB0 = 34, JISB1 = 35, JISB2 = 36, JISB3 = 37, JISB4 = 38, JISB6 = 39, JISB7 = 40, JISB8 = 41, JISB9 = 42, JISB10 = 43, C0 = 44, C1 = 45, C2 = 46, C3 = 47, C7 = 48, C8 = 49, C9 = 50, C10 = 51, USStatement = 52, BusinessCard = 53, MaxSize = 54, K8 = 0x81, K16 = 0x82, Trigeminy = 0x83, }; enum class PaperSize { G400_A3 = 0, G400_A4, G400_A4R, G400_A5, G400_A5R, G400_A6, G400_A6R, G400_B4, G400_B5, G400_B5R, G400_B6, G400_B6R, G400_DOUBLELETTER, G400_LEGAL, G400_LETTER, G400_LETTERR, G400_LONGLETTER = 16, G400_MAXSIZE = 17, G400_AUTO = 16, G400_MAXAUTO = 18 }; struct HGSize { unsigned int width; unsigned int height; bool operator<(HGSize const &right) const { if (width < right.width && height < right.height) return true; return false; } }; //usb int 端点 返回消息的生产�? enum HGType { MtBoard = 1, FPGA, V4L2, IMG, AutoCorrect, STOPSCAN, CMD_OUT, MBEvent, }; //usb int 端点通信结构�? struct HGIntInfo { HGType From; unsigned int Code; unsigned int Img_Index; }; enum SpeedMode { PPM70 = 70, PPM80 = 80, PPM90 = 90, PPM100 = 100, PPM110 = 110, PPM120 = 120, PPM130 = 130 }; typedef struct { u32 colorSp_200; u32 graySp_200; u32 colorSp_300; u32 graySp_300; u32 colorSp_600; u32 graySp_600; u32 motorSpeed; } DunNanCisSp; typedef struct { u32 colorSp; u32 graySp; u32 motorSpeed; } CisSp; static std::map cameraparmSp = { #ifdef G100 {PPM70, {.colorSp_200 = 1150 , .graySp_200= 3450,.colorSp_300 = 1207 ,.graySp_300 = 3621,.colorSp_600 = 1822 ,.graySp_600 = 5466 , 1}}, {PPM80, {.colorSp_200 = 1150 , .graySp_200= 3450,.colorSp_300 = 1207 ,.graySp_300 = 3621,.colorSp_600 = 1822 ,.graySp_600 = 5466 , 2}}, {PPM90, {.colorSp_200 = 944 , .graySp_200= 2834,.colorSp_300 = 1019 ,.graySp_300 = 3059,.colorSp_600 = 1822 ,.graySp_600 = 5466 , 0}}, {PPM100, {.colorSp_200 = 847 , .graySp_200= 2541,.colorSp_300 = 875 ,.graySp_300 = 2626,.colorSp_600 = 1822 ,.graySp_600 = 5466 , 3}},//G100 3399 暂无100 ppm {PPM110, {.colorSp_200 = 847 , .graySp_200= 2541,.colorSp_300 = 875 ,.graySp_300 = 2626,.colorSp_600 = 1822 ,.graySp_600 = 5466 , 3}}, #else {PPM100, {.colorSp_200 = 816 , .graySp_200= 2450,.colorSp_300 = 878 ,.graySp_300 = 2637,.colorSp_600 = 1531 ,.graySp_600 = 4595 , 0}}, {PPM110, {.colorSp_200 = 816 , .graySp_200= 2450,.colorSp_300 = 878 ,.graySp_300 = 2637,.colorSp_600 = 1531 ,.graySp_600 = 4595 , 1}}, {PPM120, {.colorSp_200 = 816 , .graySp_200= 2450,.colorSp_300 = 878 ,.graySp_300 = 2637,.colorSp_600 = 1531 ,.graySp_600 = 4595 , 3}}, {PPM130, {.colorSp_200 = 816 , .graySp_200= 2450,.colorSp_300 = 878 ,.graySp_300 = 2637,.colorSp_600 = 1531 ,.graySp_600 = 4595 , 2}} //默认 140 #endif }; static std::map anlogic_freq = { #ifdef G100 {PPM70, 1}, {PPM80, 2}, {PPM90, 3}, {PPM110, 4}, #else {PPM100, 1}, {PPM110, 2}, {PPM120, 3}, {PPM130, 4} #endif }; static std::map scannerSp = { #ifdef G100 {PPM70, {0x42d, 0xc88 , 1}}, {PPM80, {0x37f, 0xa7f, 2}}, {PPM90, {0x2B6, 0x822, 0}}, {PPM100, {0x27C, 0x775, 0}},//G100 3399 暂无100 ppm {PPM110, {0x24e, 0x706, 3}}, #else {PPM100, {0x27C, 0x775, 0}}, {PPM110, {0x27C, 0x775, 1}}, {PPM120, {0x27C, 0x775, 3}}, {PPM130, {0x27C, 0x775, 2}} //默认 140 #endif }; static std::map papersMap = { {PaperSize::G400_A3, {1632, 10800}}, {PaperSize::G400_A4, {1632, 8100}}, {PaperSize::G400_A4R, {1632, 6000}}, {PaperSize::G400_A5, {1632, 6000}}, {PaperSize::G400_A5R, {1632, 6000}}, {PaperSize::G400_A6, {1632, 6000}}, {PaperSize::G400_A6R, {1632, 6000}}, {PaperSize::G400_B4, {1632, 10800}}, {PaperSize::G400_B5, {1632, 8100}}, {PaperSize::G400_B5R, {1632, 6000}}, {PaperSize::G400_B6, {1632, 6000}}, {PaperSize::G400_DOUBLELETTER, {1632, 10800}}, {PaperSize::G400_B6R, {1632, 6000}}, {PaperSize::G400_LEGAL, {1632, 10800}}, {PaperSize::G400_LETTER, {1632, 8100}}, {PaperSize::G400_LETTERR, {1632, 10800}}, {PaperSize::G400_MAXSIZE, {1632, 16002}}, {PaperSize::G400_AUTO, {1632, 10800}}, {PaperSize::G400_MAXAUTO, {1632, 16002}}, }; // pair unit:mm static std::map paperHeight={ {PaperSize::G400_A3, 475}, {PaperSize::G400_A4, 337}, {PaperSize::G400_A4R, 247}, {PaperSize::G400_A5, 247}, {PaperSize::G400_A5R, 178}, {PaperSize::G400_A6, 178 }, {PaperSize::G400_A6R, 135}, {PaperSize::G400_B4, 383}, {PaperSize::G400_B5, 300}, {PaperSize::G400_B5R, 226}, {PaperSize::G400_B6, 226}, {PaperSize::G400_DOUBLELETTER, 500}, {PaperSize::G400_B6R, 175}, {PaperSize::G400_LEGAL, 386}, {PaperSize::G400_LETTER, 339}, {PaperSize::G400_LETTERR, 276}, {PaperSize::G400_MAXSIZE, 1040},//300 dpi max heigth 690 {PaperSize::G400_AUTO, 1040},//300 dpi max heigth {PaperSize::G400_MAXAUTO, 1040}//300 dpi max heigth }; enum Scanner_Reg_Defs { SR_CMD, SR_STATUS, SR_SCAN_COUNT, SR_OS, SR_SENSORS, SR_MOTOR, SR_IM_TYPE, SR_IM_COUNT, SR_IM_TX, SR_IM_FRONT_SIZE, SR_IM_CLEAR, SR_IM_TXING, SR_IM_POP, SR_IM_ABORT, SR_COUNT, SR_CONFIG_SCAN_PARAM, SR_GET_FWVERSION, SR_SET_FWERSION, SR_GET_SERIALNUM, SR_SET_SERIALNUM, SR_CONFIF_IMGPROCPARAM, SC_AUTOCORRECT, SC_GET_CORRECT_PARAM, SC_SET_CORRECT_PARAM, SR_GET_H_RATIO, SR_SET_H_RATIO, SR_GET_V_RATIO, SR_SET_V_RATIO, SR_GET_SERIAL_LEN, SR_GET_GRAY_SP, SR_GET_COLOR_SP, SR_SET_GRAY_SP, SR_SET_COLOR_SP, SR_SET_SLEEPTIME, SR_GET_SLEEPTIME, SR_GET_SLEEP_STAUTUS, SR_GET_IMAGEPROCESSDONE, SR_GET_KEEP_LAST_PAPER, SR_GET_PAPERON, SR_SET_SPEEDMODE, SR_GET_SPEEDMODE, SR_GET_JOSN_SIZE, SR_GET_JSON, SR_SET_JSON_PATH, SR_SET_JSON, SR_GET_FILE_POS, SR_SET_FILE_POS, SR_NOTIFY_SLEEP, SR_GET_FEEDMODE, SR_SET_FEEDMODE, SR_GET_AUTOMATICCONTROLFEEDMODE_ENABLE, SR_SET_AUTOMATICCONTROLFEEDMODE_ENABLE, SR_GET_AUTOMATICCONTROLFEEDMODE_THRESHOLD, SR_SET_AUTOMATICCONTROLFEEDMODE_THRESHOLD, SR_GET_TRAYPOSITION, SR_SET_TRAYPOSITION, SR_GET_LOCK_STATES, SR_SET_LOCK_STATES, SR_GET_TOKEN, SR_SET_TOKEN, SR_GET_TOKEN_LENGHT, SR_DECODE_TOKEN, SR_CLEAN_PAPER_ROAD, SR_EXECUTE_CMD, SR_EXECUTE_CMD_OUT_LENGHT, SR_GET_EXECUTE_CMD_OUT, SR_GET_CUO_ERROR = 0x50, SR_GET_DOU_ERROR, SR_GET_JAM_ERROR, SR_GET_SCANN_NUM, SR_CLR_ROLLER_NUM, SR_GET_ROLLER_NUM, SR_CLR_SCANN_NUM, SR_GET_H_200_RATIO, //非敦南cis需返回false SR_SET_H_200_RATIO, SR_GET_V_200_RATIO, SR_SET_V_200_RATIO, SR_GET_H_300_RATIO, SR_SET_H_300_RATIO, SR_GET_V_300_RATIO, SR_SET_V_300_RATIO, SR_GET_H_600_RATIO, SR_SET_H_600_RATIO, SR_GET_V_600_RATIO, SR_SET_V_600_RATIO, SR_UPDATA_START = 0x100, SR_UPDATA_STAUTUS = 0x101, SR_UPDATA_MD5_RELUST = 0x102, SR_UPDATA_RECOVERY = 0x103, SR_UPDATA_REBOOT = 0x104, SR_POWEROFF = 0x105, SR_REBOOT = 0x106, SR_FLAT_CLR_MAX_BRIGHT, SR_FLAT_GRAY_MAX_BRIGHT, SR_KERNEL_VERSION_INFO_LENGTH, SR_GET_KERNEL_VERSION, SR_GET_MBSTATUS, SR_GET_IPADDR_LENGHT = 0x200, SR_GET_MACADDR, SR_GET_IPADDR, SR_GET_MBVERSION_LENGHT, SR_GET_MBVERSION, SR_GET_USBVIDPID, SR_SET_USBVIDPID, SR_SET_STARTBACKUP,//开始备份 SR_GET_BACKUPSTATUS,//备份状态 SR_SCAN_DPI = 0x600, SR_SCAN_CNT, SR_SCAN_PAPER, SR_SCAN_PIXEL, SR_CAPTURE_SET = 0x0ffffca00, }; enum capturer_set_func { CSF_EXPO_MASK = 0x10, CSF_EXPO_FB = 0, CSF_EXPO_FG, CSF_EXPO_FR, CSF_EXPO_BB, CSF_EXPO_BG, CSF_EXPO_BR, CSF_GAIN_MASK = 0x20, CSF_GAIN_BACK = 0, CSF_GAIN_FRONT, CSF_OFFSET_MASK = 0x40, CSF_OFFSET_BACK = 0, CSF_OFFSET_FRONT, }; typedef union Ctrol_Description{ std::uint32_t value; struct{ std::uint32_t direction : 1; std::uint32_t unused : 31; }Param; }CtrolDescription; enum Updata_Stautus { Start_updata, Download_file, Download_file_error, Download_file_finish, MD5_Reovery, MD5_Rboot, MD5_Error, Reboot }; enum Scanner_Cmd_Defs { SC_START, SC_STOP, SC_CLEAR, SC_COUNT }; enum HGScanSide { Duplex, Single, DisCardBlankNormal, DisCardBlacnkVince, Flod }; enum class HGRotate { Rot_0, Rot_90, Rot_180, Rot_270, Rot_auto }; typedef union USBVIDPID { struct{ unsigned short VID; unsigned short PID; }param; unsigned int value; }; typedef union HG_ImgProcParms { unsigned int value; struct { u32 papertype : 5; u32 scanside : 3; u32 res : 10; u32 rotate : 2; u32 autodescrew : 1; u32 fillbackground : 1; u32 filter : 4; u32 enhancecolor : 2; u32 fillhole : 1; u32 reversed : 3; } imgprocparams; } HGImgProcParms; ///用于CIS 自动校正参数保存 typedef struct { u32 gainF[6]; u32 gainB[6]; u32 offsetsF[6]; u32 offsetsB[6]; u32 expF[3]; u32 expB[3]; u32 sp; } HGCISConfig; typedef struct { HGCISConfig colorCorrect; HGCISConfig color; HGCISConfig grayCorrect; HGCISConfig gray; } HGCorrectConfigs; enum class CISVendor { CIS_UNKNOWUN, HUALIN_CIS_V0, DUNNAN_CIS_V0 }; #define STR_CORRECTCOLOR CorrectColor #define STR_COLOR Color #define STR_CORRECTGRAY CorrectGray #define STR_GRAY Gray #define STR_GAINF GainF #define STR_GAINB GainB #define STR_EXPF ExpF #define STR_EXPB ExpB #define STR_OFFSETF OffsetF #define STR_OFFSETB OffsetB #define STR_SP Sp #define STR(str) #str #define STRCON(str1, str2) STR(str1) \ STR(str2) #define LUT_COLOR_BLACK_PATH "/usr/local/huago/lut_0.bmp" #define LUT_COLOR_WHITE_PATH "/usr/local/huago/lut_1.bmp" #define LUT_GRAY_BLACK_PATH "/usr/local/huago/lut_2.bmp" #define LUT_GRAY_WHITE_PATH "/usr/local/huago/lut_3.bmp" #define LUT_COLOR_LUT_PATH "/usr/local/huago/color_lut.bmp" #define LUT_GRAY_LUT_PATH "/usr/local/huago/gray_lut.bmp" #define IMAGE_COLOR 1 #define IMAGE_GRAY 0 #define JSON_CORRECTFILE_PATH "/usr/local/huago/cisconfig.json" #define JSON_CORRECTDIR_PATH "/usr/local/huago" #define JSON_SCANNER_INFO_DIR "/usr/local/huago" #define JSON_SCANNER_INFO_FILE "/usr/local/huago/scannerinfo.json" #define S_INFO_TOTALSCANNED "TotalScanned" #define S_INFO_ROLLERNUM "RollerNum" #define S_INFO_HRATIO "HRatio" #define S_INFO_VRATIO "VRatio" #define S_GRAY_SP "GraySp" #define S_COLOR_SP "ColorSp" #define S_INFO_SLEEPTIME "Sleeptime" #define S_INFO_JAMNUM "JamInNum" #define S_INFO_FEEDERROR "FeedError" #define S_INFO_DOUNUM "DoubleNum" #define S_INFO_SCANSESSIONCOUNT "ScanTimes" #define S_INFO_SERIALNUM "SerialNum" #define S_INFO_TOKEN "ScannerToken" #define S_INFO_CLR_MAXBRT "FlatClrMaxBrt" #define S_INFO_GRAY_MAXBRT "FlatGrayMaxBrt" #define S_INFO_SPEEDMODE "SpeedMode" #define S_INFO_VID "VID" #define S_INFO_PID "PID" #define S_INFO_CHUZHI_MOTOR_SPEED_200 "Chu_Motor_Speed_200" #define S_INFO_CHUZHI_MOTOR_SPEED_300 "Chu_Motor_Speed_300" #define S_INFO_CHUZHI_MOTOR_SPEED_600 "Chu_Motor_Speed_600" #pragma pack(push) #pragma pack(4) typedef struct tagFillHole { byte is_fillhole; int fillholeratio; } FillHole; typedef struct tagDetachNoise { byte is_detachnoise; int detachnoise; } DetachNoise; enum LowPowerMode : unsigned int { Min_None = 0, Min_5, Min_10, Min_20, Min_30, Min_60, Min_120, Min_240 }; typedef struct tagHARDWAREPARAMS { byte capturepixtype; byte en_doublefeed; byte en_stapledetect; byte en_skrewdetect; byte skrewdetectlevel; LowPowerMode lowpowermode; #ifdef UV byte en_uv; #endif } HardwareCaps; typedef struct Scan_Rect { int width; int height; int x; int y; } ScanRect; enum PaperAlign : unsigned char { Rot0 = 0, Rot270 = 3, AutoTextOrientation = 5 }; typedef enum Enchace_Color : short { Enhance_None = 0, Enhance_Red, Enhance_Green, Enhance_Blue } EnchaceColor; typedef enum SharpenBlur : short { Sharpen_None, Sharpen_Normal, Sharpen_More, Sharpen_Blur, Sharpen_Blur_More } SharpenBlur; typedef struct tagCrop_Rect { int enable; int x; /*****自定义裁切区域左上角x坐标*/ int y; /*****自定义裁切区域左上角y坐标*/ int width; /*****自定义裁切区域宽�?******/ int height; /*****自定义裁切区域高�?******/ }CropRect; typedef enum tagMulti_Output { Unused = -1, All, ColorGray, ColorBw, GrayBw }MultiOutput; typedef struct tagSkew_Detection { int enable; int level; }SkewDetection; typedef struct tagHhardware_Params_3399 { int capturepixtype; int doubleFeedDetection; int bindingDetection; int sizeDetection; SkewDetection skewDetection; }HardwareCaps_3399; struct GScanCap { uint8_t papertype; PaperAlign paperAlign; uint8_t en_sizecheck; float imageRotateDegree; uint8_t is_duplex; uint8_t en_fold; int pixtype; int automaticcolor; int automaticcolortype; //ScanRect scanrect; float resolution_dst; float resolution_native; float gamma; float contrast; float brightness; float threshold; uint8_t is_autocontrast; uint8_t is_autocrop; uint8_t is_autodiscradblank_normal; int discardblank_percent; uint8_t is_autodiscradblank_vince; uint8_t is_switchfrontback; uint8_t autodescrew; uint8_t multi_output_red; uint8_t hsvcorrect; uint8_t filter; uint8_t sharpen; uint8_t enhance_color; uint8_t fillbackground; bool is_convex; int noise; int indent; int AutoCrop_threshold; unsigned short scannum; uint8_t is_backrotate180; uint8_t is_dogeardetection; HardwareCaps hardwarecaps; FillHole fillhole; DetachNoise detachnoise; uint8_t is_autotext; bool isfillcolor; int refuseInflow; int colorCorrection; int removeMorr; int errorExtention; int textureRemove; int splitImage; CropRect cropRect; MultiOutput multiOutput; bool normalCrop; uint32_t dogeardistabce; bool fadeback; int fadebackrange; bool isuploadexceptionimage; int fillholeratio_up; int fillholeratio_down; int fillholeratio_left; int fillholeratio_right; std::uint8_t fold_concatmode; /*拼接模式*/ int HsvFilterType; /**< 答题卡留红除杂色功能类型 暂定0 为关闭;1为留红除杂色>*/ bool is_colorcast; /**< 色偏校正>*/ uint32_t reserve[1024]; /**< 预留4096字节做协议扩展*/ }; #pragma pack(pop)