1.添加传感器占空比配置接口
This commit is contained in:
parent
b6ce99ca7b
commit
8708f8f406
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<std::mutex> 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<std::mutex> 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 <<std::endl;
|
||||
o.close();
|
||||
o.flush();
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
|
|
@ -15,11 +15,13 @@ private:
|
|||
const std::string Sensor_ConverOpen_Pwm = "Sensor_ConverOpen_Pwm";
|
||||
const std::string Sensor_PaperOut_Pwm = "Sensor_PaperOut_Pwm";
|
||||
const std::string Sensor_PaperDetection_Pwm = "Sensor_PaperDetection_Pwm";
|
||||
const std::string Sensor_enable_config = "Sensor_enable_config";
|
||||
|
||||
const std::string Sensor_Double_double_check_cyc = "Sensor_Double_double_check_cyc";
|
||||
const std::string Sensor_Double_paper_check_cyc = "Sensor_Double_paper_check_cyc";
|
||||
const std::string Sensor_Double_double_max = "Sensor_Double_double_max";
|
||||
const std::string Sensor_Double_single_max = "Sensor_Double_single_max";
|
||||
const std::string Sensor_Double_enable_config = "Sensor_double_enable_config";
|
||||
|
||||
public:
|
||||
struct SensorConfig_Param
|
||||
|
@ -34,15 +36,17 @@ public:
|
|||
uint32_t Sensor_Double_paper_check_cyc; //双张有纸检测周期
|
||||
uint32_t Sensor_Double_double_max; //双张检测阈值
|
||||
uint32_t Sensor_Double_single_max; //双张有纸检测阈值
|
||||
uint32_t Sensor_enable_config; //对射传感器配置生效
|
||||
uint32_t Sensor_Double_enable_config; //超声波配置生效
|
||||
};
|
||||
|
||||
|
||||
|
||||
SensorConfig();
|
||||
~SensorConfig();
|
||||
SensorConfig::SensorConfig_Param get_param();
|
||||
void set_param(SensorConfig::SensorConfig_Param param);
|
||||
SensorConfig::SensorConfig_Param get_mem_param();
|
||||
SensorConfig::SensorConfig_Param& get_mem_param();
|
||||
json get_mem_param_js();
|
||||
SensorConfig_Param get_default_param();
|
||||
private:
|
||||
void initconfigfile();
|
||||
void reset_json();
|
||||
|
|
|
@ -833,9 +833,16 @@ bool MotorBoard::set_ultrasonic_param(int type,int value){
|
|||
|
||||
void MotorBoard::init_sensor_duty()
|
||||
{
|
||||
auto p = Get_Static_SC().get_mem_param();
|
||||
SensorConfig::SensorConfig_Param p = Get_Static_SC().get_mem_param();
|
||||
SensorConfig::SensorConfig_Param dft = Get_Static_SC().get_default_param();
|
||||
std::vector<uint32_t> params(sizeof(SensorConfig::SensorConfig_Param)/sizeof(uint32_t));
|
||||
memcpy(¶ms[0],&p,sizeof(SensorConfig::SensorConfig_Param));
|
||||
std::vector<uint32_t> params_p(sizeof(SensorConfig::SensorConfig_Param)/sizeof(uint32_t));
|
||||
std::vector<uint32_t> 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<params.size();i++){
|
||||
if(((i >= 0) || (i < 6)) && (params[i] < 100))
|
||||
{
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<uint32_t> 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_sz<val)
|
||||
{
|
||||
transmit->write_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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue