This commit is contained in:
masayume 2021-10-20 09:52:53 +08:00
commit 582b1fdac3
18 changed files with 323 additions and 165 deletions

View File

@ -17,3 +17,9 @@
2. 增加明场暗场校正最大明场值配置; 2. 增加明场暗场校正最大明场值配置;
3. 界面UI按钮顺序调整对齐等操作 3. 界面UI按钮顺序调整对齐等操作
V4.2版本 V4.2版本
2021年10月18日16
1. 针对3288 g300g400 增加校正信息实时显示;
2.增加usb vid pid 配置;
3.增加速度模式配置功能;
4.增加IP地址以及电机板版本读取功能

View File

@ -61,13 +61,6 @@ BOOL CA3::OnInitDialog()
{ {
m_cmbSpeedmode.InsertString(i, speedmodeMapString[i]); 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 return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE // 异常: OCX 属性页应返回 FALSE
} }
@ -151,6 +144,8 @@ void CA3::OnGetOrSetSp(bool get, int type)
} }
void CA3::OnGetOrSetSleepTime(bool get, int type) void CA3::OnGetOrSetSleepTime(bool get, int type)
{ {
int sp; int sp;
@ -245,7 +240,7 @@ void CA3::OnBnClickedBtnsetclrmaxbrt()
void CA3::OnBnClickedBtnsetgrymaxbrt() void CA3::OnBnClickedBtnsetgrymaxbrt()
{ {
// TODO: 在此添加控件通知处理程序代码 // TODO: ?¨²¡ä?¨¬¨ª?¨®???t¨ª¡§?a¡ä|¨¤¨ª3¨¬D¨°¡ä¨²??
UpdateMaxBright(false, IDC_LBGRYMAXBRT); UpdateMaxBright(false, IDC_LBGRYMAXBRT);
} }
@ -253,14 +248,14 @@ void CA3::OnBnClickedBtnsetgrymaxbrt()
void CA3::OnBnClickedBtngetclrmaxbrt() void CA3::OnBnClickedBtngetclrmaxbrt()
{ {
// TODO: 在此添加控件通知处理程序代码 // TODO: ?¨²¡ä?¨¬¨ª?¨®???t¨ª¡§?a¡ä|¨¤¨ª3¨¬D¨°¡ä¨²??
UpdateMaxBright(true, IDC_LBCLRMAXBRT); UpdateMaxBright(true, IDC_LBCLRMAXBRT);
} }
void CA3::OnBnClickedBtngetgrymaxbrt() void CA3::OnBnClickedBtngetgrymaxbrt()
{ {
// TODO: 在此添加控件通知处理程序代码 // TODO: ?¨²¡ä?¨¬¨ª?¨®???t¨ª¡§?a¡ä|¨¤¨ª3¨¬D¨°¡ä¨²??
UpdateMaxBright(true, IDC_LBGRYMAXBRT); UpdateMaxBright(true, IDC_LBGRYMAXBRT);
} }
@ -296,21 +291,15 @@ void CA3::updatespeedmode(bool get)
auto parent = (CHuaGoCorrectDlg*)GetParent(); auto parent = (CHuaGoCorrectDlg*)GetParent();
if (parent != NULL) if (parent != NULL)
{ {
if (parent->m_drv.get() && parent->m_drv->IsConnected()) if (parent->m_drv.get() && parent->m_drv->IsConnected()) {
{ int speedmode=0;
int speedmode;
std::string ver = parent->m_drv->GetFWVersion();
if (!ver.empty())
{
ver = ver.substr(0, 2);
}
if (get) if (get)
{ {
parent->m_drv->GetSpeedMode(speedmode, true); parent->m_drv->GetSpeedMode(speedmode, true);
bool bfound = false; 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) if (speedmodeMap[i].Speedmode == speedmode)
{ {
@ -321,20 +310,13 @@ void CA3::updatespeedmode(bool get)
break; break;
} }
} }
} else if (parent->m_drv->PID == 0x0300 || parent->m_drv->PID == 0x0400)
else
{ {
size_t j = 1; int startindex = parent->m_drv->PID == 0x0300 ? 6 : 10;
for (size_t i = speedmodeMap.size(); i < speedemodelen; i++) m_cmbSpeedmode.SetCurSel(startindex+ speedmode);
{
if (j == speedmode)
{
m_cmbSpeedmode.SetCurSel(i);
bfound = true; bfound = true;
break; break;
} }
++j;
}
} }
if (!bfound) if (!bfound)
MessageBox(L"未找到对应的速度模式!", L"提示", MB_OK | MB_ICONINFORMATION); MessageBox(L"未找到对应的速度模式!", L"提示", MB_OK | MB_ICONINFORMATION);
@ -342,29 +324,19 @@ void CA3::updatespeedmode(bool get)
else else
{ {
int cmbindex = m_cmbSpeedmode.GetCurSel(); int cmbindex = m_cmbSpeedmode.GetCurSel();
if (cmbindex != -1 && cmbindex < speedmodeMap.size()) if (cmbindex != -1)
{ {
if (ver == "G3" || ver == "G4")
{
MessageBox(L"设备序列号前两位为G3/G4请确认设备", L"速率选择错误", MB_OK | MB_ICONINFORMATION);
return;
}
auto t_speedmode = speedmodeMap[cmbindex]; auto t_speedmode = speedmodeMap[cmbindex];
if (parent->m_drv->PID == 0x0139 || parent->m_drv->PID == 0x0239)
{
parent->m_drv->GetSpeedMode(t_speedmode.Speedmode, false); parent->m_drv->GetSpeedMode(t_speedmode.Speedmode, false);
parent->m_drv->SetSptime(0, t_speedmode.GraySp); parent->m_drv->SetSptime(0, t_speedmode.GraySp);
parent->m_drv->SetSptime(1, t_speedmode.ColorSp); parent->m_drv->SetSptime(1, t_speedmode.ColorSp);
} }
else else if (parent->m_drv->PID == 0x0300 || parent->m_drv->PID == 0x0400)
{ {
if (ver != "G3" && ver != "G4") parent->m_drv->GetSpeedMode(t_speedmode.Speedmode, false);
{
MessageBox(L"设备序列号前两位不为G3/G4请确认设备", L"速率选择错误", MB_OK | MB_ICONINFORMATION);
return;
} }
cmbindex = cmbindex - speedmodeMap.size() + 1;
parent->m_drv->GetSpeedMode(cmbindex, false);
} }
} }
} }

View File

@ -1,21 +1,21 @@
#pragma once #pragma once
#include <map> #include <map>
// CA3 对话框 // CA3 对话框
class CA3 : public CDialog class CA3 : public CDialog
{ {
DECLARE_DYNAMIC(CA3) DECLARE_DYNAMIC(CA3)
public: public:
CA3(CWnd* pParent = NULL); // 标准构造函数 CA3(CWnd* pParent = NULL); // 标准构造函数
virtual ~CA3(); virtual ~CA3();
// 对话框数据 // 对话框数据
enum { IDD = IDD_A3_DIALOG }; enum { IDD = IDD_A3_DIALOG };
protected: protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
public: public:
@ -56,31 +56,39 @@ private:
std::map<int, speedmodeparam> speedmodeMap = { std::map<int, speedmodeparam> speedmodeMap = {
{0,{70,0x42d,0xc88}}, {0,{70,0x42d,0xc88}},
{1,{80,0x37f,0xa7f}}, {1,{80,0x37f,0xa7f}},
{2,{90,0x2b6,0x882}}, {2,{90,0x303,0x90a}},
{3,{110,0x24e,0x706}}, {3,{100,0x27c,0x775}},
{4,{100,0x27c,0x775}}, {4,{110,0x27c,0x775}},
{5,{110,0x27c,0x775}}, {5,{120,0x27c,0x775}},
{6,{120,0x27c,0x775}}, {6,{130,0x27c,0x775}},
{7,{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<int, CString> speedmodeMapString = { std::map<int, CString> speedmodeMapString = {
{0,L"G100_70PPM"}, {0,L"G139_70PPM"},
{1,L"G100_80PPM"}, {1,L"G139_80PPM"},
{2,L"G100_90PPM"}, {2,L"G139_90PPM"},
{3,L"G100_110PPM"}, {3,L"G239_100PPM"},
{4,L"G200_100PPM"}, {4,L"G239_110PPM"},
{5,L"G200_110PPM"}, {5,L"G239_120PPM"},
{6,L"G200_120PPM"}, {6,L"G239_130PPM"},
{7,L"G200_130PPM"} {7,L"G300_40PPM"},
}; {8,L"G300_50PPM"},
{9,L"G300_60PPM"},
std::map<int, CString> G300G400speedmodeMapString = { {10,L"G300_700PPM"},
{1,L"G300/G400_40PPM"}, {11,L"G400_40PPM"},
{2,L"G300/G400_50PPM"}, {12,L"G400_50PPM"},
{3,L"G300/G400_60PPM"}, {13,L"G400_60PPM"},
{4,L"G300/G400_70PPM"}, {14,L"G400_70PPM"},
{5,L"G400_80PPM"}, {15,L"G400_80PPM"},
}; };
CComboBox m_cmbSpeedmode; CComboBox m_cmbSpeedmode;
public: public:

View File

@ -192,6 +192,15 @@ void CA4::OnBnClickedBtnReboot()
/// </summary> /// </summary>
void CA4::OnBnClickedBtnSetvidpid() 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);
}
}
} }
/// <summary> /// <summary>
@ -199,7 +208,14 @@ void CA4::OnBnClickedBtnSetvidpid()
/// </summary> /// </summary>
void CA4::OnBnClickedBtnGetvidpid() 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);
}
} }
/// <summary> /// <summary>
@ -449,3 +465,34 @@ void CA4::OnBnClickedBtngetMbVersion()
SetDlgItemText(IDC_tbxMbVersion, vs); 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);
}
}

