135 lines
3.6 KiB
C++
135 lines
3.6 KiB
C++
#pragma once
|
|
#include <memory>
|
|
#include <functional>
|
|
#include "CuoZhiMotor.h"
|
|
#include "ZouZhiMotor.h"
|
|
#include "Sensor.h"
|
|
#include "PanelLeds.h"
|
|
#include "BlockingQueue.h"
|
|
#include "FsmState.h"
|
|
|
|
|
|
#include "MultiFrameCapture.h"
|
|
#include "scanservices_utils.h"
|
|
#include "Keyboard.h"
|
|
#include "utilsfunc.h"
|
|
|
|
#include "SysInforTool.h"
|
|
#include "MotorConfig.h"
|
|
#include "correct_ultis.h"
|
|
|
|
class ICapturer;
|
|
class MemoryInfo;
|
|
|
|
static int frame_time_ ;
|
|
class Scanner
|
|
{
|
|
std::mutex cb_lock_;
|
|
std::condition_variable wait_cb_;
|
|
|
|
public:
|
|
bool isRested = false;
|
|
bool isScaning = false;
|
|
public:
|
|
Scanner(ScannerGlue glue);
|
|
~Scanner();
|
|
|
|
void startScan();
|
|
void emergency_stop(int id); //只要调用 直接停止整个扫描流程
|
|
void stop_scan(); //扫描线程结束才会停止
|
|
void reset();
|
|
void paper_pullout();
|
|
void CreatCorrectData(int correctmode);
|
|
void UpdateScanInfo();
|
|
void updateSpeedMode();
|
|
static void have_img_callback(int val);
|
|
std::string GetSysInfo();
|
|
|
|
public:
|
|
Sensor &getSensor() { return *sensor.get(); }
|
|
PanelLeds &getPanelLeds() { return panelLeds; }
|
|
inline int readreg(int addr) { return capturer->read(addr); }
|
|
inline bool isFeederLoaded() { return sensor->isPaperStandby(); }
|
|
inline void put(ScanEvent evt) { sysEvent.Put(evt); }
|
|
|
|
void ConfigScanParam(HG_ScanConfiguration config) ;
|
|
|
|
inline void SetDstScanNum(int scannum) { m_DstScannum = scannum; }
|
|
inline void SetIsDoublePaper(bool isdoublepaper) { m_isDoublePaper = isdoublepaper; }
|
|
|
|
inline bool GetIsDoublePaper() { return m_isDoublePaper; }
|
|
inline bool GetIsJamPaper() { return m_jamPaper; }
|
|
inline bool GetIsJamIn() { return m_jamIn; }
|
|
inline void ResetJamIn() { m_jamIn = false; }
|
|
inline bool IsScanning() { return isScaning; }
|
|
inline void close_v4l2() { capturer->close(); }
|
|
inline void list_image_num(int num) {image_num_ = num;}
|
|
int image_num_ = 0;
|
|
CaptureParams GetCaptureParams()
|
|
{
|
|
CaptureParams param;
|
|
return param;
|
|
// return capturer->m_configprop->captureParmars;
|
|
}
|
|
|
|
ScannerScanInfo &GetScanInfo() { return m_scaninfo; }
|
|
ScannerSysInfo &GetSysinfoStruct() { return m_scansysinfo->GetInfo(); }
|
|
void ResetCorrectflags() { m_correctting = false; }
|
|
void StopScan(int Evt) { put(S_EVT_STOP_SCAN); }
|
|
|
|
|
|
private:
|
|
//处理事件
|
|
void processevent(FsmState *fsmState, ScanEvent event);
|
|
void startZouzhi() { motorZouzhi.start(); }
|
|
void stopZouzhi() { motorZouzhi.stop(); }
|
|
void startCuozhi() { motorCuozhi.start(); }
|
|
void stopCuozhi() { motorCuozhi.stop(); }
|
|
//运行消息循环
|
|
void runMessageLoop();
|
|
void runScan();
|
|
void preFeed();
|
|
|
|
private:
|
|
ZouZhiMotor motorZouzhi;
|
|
CuoZhiMotor motorCuozhi;
|
|
MotorConfig motor_cfg_;
|
|
|
|
MotorSpeedParamEx Zouzhi_ParamEx_;
|
|
MotorSpeedParamEx Cuozhi_ParamEx_;
|
|
|
|
PanelLeds panelLeds;
|
|
std::thread threadRunScan;
|
|
std::thread threadRunMessageLoop;
|
|
|
|
BlockingQueue<ScanEvent> sysEvent;
|
|
|
|
ScannerGlue m_glue;
|
|
HG_ScanConfiguration m_config;
|
|
ScannerScanInfo m_scaninfo;
|
|
std::thread m_correctThread;
|
|
|
|
bool m_isPulling;
|
|
|
|
volatile bool bMsgLoop = true;
|
|
volatile int m_DstScannum = 500;
|
|
volatile bool m_isDoublePaper;
|
|
volatile bool m_jamPaper;
|
|
volatile bool m_jamIn;
|
|
volatile bool m_correctting;
|
|
|
|
bool isPaperInit;
|
|
bool auto_size_;//匹配原始尺寸类型尺寸
|
|
|
|
int waitpapertime;
|
|
MemoryInfo *meminfo;
|
|
CISVendor cisvendor;
|
|
|
|
std::shared_ptr<SysInforTool> m_scansysinfo;
|
|
std::shared_ptr<ICapturer> m_capturer;
|
|
std::shared_ptr<FpgaComm> m_fpga;
|
|
std::shared_ptr<ICapturer> capturer;
|
|
std::shared_ptr<huagao::Keyboard> m_keyboard;
|
|
std::shared_ptr<Sensor> sensor;
|
|
};
|