#pragma once #include #include #include #include using namespace std; /***************************************** * 定义编译版本 * * G400/G300 * ******************************************/ #define G300 /****************************************** * SPEEDMODE==3 60PPM * * SPEEDMODE==4 70PPM * * SPEEDMODE==5 80PPM * *******************************************/ #define SPEEDMODE 5 #define MT_DEBUG #define COLORSENSOR_SUP /*支持低功耗模式开关*/ #define ENABLE_LOWPOWERMODE /*支持写入系统syslog 功能开关*/ #define ENLOG_SYSLOG #define IMAGE_COLOR 1 #define IMAGE_GRAY 0 #ifdef _LOG #define LOG printf #else #define LOG //printf #endif #define FWVERSION "G345230918" #define SERIALNUM "HS6010A38001P1" typedef struct { int s_FRAME_COLOR_SP; int s_FRAME_GRAY_SP; string FWVERSIO; }sp_COLOR_or_GRAY; #define STR(X) #X #define CON(a,b) STR(a##b) static std::mapmapFradme_SP={ {1,{0x08ED1003,0x1ACC1002,CON(G340,230429)}},//40 ppm {2,{0x06DB1003,0x14A01002,CON(G350,230429)}},//50 ppm {3,{0x05591003,0x100E1002,CON(G360,230429)}},//60 ppm {4,{0x04421003,0x0CD11002,CON(G370,230429)}},//70 ppm {5,{0x036c1003,0x0A421002,CON(G380,230429)}},//80 ppm }; enum class LedStatus { Ready, Scanning, Abnormal, NoPaper, StopScan, CoverOpen, Updating, UpdateDone }; struct HG_JpegCompressInfo { unsigned int data_type; unsigned int first_frame; unsigned int last_frame; unsigned int index_frame; unsigned int DataLength; unsigned int width; unsigned int height; unsigned int dpi; unsigned char *pJpegData; //cv::Mat mat; }; struct HG_JpegCompressInfo_data { HG_JpegCompressInfo info; unsigned char *pJpegData[1]; }; struct HG_Msg{ int code; std::string msg; }; enum class CISVendor { CIS_UNKNOWUN, HUALIN_CIS_V0, DUNNAN_CIS_V0, DUNNAN_CIS_COLOR_V0 }; 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, G400_MAXSIZE, G400_AUTO, G400_MAXAUTO }; 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; } }; typedef struct Paper_Res { Paper_Res(unsigned int res,PaperSize papertype):Res(res),PaperType(papertype){} Paper_Res():Res(0),PaperType(PaperSize::G400_A4){} unsigned int Res; PaperSize PaperType; friend bool operator<(const struct Paper_Res &a,const struct Paper_Res &b) { if(a.Res &imageready, const std::function &deviceevent) : m_imageready(imageready), m_deviceevent(deviceevent) {} std::function m_imageready; std::function m_deviceevent; }; struct V4L2_DATAINFO { cv::Mat mat; unsigned char *data; int width; int height; int pixtype; }; struct V4L2_DATAINFO_Ex:V4L2_DATAINFO { unsigned int snaped_index; unsigned int frame_index; //总帧数 unsigned int dpi; //dpi unsigned int error_code; unsigned int first_frame; //第一帧 unsigned int lost_frame; //丢失帧 unsigned int last_frame; //最后一帧 unsigned int snap_end; //采集结束 }; typedef struct CaptureParams { int correctColorExposure[2][3]; int correctColorGain[2][6]; int correctColorOffset[2][6]; int correctGrayExposure[2][3]; int correctGrayGain[2][6]; int correctGrayOffset[2][6]; int colorExposure[2][3]; int colorGain[2][6]; int colorOffset[2][6]; int grayExposure[2][3]; int grayGain[2][6]; int grayOffset[2][6]; int uvCorrectColorExposure[2]; int uvCorrectGrayExposure[2]; int uvColorExposure[2]; int uvGrayExposure[2]; } CaptureParams; struct ScannerScanInfo { unsigned int TotalScanned; //扫描总页数 unsigned int RollerNum; unsigned int CuoNum; //搓纸总数 unsigned int JamInNum; //搓纸失败次数 unsigned int JamOutNum; //卡纸次数 unsigned int DoubleNum; //双张次数 unsigned int ErrorNum; //其他异常次数 unsigned int HRatio; //横向校正系数 unsigned int VRatio; //纵向校正系数 unsigned int SleepTime; //休眠时间 单位s unsigned int SpeedMode; //速率模式 unsigned int VID; //vid unsigned short PID; //pid std::string SerialNum; //序列号 std::string FWVersion; //固件版本号 std::string Token; //token 令牌 }; constexpr char BULK_CTL_PATH[] = "/dev/usb-ffs/mtp/ep0"; constexpr char BULK_OUT_PATH[] = "/dev/usb-ffs/mtp/ep2"; constexpr char BULK_IN_PATH[] = "/dev/usb-ffs/mtp/ep1"; constexpr char BULK_INT_PATH[] = "/dev/usb-ffs/mtp/ep3"; constexpr char STATE_PATH[] = "/sys/class/android_usb/android0/state"; union FLAT_INFO { struct { unsigned int dpi:5; unsigned int colormode:1; unsigned int is_whiteimage:1; unsigned int status:8; unsigned int reversed:1; unsigned int datalen:16; }params; unsigned int value; }; #define SLEEP_STATUS_PATH "/mnt/flash-disk/sleep_status.txt" #define UPDATE_STATUS_PATH "/mnt/flash-disk/update_status.txt" enum scanner_err { SCANNER_ERR_OK = 0, //设备正常状态 SCANNER_ERR_SLEEP, //设备处于休眠当中 SCANNER_ERR_UPDATE_OK, //设备更新:成功 SCANNER_ERR_UPDATE_UPDATAING, //设备更新:进行中 SCANNER_ERR_UPDATE_CHECK_VAL_ERROR, //设备更新:校验检测错误 SCANNER_ERR_UPDATE_CHECK_FILE_LOST, //设备更新:文件丢失 SCANNER_ERR_UPDATE_UNZIP_FAIL, //设备更新:解压失败 };