View File

@ -8,23 +8,31 @@
#include "JsonConfig.h" #include "JsonConfig.h"
#include <functional> #include <functional>
// CA4 对话框 // CA4 对话框
#define INI_FILE_NAME "./HuaGoScan.ini" #define INI_FILE_NAME "./HuaGoScan.ini"
class CA4 : public CDialog class CA4 : public CDialog
{ {
DECLARE_DYNAMIC(CA4) DECLARE_DYNAMIC(CA4)
public: public:
CA4(CWnd* pParent = NULL); // 标准构造函数 CA4(CWnd* pParent = NULL); // 标准构造函数
virtual ~CA4(); virtual ~CA4();
void updateA4Config(CaptureParams& pValues); void updateA4Config(CaptureParams& pValues);
void LoadCfg(); void LoadCfg();
// 对话框数据 // 对话框数据
enum { IDD = IDD_A4_DIALOG }; enum { IDD = IDD_A4_DIALOG };
union VIDPID
{
struct
{
unsigned short VID;
unsigned short PID;
};
unsigned int Value;
};
protected: protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
public: public:
@ -76,4 +84,6 @@ public:
void UpdateGains(int id, bool get); void UpdateGains(int id, bool get);
afx_msg void OnEnChangetbxfrexposure2(); afx_msg void OnEnChangetbxfrexposure2();
afx_msg void OnBnClickedBtngetMbVersion(); afx_msg void OnBnClickedBtngetMbVersion();
int AqrVIDPID();
void UpdateVidPid(VIDPID vidpid);
}; };

