完善第二版主板 ARM流程
This commit is contained in:
parent
b99cd8a633
commit
c7683cdcdc
|
@ -29,29 +29,7 @@ using namespace std;
|
|||
using json = nlohmann::json;
|
||||
class JsonConfig
|
||||
{
|
||||
public:
|
||||
enum class ConfigType
|
||||
{
|
||||
Color_Flat,
|
||||
Color_Correct,
|
||||
Gray_Flat,
|
||||
Gray_Correct
|
||||
};
|
||||
private:
|
||||
map<ConfigType,string> cfgPaths={
|
||||
{ConfigType::Color_Flat,"/usr/local/etc/huago/Color_Flat.json"},
|
||||
{ConfigType::Color_Correct,"/usr/local/etc/huago/Color_Correct.json"},
|
||||
{ConfigType::Gray_Flat,"/usr/local/etc/huago/Gray_Flat.json"},
|
||||
{ConfigType::Gray_Correct,"/usr/local/etc/huago/Gray_Correct.json"}
|
||||
};
|
||||
|
||||
map<ConfigType,string> cfgPrefix={
|
||||
{ConfigType::Color_Flat,"Color_Flat"},
|
||||
{ConfigType::Color_Correct,"Color_Correct"},
|
||||
{ConfigType::Gray_Flat,"Gray_Flat"},
|
||||
{ConfigType::Gray_Correct,"Gray_Correct"}
|
||||
};
|
||||
ConfigType m_cfgType;
|
||||
public:
|
||||
JsonConfig();
|
||||
JsonConfig(ConfigType type);
|
||||
|
|
|
@ -8,7 +8,7 @@ CuoZhiMotor::CuoZhiMotor()
|
|||
m_cuoparamex = m_mtconfig->GetMotorSpeedParam(false, t_smbtype, 4, 1, 1);
|
||||
speedConfig();
|
||||
mspCuozhiFeeding = {.finalPeriod = 1427500, .Fmin = 2027500, .stepnum = 30, .a = 100, .offset = 4, .finalDelay = 3000};
|
||||
if (smbtype == SMBType::MB_DRV_TMC216)
|
||||
//if (smbtype == SMBType::MB_DRV_TMC216)
|
||||
{
|
||||
mspCuozhiFeeding.finalPeriod /= 4;
|
||||
mspCuozhiFeeding.Fmin /= 4;
|
||||
|
@ -96,10 +96,9 @@ void CuoZhiMotor::feeding()
|
|||
Motor::start(delays_feeding, mspCuozhiFeeding);
|
||||
}
|
||||
|
||||
void CuoZhiMotor::speedChange(int speed, int dpi, int colormode) // speed should be in range [0,5] (by ply,at 2019.5.23)
|
||||
void CuoZhiMotor::speedChange(MotorSpeedParamEx paramex)
|
||||
{
|
||||
auto t_smbtype = MotorConfig::MTBDType::MT_TMC;//SMBType::MB_DRV_TMC216;//smbtype == SMBType::MB_DRV_8825 ? MotorConfig::MTBDType::MT_DRV : MotorConfig::MTBDType::MT_TMC;
|
||||
m_cuoparamex = m_mtconfig->GetMotorSpeedParam(false, t_smbtype, speed, colormode, dpi);
|
||||
m_cuoparamex = paramex;
|
||||
speedConfig();
|
||||
}
|
||||
|
||||
|
@ -110,17 +109,6 @@ void CuoZhiMotor::speedRecover()
|
|||
|
||||
void CuoZhiMotor::speedConfig()
|
||||
{
|
||||
LOG("CuoZhiMotor speed=%d \n dpi=%d \n colormode=%d \n finalPeriod=%d \n Fmin=%d \n a=%.2f \n offset=%.2f \n stepnum=%.2f \n finalDelay=%.2f \n ",
|
||||
m_cuoparamex.speed,
|
||||
m_cuoparamex.dpi,
|
||||
m_cuoparamex.colormode,
|
||||
m_cuoparamex.mt_param.finalPeriod,
|
||||
m_cuoparamex.mt_param.Fmin,
|
||||
m_cuoparamex.mt_param.a,
|
||||
m_cuoparamex.mt_param.offset,
|
||||
m_cuoparamex.mt_param.stepnum,
|
||||
m_cuoparamex.mt_param.finalDelay);
|
||||
|
||||
delays_forward.clear();
|
||||
delays_forward = speedup_cfg(m_cuoparamex.mt_param.finalPeriod, m_cuoparamex.mt_param.Fmin, m_cuoparamex.mt_param.stepnum, m_cuoparamex.mt_param.a,
|
||||
m_cuoparamex.mt_param.offset, m_cuoparamex.mt_param.finalDelay);
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
|
||||
void feeding();
|
||||
|
||||
void speedChange(int speed, int dpi = 1,int colormode = 1);
|
||||
void speedChange(MotorSpeedParamEx paramex);
|
||||
|
||||
void speedRecover();
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@ DeviceExport::DeviceExport()
|
|||
write_dev(IOEXPORTPATH, ports[i]);
|
||||
|
||||
num = sizeof(pwms) / sizeof(pwms[0]);
|
||||
for (int i = 0; i < num; i++)
|
||||
write_dev(string_format(PWMEXPORTPATH, pwms[i]), 0);
|
||||
// for (int i = 0; i < num; i++)
|
||||
// write_dev(string_format(PWMEXPORTPATH, pwms[i]), 0); 2024第二版
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
write_dev(string_format(PWMEXPORTPATH, pwms[0]), i);
|
||||
}
|
||||
|
|
|
@ -25,43 +25,45 @@ extern std::string read_dev_s(std::string path);
|
|||
enum PIN_PORT_7010
|
||||
{
|
||||
//通道0-------------START
|
||||
SCAN_SENSOR = 0 + 1019, //扫描传感器
|
||||
HAVE_OR_NO_PAPER = 3 + 1019, //有无纸(0:无纸,1:有纸)
|
||||
OPEN_COVER_SENSOR = 4 + 1019, //是否开盖(0:未开盖,1:开盖)
|
||||
SCAN_SENSOR = 0 + 1017, //扫描传感器
|
||||
HAVE_OR_NO_PAPER = 3 + 1017, //有无纸(0:无纸,1:有纸)
|
||||
OPEN_COVER_SENSOR = 4 + 1017, //是否开盖(0:未开盖,1:开盖)
|
||||
WIDTH_DETECTION = 5 + 1017,
|
||||
SCREW_DETECTION = 6 + 1017,
|
||||
|
||||
ULTRASONIC_SENSORS_OUT0 = 18 + 901,
|
||||
ULTRASONIC_SENSORS_OUT1 = 17 + 901,
|
||||
ULTRASONIC_SENSORS_ON = 20 + 901,
|
||||
ULTRASONIC_SENSORS_ADJ = 19 + 901,
|
||||
ULTRASONIC_SENSORS_OUT0 = 18 + 899,
|
||||
ULTRASONIC_SENSORS_OUT1 = 17 + 899,
|
||||
ULTRASONIC_SENSORS_ON = 20 + 899,
|
||||
ULTRASONIC_SENSORS_ADJ = 19 + 899,
|
||||
//通道0-------------END
|
||||
SENSOR_POWER = 66 + 1019,
|
||||
SENSOR_POWER = 66 + 1017,
|
||||
|
||||
//通道1-------------START
|
||||
BUTTON_1_POWER = 21+1019, //按键1 电源
|
||||
BUTTON_2 = 22+1019, //按键2
|
||||
BUTTON_3 = 23+1019, //按键3
|
||||
LED_0_GREEN = 24+1019,
|
||||
LED_1_WHITE = 25+1019,
|
||||
LED_2_RED = 26+1019,
|
||||
BUTTON_1_POWER = 21+1017, //按键1 电源
|
||||
BUTTON_2 = 22+1017, //按键2
|
||||
BUTTON_3 = 23+1017, //按键3
|
||||
LED_0_GREEN = 24+1017,
|
||||
LED_1_WHITE = 25+1017,
|
||||
LED_2_RED = 26+1017,
|
||||
|
||||
//PWM0 电机1-START
|
||||
CUOZHI_PIN_DIR = 54+901, //方向(顺:0)
|
||||
CUOZHI_PIN_ENABEL = 55+901, //使能(有效:0)
|
||||
CUOZHI_PIN_RESET = 56+901, //重启 (1:电机转动,一般默认为1)
|
||||
CUOZHI_PIN_SLEEP = 57+901, //睡眠 (1:电机转动,一般默认为1)
|
||||
CUOZHI_PIN_DIR = 54+899, //方向(顺:0)
|
||||
CUOZHI_PIN_ENABEL = 55+899, //使能(有效:0)
|
||||
CUOZHI_PIN_RESET = 56+899, //重启 (1:电机转动,一般默认为1)
|
||||
CUOZHI_PIN_SLEEP = 57+899, //睡眠 (1:电机转动,一般默认为1)
|
||||
//PWM0 电机1-END
|
||||
|
||||
//PWM1 电机2-START
|
||||
ZOUZHI_PIN_DIR = 59+901, //方向(顺:0)
|
||||
ZOUZHI_PIN_ENABEL = 60+901, //使能(有效:0)
|
||||
ZOUZHI_PIN_RESET = 61+901, //重启 (1:电机转动,一般默认为1)
|
||||
ZOUZHI_PIN_SLEEP = 62+901, //睡眠 (1:电机转动,一般默认为1)
|
||||
ZOUZHI_PIN_DIR = 59+899, //方向(顺:0)
|
||||
ZOUZHI_PIN_ENABEL = 60+899, //使能(有效:0)
|
||||
ZOUZHI_PIN_RESET = 61+899, //重启 (1:电机转动,一般默认为1)
|
||||
ZOUZHI_PIN_SLEEP = 62+899, //睡眠 (1:电机转动,一般默认为1)
|
||||
|
||||
|
||||
//PWM1 电机2-END
|
||||
//通道1-------------END
|
||||
MOTOR_POWER_1 = 64 + 901, //电机1 电源开关
|
||||
MOTOR_POWER_2 = 65 + 901, //电机2 电源开关
|
||||
MOTOR_POWER_1 = 64 + 899, //电机1 电源开关
|
||||
MOTOR_POWER_2 = 65 + 899, //电机2 电源开关
|
||||
};
|
||||
|
||||
class DeviceExport
|
||||
|
@ -69,10 +71,12 @@ class DeviceExport
|
|||
public:
|
||||
DeviceExport();
|
||||
private:
|
||||
const int ports[17] = { MOTOR_POWER_1, CUOZHI_PIN_RESET, CUOZHI_PIN_SLEEP,CUOZHI_PIN_ENABEL, CUOZHI_PIN_DIR,
|
||||
const int ports[20] = { MOTOR_POWER_1, CUOZHI_PIN_RESET, CUOZHI_PIN_SLEEP,CUOZHI_PIN_ENABEL, CUOZHI_PIN_DIR,
|
||||
MOTOR_POWER_2, ZOUZHI_PIN_RESET, ZOUZHI_PIN_SLEEP,ZOUZHI_PIN_ENABEL, ZOUZHI_PIN_DIR,
|
||||
SCAN_SENSOR,HAVE_OR_NO_PAPER, OPEN_COVER_SENSOR,ULTRASONIC_SENSORS_OUT0,ULTRASONIC_SENSORS_OUT1,ULTRASONIC_SENSORS_ON};
|
||||
SCAN_SENSOR,HAVE_OR_NO_PAPER, OPEN_COVER_SENSOR,ULTRASONIC_SENSORS_OUT0,ULTRASONIC_SENSORS_OUT1,ULTRASONIC_SENSORS_ON,
|
||||
SCREW_DETECTION,WIDTH_DETECTION};
|
||||
|
||||
const int pwms[3] = { 0, 1 ,2};
|
||||
//const int pwms[3] = { 0, 1 ,2}; //2024 第二版
|
||||
const int pwms[3] = { 0};
|
||||
};
|
||||
|
||||
|
|
|
@ -1226,7 +1226,9 @@ void HCamDevice::HtCamGetFrameCnt(uint32_t &val)
|
|||
|
||||
void HCamDevice::HtCamGetFrameNum(uint32_t &val)
|
||||
{
|
||||
val = HtCamReadFpgaRegs(0x15);
|
||||
CamZ_Reg_2Short reg;
|
||||
reg.value = HtCamReadFpgaRegs(0x15);
|
||||
val = reg.NShort[0];
|
||||
camera_print(" HtCamGetFrameNum :%d\n",val);
|
||||
}
|
||||
void HCamDevice:: HtCamWriteFpgaRegs(uint8_t reg_addr, uint32_t reg_value)
|
||||
|
|
|
@ -50,13 +50,11 @@ std::vector<int> speedup_cfg(int finalPeriod, int Fmin, int stepnum, int a, int
|
|||
return freqs;
|
||||
}
|
||||
|
||||
//GpioOut Motor::powerPin(MotorPower);
|
||||
|
||||
Motor::Motor(MotorPorts motorPorts):sleepPin(motorPorts.sleep),
|
||||
resetPin(motorPorts.reset),
|
||||
enablePin(motorPorts.enable),
|
||||
dirPin(motorPorts.dir),
|
||||
pwm(motorPorts.pwm),
|
||||
pwm(0,motorPorts.pwm),
|
||||
motor_power(motorPorts.power)
|
||||
{
|
||||
sleepPin.setDirection(Gpio::out);
|
||||
|
|
|
@ -71,17 +71,17 @@ void MultiFrameCapture::snap()
|
|||
|
||||
if (is_remove_morr_)
|
||||
this_thread::sleep_for(std::chrono::milliseconds(70));
|
||||
else
|
||||
{
|
||||
if (resolution_ == 3 )
|
||||
this_thread::sleep_for(std::chrono::milliseconds(140));
|
||||
else if(resolution_ == 2 && paper_size_ != (int)PaperSize::G400_AUTO && color_mode_ == 1)
|
||||
this_thread::sleep_for(std::chrono::milliseconds(45));
|
||||
else
|
||||
this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
}
|
||||
|
||||
// else
|
||||
// {
|
||||
// if (resolution_ == 3 )
|
||||
// this_thread::sleep_for(std::chrono::milliseconds(140));
|
||||
// else if(resolution_ == 2 && paper_size_ != (int)PaperSize::G400_AUTO && color_mode_ == 1)
|
||||
// this_thread::sleep_for(std::chrono::milliseconds(45));
|
||||
// else
|
||||
// this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
// }
|
||||
|
||||
printf("开始采集---------------------------\r\n");
|
||||
|
||||
video->HtCamStartVideoCapturing();
|
||||
m_cv_snap.notify_all();
|
||||
|
@ -185,7 +185,8 @@ void MultiFrameCapture::UpdateScanParam(HG_ScanConfiguration config)
|
|||
paper_size_ = config.params.pageSize;
|
||||
is_double_paper_ = config.params.doubleFeeded;
|
||||
is_remove_morr_ = config.params.slow_moire;
|
||||
|
||||
screw_detect_enable = config.params.screw_detect_enable;
|
||||
width_detect_enable = config.params.width_detect_enable;
|
||||
//width_ = paper_size_ == PaperSize::G400_MAXSIZE || paper_size_ ==PaperSize::G400_MAXAUTO &&
|
||||
|
||||
video->HtCamSetPeriod(config.params.dc);
|
||||
|
|
|
@ -75,6 +75,8 @@ private:
|
|||
unsigned int is_correct_; // 是否校正
|
||||
unsigned int is_double_paper_; // 是否启动双张检测
|
||||
unsigned int is_remove_morr_; // 去除摩尔纹
|
||||
unsigned int width_detect_enable; // 是否宽度检测
|
||||
unsigned int screw_detect_enable; // 是否歪斜检测
|
||||
|
||||
cv::Mat lut;
|
||||
std::map<PaperSize, SIZE> paper_map_
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#include "Pwm.h"
|
||||
#include "DevUtil.h"
|
||||
|
||||
#define PWMPATH "%s%d/pwm0/%s"
|
||||
#define PWMPATH "%s%d/pwm%d/%s"
|
||||
|
||||
Pwm::Pwm(int port)
|
||||
Pwm::Pwm(int port,int pwm)
|
||||
{
|
||||
path_enable = string_format(PWMPATH, path_base.c_str(), port, path_enable.c_str());
|
||||
path_duty_cycle = string_format(PWMPATH, path_base.c_str(), port, path_duty_cycle.c_str());
|
||||
path_period = string_format(PWMPATH, path_base.c_str(), port, path_period.c_str());
|
||||
path_enable = string_format(PWMPATH, path_base.c_str(), port,pwm, path_enable.c_str());
|
||||
path_duty_cycle = string_format(PWMPATH, path_base.c_str(), port,pwm, path_duty_cycle.c_str());
|
||||
path_period = string_format(PWMPATH, path_base.c_str(), port, pwm,path_period.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@ void Pwm::setFreq(int freq)
|
|||
int value = PWM_PERIOD / freq;
|
||||
write_dev(path_period, value);
|
||||
write_dev(path_duty_cycle, value / 2);
|
||||
//printf("value:%d\r\n",value);
|
||||
}
|
||||
|
||||
int Pwm::getFreq()
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
class Pwm
|
||||
{
|
||||
public:
|
||||
Pwm(int port);
|
||||
Pwm(int port,int pwm);
|
||||
~Pwm();
|
||||
|
||||
void setFreq(int freq);
|
||||
|
|
|
@ -11,23 +11,17 @@
|
|||
#define BTN_NORMAL_POWER 3 //按键正常模式 (退出低功耗)
|
||||
|
||||
Scanner::Scanner(ScannerGlue glue)
|
||||
: motorZouzhi(),
|
||||
motorCuozhi(),
|
||||
m_glue(glue),
|
||||
m_isPulling(false),
|
||||
m_isDoublePaper(false),
|
||||
isPaperInit(false),
|
||||
m_jamPaper(false),
|
||||
m_jamIn(false),
|
||||
m_correctting(false),
|
||||
waitpapertime(200),
|
||||
m_scansysinfo(nullptr)
|
||||
: motorZouzhi(),motorCuozhi(),motor_cfg_(),
|
||||
m_glue(glue),m_isPulling(false),
|
||||
m_isDoublePaper(false),isPaperInit(false),
|
||||
m_jamPaper(false),m_jamIn(false),
|
||||
m_correctting(false),waitpapertime(200),
|
||||
m_scansysinfo(nullptr),auto_size_(false)
|
||||
{
|
||||
frame_time_ = 3000;
|
||||
m_scaninfo = GetScanInfoFromJson();
|
||||
|
||||
capturer.reset(new MultiFrameCapture(m_glue));
|
||||
|
||||
capturer->SetParent(this);
|
||||
capturer->set_image_callback(&have_img_callback);
|
||||
|
||||
|
@ -78,6 +72,7 @@ Scanner::Scanner(ScannerGlue glue)
|
|||
FsmState::setScanner(this);
|
||||
threadRunMessageLoop = std::thread(&Scanner::runMessageLoop, this);
|
||||
Motor::enablePower(true);
|
||||
UpdateScanInfo();
|
||||
}
|
||||
|
||||
Scanner::~Scanner()
|
||||
|
@ -93,25 +88,63 @@ Scanner::~Scanner()
|
|||
threadRunScan.join();
|
||||
}
|
||||
|
||||
|
||||
void Scanner::updateSpeedMode()
|
||||
{
|
||||
m_scaninfo = GetScanInfoFromJson();
|
||||
int sp = m_scaninfo.SpeedMode;
|
||||
if(sp == 0)
|
||||
sp = 3;
|
||||
int speed = m_scaninfo.SpeedMode;
|
||||
printf("JSON文件获取当前速度:%d\r\n",speed);
|
||||
if(speed == 0)
|
||||
speed = 3;
|
||||
|
||||
unsigned int t_dpi = m_config.params.dpi;
|
||||
|
||||
if(m_config.params.pageSize == (unsigned int)PaperSize::G400_MAXSIZE || m_config.params.pageSize == (unsigned int)PaperSize::G400_MAXAUTO ) //长文稿采用600dpi模式扫描
|
||||
t_dpi = 3;
|
||||
if (m_config.params.slow_moire) //摩尔纹特殊处理
|
||||
t_dpi = sp = 16;
|
||||
t_dpi = speed = 16;
|
||||
|
||||
motorCuozhi.speedChange(sp, t_dpi,m_config.params.isColor);
|
||||
motorZouzhi.speedChange(sp, t_dpi,m_config.params.isColor);
|
||||
Zouzhi_ParamEx_ = motor_cfg_.GetMotorSpeedParam(true,MotorConfig::MTBDType::MT_TMC,speed,m_config.params.isColor,t_dpi);
|
||||
Cuozhi_ParamEx_ = motor_cfg_.GetMotorSpeedParam(false,MotorConfig::MTBDType::MT_TMC,speed,m_config.params.isColor,t_dpi);
|
||||
|
||||
motorCuozhi.speedChange(Cuozhi_ParamEx_);
|
||||
motorZouzhi.speedChange(Zouzhi_ParamEx_);
|
||||
}
|
||||
void Scanner::ConfigScanParam(HG_ScanConfiguration config)
|
||||
{
|
||||
m_config = config;
|
||||
auto_size_ = m_config.params.pageSize==(int)PaperSize::G400_AUTO ||
|
||||
m_config.params.pageSize==(int)PaperSize::G400_MAXAUTO ||
|
||||
m_config.params.pageSize==(int)PaperSize::G400_MAXSIZE;
|
||||
|
||||
updateSpeedMode();
|
||||
capturer->UpdateScanParam(m_config);
|
||||
}
|
||||
void Scanner::UpdateScanInfo()
|
||||
{
|
||||
m_scaninfo = GetScanInfoFromJson();
|
||||
auto params = motor_cfg_.GetMotorSpeedParams(true,MotorConfig::MTBDType::MT_TMC);
|
||||
for (int i = 0; i < params.size(); i++)
|
||||
{
|
||||
if (params[i].speed == m_scaninfo.SpeedMode)
|
||||
{
|
||||
auto fpgaparam = GetFpgaparam(params[i].dpi, params[i].colormode);
|
||||
fpgaparam.Sp = params[i].sp;
|
||||
SaveFpgaparam(fpgaparam);
|
||||
if (params[i].dpi == 3 && params[i].colormode)
|
||||
{
|
||||
printf("sp sp sp sp sp sp sp sp sp:%d :%d\r\n",params[i].sp,fpgaparam.Sp);
|
||||
}
|
||||
|
||||
}
|
||||
// if(params[i].speed == 0x10)
|
||||
// {
|
||||
// auto fpgaparam = GetFpgaparam(params[i].dpi, params[i].colormode);
|
||||
// fpgaparam.Sp = params[i].sp;
|
||||
// SaveFpgaparam(fpgaparam);
|
||||
// }
|
||||
}
|
||||
updateSpeedMode();
|
||||
}
|
||||
void Scanner::have_img_callback(int val)
|
||||
{
|
||||
if (val < 0)
|
||||
|
@ -126,7 +159,7 @@ void Scanner::startScan()
|
|||
if (threadRunScan.joinable())
|
||||
threadRunScan.join();
|
||||
stop_countdown();
|
||||
this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
|
||||
updateSpeedMode();
|
||||
// //开始进行扫描
|
||||
threadRunScan = std::thread(&Scanner::runScan, this);
|
||||
|
@ -208,8 +241,8 @@ void Scanner::processevent(FsmState *fsmState, ScanEvent event)
|
|||
void Scanner::runScan()
|
||||
{
|
||||
LOG("-------------Scanner RunScan Start-------------\r\n");
|
||||
sensor->resetPaperPin();
|
||||
capturer->open();
|
||||
motorZouzhi.start();
|
||||
motorCuozhi.pauseWaitForThread();
|
||||
|
||||
if (!isPaperInit)
|
||||
|
@ -217,26 +250,18 @@ void Scanner::runScan()
|
|||
preFeed();
|
||||
isPaperInit = true;
|
||||
}
|
||||
|
||||
this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
sensor->resetPaperPin();
|
||||
capturer->resetimageremain();
|
||||
motorZouzhi.start();
|
||||
capturer->setScanFlag(true);
|
||||
|
||||
bool b_autosize = m_config.params.pageSize==(int)PaperSize::G400_AUTO ||
|
||||
m_config.params.pageSize==(int)PaperSize::G400_MAXAUTO ||
|
||||
m_config.params.pageSize==(int)PaperSize::G400_MAXSIZE;
|
||||
StopWatch sw;
|
||||
StopWatch sw1;
|
||||
|
||||
isScaning = true;
|
||||
int error_code = 0;
|
||||
while (m_DstScannum > 0)
|
||||
{
|
||||
isScaning = true;
|
||||
sw1.reset();
|
||||
m_isDoublePaper = false;
|
||||
m_jamPaper = false;
|
||||
m_jamIn = false;
|
||||
int error_code = 0;
|
||||
while (m_DstScannum > 0)
|
||||
{
|
||||
if (!sensor->isPaperStandby()) //无纸
|
||||
{
|
||||
if (!sensor->waitPaperStandBy(0))
|
||||
|
@ -254,7 +279,7 @@ void Scanner::runScan()
|
|||
break;
|
||||
}
|
||||
|
||||
motorCuozhi.startAsyn(); //
|
||||
motorCuozhi.startAsyn();
|
||||
if (!sensor->isPaperStandby())
|
||||
{
|
||||
put(S_EVT_STOP_SCAN);
|
||||
|
@ -287,6 +312,11 @@ void Scanner::runScan()
|
|||
}
|
||||
|
||||
printf("一张纸所需要的采集时间:%dms\r\n",frame_time_);
|
||||
if (auto_size_ || m_config.params.dpi == 3)
|
||||
{
|
||||
frame_time_ += 2000;
|
||||
}
|
||||
|
||||
if (sensor->waitPaperOut(frame_time_))
|
||||
{
|
||||
if (!m_isDoublePaper)
|
||||
|
@ -306,7 +336,7 @@ void Scanner::runScan()
|
|||
}
|
||||
|
||||
sensor->enableDoubleSensor(false);
|
||||
capturer->stopsnap(b_autosize);
|
||||
capturer->stopsnap(auto_size_);
|
||||
|
||||
error_code = m_isDoublePaper ? (int)HG_ScannerStatus::DETECT_DOUBLE_FEED : m_jamPaper ? (int)HG_ScannerStatus::PAPER_JAM :0;
|
||||
capturer->waitsnapdone(error_code);//等待采集完成
|
||||
|
@ -330,7 +360,7 @@ void Scanner::runScan()
|
|||
printf("200DPI 图像队列过多,正在等待图像取走:%d\r\n",image_num_);
|
||||
this_thread::sleep_for(std::chrono::milliseconds(300));
|
||||
}
|
||||
while ( m_config.params.dpi == 0x02 && image_num_ >= 8 && m_config.params.isColor == 1)
|
||||
while ( m_config.params.dpi == 0x02 && image_num_ >= 12 && m_config.params.isColor == 1)
|
||||
{
|
||||
printf("300DPI 图像队列过多,正在等待图像取走:%d\r\n",image_num_);
|
||||
this_thread::sleep_for(std::chrono::milliseconds(300));
|
||||
|
@ -362,7 +392,7 @@ void Scanner::runScan()
|
|||
sensor->enableDoubleSensor(false);
|
||||
sensor->resetPaperPin();
|
||||
capturer->setScanFlag(false);
|
||||
capturer->stopsnap(b_autosize);
|
||||
capturer->stopsnap(auto_size_);
|
||||
|
||||
int t_delay = 500;
|
||||
this_thread::sleep_for(std::chrono::milliseconds(t_delay)); //走纸多转一会儿 确保扫描传感器过了之后 纸能出完
|
||||
|
@ -378,11 +408,11 @@ void Scanner::CreatCorrectData(int correctmode)
|
|||
|
||||
void Scanner::preFeed()
|
||||
{
|
||||
int sleeptime = 300;
|
||||
int sleeptime = 150;
|
||||
motorCuozhi.feeding();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(sleeptime));
|
||||
motorCuozhi.pause();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(300));
|
||||
//std::this_thread::sleep_for(std::chrono::milliseconds(300));
|
||||
}
|
||||
|
||||
std::string Scanner::GetSysInfo()
|
||||
|
@ -452,7 +482,7 @@ void Scanner::reset()
|
|||
motorCuozhi.reset();
|
||||
isRested = true;
|
||||
isPaperInit = false;
|
||||
LOG("Scanner->motorCuozhi is reseted \n");
|
||||
printf("Scanner->motorCuozhi is reseted \n");
|
||||
}
|
||||
}
|
||||
void Scanner::paper_pullout()
|
||||
|
@ -461,7 +491,8 @@ void Scanner::paper_pullout()
|
|||
m_isPulling = true;
|
||||
|
||||
motorCuozhi.stop();
|
||||
motorZouzhi.speedChange(1);
|
||||
MotorSpeedParamEx ParamEx = motor_cfg_.GetMotorSpeedParam(true,MotorConfig::MTBDType::MT_TMC,1,1,1);
|
||||
motorZouzhi.speedChange(ParamEx);
|
||||
motorZouzhi.setDirection(1);
|
||||
motorZouzhi.start();
|
||||
if (sensor->waitPaperOut(5000))
|
||||
|
@ -471,8 +502,3 @@ void Scanner::paper_pullout()
|
|||
m_isPulling = false;
|
||||
}
|
||||
|
||||
void Scanner::UpdateScanInfo()
|
||||
{
|
||||
m_scaninfo = GetScanInfoFromJson();
|
||||
updateSpeedMode();
|
||||
}
|
|
@ -17,10 +17,11 @@
|
|||
#include "SysInforTool.h"
|
||||
#include "MotorConfig.h"
|
||||
#include "correct_ultis.h"
|
||||
|
||||
class ICapturer;
|
||||
class MemoryInfo;
|
||||
// class SysInforTool;
|
||||
static int frame_time_ ;
|
||||
|
||||
static int frame_time_ ;
|
||||
class Scanner
|
||||
{
|
||||
std::mutex cb_lock_;
|
||||
|
@ -51,7 +52,8 @@ public:
|
|||
inline bool isFeederLoaded() { return sensor->isPaperStandby(); }
|
||||
inline void put(ScanEvent evt) { sysEvent.Put(evt); }
|
||||
|
||||
inline void ConfigScanParam(HG_ScanConfiguration config) {capturer->UpdateScanParam(m_config = config); }
|
||||
void ConfigScanParam(HG_ScanConfiguration config) ;
|
||||
|
||||
inline void SetDstScanNum(int scannum) { m_DstScannum = scannum; }
|
||||
inline void SetIsDoublePaper(bool isdoublepaper) { m_isDoublePaper = isdoublepaper; }
|
||||
|
||||
|
@ -91,6 +93,10 @@ private:
|
|||
private:
|
||||
ZouZhiMotor motorZouzhi;
|
||||
CuoZhiMotor motorCuozhi;
|
||||
MotorConfig motor_cfg_;
|
||||
|
||||
MotorSpeedParamEx Zouzhi_ParamEx_;
|
||||
MotorSpeedParamEx Cuozhi_ParamEx_;
|
||||
|
||||
PanelLeds panelLeds;
|
||||
std::thread threadRunScan;
|
||||
|
@ -113,6 +119,7 @@ private:
|
|||
volatile bool m_correctting;
|
||||
|
||||
bool isPaperInit;
|
||||
bool auto_size_;//匹配原始尺寸类型尺寸
|
||||
|
||||
int waitpapertime;
|
||||
MemoryInfo *meminfo;
|
||||
|
|
|
@ -14,22 +14,26 @@
|
|||
|
||||
Sensor::Sensor(BlockingQueue<ScanEvent> &sysEvents)
|
||||
:events(sysEvents),
|
||||
pwm2(2),
|
||||
//pwm2(0,1),
|
||||
coverPin(PIN_PORT_7010::OPEN_COVER_SENSOR),
|
||||
paperPin(PIN_PORT_7010::HAVE_OR_NO_PAPER),
|
||||
scanPin (PIN_PORT_7010::SCAN_SENSOR),
|
||||
doubleEnablePin(PIN_PORT_7010::ULTRASONIC_SENSORS_ON),
|
||||
double_out0_Pin(PIN_PORT_7010::ULTRASONIC_SENSORS_OUT1),
|
||||
double_out1_Pin(PIN_PORT_7010::ULTRASONIC_SENSORS_OUT0),
|
||||
sensor_power(PIN_PORT_7010::SENSOR_POWER)
|
||||
sensor_power(PIN_PORT_7010::SENSOR_POWER),
|
||||
screw_detect(PIN_PORT_7010::SCREW_DETECTION),
|
||||
width_detect(PIN_PORT_7010::WIDTH_DETECTION)
|
||||
|
||||
{
|
||||
|
||||
pwm2.setFreq(2583);
|
||||
//pwm2.setFreq(2583);
|
||||
|
||||
pwm2.enable(Gpio::High);
|
||||
//pwm2.enable(Gpio::High);
|
||||
sensor_power.setValue(Gpio::High); //默认打开电源
|
||||
doubleEnablePin.setValue(Gpio::High);
|
||||
doubleEnablePin.setValue(Gpio::Low);
|
||||
screw_detect.setValue(Gpio::Low);
|
||||
width_detect.setValue(Gpio::Low);
|
||||
|
||||
///////输入输出模式//////
|
||||
coverPin.setDirection(Gpio::in);
|
||||
|
@ -39,6 +43,9 @@ Sensor::Sensor(BlockingQueue<ScanEvent> &sysEvents)
|
|||
double_out1_Pin.setDirection(Gpio::in);
|
||||
sensor_power.setDirection(Gpio::in);
|
||||
|
||||
screw_detect.setDirection(Gpio::in);
|
||||
width_detect.setDirection(Gpio::in);
|
||||
|
||||
doubleEnablePin.setDirection(Gpio::out);
|
||||
|
||||
|
||||
|
@ -98,13 +105,18 @@ bool Sensor::isDoublePaper()
|
|||
bool Sensor::waitPaperIn(int timeout_ms)
|
||||
{
|
||||
std::unique_lock<std::mutex> lck(cv_m);
|
||||
return cv_scan_at.wait_for(lck, std::chrono::milliseconds(timeout_ms)) == std::cv_status::no_timeout;
|
||||
printf("等待纸张进入\r\n");
|
||||
bool b = cv_scan_at.wait_for(lck, std::chrono::milliseconds(timeout_ms)) == std::cv_status::no_timeout;
|
||||
printf("纸张进入\r\n");
|
||||
return b;
|
||||
}
|
||||
|
||||
bool Sensor::waitPaperOut(int timeout_ms)
|
||||
{
|
||||
std::unique_lock<std::mutex> lck(cv_m);
|
||||
printf("等待纸张出去\r\n");
|
||||
cv_scan_not_at.wait_for(lck, std::chrono::milliseconds(timeout_ms)) == std::cv_status::no_timeout;
|
||||
printf("纸张出去\r\n");
|
||||
return isPaperIn();
|
||||
}
|
||||
|
||||
|
@ -152,6 +164,7 @@ void Sensor::monitor()
|
|||
ret = poll(&pfd, 1, 1000);
|
||||
if (ret <= 0)
|
||||
{
|
||||
sw2.reset();
|
||||
continue;
|
||||
}
|
||||
if (pfd.revents & POLLPRI)
|
||||
|
|
|
@ -13,11 +13,23 @@ public:
|
|||
~Sensor();
|
||||
|
||||
//出现双张或者在没有双张时并且结束扫描需要关闭超声波检测,
|
||||
void enableDoubleSensor(bool enable) {
|
||||
void enableDoubleSensor(bool enable)
|
||||
{
|
||||
enbale_double_ = enable;
|
||||
doubleEnablePin.setValue((Gpio::GpioLevel)enable);
|
||||
printf("是否使能超声波:%s\r\n",enable?"true":"false");
|
||||
}
|
||||
void screw_detect_enable(bool enable)
|
||||
{
|
||||
screw_detect.setValue((Gpio::GpioLevel)enable);
|
||||
printf("是否使能歪斜检测:%s\r\n",enable?"true":"false");
|
||||
}
|
||||
void width_detect_enable(bool enable)
|
||||
{
|
||||
width_detect.setValue((Gpio::GpioLevel)enable);
|
||||
printf("是否使能宽度检测:%s\r\n",enable?"true":"false");
|
||||
}
|
||||
|
||||
|
||||
void resetPaperPin();
|
||||
//是否扫描仪盖关上
|
||||
|
@ -49,7 +61,10 @@ private:
|
|||
Gpio double_out1_Pin;
|
||||
Gpio doubleEnablePin;
|
||||
Gpio sensor_power;
|
||||
Pwm pwm2;
|
||||
|
||||
Gpio screw_detect;
|
||||
Gpio width_detect;
|
||||
//Pwm pwm2;
|
||||
BlockingQueue<ScanEvent>& events;
|
||||
std::mutex cv_m;
|
||||
std::condition_variable cv_cover_opened;
|
||||
|
@ -65,7 +80,7 @@ private:
|
|||
volatile bool bMonitor2 = true;
|
||||
volatile bool double_1 = false;
|
||||
volatile bool double_2 = false;
|
||||
volatile bool enbale_double_=false;
|
||||
volatile bool enbale_double_= false;
|
||||
volatile bool is_open_cover = false;
|
||||
void monitor();
|
||||
void monitor2();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
ZouZhiMotor::ZouZhiMotor()
|
||||
: Motor(motorPorts_Zouzhi)
|
||||
{
|
||||
auto t_smbtype =MotorConfig::MTBDType::MT_TMC;//SMBType::MB_DRV_TMC216;// smbtype == SMBType::MB_DRV_TMC216 ? MotorConfig::MTBDType::MT_TMC : MotorConfig::MTBDType::MT_DRV;
|
||||
auto t_smbtype =MotorConfig::MTBDType::MT_TMC;
|
||||
m_zouparamex = m_mtconfig->GetMotorSpeedParam(true, t_smbtype, 4, 1, 1);
|
||||
speedConfig();
|
||||
}
|
||||
|
@ -18,10 +18,9 @@ void ZouZhiMotor::start()
|
|||
Motor::start(delays, m_zouparamex.mt_param);
|
||||
}
|
||||
|
||||
void ZouZhiMotor::speedChange(int speed, int dpi, int colormode) // speed should be in range [0,5] (by ply,at 2019.5.23)
|
||||
void ZouZhiMotor::speedChange(MotorSpeedParamEx paramex)
|
||||
{
|
||||
auto t_smbtype = MotorConfig::MTBDType::MT_TMC;//SMBType::MB_DRV_TMC216;//smbtype == SMBType::MB_DRV_TMC216 ? MotorConfig::MTBDType::MT_TMC : MotorConfig::MTBDType::MT_DRV;
|
||||
m_zouparamex = m_mtconfig->GetMotorSpeedParam(true, t_smbtype, speed, colormode, dpi);
|
||||
m_zouparamex = paramex;
|
||||
speedConfig();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ public:
|
|||
ZouZhiMotor();
|
||||
~ZouZhiMotor();
|
||||
virtual void start();
|
||||
void speedChange(int speed, int dpi = 1,int colormode = 1);
|
||||
void speedChange(MotorSpeedParamEx paramex);
|
||||
void speedRecover();
|
||||
|
||||
private:
|
||||
|
|
|
@ -62,11 +62,11 @@ typedef struct
|
|||
|
||||
typedef void (*image_callback)(int element);
|
||||
static std::map<int , sp_COLOR_or_GRAY>mapFradme_SP={
|
||||
{1,{0x08ED1003,0x1ACC1002,CON(G34D,231027)}},//40 ppm
|
||||
{2,{0x06DB1003,0x14A01002,CON(G3ZY,240102)}},//50 ppm
|
||||
{3,{0x05591003,0x100E1002,CON(G36D,231027)}},//60 ppm
|
||||
{4,{0x04421003,0x0CD11002,CON(G37D,231027)}},//70 ppm
|
||||
{5,{0x036c1003,0x0A421002,CON(G38D,231027)}},//80 ppm
|
||||
{1,{0x08ED1003,0x1ACC1002,CON(G33Z,240201)}},//40 ppm
|
||||
{2,{0x06DB1003,0x14A01002,CON(G34Z,240201)}},//50 ppm
|
||||
{3,{0x05591003,0x100E1002,CON(G35Z,240201)}},//60 ppm
|
||||
{4,{0x04421003,0x0CD11002,CON(G36Z,240201)}},//70 ppm
|
||||
{5,{0x036c1003,0x0A421002,CON(G37Z,240201)}},//80 ppm
|
||||
};
|
||||
|
||||
enum class LedStatus
|
||||
|
@ -187,7 +187,9 @@ struct
|
|||
unsigned int reversed1 : 2;
|
||||
unsigned int isCorrect : 1;
|
||||
unsigned int dc : 7; //0 - 100
|
||||
unsigned int reversed2 : 8;
|
||||
unsigned int screw_detect_enable : 1;
|
||||
unsigned int width_detect_enable : 1;
|
||||
unsigned int reversed2 : 6;
|
||||
} params;
|
||||
unsigned int value;
|
||||
};
|
||||
|
|
|
@ -105,14 +105,14 @@ unsigned int get_proc_mem(unsigned int pid)
|
|||
|
||||
int get_total_mem()
|
||||
{
|
||||
const char *file = "/proc/meminfo"; //文件名
|
||||
FILE *fd; //定义文件指针fd
|
||||
char line_buff[256] = {0}; //读取行的缓冲区
|
||||
fd = fopen(file, "r"); //以R读的方式打开文件再赋给指针fd
|
||||
const char *file = "/proc/meminfo";
|
||||
FILE *fd;
|
||||
char line_buff[256] = {0};
|
||||
fd = fopen(file, "r");
|
||||
|
||||
//获取memtotal:总内存占用大小
|
||||
int i;
|
||||
char name[32]; //存放项目名称
|
||||
char name[32];
|
||||
int memtotal; //存放内存峰值大小
|
||||
char *ret = fgets(line_buff, sizeof(line_buff), fd); //读取memtotal这一行的数据,memtotal在第1行
|
||||
sscanf(line_buff, "%s %d", name, &memtotal);
|
||||
|
|
Loading…
Reference in New Issue