From 5a8f86b81bdc4ff075d213a61443b4d62ce65f71 Mon Sep 17 00:00:00 2001 From: modehua Date: Thu, 31 Aug 2023 18:51:35 -0700 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=B6=85=E5=A3=B0=E6=B3=A2?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MultiFrameCapture.cpp | 10 +++++----- Scanner.cpp | 8 ++++---- Scanner.h | 11 +++++++---- Sensor.cpp | 24 +++++++++++------------- Sensor.h | 4 ++++ main.cpp | 2 +- 6 files changed, 32 insertions(+), 27 deletions(-) diff --git a/MultiFrameCapture.cpp b/MultiFrameCapture.cpp index 396ae24..4c25d36 100644 --- a/MultiFrameCapture.cpp +++ b/MultiFrameCapture.cpp @@ -410,7 +410,7 @@ void MultiFrameCapture::snaprun() } 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) { 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); if (cnt == 2) { - 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"); } @@ -446,7 +446,7 @@ void MultiFrameCapture::snaprun() m_glue.m_imageready(info); //m_frameinfos.Put(frame_info); - printf("采集图像耗时:%f\r\n",sw.elapsed_ms()); + //printf("采集图像耗时:%f\r\n",sw.elapsed_ms()); } return ret; }; @@ -491,7 +491,7 @@ void MultiFrameCapture::snaprun() 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.last_frame = i == frame_cnt ? true : false; @@ -518,7 +518,7 @@ void MultiFrameCapture::snaprun() { frame_info.last_frame = val == 1 ? true : false; 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 ) { diff --git a/Scanner.cpp b/Scanner.cpp index 78dfc49..5adde26 100644 --- a/Scanner.cpp +++ b/Scanner.cpp @@ -83,9 +83,9 @@ Scanner::Scanner(ScannerGlue glue) motorCuozhi.setDirection(false); //sensor->isPaperAtScan(); //system("cat /sys/class/gpio/gpio226/value"); - sensor->enableDoubleSensor(true); + //sensor->enableDoubleSensor(true); std::this_thread::sleep_for(std::chrono::milliseconds(50)); - sensor->enableDoubleSensor(false); + //sensor->enableDoubleSensor(false); FsmState::setScanner(this); threadRunMessageLoop = std::thread(&Scanner::runMessageLoop, this); Motor::enablePower(true); @@ -216,7 +216,7 @@ void Scanner::runScan() motorCuozhi.pauseWaitForThread(); //capturer->open(); - sensor->enableDoubleSensor(false); + //sensor->enableDoubleSensor(false); if (!isPaperInit) { @@ -269,7 +269,7 @@ void Scanner::runScan() } 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) //被取消扫描了 { LOG("canceled canceled canceled 999999999999999999999999999999999999999999 \n"); diff --git a/Scanner.h b/Scanner.h index dc5e7b1..c73ded9 100644 --- a/Scanner.h +++ b/Scanner.h @@ -33,7 +33,7 @@ public: void startScan(); void emergency_stop(int id) { - sensor->enableDoubleSensor(false); + sensor->cancelWaitPaper(); m_DstScannum = 0; if (id == 1) //双张 @@ -45,13 +45,16 @@ public: put(S_EVT_SCAN_STOPPED); SaveScaninfo(m_scaninfo); start_enter_lowpwoer(); - LOG("emergency_stop capturer->close() \n"); + printf("emergency_stop capturer->close() \n"); + + + //sensor->enableDoubleSensor(false); } void stop_scan() { - //LOG("!!!!!!!!!!!!!!!!!!!!!stop_scan() waitting snap session done \n"); - sensor->enableDoubleSensor(false); + printf("!!!!!!!!!!!!!!!!!!!!!stop_scan() waitting snap session done \n"); + //sensor->enableDoubleSensor(false); sensor->cancelWaitPaper(); m_DstScannum = 0; //LOG("!!!!!!!!!!!!!!!!!!!!!!!!!!stop_scan() waitting snap session done \n"); diff --git a/Sensor.cpp b/Sensor.cpp index 17ddacc..687ef17 100644 --- a/Sensor.cpp +++ b/Sensor.cpp @@ -18,8 +18,8 @@ Sensor::Sensor(BlockingQueue &sysEvents) 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_OUT0), - double_out1_Pin(PIN_PORT_7010::ULTRASONIC_SENSORS_OUT1), + 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) { @@ -52,7 +52,6 @@ Sensor::Sensor(BlockingQueue &sysEvents) //std::cout<<"scanPin "<< scanPin.getValue()<& sysEvents); ~Sensor(); + //出现双张或者在没有双张时并且结束扫描需要关闭超声波检测, void enableDoubleSensor(bool enable) { + enbale_double_ = enable; doubleEnablePin.setValue((Gpio::GpioLevel)enable); + printf("是否使能超声波:%s\r\n",enable?"true":"false"); } void resetPaperPin(); @@ -62,6 +65,7 @@ private: volatile bool bMonitor2 = true; volatile bool double_1 = false; volatile bool double_2 = false; + volatile bool enbale_double_=false; void monitor(); void monitor2(); int readfile(int fd,int num , char* buf); diff --git a/main.cpp b/main.cpp index 1569705..b375ebe 100644 --- a/main.cpp +++ b/main.cpp @@ -386,7 +386,7 @@ int main(int argc, char *argv[]) //free(info.pJpegData); tjFree(info.pJpegData); 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;