Binary file not shown.

View File

@ -1,18 +1,18 @@
// HuaGoCorrect.h : PROJECT_NAME 应用程序的主头文件 // HuaGoCorrect.h : PROJECT_NAME 应用程序的主头文件
// //
#pragma once #pragma once
#ifndef __AFXWIN_H__ #ifndef __AFXWIN_H__
#error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件" #error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件"
#endif #endif
#include "resource.h" // 主符号 #include "resource.h" // 主符号
// CHuaGoCorrectApp: // CHuaGoCorrectApp:
// 有关此类的实现,请参阅 HuaGoCorrect.cpp // 有关此类的实现,请参阅 HuaGoCorrect.cpp
// //
class CHuaGoCorrectApp : public CWinApp class CHuaGoCorrectApp : public CWinApp
@ -24,11 +24,11 @@ public:
CString path; CString path;
// 重写 // 重写
public: public:
virtual BOOL InitInstance(); virtual BOOL InitInstance();
// 实现 // 实现
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
}; };

View File

@ -340,6 +340,8 @@ void CHuaGoCorrectDlg::RefreshTabChange()
void CHuaGoCorrectDlg::Scan() void CHuaGoCorrectDlg::Scan()
{ {
HGScanConfig config = { 0 }; HGScanConfig config = { 0 };
if (m_drv->PID == 0x0139 || m_drv->PID == 0x0239)
{
config.g200params.dpi = 1;//only support 200DPI config.g200params.dpi = 1;//only support 200DPI
config.g200params.paper = 0; config.g200params.paper = 0;
config.g200params.pc_correct = ((CButton*)GetDlgItem(IDC_CKBORGINIMG))->GetCheck(); config.g200params.pc_correct = ((CButton*)GetDlgItem(IDC_CKBORGINIMG))->GetCheck();
@ -347,6 +349,18 @@ void CHuaGoCorrectDlg::Scan()
config.g200params.double_feed_enbale = TRUE; config.g200params.double_feed_enbale = TRUE;
config.g200params.screw_detect_enable = FALSE; config.g200params.screw_detect_enable = FALSE;
config.g200params.iscorrect_mode = 1;//УÕýģʽ 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); m_drv->Config_Scanner(config);
this_thread::sleep_for(std::chrono::milliseconds(1000)); this_thread::sleep_for(std::chrono::milliseconds(1000));
@ -409,6 +423,7 @@ void CHuaGoCorrectDlg::OnBnClickedBtnFlat()
std::string c_str = StringToUtf(info); std::string c_str = StringToUtf(info);
CString pWideChar = A2T(c_str.c_str()); CString pWideChar = A2T(c_str.c_str());
CString oldinfo; CString oldinfo;
UpdateData(FALSE);
((CEdit*)(m_A3dlg.GetDlgItem(IDC_LSTFLATINFO)))->GetWindowText(oldinfo); ((CEdit*)(m_A3dlg.GetDlgItem(IDC_LSTFLATINFO)))->GetWindowText(oldinfo);
oldinfo += pWideChar; oldinfo += pWideChar;
((CEdit*)(m_A3dlg.GetDlgItem(IDC_LSTFLATINFO)))->SetWindowText(oldinfo); ((CEdit*)(m_A3dlg.GetDlgItem(IDC_LSTFLATINFO)))->SetWindowText(oldinfo);

View File

@ -53,6 +53,7 @@ public:
virtual bool Updata(std::string filename, std::function<void(long, long)> func) = 0; virtual bool Updata(std::string filename, std::function<void(long, long)> func) = 0;
virtual void SetFlatCallback(std::function<void(std::string)> func) = 0; virtual void SetFlatCallback(std::function<void(std::string)> func) = 0;
virtual void GetSpeedMode(int& speedmode,bool get) = 0 ; virtual void GetSpeedMode(int& speedmode,bool get) = 0 ;
virtual void GetOrSetVIDPID(int& value, bool get) = 0;
void SetPath(std::string csFilePath) void SetPath(std::string csFilePath)
{ {
csPath = csFilePath; csPath = csFilePath;
@ -67,4 +68,6 @@ public:
ImageMatQueue m_pImages; ImageMatQueue m_pImages;
HWND h; HWND h;
std::string csPath; std::string csPath;
unsigned short VID;
unsigned short PID;
}; };

View File

@ -4,8 +4,6 @@
#include "filetools.h" #include "filetools.h"
#include "imageprocess.h" #include "imageprocess.h"
#include <atlconv.h> #include <atlconv.h>
#include<iostream>
using namespace std;
static int imgindex = 0; static int imgindex = 0;
ImageMatQueue::ImageMatQueue(void) ImageMatQueue::ImageMatQueue(void)
{ {
@ -113,25 +111,26 @@ void ImageMatQueue::proc()
{ {
if (pixType != -1) if (pixType != -1)
{ {
//string csName;
SYSTEMTIME st = { 0 }; SYSTEMTIME st = { 0 };
GetLocalTime(&st); //获取当前时间 可精确到ms GetLocalTime(&st); //获取当前时间 可精确到ms
//csName.Format(_T("%02d%02d%02d-%d.bmp"), st.wHour, st.wMinute, st.wSecond,++imgindex); time_t timp;
char szDateTime[20] = { 0 }; tm* p;
sprintf(szDateTime,"%02d%02d%02d-%d.bmp", st.wHour, st.wMinute, st.wSecond, ++imgindex); time(&timp);
string csName(szDateTime); 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 matPicImage;
cv::Mat matFront, matBack; cv::Mat matFront, matBack;
//vector<cv::Mat> mats; //vector<cv::Mat> mats;
switch (DevModel) switch (DevModel)
{ {
case 0://G100 case 0://G100
case 1://G200//正反面图像分开的 case 1://G200//正反面图像分开的
{ {
if (m_pImages.Size() >= 2) if (m_pImages.Size() >= 2)
{ {
matFront = m_pImages.Take().getMat(pixType); matFront = m_pImages.Take().getMat(pixType==1 ? 1 : 6);//bgr or gray
matBack = m_pImages.Take().getMat(pixType); matBack = m_pImages.Take().getMat(pixType == 1 ? 1 : 6);
//mats.push_back(matFront); //mats.push_back(matFront);
//mats.push_back(matBack); //mats.push_back(matBack);
} }
@ -139,18 +138,11 @@ void ImageMatQueue::proc()
break; break;
case 2://G300 case 2://G300
case 3://G400 case 3://G400
case 4://G500 正反面图像在一副图上,需要均分图像 case 4://G500 正反面图像在一副图上,需要均分图像
{ {
std::string csImage; std::string csImage;
csImage = csPath + "\\G300"+ csName; csImage = csPath+"//" + csName;
cv::Mat mat = m_pImages.Take().getMat(pixType == 1 ? 1 : 6);
//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
cv::imwrite(csImage, mat); cv::imwrite(csImage, mat);
m_images.Put(csImage); m_images.Put(csImage);
} }

View File

@ -228,6 +228,8 @@ enum tagUsbSupported
V4L2_AQULRE_ERROR = 79, V4L2_AQULRE_ERROR = 79,
//扫描仪内部图片丢失 //扫描仪内部图片丢失
V4L2_IMAGE_EMPTY = 80, V4L2_IMAGE_EMPTY = 80,
//自动校正中
AUTO_FLATTING = 198,
//USB 未连接 //USB 未连接
USB_DISCONNECTED = 200, USB_DISCONNECTED = 200,
//用户点击停止 //用户点击停止

View File

@ -60,6 +60,8 @@ void gscan3399::open(int vid, int pid, int index)
if (!usbs.empty()) if (!usbs.empty())
{ {
m_usb = *usbs.begin(); m_usb = *usbs.begin();
VID = vid;
PID = pid;
m_usb->open(); m_usb->open();
if (m_usb->is_connected()) 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) void gscan3399::usbcallback(bool isleft, void* usrdata)
{ {
gscan3399* This = (gscan3399*)usrdata; gscan3399* This = (gscan3399*)usrdata;

View File

@ -71,7 +71,7 @@ public:
virtual void SetFlatCallback(std::function<void(std::string)> func); virtual void SetFlatCallback(std::function<void(std::string)> func);
virtual void GetSpeedMode(int& speedmode,bool getorset); virtual void GetSpeedMode(int& speedmode,bool getorset);
virtual void GetOrSetVIDPID(int& value, bool get) override;
private: private:
static void usbcallback(bool isleft, void* usrdata); static void usbcallback(bool isleft, void* usrdata);

View File

@ -57,6 +57,7 @@ void GScn_Drv::InitMSGMap()
} }
void GScn_Drv::InitScannerDiviceMap() void GScn_Drv::InitScannerDiviceMap()
{ {
if (devType.size()>0) if (devType.size()>0)
@ -79,7 +80,9 @@ void GScn_Drv::open(int vid, int pid,int index)
if (devs.size() != 0) if (devs.size() != 0)
{ {
m_usb = *devs.begin(); m_usb = *devs.begin();
m_usb->open();//同时存在多个同种扫描设备时默认选取第一个vid pid匹配的设备 m_usb->open();//?同时存在多个同种扫描设备时默认选取第一个vid pid匹配的设备
VID = vid;
PID = pid;
selectDeviceIndex=index; selectDeviceIndex=index;
m_scannerType=G300; m_scannerType=G300;
h= ::FindWindow(NULL, L"HGScannerTool"); 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()) 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) if (get)
{ {
m_usb->read_bulk(&speed, sizeof(speed));
USBCB usb = { GET_SPEED_MODE ,speedmode,0 }; speedmode = speed.u32_Data;
m_usb->write_bulk(&usb, sizeof(usb));
m_usb->read_bulk(&usb, sizeof(usb));
speedmode = usb.u32_Data;
} }
else }
}
void GScn_Drv::GetOrSetVIDPID(int& value, bool get)
{ {
USBCB usb = { SET_SPEED_MODE,speedmode,0 }; if (m_usb.get() && m_usb->is_connected())
m_usb->write_bulk(&usb, sizeof(usb)); {
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() void GScn_Drv::reset()
@ -429,7 +439,12 @@ DWORD GScn_Drv::usbmain()
case G300: case G300:
case G400: case G400:
case G500: case G500:
{
pushMat(JpegBuffer(imgData, m_config.g200params.color == 1 ? TJPF_BGR : TJPF_GRAY,0,0)); 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; break;
default: default:
break; break;
@ -448,7 +463,26 @@ DWORD GScn_Drv::usbmain()
{ {
m_isScanning = false; m_isScanning = false;
devState = DEV_STOP; 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; break;
case COUNT_MODE: case COUNT_MODE:
@ -461,7 +495,7 @@ DWORD GScn_Drv::usbmain()
case HARDWARE_ERROR: case HARDWARE_ERROR:
case PC_SCAN_BUSY_or_ERROR:{ case PC_SCAN_BUSY_or_ERROR:{
USES_CONVERSION; 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; devState = DEV_WRONG;
m_pImages.SetScanFlag(false); m_pImages.SetScanFlag(false);
break; break;

View File

@ -34,52 +34,52 @@ public:
virtual void GetRatio(int type, int& ratio); virtual void GetRatio(int type, int& ratio);
virtual void Reboot(); virtual void Reboot();
virtual void PowerOff() {}; virtual void PowerOff() {};
virtual bool is_scan(); virtual bool is_scan()override;
virtual bool Get_Scanner_PaperOn(); virtual bool Get_Scanner_PaperOn()override;
virtual void Config_Scanner(PUSBCB pUSBCB); virtual void Config_Scanner(PUSBCB pUSBCB);
virtual void Config_Scanner(HGScanConfig config); virtual void Config_Scanner(HGScanConfig config)override;
virtual void Scanner_StartScan(UINT16 count); virtual void Scanner_StartScan(UINT16 count)override;
virtual void Stop_scan(); virtual void Stop_scan()override;
virtual void ResetScanner(); virtual void ResetScanner()override;
virtual bool Get_IsImageQueueEmpty(); virtual bool Get_IsImageQueueEmpty()override;
virtual void reset(); virtual void reset()override;
virtual void run(); virtual void run()override;
virtual void ActiveteUSB(); virtual void ActiveteUSB()override;
virtual bool Updata(std::string filename, std::function<void(long, long)> func); virtual bool Updata(std::string filename, std::function<void(long, long)> 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 GetExpose(int& Aside, int& Bside)override;
virtual void SetExpose(int aside, int bside); virtual void SetExpose(int aside, int bside)override;
virtual void GetSptime(int type, int& time); virtual void GetSptime(int type, int& time)override;
virtual void SetSptime(int type, int time); virtual void SetSptime(int type, int time)override;
virtual void GetSleepTime(int& sleeptime); virtual void GetSleepTime(int& sleeptime)override;
virtual void SetSleepTime(int sleeptime); virtual void SetSleepTime(int sleeptime)override;
virtual void GetFlatMaxBright(bool iscolor, unsigned int& val); virtual void GetFlatMaxBright(bool iscolor, unsigned int& val)override;
virtual void SetFlatMaxBright(bool iscolor, unsigned int val); virtual void SetFlatMaxBright(bool iscolor, unsigned int val)override;
virtual void SetFlatCallback(std::function<void(std::string)> func);
virtual void GetSpeedMode(int& speedmode, bool get);
virtual void SetFlatCallback(std::function<void(std::string)> func)override;
virtual void GetSpeedMode(int& speedmode, bool get)override;
virtual void GetOrSetVIDPID(int& value, bool get) override;
private: private:
volatile int devState; volatile int devState;
volatile bool m_bRun; volatile bool m_bRun;

View File

@ -0,0 +1,35 @@
#include "stdafx.h"
#include "vendorconfig.h"
#ifdef WIN32
#include <io.h>
#endif // WIN32
const char* vendorfile = "./vendorjson.json";
VendorConfig::VendorConfig()
{
if (access(vendorfile, 0) != 0)// not exist
{
}
}
VendorConfig::~VendorConfig()
{
}
std::vector<ScanerVendor> VendorConfig::GetVendorList()
{
return m_suprtvendor;
}
void VendorConfig::AddVendor(ScanerVendor& vendor)
{
}
void VendorConfig::createdefaultvendor()
{
}

View File

@ -0,0 +1,27 @@
#pragma once
#include "json.h"
#include <vector>
#include <sstream>
typedef struct ScanerVendor
{
std::string Vendor;
unsigned short VID;
unsigned short PID;
};
class VendorConfig
{
public:
VendorConfig();
~VendorConfig();
std::vector<ScanerVendor> GetVendorList();
void AddVendor(ScanerVendor& vendor);
private:
void createdefaultvendor();
//void read
private:
std::vector<ScanerVendor> m_suprtvendor;
};