调整超声波流程

This commit is contained in:
modehua 2023-08-31 18:51:35 -07:00
parent f670bc5342
commit 5a8f86b81b
6 changed files with 32 additions and 27 deletions

View File

@ -410,7 +410,7 @@ void MultiFrameCapture::snaprun()
} }
uint32_t sendLine = video->HtCamReadFpgaRegs(0x000e);////0x000e 取出来的实际行数 uint32_t sendLine = video->HtCamReadFpgaRegs(0x000e);////0x000e 取出来的实际行数
printf("--------------fpga send line ------------:%d\r\n",sendLine); //printf("--------------fpga send line ------------:%d\r\n",sendLine);
if (data) if (data)
{ {
cv::Mat mat = cv::Mat(frame_info.height, frame_info.width, CV_8UC1, data, cv::Mat::AUTO_STEP); cv::Mat mat = cv::Mat(frame_info.height, frame_info.width, CV_8UC1, data, cv::Mat::AUTO_STEP);
@ -418,7 +418,7 @@ void MultiFrameCapture::snaprun()
// printf("--------------frame_index------------:%d\r\n",frame_index); // printf("--------------frame_index------------:%d\r\n",frame_index);
if (cnt == 2) if (cnt == 2)
{ {
cv::imwrite("/home/root/test.bmp", mat); //cv::imwrite("/home/root/test.bmp", mat);
//cv::imwrite("/home/root/test.bmp", mat); //cv::imwrite("/home/root/test.bmp", mat);
//savebitmap(data,15552,512,"1.bmp"); //savebitmap(data,15552,512,"1.bmp");
} }
@ -446,7 +446,7 @@ void MultiFrameCapture::snaprun()
m_glue.m_imageready(info); m_glue.m_imageready(info);
//m_frameinfos.Put(frame_info); //m_frameinfos.Put(frame_info);
printf("采集图像耗时:%f\r\n",sw.elapsed_ms()); //printf("采集图像耗时:%f\r\n",sw.elapsed_ms());
} }
return ret; return ret;
}; };
@ -491,7 +491,7 @@ void MultiFrameCapture::snaprun()
for (size_t i = 1; i <= frame_cnt; i++) for (size_t i = 1; i <= frame_cnt; i++)
{ {
printf("***********设置的帧数:%d 正在采集第[%d]帧************\r\n",frame_cnt,i); //printf("***********设置的帧数:%d 正在采集第[%d]帧************\r\n",frame_cnt,i);
frame_info.first_frame = i == 1 ? true : false; frame_info.first_frame = i == 1 ? true : false;
frame_info.last_frame = i == frame_cnt ? true : false; frame_info.last_frame = i == frame_cnt ? true : false;
@ -518,7 +518,7 @@ void MultiFrameCapture::snaprun()
{ {
frame_info.last_frame = val == 1 ? true : false; frame_info.last_frame = val == 1 ? true : false;
func_sig = snap_func(frame_info, channels,time_out);//同上面一样 func_sig = snap_func(frame_info, channels,time_out);//同上面一样
printf("-----------当前采集到第:[%d]帧 CIS总共采集[%d]帧 -------\r\n",ind,frame_num); //printf("-----------当前采集到第:[%d]帧 CIS总共采集[%d]帧 -------\r\n",ind,frame_num);
if (func_sig == -1 ) if (func_sig == -1 )
{ {

View File

@ -83,9 +83,9 @@ Scanner::Scanner(ScannerGlue glue)
motorCuozhi.setDirection(false); motorCuozhi.setDirection(false);
//sensor->isPaperAtScan(); //sensor->isPaperAtScan();
//system("cat /sys/class/gpio/gpio226/value"); //system("cat /sys/class/gpio/gpio226/value");
sensor->enableDoubleSensor(true); //sensor->enableDoubleSensor(true);
std::this_thread::sleep_for(std::chrono::milliseconds(50)); std::this_thread::sleep_for(std::chrono::milliseconds(50));
sensor->enableDoubleSensor(false); //sensor->enableDoubleSensor(false);
FsmState::setScanner(this); FsmState::setScanner(this);
threadRunMessageLoop = std::thread(&Scanner::runMessageLoop, this); threadRunMessageLoop = std::thread(&Scanner::runMessageLoop, this);
Motor::enablePower(true); Motor::enablePower(true);
@ -216,7 +216,7 @@ void Scanner::runScan()
motorCuozhi.pauseWaitForThread(); motorCuozhi.pauseWaitForThread();
//capturer->open(); //capturer->open();
sensor->enableDoubleSensor(false); //sensor->enableDoubleSensor(false);
if (!isPaperInit) if (!isPaperInit)
{ {
@ -269,7 +269,7 @@ void Scanner::runScan()
} }
sensor->enableDoubleSensor(m_config.params.doubleFeeded); sensor->enableDoubleSensor(m_config.params.doubleFeeded);
//LOG("enableDoubleSensor QQQQQQQ:%s %s\n", m_config.params.doubleFeeded ? "true" : "false",GetCurrentTimeStamp(2).c_str()); LOG("enableDoubleSensor QQQQQQQ:%s %s\n", m_config.params.doubleFeeded ? "true" : "false",GetCurrentTimeStamp(2).c_str());
if (m_DstScannum == 0) //被取消扫描了 if (m_DstScannum == 0) //被取消扫描了
{ {
LOG("canceled canceled canceled 999999999999999999999999999999999999999999 \n"); LOG("canceled canceled canceled 999999999999999999999999999999999999999999 \n");

View File

@ -33,7 +33,7 @@ public:
void startScan(); void startScan();
void emergency_stop(int id) void emergency_stop(int id)
{ {
sensor->enableDoubleSensor(false);
sensor->cancelWaitPaper(); sensor->cancelWaitPaper();
m_DstScannum = 0; m_DstScannum = 0;
if (id == 1) //双张 if (id == 1) //双张
@ -45,13 +45,16 @@ public:
put(S_EVT_SCAN_STOPPED); put(S_EVT_SCAN_STOPPED);
SaveScaninfo(m_scaninfo); SaveScaninfo(m_scaninfo);
start_enter_lowpwoer(); start_enter_lowpwoer();
LOG("emergency_stop capturer->close() \n"); printf("emergency_stop capturer->close() \n");
//sensor->enableDoubleSensor(false);
} }
void stop_scan() void stop_scan()
{ {
//LOG("!!!!!!!!!!!!!!!!!!!!!stop_scan() waitting snap session done \n"); printf("!!!!!!!!!!!!!!!!!!!!!stop_scan() waitting snap session done \n");
sensor->enableDoubleSensor(false); //sensor->enableDoubleSensor(false);
sensor->cancelWaitPaper(); sensor->cancelWaitPaper();
m_DstScannum = 0; m_DstScannum = 0;
//LOG("!!!!!!!!!!!!!!!!!!!!!!!!!!stop_scan() waitting snap session done \n"); //LOG("!!!!!!!!!!!!!!!!!!!!!!!!!!stop_scan() waitting snap session done \n");

View File

@ -18,8 +18,8 @@ Sensor::Sensor(BlockingQueue<ScanEvent> &sysEvents)
paperPin(PIN_PORT_7010::HAVE_OR_NO_PAPER), paperPin(PIN_PORT_7010::HAVE_OR_NO_PAPER),
scanPin (PIN_PORT_7010::SCAN_SENSOR), scanPin (PIN_PORT_7010::SCAN_SENSOR),
doubleEnablePin(PIN_PORT_7010::ULTRASONIC_SENSORS_ON), doubleEnablePin(PIN_PORT_7010::ULTRASONIC_SENSORS_ON),
double_out0_Pin(PIN_PORT_7010::ULTRASONIC_SENSORS_OUT0), double_out0_Pin(PIN_PORT_7010::ULTRASONIC_SENSORS_OUT1),
double_out1_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)
{ {
@ -52,7 +52,6 @@ Sensor::Sensor(BlockingQueue<ScanEvent> &sysEvents)
//std::cout<<"scanPin "<< scanPin.getValue()<<std::endl; //std::cout<<"scanPin "<< scanPin.getValue()<<std::endl;
thread_monitor = std::thread(&Sensor::monitor, this); thread_monitor = std::thread(&Sensor::monitor, this);
thread_monitor2 = std::thread(&Sensor::monitor2, this); thread_monitor2 = std::thread(&Sensor::monitor2, this);
enableDoubleSensor(true);
std::this_thread::sleep_for(std::chrono::milliseconds(10)); std::this_thread::sleep_for(std::chrono::milliseconds(10));
enableDoubleSensor(false); enableDoubleSensor(false);
LOG(" init sensor done \n"); LOG(" init sensor done \n");
@ -70,7 +69,7 @@ Sensor::~Sensor()
bool Sensor::isCoverClosed() bool Sensor::isCoverClosed()
{ {
std::cout<<"isCoverClosed "<< coverPin.getValue()<<std::endl; //std::cout<<"isCoverClosed "<< coverPin.getValue()<<std::endl;
return coverPin.getValue() == Gpio::Low; return coverPin.getValue() == Gpio::Low;
} }
@ -80,7 +79,7 @@ void Sensor::resetPaperPin()
} }
bool Sensor::isPaperStandby() bool Sensor::isPaperStandby()
{ {
std::cout<<"isPaperStandby "<< paperPin.getValue()<<std::endl; //std::cout<<"isPaperStandby "<< paperPin.getValue()<<std::endl;
return paperPin.getValue(); return paperPin.getValue();
} }
@ -239,40 +238,39 @@ void Sensor::monitor2()
// //LOG("\n\n---------------double paper ----------------:%s \n\n", GetCurrentTimeStamp(2).c_str()); // //LOG("\n\n---------------double paper ----------------:%s \n\n", GetCurrentTimeStamp(2).c_str());
// enableDoubleSensor(false); // enableDoubleSensor(false);
// } // }
printf("i:%d\r\n",i);
if (i == 2) if (i == 2)
{ {
double_1 = ret; double_1 = ret;
printf("2 double_1 :%d double_2:%d\r\n",double_1,double_2); printf("2 double_1 :%d double_2:%d\r\n",double_1,double_2);
if (double_2 && double_1) if (double_2 && double_1 && enbale_double_)
{ {
printf("双张111111111111111111111111\r\n");
events.Put(ScanEvent(S_EVT_DOUBLEPAPER)); events.Put(ScanEvent(S_EVT_DOUBLEPAPER));
enableDoubleSensor(false); enableDoubleSensor(false);
} }
else else
{ {
//printf("3 double_1 :%d double_2:%d\r\n",double_1,double_2); //printf("3 double_1 :%d double_2:%d\r\n",double_1,double_2);
events.Put(ScanEvent(S_EVT_NOT_DOUBLEPAPER)); //events.Put(ScanEvent(S_EVT_NOT_DOUBLEPAPER));
} }
} }
if (i == 3) if (i == 3)
{ {
double_2 = ret; double_2 = ret;
printf("3 double_1 :%d double_2:%d\r\n",double_1,double_2); printf("3 double_1 :%d double_2:%d\r\n",double_1,double_2);
if (double_2 && double_1) if (double_2 && double_1 && enbale_double_)
{ {
printf("双张2222222222222222222222\r\n");
events.Put(ScanEvent(S_EVT_DOUBLEPAPER)); events.Put(ScanEvent(S_EVT_DOUBLEPAPER));
enableDoubleSensor(false); enableDoubleSensor(false);
} }
else else
{ {
//printf("4 double_1 :%d double_2:%d\r\n",double_1,double_2); //printf("4 double_1 :%d double_2:%d\r\n",double_1,double_2);
events.Put(ScanEvent(S_EVT_NOT_DOUBLEPAPER)); //events.Put(ScanEvent(S_EVT_NOT_DOUBLEPAPER));
} }
} }
if (i != 4 && i != 3) if (i != 2 && i != 3)
{ {
if(i == 1) if(i == 1)
{ {

View File

@ -12,8 +12,11 @@ public:
Sensor(BlockingQueue<ScanEvent>& sysEvents); Sensor(BlockingQueue<ScanEvent>& sysEvents);
~Sensor(); ~Sensor();
//出现双张或者在没有双张时并且结束扫描需要关闭超声波检测,
void enableDoubleSensor(bool enable) { void enableDoubleSensor(bool enable) {
enbale_double_ = enable;
doubleEnablePin.setValue((Gpio::GpioLevel)enable); doubleEnablePin.setValue((Gpio::GpioLevel)enable);
printf("是否使能超声波:%s\r\n",enable?"true":"false");
} }
void resetPaperPin(); void resetPaperPin();
@ -62,6 +65,7 @@ private:
volatile bool bMonitor2 = true; volatile bool bMonitor2 = true;
volatile bool double_1 = false; volatile bool double_1 = false;
volatile bool double_2 = false; volatile bool double_2 = false;
volatile bool enbale_double_=false;
void monitor(); void monitor();
void monitor2(); void monitor2();
int readfile(int fd,int num , char* buf); int readfile(int fd,int num , char* buf);

View File

@ -386,7 +386,7 @@ int main(int argc, char *argv[])
//free(info.pJpegData); //free(info.pJpegData);
tjFree(info.pJpegData); tjFree(info.pJpegData);
LOG("Free info.pJpegData done\n"); LOG("Free info.pJpegData done\n");
printf("TIME!!!!!!!!!!!!! :%f info.DataLength:%d\r\n",sw.elapsed_ms(),info.DataLength); //printf("TIME!!!!!!!!!!!!! :%f info.DataLength:%d\r\n",sw.elapsed_ms(),info.DataLength);
} }
} }
break; break;