diff --git a/HaoGaoCOrrect修改记录.txt b/HaoGaoCOrrect修改记录.txt index 14a61fd..0c66052 100644 --- a/HaoGaoCOrrect修改记录.txt +++ b/HaoGaoCOrrect修改记录.txt @@ -17,3 +17,9 @@ 2. 增加明场暗场校正最大明场值配置; 3. 界面UI按钮顺序调整对齐等操作; V4.2版本 + +2021年10月18日16 +1. 针对3288 g300g400 增加校正信息实时显示; +2.增加usb vid pid 配置; +3.增加速度模式配置功能; +4.增加IP地址以及电机板版本读取功能; diff --git a/HuaGoCorrect/A3.cpp b/HuaGoCorrect/A3.cpp index 762afef..9708fce 100644 --- a/HuaGoCorrect/A3.cpp +++ b/HuaGoCorrect/A3.cpp @@ -61,13 +61,6 @@ BOOL CA3::OnInitDialog() { m_cmbSpeedmode.InsertString(i, speedmodeMapString[i]); } - speedemodelen = speedmodeMap.size() + G300G400speedmodeMapString.size(); - size_t j = 1; - for (size_t i = speedmodeMap.size(); i < speedemodelen; i++) - { - m_cmbSpeedmode.InsertString(i, G300G400speedmodeMapString[j]); - ++j; - } return TRUE; // return TRUE unless you set the focus to a control // 쳣: OCX ҳӦ FALSE } @@ -151,6 +144,8 @@ void CA3::OnGetOrSetSp(bool get, int type) } + + void CA3::OnGetOrSetSleepTime(bool get, int type) { int sp; @@ -245,7 +240,7 @@ void CA3::OnBnClickedBtnsetclrmaxbrt() void CA3::OnBnClickedBtnsetgrymaxbrt() { - // TODO: ڴӿؼ֪ͨ + // TODO: ??????t?a|3D䨲?? UpdateMaxBright(false, IDC_LBGRYMAXBRT); } @@ -253,14 +248,14 @@ void CA3::OnBnClickedBtnsetgrymaxbrt() void CA3::OnBnClickedBtngetclrmaxbrt() { - // TODO: ڴӿؼ֪ͨ + // TODO: ??????t?a|3D䨲?? UpdateMaxBright(true, IDC_LBCLRMAXBRT); } void CA3::OnBnClickedBtngetgrymaxbrt() { - // TODO: ڴӿؼ֪ͨ + // TODO: ??????t?a|3D䨲?? UpdateMaxBright(true, IDC_LBGRYMAXBRT); } @@ -296,21 +291,15 @@ void CA3::updatespeedmode(bool get) auto parent = (CHuaGoCorrectDlg*)GetParent(); if (parent != NULL) { - if (parent->m_drv.get() && parent->m_drv->IsConnected()) - { - int speedmode; - std::string ver = parent->m_drv->GetFWVersion(); - if (!ver.empty()) - { - ver = ver.substr(0, 2); - } + if (parent->m_drv.get() && parent->m_drv->IsConnected()) { + int speedmode=0; if (get) { parent->m_drv->GetSpeedMode(speedmode, true); bool bfound = false; - if (ver != "G3" && ver != "G4") + for (size_t i = 0; i < speedmodeMap.size(); i++) { - for (size_t i = 0; i < speedmodeMap.size(); i++) + if (parent->m_drv->PID == 0x0139 || parent->m_drv->PID == 0x0239) { if (speedmodeMap[i].Speedmode == speedmode) { @@ -321,19 +310,12 @@ void CA3::updatespeedmode(bool get) break; } } - } - else - { - size_t j = 1; - for (size_t i = speedmodeMap.size(); i < speedemodelen; i++) + else if (parent->m_drv->PID == 0x0300 || parent->m_drv->PID == 0x0400) { - if (j == speedmode) - { - m_cmbSpeedmode.SetCurSel(i); - bfound = true; - break; - } - ++j; + int startindex = parent->m_drv->PID == 0x0300 ? 6 : 10; + m_cmbSpeedmode.SetCurSel(startindex+ speedmode); + bfound = true; + break; } } if (!bfound) @@ -342,29 +324,19 @@ void CA3::updatespeedmode(bool get) else { int cmbindex = m_cmbSpeedmode.GetCurSel(); - if (cmbindex != -1 && cmbindex < speedmodeMap.size()) + if (cmbindex != -1) { - if (ver == "G3" || ver == "G4") + auto t_speedmode = speedmodeMap[cmbindex]; + if (parent->m_drv->PID == 0x0139 || parent->m_drv->PID == 0x0239) { - MessageBox(L"豸кǰλΪG3/G4ȷ豸", L"ѡ", MB_OK | MB_ICONINFORMATION); - return; - } - - auto t_speedmode = speedmodeMap[cmbindex]; parent->m_drv->GetSpeedMode(t_speedmode.Speedmode, false); parent->m_drv->SetSptime(0, t_speedmode.GraySp); parent->m_drv->SetSptime(1, t_speedmode.ColorSp); - - } - else - { - if (ver != "G3" && ver != "G4") - { - MessageBox(L"豸кǰλΪG3/G4ȷ豸", L"ѡ", MB_OK | MB_ICONINFORMATION); - return; } - cmbindex = cmbindex - speedmodeMap.size() + 1; - parent->m_drv->GetSpeedMode(cmbindex, false); + else if (parent->m_drv->PID == 0x0300 || parent->m_drv->PID == 0x0400) + { + parent->m_drv->GetSpeedMode(t_speedmode.Speedmode, false); + } } } } diff --git a/HuaGoCorrect/A3.h b/HuaGoCorrect/A3.h index 98bb484..3e8f50c 100644 --- a/HuaGoCorrect/A3.h +++ b/HuaGoCorrect/A3.h @@ -1,21 +1,21 @@ #pragma once #include -// CA3 Ի +// CA3 对话框 class CA3 : public CDialog { DECLARE_DYNAMIC(CA3) public: - CA3(CWnd* pParent = NULL); // ׼캯 + CA3(CWnd* pParent = NULL); // 标准构造函数 virtual ~CA3(); -// Ի +// 对话框数据 enum { IDD = IDD_A3_DIALOG }; protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 DECLARE_MESSAGE_MAP() public: @@ -56,31 +56,39 @@ private: std::map speedmodeMap = { {0,{70,0x42d,0xc88}}, {1,{80,0x37f,0xa7f}}, - {2,{90,0x2b6,0x882}}, - {3,{110,0x24e,0x706}}, - {4,{100,0x27c,0x775}}, - {5,{110,0x27c,0x775}}, - {6,{120,0x27c,0x775}}, - {7,{130,0x27c,0x775}} + {2,{90,0x303,0x90a}}, + {3,{100,0x27c,0x775}}, + {4,{110,0x27c,0x775}}, + {5,{120,0x27c,0x775}}, + {6,{130,0x27c,0x775}}, + {7,{1,0,0}}, + {8,{2,0,0}}, + {9,{3,0,0}}, + {10,{4,0,0}}, + {11,{1,0,0}}, + {12,{2,0,0}}, + {13,{3,0,0}}, + {14,{4,0,0}}, + {15,{5,0,0}} }; std::map speedmodeMapString = { - {0,L"G100_70PPM"}, - {1,L"G100_80PPM"}, - {2,L"G100_90PPM"}, - {3,L"G100_110PPM"}, - {4,L"G200_100PPM"}, - {5,L"G200_110PPM"}, - {6,L"G200_120PPM"}, - {7,L"G200_130PPM"} - }; - - std::map G300G400speedmodeMapString = { - {1,L"G300/G400_40PPM"}, - {2,L"G300/G400_50PPM"}, - {3,L"G300/G400_60PPM"}, - {4,L"G300/G400_70PPM"}, - {5,L"G400_80PPM"}, + {0,L"G139_70PPM"}, + {1,L"G139_80PPM"}, + {2,L"G139_90PPM"}, + {3,L"G239_100PPM"}, + {4,L"G239_110PPM"}, + {5,L"G239_120PPM"}, + {6,L"G239_130PPM"}, + {7,L"G300_40PPM"}, + {8,L"G300_50PPM"}, + {9,L"G300_60PPM"}, + {10,L"G300_700PPM"}, + {11,L"G400_40PPM"}, + {12,L"G400_50PPM"}, + {13,L"G400_60PPM"}, + {14,L"G400_70PPM"}, + {15,L"G400_80PPM"}, }; CComboBox m_cmbSpeedmode; public: diff --git a/HuaGoCorrect/A4.cpp b/HuaGoCorrect/A4.cpp index 71c328e..bfa2a7e 100644 --- a/HuaGoCorrect/A4.cpp +++ b/HuaGoCorrect/A4.cpp @@ -87,9 +87,9 @@ BOOL CA4::OnInitDialog() LoadCfg(); m_A4FlatModel.InsertString(0, _T("ɫУģʽ")); - m_A4FlatModel.InsertString(1, _T("ɫ")); - m_A4FlatModel.InsertString(2, _T("ҶУģʽ")); - m_A4FlatModel.InsertString(3, _T("Ҷ")); + m_A4FlatModel.InsertString(1, _T("ɫ")); + m_A4FlatModel.InsertString(2, _T("ҶУģʽ")); + m_A4FlatModel.InsertString(3, _T("Ҷ")); m_A4FlatModel.SetCurSel(0); GetDlgItem(IDC_BTN_GENSERIAL)->EnableWindow(FALSE); @@ -192,6 +192,15 @@ void CA4::OnBnClickedBtnReboot() /// void CA4::OnBnClickedBtnSetvidpid() { + auto ret = MessageBox(L"ǰȷУԼٶģʽ豸صɣVID PID󲿷ֹܲãȷ", L"ʾ", MB_YESNO | MB_ICONWARNING); + if (ret == IDOK || ret == IDYES) + { + auto parent = (CHuaGoCorrectDlg*)GetParent(); + if (parent->m_drv.get() && parent->m_drv->IsConnected()) { + auto vidpid = AqrVIDPID(); + parent->m_drv->GetOrSetVIDPID(vidpid, false); + } + } } /// @@ -199,7 +208,14 @@ void CA4::OnBnClickedBtnSetvidpid() /// void CA4::OnBnClickedBtnGetvidpid() { - // TODO: ڴӿؼ֪ͨ + auto parent = (CHuaGoCorrectDlg*)GetParent(); + if (parent->m_drv.get() && parent->m_drv->IsConnected()) { + int vidpid = 0; + parent->m_drv->GetOrSetVIDPID(vidpid, true); + VIDPID tvpd; + tvpd.Value = vidpid; + UpdateVidPid(tvpd); + } } /// @@ -449,3 +465,34 @@ void CA4::OnBnClickedBtngetMbVersion() SetDlgItemText(IDC_tbxMbVersion, vs); } } +int CA4::AqrVIDPID() +{ + VIDPID t_vidpid = { 0 }; + CString str_vid, str_pid; + GetDlgItemText(IDC_tbxVID, str_vid); + str_vid.Replace(L"0x",L""); + USES_CONVERSION; + std::string str(W2A(str_vid)); + t_vidpid.VID = strtol(str.c_str(),NULL,16);// atoi(str.c_str()); + GetDlgItemText(IDC_tbxPID, str_pid); + str_pid.Replace(L"0x", L""); + std::string cstr_pid(W2A(str_pid)); + t_vidpid.PID = strtol(cstr_pid.c_str(), NULL, 16);// atoi(cstr_pid.c_str()); + return t_vidpid.Value; +} + +void CA4::UpdateVidPid(VIDPID vidpid) +{ + if (vidpid.PID != 0 && vidpid.VID != 0) + { + CString str_vid, str_pid; + str_vid.Format(L"0x%x", vidpid.VID); + str_pid.Format(L"0x%x", vidpid.PID); + GetDlgItem(IDC_tbxVID)->SetWindowText(str_vid); + GetDlgItem(IDC_tbxPID)->SetWindowText(str_pid); + } + else + { + MessageBox(L"VID PID", L"ʾ", MB_OK); + } +} diff --git a/HuaGoCorrect/A4.h b/HuaGoCorrect/A4.h index 6ca56e6..57eeec5 100644 --- a/HuaGoCorrect/A4.h +++ b/HuaGoCorrect/A4.h @@ -8,23 +8,31 @@ #include "JsonConfig.h" #include -// CA4 Ի +// CA4 对话框 #define INI_FILE_NAME "./HuaGoScan.ini" class CA4 : public CDialog { DECLARE_DYNAMIC(CA4) public: - CA4(CWnd* pParent = NULL); // ׼캯 + CA4(CWnd* pParent = NULL); // 标准构造函数 virtual ~CA4(); void updateA4Config(CaptureParams& pValues); void LoadCfg(); -// Ի +// 对话框数据 enum { IDD = IDD_A4_DIALOG }; - + union VIDPID + { + struct + { + unsigned short VID; + unsigned short PID; + }; + unsigned int Value; + }; protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 DECLARE_MESSAGE_MAP() public: @@ -76,4 +84,6 @@ public: void UpdateGains(int id, bool get); afx_msg void OnEnChangetbxfrexposure2(); afx_msg void OnBnClickedBtngetMbVersion(); + int AqrVIDPID(); + void UpdateVidPid(VIDPID vidpid); }; diff --git a/HuaGoCorrect/HuaGoCorrect.aps b/HuaGoCorrect/HuaGoCorrect.aps new file mode 100644 index 0000000..ec59b2e Binary files /dev/null and b/HuaGoCorrect/HuaGoCorrect.aps differ diff --git a/HuaGoCorrect/HuaGoCorrect.h b/HuaGoCorrect/HuaGoCorrect.h index 5de0723..fd9d81d 100644 --- a/HuaGoCorrect/HuaGoCorrect.h +++ b/HuaGoCorrect/HuaGoCorrect.h @@ -1,18 +1,18 @@ -// HuaGoCorrect.h : PROJECT_NAME Ӧóͷļ +// HuaGoCorrect.h : PROJECT_NAME 应用程序的主头文件 // #pragma once #ifndef __AFXWIN_H__ - #error "ڰļ֮ǰstdafx.h PCH ļ" + #error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件" #endif -#include "resource.h" // +#include "resource.h" // 主符号 // CHuaGoCorrectApp: -// йشʵ֣ HuaGoCorrect.cpp +// 有关此类的实现,请参阅 HuaGoCorrect.cpp // class CHuaGoCorrectApp : public CWinApp @@ -24,11 +24,11 @@ public: CString path; -// д +// 重写 public: virtual BOOL InitInstance(); -// ʵ +// 实现 DECLARE_MESSAGE_MAP() }; diff --git a/HuaGoCorrect/HuaGoCorrectDlg.cpp b/HuaGoCorrect/HuaGoCorrectDlg.cpp index 473355a..9935f31 100644 --- a/HuaGoCorrect/HuaGoCorrectDlg.cpp +++ b/HuaGoCorrect/HuaGoCorrectDlg.cpp @@ -340,13 +340,27 @@ void CHuaGoCorrectDlg::RefreshTabChange() void CHuaGoCorrectDlg::Scan() { HGScanConfig config = { 0 }; - config.g200params.dpi = 1;//only support 200DPI - config.g200params.paper = 0; - config.g200params.pc_correct = ((CButton*)GetDlgItem(IDC_CKBORGINIMG))->GetCheck(); - config.g200params.color = m_iColorIndex == 1 ? 1 : 0; - config.g200params.double_feed_enbale = TRUE; - config.g200params.screw_detect_enable = FALSE; - config.g200params.iscorrect_mode = 1;//Уģʽ + if (m_drv->PID == 0x0139 || m_drv->PID == 0x0239) + { + config.g200params.dpi = 1;//only support 200DPI + config.g200params.paper = 0; + config.g200params.pc_correct = ((CButton*)GetDlgItem(IDC_CKBORGINIMG))->GetCheck(); + config.g200params.color = m_iColorIndex == 1 ? 1 : 0; + config.g200params.double_feed_enbale = TRUE; + config.g200params.screw_detect_enable = FALSE; + config.g200params.iscorrect_mode = 1;//Уģʽ + } + else + { + config.g400params.dpi = 1;//only support 200DPI + config.g400params.pageSize = 0; + config.g400params.isCorrect = !((CButton*)GetDlgItem(IDC_CKBORGINIMG))->GetCheck(); + config.g400params.isColor = m_iColorIndex == 1 ? 1 : 0; + config.g400params.doubleFeeded = TRUE; + config.g400params.enableStable = FALSE; + config.g400params.reversed1 = 0;//Уģʽ + } + m_drv->Config_Scanner(config); this_thread::sleep_for(std::chrono::milliseconds(1000)); @@ -409,6 +423,7 @@ void CHuaGoCorrectDlg::OnBnClickedBtnFlat() std::string c_str = StringToUtf(info); CString pWideChar = A2T(c_str.c_str()); CString oldinfo; + UpdateData(FALSE); ((CEdit*)(m_A3dlg.GetDlgItem(IDC_LSTFLATINFO)))->GetWindowText(oldinfo); oldinfo += pWideChar; ((CEdit*)(m_A3dlg.GetDlgItem(IDC_LSTFLATINFO)))->SetWindowText(oldinfo); diff --git a/HuaGoCorrect/IScanner.h b/HuaGoCorrect/IScanner.h index 6c881bb..7c4bbec 100644 --- a/HuaGoCorrect/IScanner.h +++ b/HuaGoCorrect/IScanner.h @@ -53,6 +53,7 @@ public: virtual bool Updata(std::string filename, std::function func) = 0; virtual void SetFlatCallback(std::function func) = 0; virtual void GetSpeedMode(int& speedmode,bool get) = 0 ; + virtual void GetOrSetVIDPID(int& value, bool get) = 0; void SetPath(std::string csFilePath) { csPath = csFilePath; @@ -67,4 +68,6 @@ public: ImageMatQueue m_pImages; HWND h; std::string csPath; + unsigned short VID; + unsigned short PID; }; \ No newline at end of file diff --git a/HuaGoCorrect/ImageMatQueue.cpp b/HuaGoCorrect/ImageMatQueue.cpp index f57aacd..3b68738 100644 --- a/HuaGoCorrect/ImageMatQueue.cpp +++ b/HuaGoCorrect/ImageMatQueue.cpp @@ -4,8 +4,6 @@ #include "filetools.h" #include "imageprocess.h" #include -#include -using namespace std; static int imgindex = 0; ImageMatQueue::ImageMatQueue(void) { @@ -113,25 +111,26 @@ void ImageMatQueue::proc() { if (pixType != -1) { - //string csName; SYSTEMTIME st = { 0 }; - GetLocalTime(&st); //ȡǰʱ ɾȷms - //csName.Format(_T("%02d%02d%02d-%d.bmp"), st.wHour, st.wMinute, st.wSecond,++imgindex); - char szDateTime[20] = { 0 }; - sprintf(szDateTime,"%02d%02d%02d-%d.bmp", st.wHour, st.wMinute, st.wSecond, ++imgindex); - string csName(szDateTime); + GetLocalTime(&st); //获取当前时间 可精确到ms + time_t timp; + tm* p; + time(&timp); + p = localtime(&timp); + std::string csName = std::to_string(p->tm_hour) + "_" + std::to_string(p->tm_min) + "_" + std::to_string(p->tm_sec)+".png"; + cv::Mat matPicImage; cv::Mat matFront, matBack; //vector mats; switch (DevModel) { case 0://G100 - case 1://G200//ͼֿ + case 1://G200//正反面图像分开的 { if (m_pImages.Size() >= 2) { - matFront = m_pImages.Take().getMat(pixType); - matBack = m_pImages.Take().getMat(pixType); + matFront = m_pImages.Take().getMat(pixType==1 ? 1 : 6);//bgr or gray + matBack = m_pImages.Take().getMat(pixType == 1 ? 1 : 6); //mats.push_back(matFront); //mats.push_back(matBack); } @@ -139,18 +138,11 @@ void ImageMatQueue::proc() break; case 2://G300 case 3://G400 - case 4://G500 ͼһͼϣҪͼ + case 4://G500 正反面图像在一副图上,需要均分图像 { std::string csImage; - csImage = csPath + "\\G300"+ csName; - - //cv::Mat mat = m_pImages.Take().getMat(pixType); - //matPicImage = mat(cv::Rect(0, 0, mat.cols, mat.rows)); - ////mats.push_back(matPicImage); - //IplImage qqImg; - //qqImg = IplImage(matPicImage); // cv::Mat -> IplImage - //cvSaveImage(csImage, &qqImg); - cv::Mat mat = m_pImages.Take().getMat(pixType);//1 color 6 gray + csImage = csPath+"//" + csName; + cv::Mat mat = m_pImages.Take().getMat(pixType == 1 ? 1 : 6); cv::imwrite(csImage, mat); m_images.Put(csImage); } diff --git a/HuaGoCorrect/commondef.h b/HuaGoCorrect/commondef.h index 65d7340..4bd302f 100644 --- a/HuaGoCorrect/commondef.h +++ b/HuaGoCorrect/commondef.h @@ -228,6 +228,8 @@ enum tagUsbSupported V4L2_AQULRE_ERROR = 79, //ɨڲͼƬʧ V4L2_IMAGE_EMPTY = 80, + //ԶУ + AUTO_FLATTING = 198, //USB δ USB_DISCONNECTED = 200, //ûֹͣ diff --git a/HuaGoCorrect/gscan3399.cpp b/HuaGoCorrect/gscan3399.cpp index 29cefe0..947da99 100644 --- a/HuaGoCorrect/gscan3399.cpp +++ b/HuaGoCorrect/gscan3399.cpp @@ -60,6 +60,8 @@ void gscan3399::open(int vid, int pid, int index) if (!usbs.empty()) { m_usb = *usbs.begin(); + VID = vid; + PID = pid; m_usb->open(); if (m_usb->is_connected()) { @@ -519,6 +521,11 @@ void gscan3399::GetSpeedMode(int& speedmode, bool get) } } +void gscan3399::GetOrSetVIDPID(int& value, bool get) +{ + +} + void gscan3399::usbcallback(bool isleft, void* usrdata) { gscan3399* This = (gscan3399*)usrdata; diff --git a/HuaGoCorrect/gscan3399.h b/HuaGoCorrect/gscan3399.h index 96f83a2..dc113d8 100644 --- a/HuaGoCorrect/gscan3399.h +++ b/HuaGoCorrect/gscan3399.h @@ -71,7 +71,7 @@ public: virtual void SetFlatCallback(std::function func); virtual void GetSpeedMode(int& speedmode,bool getorset); - + virtual void GetOrSetVIDPID(int& value, bool get) override; private: static void usbcallback(bool isleft, void* usrdata); diff --git a/HuaGoCorrect/gscn_drv.cpp b/HuaGoCorrect/gscn_drv.cpp index 72181b8..492eae0 100644 --- a/HuaGoCorrect/gscn_drv.cpp +++ b/HuaGoCorrect/gscn_drv.cpp @@ -57,6 +57,7 @@ void GScn_Drv::InitMSGMap() } + void GScn_Drv::InitScannerDiviceMap() { if (devType.size()>0) @@ -79,7 +80,9 @@ void GScn_Drv::open(int vid, int pid,int index) if (devs.size() != 0) { m_usb = *devs.begin(); - m_usb->open();//ͬʱڶͬɨ豸ʱĬѡȡһvid pidƥ豸 + m_usb->open();//?ͬʱڶͬɨ豸ʱĬѡȡһvid pidƥ豸 + VID = vid; + PID = pid; selectDeviceIndex=index; m_scannerType=G300; h= ::FindWindow(NULL, L"HGScannerTool"); @@ -240,21 +243,28 @@ void GScn_Drv::GetSpeedMode(int& speedmode, bool get) { if (m_usb.get() && m_usb->is_connected()) { + USBCB speed = { get ? GET_SPEED_MODE:SET_SPEED_MODE,speedmode,0 }; + m_usb->write_bulk(&speed, sizeof(speed)); if (get) { - - USBCB usb = { GET_SPEED_MODE ,speedmode,0 }; - m_usb->write_bulk(&usb, sizeof(usb)); - m_usb->read_bulk(&usb, sizeof(usb)); - speedmode = usb.u32_Data; - } - else - { - USBCB usb = { SET_SPEED_MODE,speedmode,0 }; - m_usb->write_bulk(&usb, sizeof(usb)); + m_usb->read_bulk(&speed, sizeof(speed)); + speedmode = speed.u32_Data; } } +} +void GScn_Drv::GetOrSetVIDPID(int& value, bool get) +{ + if (m_usb.get() && m_usb->is_connected()) + { + USBCB u_cmd = { get ? GET_USB_INFOR_VIDPID : SET_USB_INFOR_VIDPID,value,0 }; + m_usb->write_bulk(&u_cmd, sizeof(u_cmd)); + if (get) + { + m_usb->read_bulk(&u_cmd, sizeof(u_cmd)); + value = u_cmd.u32_Data; + } + } } void GScn_Drv::reset() @@ -400,7 +410,7 @@ DWORD GScn_Drv::usbmain() DWORD transferCount = 0; iNum++; cv::Mat imgData = Get_Img_Data(totalNum); - switch(m_scannerType) + switch(m_scannerType) { case G100: case G200: @@ -429,7 +439,12 @@ DWORD GScn_Drv::usbmain() case G300: case G400: case G500: + { pushMat(JpegBuffer(imgData, m_config.g200params.color == 1 ? TJPF_BGR : TJPF_GRAY,0,0)); + //auto img = fopen("inmg.jpg", "wb+"); + //fwrite(imgData.data, 1, totalNum, img); + //fclose(img); + } break; default: break; @@ -448,7 +463,26 @@ DWORD GScn_Drv::usbmain() { m_isScanning = false; devState = DEV_STOP; - MessageBox(NULL,TEXT("ԶУɣ"), TEXT("ʾ"), MB_OK); + if (usbcb.u32_Count != 0) + { + std::string msg; + msg.resize(usbcb.u32_Count); + m_usb->read_bulk(&msg[0], usbcb.u32_Count); + if (m_flatcallback) + m_flatcallback(msg); + } + //MessageBox(NULL,TEXT("ԶУɣ"), TEXT("ʾ"), MB_OK); + } + case AUTO_FLATTING: + { + if (usbcb.u32_Count != 0) + { + std::string msg; + msg.resize(usbcb.u32_Count); + m_usb->read_bulk(&msg[0], usbcb.u32_Count); + if (m_flatcallback) + m_flatcallback(msg); + } } break; case COUNT_MODE: @@ -461,7 +495,7 @@ DWORD GScn_Drv::usbmain() case HARDWARE_ERROR: case PC_SCAN_BUSY_or_ERROR:{ USES_CONVERSION; - MessageBox(h, CString(ntcMsg[usbcb.u32_Data].c_str()), L"ʾ", MB_OK | MB_ICONERROR); + MessageBox(h, CString(ntcMsg[usbcb.u32_Data].c_str()), L"ʾ?", MB_OK | MB_ICONERROR); devState = DEV_WRONG; m_pImages.SetScanFlag(false); break; diff --git a/HuaGoCorrect/gscn_drv.h b/HuaGoCorrect/gscn_drv.h index 9ba8ae8..5c29ba2 100644 --- a/HuaGoCorrect/gscn_drv.h +++ b/HuaGoCorrect/gscn_drv.h @@ -34,52 +34,52 @@ public: virtual void GetRatio(int type, int& ratio); virtual void Reboot(); virtual void PowerOff() {}; - virtual bool is_scan(); - virtual bool Get_Scanner_PaperOn(); + virtual bool is_scan()override; + virtual bool Get_Scanner_PaperOn()override; virtual void Config_Scanner(PUSBCB pUSBCB); - virtual void Config_Scanner(HGScanConfig config); - virtual void Scanner_StartScan(UINT16 count); - virtual void Stop_scan(); - virtual void ResetScanner(); - virtual bool Get_IsImageQueueEmpty(); - virtual void reset(); - virtual void run(); - virtual void ActiveteUSB(); - virtual bool Updata(std::string filename, std::function func); + virtual void Config_Scanner(HGScanConfig config)override; + virtual void Scanner_StartScan(UINT16 count)override; + virtual void Stop_scan()override; + virtual void ResetScanner()override; + virtual bool Get_IsImageQueueEmpty()override; + virtual void reset()override; + virtual void run()override; + virtual void ActiveteUSB()override; + virtual bool Updata(std::string filename, std::function func)override; - virtual int GetScanNum(); + virtual int GetScanNum()override; - virtual void ClrRollerNum(); + virtual void ClrRollerNum()override; - virtual void ClrScanNum(); + virtual void ClrScanNum()override; - virtual void SendFlatData(CorrectParam param, int index); + virtual void SendFlatData(CorrectParam param, int index)override; - virtual CaptureParams GetFlatData(); + virtual CaptureParams GetFlatData()override; - virtual void StartFlat(bool iscolor); + virtual void StartFlat(bool iscolor)override; - virtual void DevStateChange(); + virtual void DevStateChange()override; - virtual int getMatSum(); + virtual int getMatSum()override; - virtual void close(); + virtual void close()override; - virtual void GetExpose(int& Aside, int& Bside); - virtual void SetExpose(int aside, int bside); + virtual void GetExpose(int& Aside, int& Bside)override; + virtual void SetExpose(int aside, int bside)override; - virtual void GetSptime(int type, int& time); - virtual void SetSptime(int type, int time); + virtual void GetSptime(int type, int& time)override; + virtual void SetSptime(int type, int time)override; - virtual void GetSleepTime(int& sleeptime); - virtual void SetSleepTime(int sleeptime); + virtual void GetSleepTime(int& sleeptime)override; + virtual void SetSleepTime(int sleeptime)override; - virtual void GetFlatMaxBright(bool iscolor, unsigned int& val); - virtual void SetFlatMaxBright(bool iscolor, unsigned int val); - - virtual void SetFlatCallback(std::function func); - virtual void GetSpeedMode(int& speedmode, bool get); + virtual void GetFlatMaxBright(bool iscolor, unsigned int& val)override; + virtual void SetFlatMaxBright(bool iscolor, unsigned int val)override; + virtual void SetFlatCallback(std::function func)override; + virtual void GetSpeedMode(int& speedmode, bool get)override; + virtual void GetOrSetVIDPID(int& value, bool get) override; private: volatile int devState; volatile bool m_bRun; diff --git a/HuaGoCorrect/scn_usb.cpp b/HuaGoCorrect/scn_usb.cpp index 367b5cf..4ca74a4 100644 --- a/HuaGoCorrect/scn_usb.cpp +++ b/HuaGoCorrect/scn_usb.cpp @@ -236,7 +236,7 @@ int UsbScanEx::control_msg(int rtype, int req, int value, int index, int len, vo irp.fTransferDirectionIn = (rtype >> 7); irp.bRequest = req; irp.bmRequestType = (rtype >> 5) & 0x03; - + LPOVERLAPPED lp_overlap = ov + CTRL_IN_OUT; b_ret = DeviceIoControl(m_h_dev, IOCTL_SEND_USB_REQUEST, &irp, sizeof(irp), data, len, &dw_ret, lp_overlap); diff --git a/HuaGoCorrect/vendorconfig.cpp b/HuaGoCorrect/vendorconfig.cpp new file mode 100644 index 0000000..473ab74 --- /dev/null +++ b/HuaGoCorrect/vendorconfig.cpp @@ -0,0 +1,35 @@ +#include "stdafx.h" +#include "vendorconfig.h" + +#ifdef WIN32 +#include +#endif // WIN32 + +const char* vendorfile = "./vendorjson.json"; + +VendorConfig::VendorConfig() +{ + if (access(vendorfile, 0) != 0)// not exist + { + + } +} + +VendorConfig::~VendorConfig() +{ +} + +std::vector VendorConfig::GetVendorList() +{ + return m_suprtvendor; +} + +void VendorConfig::AddVendor(ScanerVendor& vendor) +{ + +} + +void VendorConfig::createdefaultvendor() +{ + +} \ No newline at end of file diff --git a/HuaGoCorrect/vendorconfig.h b/HuaGoCorrect/vendorconfig.h new file mode 100644 index 0000000..6a0cef0 --- /dev/null +++ b/HuaGoCorrect/vendorconfig.h @@ -0,0 +1,27 @@ +#pragma once +#include "json.h" +#include +#include + +typedef struct ScanerVendor +{ + std::string Vendor; + unsigned short VID; + unsigned short PID; +}; + + +class VendorConfig +{ +public: + VendorConfig(); + ~VendorConfig(); + std::vector GetVendorList(); + void AddVendor(ScanerVendor& vendor); +private: + void createdefaultvendor(); + //void read +private: + std::vector m_suprtvendor; +}; +