404 lines
9.2 KiB
C++
404 lines
9.2 KiB
C++
// A3.cpp : 实现文件
|
||
//
|
||
|
||
#include "stdafx.h"
|
||
#include "HuaGoCorrect.h"
|
||
#include "A3.h"
|
||
#include "afxdialogex.h"
|
||
#include "HuaGoCorrectDlg.h"
|
||
|
||
|
||
// CA3 对话框
|
||
|
||
IMPLEMENT_DYNAMIC(CA3, CDialog)
|
||
|
||
CA3::CA3(CWnd* pParent /*=NULL*/)
|
||
: CDialog(CA3::IDD, pParent)
|
||
{
|
||
|
||
}
|
||
|
||
CA3::~CA3()
|
||
{
|
||
}
|
||
|
||
void CA3::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CDialog::DoDataExchange(pDX);
|
||
DDX_Control(pDX, IDC_CMBSPEEDMODE, m_cmbSpeedmode);
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(CA3, CDialog)
|
||
ON_BN_CLICKED(IDC_BTNGETGRAYSP, &CA3::OnBnClickedBtngetgraysp)
|
||
ON_BN_CLICKED(IDC_BTNSETGRAYSP, &CA3::OnBnClickedBtnsetgraysp)
|
||
ON_BN_CLICKED(IDC_BTNGETUVSP, &CA3::OnBnClickedBtngetuvsp)
|
||
ON_BN_CLICKED(IDC_BTNSETUVSP, &CA3::OnBnClickedBtnsetuvsp)
|
||
ON_BN_CLICKED(IDC_BTNGETCOLORSP, &CA3::OnBnClickedBtngetcolorsp)
|
||
ON_BN_CLICKED(IDC_BTNSETCOLORSP, &CA3::OnBnClickedBtnsetcolorsp)
|
||
ON_BN_CLICKED(IDC_BTNGETSLEEPTIME, &CA3::OnBnClickedBtngetsleeptime)
|
||
ON_BN_CLICKED(IDC_BTNSETSLEEPTIME, &CA3::OnBnClickedBtnsetsleeptime)
|
||
ON_BN_CLICKED(IDC_BTNSETCLRMAXBRT, &CA3::OnBnClickedBtnsetclrmaxbrt)
|
||
ON_BN_CLICKED(IDC_BTNSETGRYMAXBRT, &CA3::OnBnClickedBtnsetgrymaxbrt)
|
||
ON_BN_CLICKED(IDC_BTNGETCLRMAXBRT, &CA3::OnBnClickedBtngetclrmaxbrt)
|
||
ON_BN_CLICKED(IDC_BTNGETGRYMAXBRT, &CA3::OnBnClickedBtngetgrymaxbrt)
|
||
ON_BN_CLICKED(IDC_BTNGETVERSION, &CA3::OnBnClickedBtngetversion)
|
||
ON_BN_CLICKED(IDC_BTNSETSPEED, &CA3::OnBnClickedBtnsetspeed)
|
||
ON_BN_CLICKED(IDC_BTNGETSPEED, &CA3::OnBnClickedBtngetspeed)
|
||
ON_BN_CLICKED(IDC_BTNGETIP, &CA3::OnBnClickedBtngetip)
|
||
ON_BN_CLICKED(IDC_BTNGETSYSINFO, &CA3::OnBnClickedBtnGetSysInfo)
|
||
END_MESSAGE_MAP()
|
||
|
||
|
||
// CA3 消息处理程序
|
||
|
||
|
||
BOOL CA3::OnInitDialog()
|
||
{
|
||
CDialog::OnInitDialog();
|
||
|
||
// TODO: 在此添加额外的初始化
|
||
for (size_t i = 0; i < speedmodeMap.size(); i++)
|
||
{
|
||
m_cmbSpeedmode.InsertString(i, speedmodeMapString[i]);
|
||
}
|
||
return TRUE; // return TRUE unless you set the focus to a control
|
||
// 异常: OCX 属性页应返回 FALSE
|
||
}
|
||
|
||
|
||
void CA3::OnBnClickedBtngetsp()
|
||
{
|
||
// TODO: 在此添加控件通知处理程序代码
|
||
}
|
||
|
||
|
||
void CA3::OnBnClickedBtnsetsp()
|
||
{
|
||
// TODO: 在此添加控件通知处理程序代码
|
||
}
|
||
|
||
void CA3::OnBnClickedBtngetgraysp()
|
||
{
|
||
// TODO: 在此添加控件通知处理程序代码
|
||
OnGetOrSetSp(true, 0);
|
||
}
|
||
|
||
|
||
void CA3::OnBnClickedBtnsetgraysp()
|
||
{
|
||
// TODO: 在此添加控件通知处理程序代码
|
||
OnGetOrSetSp(false, 0);
|
||
}
|
||
|
||
|
||
void CA3::OnBnClickedBtngetuvsp()
|
||
{
|
||
// TODO: 在此添加控件通知处理程序代码
|
||
OnGetOrSetSp(true, 2);
|
||
}
|
||
|
||
|
||
void CA3::OnBnClickedBtnsetuvsp()
|
||
{
|
||
// TODO: 在此添加控件通知处理程序代码
|
||
OnGetOrSetSp(false, 2);
|
||
}
|
||
|
||
|
||
void CA3::OnBnClickedBtngetcolorsp()
|
||
{
|
||
// TODO: 在此添加控件通知处理程序代码
|
||
OnGetOrSetSp(true, 1);
|
||
}
|
||
|
||
|
||
void CA3::OnBnClickedBtnsetcolorsp()
|
||
{
|
||
OnGetOrSetSp(false, 1);
|
||
}
|
||
|
||
|
||
void CA3::OnGetOrSetSp(bool get, int type)
|
||
{
|
||
int sp;
|
||
CString str_sp;
|
||
auto parent = (CHuaGoCorrectDlg*)GetParent();
|
||
int itemid = type == 0 ? IDC_LBGRAYSP : (type == 1 ? IDC_LBCOLORSP : IDC_LBGUVSP); //IDC_LBCOLORSP
|
||
if (parent->m_drv.get() && parent->m_drv->IsConnected()) {
|
||
if (get)
|
||
{
|
||
|
||
parent->m_drv->GetSptime(type, sp);
|
||
str_sp.Format(L"%d", sp);
|
||
SetDlgItemText(itemid, str_sp);
|
||
}
|
||
else
|
||
{
|
||
GetDlgItemText(itemid, str_sp);
|
||
USES_CONVERSION;
|
||
std::string str(W2A(str_sp));
|
||
int value = atoi(str.c_str());
|
||
parent->m_drv->SetSptime(type, value);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
void CA3::OnGetOrSetSleepTime(bool get, int type)
|
||
{
|
||
int sp;
|
||
CString str_sp;
|
||
auto parent = (CHuaGoCorrectDlg*)GetParent();
|
||
int itemid = type == 0 ? IDC_LBGRAYSP : (type == 1 ? IDC_LBCOLORSP : IDC_LBGUVSP); //IDC_LBCOLORSP
|
||
if (parent->m_drv.get() && parent->m_drv->IsConnected()) {
|
||
if (get)
|
||
{
|
||
|
||
parent->m_drv->GetSptime(type, sp);
|
||
str_sp.Format(L"%d", sp);
|
||
SetDlgItemText(itemid, str_sp);
|
||
}
|
||
else
|
||
{
|
||
GetDlgItemText(itemid, str_sp);
|
||
USES_CONVERSION;
|
||
std::string str(W2A(str_sp));
|
||
int value = atoi(str.c_str());
|
||
parent->m_drv->SetSptime(type, value);
|
||
}
|
||
}
|
||
}
|
||
|
||
void CA3::UpdateMaxBright(bool get, int id)
|
||
{
|
||
int sp;
|
||
CString str_sp;
|
||
auto parent = (CHuaGoCorrectDlg*)GetParent();
|
||
if (parent->m_drv.get() && parent->m_drv->IsConnected()) {
|
||
if (get)
|
||
{
|
||
unsigned int val = 0;
|
||
parent->m_drv->GetFlatMaxBright(id == IDC_LBCLRMAXBRT, val);
|
||
str_sp.Format(L"%d", val);
|
||
SetDlgItemText(id, str_sp);
|
||
}
|
||
else
|
||
{
|
||
GetDlgItemText(id, str_sp);
|
||
USES_CONVERSION;
|
||
std::string str(W2A(str_sp));
|
||
int value = atoi(str.c_str());
|
||
if (value <= 0) value = 180;
|
||
|
||
parent->m_drv->SetFlatMaxBright(id == IDC_LBCLRMAXBRT, value);
|
||
}
|
||
}
|
||
}
|
||
|
||
void CA3::UpdateSleepTime(bool get)
|
||
{
|
||
int sp;
|
||
CString str_sp;
|
||
auto parent = (CHuaGoCorrectDlg*)GetParent();
|
||
if (parent->m_drv.get() && parent->m_drv->IsConnected()) {
|
||
if (get)
|
||
{
|
||
parent->m_drv->GetSleepTime(sp);
|
||
str_sp.Format(L"%d", sp);
|
||
SetDlgItemText(IDC_LBSLEEPTIME, str_sp);
|
||
}
|
||
else
|
||
{
|
||
GetDlgItemText(IDC_LBSLEEPTIME, str_sp);
|
||
USES_CONVERSION;
|
||
std::string str(W2A(str_sp));
|
||
int value = atoi(str.c_str());
|
||
parent->m_drv->SetSleepTime(value);
|
||
}
|
||
}
|
||
}
|
||
|
||
void CA3::OnBnClickedBtngetsleeptime()
|
||
{
|
||
UpdateSleepTime(true);
|
||
}
|
||
|
||
|
||
void CA3::OnBnClickedBtnsetsleeptime()
|
||
{
|
||
UpdateSleepTime(false);
|
||
}
|
||
|
||
void CA3::OnBnClickedBtnsetclrmaxbrt()
|
||
{
|
||
UpdateMaxBright(false, IDC_LBCLRMAXBRT);
|
||
}
|
||
|
||
|
||
void CA3::OnBnClickedBtnsetgrymaxbrt()
|
||
{
|
||
// TODO: ?ú′?ìí?ó???tí¨?a′|àí3ìDò′ú??
|
||
UpdateMaxBright(false, IDC_LBGRYMAXBRT);
|
||
|
||
}
|
||
|
||
|
||
void CA3::OnBnClickedBtngetclrmaxbrt()
|
||
{
|
||
// TODO: ?ú′?ìí?ó???tí¨?a′|àí3ìDò′ú??
|
||
UpdateMaxBright(true, IDC_LBCLRMAXBRT);
|
||
}
|
||
|
||
|
||
void CA3::OnBnClickedBtngetgrymaxbrt()
|
||
{
|
||
// TODO: ?ú′?ìí?ó???tí¨?a′|àí3ìDò′ú??
|
||
UpdateMaxBright(true, IDC_LBGRYMAXBRT);
|
||
}
|
||
|
||
|
||
void CA3::OnBnClickedBtngetversion()
|
||
{
|
||
auto parent = (CHuaGoCorrectDlg*)GetParent();
|
||
if (parent != NULL)
|
||
{
|
||
if (parent->m_drv.get() && parent->m_drv->IsConnected()) {
|
||
auto kversion = parent->m_drv->GetKernelVersion();
|
||
CString version(kversion.c_str());
|
||
SetDlgItemText(IDC_LBKERNEL_VERSION, version);
|
||
}
|
||
}
|
||
}
|
||
|
||
void CA3::OnBnClickedBtnsetspeed()
|
||
{
|
||
// TODO: 在此添加控件通知处理程序代码
|
||
updatespeedmode(false);
|
||
}
|
||
|
||
void CA3::OnBnClickedBtngetspeed()
|
||
{
|
||
// TODO: 在此添加控件通知处理程序代码
|
||
updatespeedmode(true);
|
||
}
|
||
|
||
|
||
void CA3::updatespeedmode(bool get)
|
||
{
|
||
auto parent = (CHuaGoCorrectDlg*)GetParent();
|
||
if (parent != NULL)
|
||
{
|
||
if (parent->m_drv.get() && parent->m_drv->IsConnected()) {
|
||
int speedmode=0;
|
||
if (get)
|
||
{
|
||
parent->m_drv->GetSpeedMode(speedmode, true);
|
||
bool bfound = false;
|
||
for (size_t i = 0; i < speedmodeMap.size(); i++)
|
||
{
|
||
if (parent->m_drv->CPU == 3399)
|
||
{
|
||
if ((parent->m_drv->Driver_type == 200) && (i < 4))
|
||
continue;
|
||
if ((parent->m_drv->Driver_type == 300) && (i < 8))
|
||
continue;
|
||
if ((parent->m_drv->Driver_type == 400) && (i < 12))
|
||
continue;
|
||
if ((parent->m_drv->Driver_type == 400) || (parent->m_drv->Driver_type == 300))
|
||
{
|
||
switch (speedmode)
|
||
{
|
||
case 40:speedmode = 1; break;
|
||
case 50:speedmode = 2; break;
|
||
case 60:speedmode = 3; break;
|
||
case 70:speedmode = 4; break;
|
||
case 80:speedmode = 5; break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
if (speedmodeMap[i].Speedmode == speedmode)
|
||
{
|
||
m_cmbSpeedmode.SetCurSel(i);
|
||
OnGetOrSetSp(true, 0);//更新灰度sp
|
||
OnGetOrSetSp(true, 1);//更新彩色sp
|
||
bfound = true;
|
||
break;
|
||
}
|
||
}
|
||
else if ((parent->m_drv->Driver_type == 300 || parent->m_drv->Driver_type == 400)||(parent->m_drv->CPU == 3288))
|
||
{
|
||
if ((parent->m_drv->Driver_type == 400) && (i < 12))
|
||
continue;
|
||
int startindex = parent->m_drv->Driver_type == 300 ? 7: 11;
|
||
m_cmbSpeedmode.SetCurSel(startindex+ speedmode);
|
||
bfound = true;
|
||
break;
|
||
}
|
||
}
|
||
if (!bfound)
|
||
MessageBox(L"未找到对应的速度模式!", L"提示", MB_OK | MB_ICONINFORMATION);
|
||
}
|
||
else
|
||
{
|
||
int cmbindex = m_cmbSpeedmode.GetCurSel();
|
||
if (cmbindex != -1)
|
||
{
|
||
auto t_speedmode = speedmodeMap[cmbindex];
|
||
if (parent->m_drv->CPU == 3399)
|
||
{
|
||
if ((parent->m_drv->Driver_type == 400) || (parent->m_drv->Driver_type == 300))
|
||
{
|
||
switch (t_speedmode.Speedmode)
|
||
{
|
||
case 1:t_speedmode.Speedmode = 40; break;
|
||
case 2:t_speedmode.Speedmode = 50; break;
|
||
case 3:t_speedmode.Speedmode = 60; break;
|
||
case 4:t_speedmode.Speedmode = 70; break;
|
||
case 5:t_speedmode.Speedmode = 80; break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
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 ((parent->m_drv->Driver_type == 300 || parent->m_drv->Driver_type == 400) || (parent->m_drv->CPU == 3288))
|
||
{
|
||
parent->m_drv->GetSpeedMode(t_speedmode.Speedmode, false);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
MessageBox(L"未找到扫描仪!", L"提示", MB_OK | MB_ICONINFORMATION);
|
||
}
|
||
}
|
||
}
|
||
|
||
void CA3::OnBnClickedBtngetip()
|
||
{
|
||
// TODO: 在此添加控件通知处理程序代码
|
||
auto parent = (CHuaGoCorrectDlg*)GetParent();
|
||
if (parent->m_drv.get() && parent->m_drv->IsConnected()) {
|
||
std::string version = parent->m_drv->GetIpAddr();
|
||
CString vs(version.c_str());
|
||
SetDlgItemText(IDC_LBIPADDR, vs);
|
||
}
|
||
}
|
||
|
||
void CA3::OnBnClickedBtnGetSysInfo()
|
||
{
|
||
auto parent = (CHuaGoCorrectDlg*)GetParent();
|
||
if (parent->m_drv.get() && parent->m_drv->IsConnected()) {
|
||
std::string version = parent->m_drv->GetSysInfo();
|
||
CString vs(version.c_str());
|
||
MessageBox(vs, TEXT("系统信息"),MB_OK);
|
||
}
|
||
}
|