diff --git a/capimage/MultiFrameCapture.cpp b/capimage/MultiFrameCapture.cpp index dd9ee3e..d3b8eb4 100644 --- a/capimage/MultiFrameCapture.cpp +++ b/capimage/MultiFrameCapture.cpp @@ -148,6 +148,16 @@ void MultiFrameCapture::open(HGScanConfig config, FPGAConfigParam_8478 fpgaparam set_dpi_mode(config.g200params.dpi == 3); set_pixel_count_8478(fpgaparam.Sp / 3 / (config.g200params.color ? 3 : 1), config.g200params.color == false); configFPGAParam(config.g200params.color, config.g200params.dpi); + // write_adc_8478(bank_change[0],0x22,0x84,true); + // write_adc_8478(bank_change[0],0x22,0x84,false); + // for(int channel_ = 0;channel_<9;channel_++) + // { + // int i = 120*channel_; + // write_adc_8478(bank_change[0],7+channel_*2,(i/0x100)&0x3,true); + // write_adc_8478(bank_change[0],7+1+channel_*2,i&0xff,true); + // write_adc_8478(bank_change[0],7+channel_*2,(i/0x100)&0x3,false); + // write_adc_8478(bank_change[0],7+1+channel_*2,i&0xff,false); + // } configFPGAParam_digital_gain(config.g200params.color, config.g200params.dpi); set_exp_8478_single(fpgaparam.ExposureF[0], fpgaparam.ExposureF[1], fpgaparam.ExposureF[2], fpgaparam.Sp / (config.g200params.color ? 3 : 1), true, config.g200params.color); set_exp_8478_single(fpgaparam.ExposureB[0], fpgaparam.ExposureB[1], fpgaparam.ExposureB[2], fpgaparam.Sp / (config.g200params.color ? 3 : 1), false, config.g200params.color); @@ -180,8 +190,8 @@ void MultiFrameCapture::open(HGScanConfig config, FPGAConfigParam_8478 fpgaparam // fpgaComm->write(12,0x04e20400); //0x494e491 0x79de496 范围 0-12 16-28 (16-28 > 0-12) fpgaComm->read(10, reg10); - fpgaComm->write(12, 0x00f000e0); // 58us 300*600 多帧 - + // fpgaComm->write(12, 0x00f000e0); // 58us 300*600 多帧 + fpgaComm->write(12, 0x00200010); // 58us 300*600 多帧 fpgaComm->write(10, 0x0150012a); // 58us 300*600 多帧 fpgaComm->setFrameNum(1); diff --git a/capimage/MultiFrameCapture.h b/capimage/MultiFrameCapture.h index d996169..8688ec3 100644 --- a/capimage/MultiFrameCapture.h +++ b/capimage/MultiFrameCapture.h @@ -142,7 +142,7 @@ private: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x55, 0x00, 0x42, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x03, // bank 2 + 0x55, 0x00, 0x42, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x03, // bank 2 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/motorboard/SensorConfig.cpp b/motorboard/SensorConfig.cpp index af8ed2f..aee34f2 100644 --- a/motorboard/SensorConfig.cpp +++ b/motorboard/SensorConfig.cpp @@ -55,14 +55,18 @@ void SensorConfig::set_param(SensorConfig::SensorConfig_Param param) o.flush(); } -SensorConfig::SensorConfig_Param SensorConfig::get_mem_param() +SensorConfig::SensorConfig_Param& SensorConfig::get_mem_param() { return m_param; } +json SensorConfig::get_mem_param_js() +{ + return to_json(m_param); +} + void SensorConfig::initconfigfile() { - //std::lock_guard m_lc(m_lock); if(access(this->Path.c_str(),F_OK) == 0) return; SensorConfig::SensorConfig_Param param{ @@ -76,6 +80,8 @@ void SensorConfig::initconfigfile() .Sensor_Double_paper_check_cyc = 8, .Sensor_Double_double_max = 0x1c, .Sensor_Double_single_max = 0x70, + .Sensor_enable_config = 0, + .Sensor_Double_enable_config = 0, }; m_param = param; printf("\nfile: %s not found creat ...",this->Path.c_str()); @@ -86,6 +92,25 @@ void SensorConfig::initconfigfile() o.flush(); } +SensorConfig::SensorConfig_Param SensorConfig::get_default_param() +{ + SensorConfig::SensorConfig_Param param{ + .Sensor_Scan_Pwm = 40, + .Sensor_ConverOpen_Pwm = 40, + .Sensor_Screw_1_Pwm = 40, + .Sensor_Screw_2_Pwm = 40, + .Sensor_PaperOut_Pwm = 40, + .Sensor_PaperDetection_Pwm = 40, + .Sensor_Double_double_check_cyc = 4, + .Sensor_Double_paper_check_cyc = 8, + .Sensor_Double_double_max = 0x1c, + .Sensor_Double_single_max = 0x70, + .Sensor_enable_config = 0, + .Sensor_Double_enable_config = 0, + }; + return param; +} + void SensorConfig::reset_json() { std::lock_guard m_lc(m_lock); @@ -106,6 +131,8 @@ json SensorConfig::to_json(SensorConfig::SensorConfig_Param param) js[Sensor_Double_paper_check_cyc] = param.Sensor_Double_paper_check_cyc; js[Sensor_Double_double_max] = param.Sensor_Double_double_max; js[Sensor_Double_single_max] = param.Sensor_Double_single_max; + js[Sensor_enable_config] = param.Sensor_enable_config; + js[Sensor_Double_enable_config] = param.Sensor_Double_enable_config; return js; } @@ -122,26 +149,54 @@ SensorConfig::SensorConfig_Param SensorConfig::to_param(json js) .Sensor_Double_paper_check_cyc = 8, .Sensor_Double_double_max = 0x1c, .Sensor_Double_single_max = 0x70, + .Sensor_enable_config = 0, + .Sensor_Double_enable_config = 0, }; + bool b_save= false; if(js[Sensor_Scan_Pwm].is_object() && js[Sensor_Scan_Pwm].is_number_integer()) param.Sensor_Scan_Pwm = js[Sensor_Scan_Pwm]; + else b_save = true; if(js[Sensor_Screw_1_Pwm].is_object() && js[Sensor_Screw_1_Pwm].is_number_integer()) param.Sensor_Screw_1_Pwm = js[Sensor_Screw_1_Pwm]; + else b_save = true; if(js[Sensor_Screw_2_Pwm].is_object() && js[Sensor_Screw_2_Pwm].is_number_integer()) param.Sensor_Screw_2_Pwm = js[Sensor_Screw_2_Pwm]; + else b_save = true; if(js[Sensor_ConverOpen_Pwm].is_object() && js[Sensor_ConverOpen_Pwm].is_number_integer()) param.Sensor_ConverOpen_Pwm = js[Sensor_ConverOpen_Pwm]; + else b_save = true; if(js[Sensor_PaperOut_Pwm].is_object() && js[Sensor_PaperOut_Pwm].is_number_integer()) param.Sensor_PaperOut_Pwm = js[Sensor_PaperOut_Pwm]; + else b_save = true; if(js[Sensor_PaperDetection_Pwm].is_object() && js[Sensor_PaperDetection_Pwm].is_number_integer()) param.Sensor_PaperDetection_Pwm = js[Sensor_PaperDetection_Pwm]; + else b_save = true; if(js[Sensor_Double_double_check_cyc].is_object() && js[Sensor_Double_double_check_cyc].is_number_integer()) param.Sensor_Double_double_check_cyc = js[Sensor_Double_double_check_cyc]; + else b_save = true; if(js[Sensor_Double_paper_check_cyc].is_object() && js[Sensor_Double_paper_check_cyc].is_number_integer()) param.Sensor_Double_paper_check_cyc = js[Sensor_Double_paper_check_cyc]; + else b_save = true; if(js[Sensor_Double_double_max].is_object() && js[Sensor_Double_double_max].is_number_integer()) param.Sensor_Double_double_max = js[Sensor_Double_double_max]; + else b_save = true; if(js[Sensor_Double_single_max].is_object() && js[Sensor_Double_single_max].is_number_integer()) param.Sensor_Double_single_max = js[Sensor_Double_single_max]; + else b_save = true; + if(js[Sensor_enable_config].is_object() && js[Sensor_enable_config].is_number_integer()) + param.Sensor_enable_config = js[Sensor_enable_config]; + else b_save = true; + if(js[Sensor_Double_enable_config].is_object() && js[Sensor_Double_enable_config].is_number_integer()) + param.Sensor_enable_config = js[Sensor_Double_enable_config]; + else b_save = true; + if(b_save) + { + m_param = param; + auto js = to_json(param); + std::ofstream o(this->Path); + o << std::setw(4) << js < params(sizeof(SensorConfig::SensorConfig_Param)/sizeof(uint32_t)); - memcpy(¶ms[0],&p,sizeof(SensorConfig::SensorConfig_Param)); + std::vector params_p(sizeof(SensorConfig::SensorConfig_Param)/sizeof(uint32_t)); + std::vector params_dft(sizeof(SensorConfig::SensorConfig_Param)/sizeof(uint32_t)); + memcpy(¶ms_p[0],&p,sizeof(SensorConfig::SensorConfig_Param)); + memcpy(¶ms_dft[0],&dft,sizeof(SensorConfig::SensorConfig_Param)); + memcpy(¶ms[0],&dft,sizeof(SensorConfig::SensorConfig_Param)); + if(p.Sensor_enable_config) memcpy(¶ms[0],¶ms_p[0],sizeof(uint32_t)*6); + if(p.Sensor_Double_enable_config) memcpy(¶ms[6],¶ms[6],sizeof(uint32_t)*4); for(int i = 0;i= 0) || (i < 6)) && (params[i] < 100)) { diff --git a/packages/common.pkg/include/commondef.h b/packages/common.pkg/include/commondef.h index 889cf5a..4a743f1 100644 --- a/packages/common.pkg/include/commondef.h +++ b/packages/common.pkg/include/commondef.h @@ -8,10 +8,10 @@ #define G200 #ifdef G200 -#define FWVersion "G2393D0311" +#define FWVersion "G2393D0318" #define SERIALNUM "G2396021071101" #else -#define FWVersion "G1393D0311" +#define FWVersion "G1393D0318" #define SERIALNUM "G1396021071101" #endif @@ -521,6 +521,9 @@ enum Scanner_Reg_Defs SR_BACKUP_RESTORES_HUAGODIR, SR_SINGLE_CORRECT_MODE, SR_GET_DAIL_CODE, + SR_GET_COMB_Coefficients_Lenght, + SR_GET_COMB_Coefficients, + SR_SET_COMB_Coefficients, SR_GET_CUO_ERROR = 0x50, SR_GET_DOU_ERROR, SR_GET_JAM_ERROR, @@ -545,10 +548,12 @@ enum Scanner_Reg_Defs SR_GET_ARM_DATETIME, SR_GET_ARM_DATETIME_LENGHT, SR_SET_ARM_DATETIME, - SR_SET_SENSOR_PARAM, - SR_GET_SENSOR_PARAM, + SR_SET_SENSOR_CONFIG, + SR_GET_SENSOR_CONFIG, SR_SET_LCD_LANGUAGE, SR_GET_LCD_LANGUAGE, + SR_GET_SENSOR_CONFIG_LENGHT, + SR_GET_ULTRASONIC_VERSION, SR_UPDATA_START = 0x100, SR_UPDATA_STAUTUS = 0x101, SR_UPDATA_MD5_RELUST = 0x102, diff --git a/scanner/IScanner.h b/scanner/IScanner.h index d2dfab5..1b18b40 100644 --- a/scanner/IScanner.h +++ b/scanner/IScanner.h @@ -45,4 +45,5 @@ public: virtual void single_correct(std::uint32_t mode) = 0; virtual void set_sensor_param(int type,uint32_t val) =0; virtual std::uint32_t get_fpga_version() = 0; + virtual std::uint32_t get_ultrasonic_version() = 0; }; diff --git a/scanner/imageusbhandler.cpp b/scanner/imageusbhandler.cpp index 41a4e0f..6da0ea4 100644 --- a/scanner/imageusbhandler.cpp +++ b/scanner/imageusbhandler.cpp @@ -564,6 +564,7 @@ void ImageUsbHandler::add_image(void *data, int width, int height, int type, int imageencode.reset(new JpegImageEncode(false)); else imageencode.reset(new JpegImageEncode(m_hgimgconfig.pixtype == 0)); + // imageencode.reset(new JpegImageEncode(true)); // imageencode.reset(new BmpImageEncode()); encodedata.push_back(imageencode->encode(enMat)); } diff --git a/scanner/scanner.cpp b/scanner/scanner.cpp index c237ee0..df48b2e 100644 --- a/scanner/scanner.cpp +++ b/scanner/scanner.cpp @@ -1611,6 +1611,18 @@ void Scanner::set_sensor_param(int type, uint32_t val) params[type] = val; mb->set_ultrasonic_param(type-5,val); } + if((type == 10) || (type == 11)) + { + params[type] = (bool)val; + } + memcpy(&p,¶ms[0],sizeof(SensorConfig::SensorConfig_Param)); + Get_Static_SC().set_param(p); +} + +std::uint32_t Scanner::get_ultrasonic_version() +{ + if(!mb.get()) return 0; + return mb->get_ultrasonic_version(); } void Scanner::update_disk_syslog(std::string info,bool bprintf_diskinfo) diff --git a/scanner/scanner.h b/scanner/scanner.h index b159fb6..0eefa8f 100644 --- a/scanner/scanner.h +++ b/scanner/scanner.h @@ -54,6 +54,7 @@ public: virtual void clean_paper_road() override; virtual void single_correct(std::uint32_t mode) override; virtual void set_sensor_param(int type,uint32_t val) override; + virtual std::uint32_t get_ultrasonic_version() override; virtual std::uint32_t get_fpga_version() override { return mfpgaversion;} private: void runMessageLoop(); diff --git a/scanner/scannerregs.cpp b/scanner/scannerregs.cpp index e1cdcf7..3d2548c 100644 --- a/scanner/scannerregs.cpp +++ b/scanner/scannerregs.cpp @@ -672,36 +672,6 @@ bool ScannerRegAccess::write(unsigned int addr, const unsigned int val) +" "+std::to_string(hours)+":"+std::to_string(min)+":"+std::to_string(seconds)+"\"").c_str()); return true; } - case SR_GET_SENSOR_PARAM: - { - if(val < 1) return true; - printf("SR_GET_SENSOR_PARAM val %d \n ",val); - auto p = Get_Static_SC().get_mem_param(); - std::vector buf(val > 51200 ? 51200 : val,0); - memcpy(&buf[0],&p,(val*sizeof(uint32_t) > sizeof(p)) ? sizeof(p) : (val*sizeof(uint32_t))); - if(val>51200) - { - uint32_t copy_sz = 0; - while(copy_szwrite_bulk(&buf[0],(buf.size()>(val-copy_sz) ?(val - copy_sz) : buf.size())*sizeof(uint32_t)); - copy_sz += buf.size()>(val-copy_sz) ? (val - copy_sz) : buf.size(); - } - } - else transmit->write_bulk(&buf[0],val*sizeof(uint32_t)); - - return true; - } - case SR_SET_SENSOR_PARAM: - { - if((val < 0) || (val > 9)) - return true; - printf("SR_SET_SENSOR_PARAM val %d \n ",val); - if(scanner.get()) - scanner->set_sensor_param((val&0xff000000) >> 24,val&0xffffff); - return true; - - } case SR_SET_LCD_LANGUAGE: { if(val >=0 && val < 3) @@ -712,6 +682,36 @@ bool ScannerRegAccess::write(unsigned int addr, const unsigned int val) } return true; } + case SR_GET_SENSOR_CONFIG: + { + if(val < 1) return true; + std::string str = Get_Static_SC().get_mem_param_js().dump(); + str.resize(val); + transmit->write_bulk(&str[0],val); + return true; + } + case SR_SET_SENSOR_CONFIG: + { + if(val < 1) return true; + //1:扫描;2:开盖;3:歪斜—1;4:歪斜-2;5:出纸口;6:有无纸 7:双张检测周期;8:有无纸检测周期;9:双张阈值;10:单张阈值; + //11: 对射传感器配置使能; 12:双张传感器配置使能 + int type = val >> 24; + uint32_t duty = val & 0xffffff; + auto config = Get_Static_SC().get_mem_param(); + if((type>0)&&(type < 7)&&(duty < 100)) + { + scanner->set_sensor_param(type - 1,duty); + } + if((type>6)&&(type < 11)&&(duty < 255)) + { + scanner->set_sensor_param(type - 1,duty); + } + if((type == 11) || (type == 12)) + { + scanner->set_sensor_param(type - 1,duty); + } + return true; + } default: break; } @@ -1009,6 +1009,17 @@ bool ScannerRegAccess::read(unsigned int addr, unsigned int &val) val = Get_static_deviceconfig().GetParam().language; return true; } + case SR_GET_SENSOR_CONFIG_LENGHT: + { + json j = Get_Static_SC().get_mem_param_js(); + val = j.dump().length(); + return true; + } + case SR_GET_ULTRASONIC_VERSION: + { + val = scanner->get_ultrasonic_version(); + return true; + } default: break; }