1.增加幅面检测功能;

2.增加UI幅面选项逻辑以及相应twain协议
3.删除多余无效类
4.调整通信协议,增加配置开启DSP缓存以及幅面检测配置
This commit is contained in:
lovelyyoung 2020-12-10 10:01:22 +08:00
parent 1bc01856f1
commit d3b7e44580
16 changed files with 107 additions and 552 deletions

View File

@ -123,6 +123,7 @@ void CBasicPage::DoDataExchange(CDataExchange* pDX)
{
CTabPageSSL::DoDataExchange(pDX);
DDX_Check(pDX, IDC_CKBSWITCHFRONTBACK, m_bswitchfrontback);
DDX_Check(pDX, IDC_CKBSIZEDETECT, m_enableSizeCheck);
}
BOOL CBasicPage::OnInitDialog()
@ -260,4 +261,18 @@ void CBasicPage::updateCmbDuplex(BOOL insert)
m_cmBoxDuplex->InsertString(4, TEXT("对折"));
}
}
#ifdef G200
#ifndef ISG100
if (tmp_paperindex == 16 || tmp_paperindex == 17)
{
(((CButton*)GetDlgItem(IDC_CKBSIZEDETECT)))->SetCheck(false);
GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(false);
}
else
{
GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(true);
}
#endif
#endif // G200
}

View File

@ -29,7 +29,7 @@ public:
int DevnMax;
BOOL m_bswitchfrontback;
int discardblank_percent;
BOOL m_enableSizeCheck;
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_PAGEBASIC };

View File

@ -157,6 +157,7 @@ void CTwainUI::UpdateUI()
m_pageBasic->m_cmBoxResultion->SetCurSel(get_map_key_by_value(resolutions, settings->resolution_dst));//!< 分辨率
m_pageBasic->m_cmBoxDuplex->SetCurSel(getCmbDuplexIndex());//!< 单双面
m_pageBasic->m_cmBoxSS->SetCurSel(getPaparSizeIndex(settings->papertype, settings->paperAlign)); //!< 纸张类型
m_pageBasic->m_enableSizeCheck = settings->en_sizecheck==1?TRUE:FALSE;//!< 尺寸检测
m_pageBasic->m_bswitchfrontback = settings->is_switchfrontback ? TRUE : FALSE; //!< 交换正反面
m_pageBasic->UpdateData(FALSE);
if(getCmbDuplexIndex()==2|| getCmbDuplexIndex()==3)
@ -380,6 +381,7 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs)
//!< Page Basic
m_pageBasic->UpdateData();
configItem->Pixtype = m_pageBasic->m_cmBoxColorMode->GetCurSel();//!< 颜色模式 index
configItem->EnSizeCheck = m_pageBasic->m_enableSizeCheck;
configItem->Resolution = m_pageBasic->m_cmBoxResultion->GetCurSel();//!< 分辨率 index
configItem->Duplex = m_pageBasic->m_cmBoxDuplex->GetCurSel();//!< 单双面
configItem->PaperSize = m_pageBasic->m_cmBoxSS->GetCurSel();//!< 纸张类型 index
@ -440,6 +442,7 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs)
settings->papertype = paper.Paper;
settings->paperAlign = (PaperAlign)paper.Orentate;
settings->en_sizecheck = configItem->EnSizeCheck;
settings->resolution_dst = Resolutions[configItem->Resolution];
settings->resolution_native = 200.0f;
settings->is_switchfrontback = configItem->EnSwitchFrontBack ? 1 : 0;

View File

@ -62,12 +62,20 @@ typedef enum tagUsbSupported {
UPDATE_SCAN_PARAMETER = 72,
// PC繁忙或出错
PC_SCAN_BUSY_or_ERROR = 73,
//摺角
DOG_EAR=74,
//幅面检测错误
SIZE_ERROR=75,
//USB 未连接
USB_DISCONNECTED = 200,
//用户点击停止
USER_STOP = 201
USER_STOP = 201,
//自动校正完成
AUTO_FLAT_FINISHED = 202,
//usb 已连接
USB_CONNECTED,
HAVE_PAPER
} UsbSupported, * PUsbSupported;

View File

@ -645,6 +645,7 @@ void GScanO200::usbmain()
case PAPER_SKEW:
case HARDWARE_ERROR:
case PC_SCAN_BUSY_or_ERROR:
case SIZE_ERROR:
#ifdef G200
Set_ErrorCode(usbcb.u32_Data);
m_pImages->setscanflags(false);

View File

@ -4,9 +4,31 @@
#include <map>
#include "PublicFunc.h"
#include "PaperSize.h"
#define FOR_LANXUM
static std::map<PaperStatus, unsigned int> SupPaperTyps = {
#ifdef G200
#ifdef FOR_LANXUM
{{TwSS::A3,PaperAlign::Rot0},0},
{{TwSS::A4,PaperAlign::Rot0},1},
{{TwSS::A4,PaperAlign::Rot270},2},
{{TwSS::A5,PaperAlign::Rot0 },3},
{{TwSS::A5,PaperAlign::Rot270},4},
{{TwSS::A6,PaperAlign::Rot0},5},
{{TwSS::A6,PaperAlign::Rot270},6},
{{TwSS::B4,PaperAlign::Rot0},7},
{{TwSS::B5,PaperAlign::Rot0},8},
{{TwSS::B5,PaperAlign::Rot270},9},
{{TwSS::B6,PaperAlign::Rot0},10},
{{TwSS::B6,PaperAlign::Rot270},11},
{{TwSS::USLetter,PaperAlign::Rot0},14},
{{TwSS::USLetter,PaperAlign::Rot270},15},
{{TwSS::USLedger,PaperAlign::Rot0},12},
{{TwSS::USLegal,PaperAlign::Rot0},13},
{{TwSS::None,PaperAlign::Rot0},0},
{{TwSS::USStatement,PaperAlign::Rot0},16},
{{TwSS::MaxSize,PaperAlign::Rot0},16}
#else
{{TwSS::A3,PaperAlign::Rot0},0},
{{TwSS::A4,PaperAlign::Rot0},1},
{{TwSS::A4,PaperAlign::Rot270},2},
@ -26,6 +48,7 @@ static std::map<PaperStatus, unsigned int> SupPaperTyps = {
{{TwSS::None,PaperAlign::Rot0},0},
{{TwSS::USStatement,PaperAlign::Rot0},16},
{{TwSS::MaxSize,PaperAlign::Rot0},16}
#endif
#else
{{TwSS::A3,PaperAlign::Rot0},G400_A3},
{{TwSS::A4,PaperAlign::Rot0},G400_A4},
@ -87,7 +110,9 @@ typedef union Config_Param {
unsigned int screw_detect_level : 3;//µÚÊ®ËÄλ
unsigned int unused_one : 6;
unsigned int pc_correct : 1;
unsigned int unused_two : 11;
unsigned int enable_sizecheck : 1;
unsigned int enabledsp_cache : 1;
unsigned int sizeerror_errorratio : 9;
};
} ConfigParam;

View File

@ -1,522 +0,0 @@
#include "StdAfx.h"
#include "JsonConfig.h"
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <sstream>
#include "CJsonObject.hpp"
JsonConfig::JsonConfig(void)
{
}
JsonConfig::~JsonConfig(void)
{
}
/************************************************************************/
/* 保存配置参数 */
/************************************************************************/
void JsonConfig::WriteToJson(PCONFIGPARAMS pConfigItem,const std::string fileNames,bool isConfigItem)
{
neb::CJsonObject outJson;
outJson.AddEmptySubObject("Config");//header
outJson["Config"].Add(PIXTYPE,(int)(pConfigItem->Pixtype));
outJson["Config"].Add(PAPARSIZE,(int)(pConfigItem->PaperSize));
outJson["Config"].Add(AUTOCROP,(bool)(pConfigItem->EnAutoCrop),false);
outJson["Config"].Add(RESOLUTION,(int)(pConfigItem->Resolution));
outJson["Config"].Add(DUPLEX,(int)(pConfigItem->Duplex));
outJson["Config"].Add(DISCARBLANK,(bool)(pConfigItem->EnDiscardBlank),false);
outJson["Config"].Add(DISCARBLANKVINCE,(bool)(pConfigItem->EnDiscardBlankVince),false);
outJson["Config"].Add(DB_AREANUM, (int)(pConfigItem->DBlank_AreaNum));
outJson["Config"].Add(DB_DEVNMAX, (int)(pConfigItem->DBlank_DevnMax));
outJson["Config"].Add(FLOD, (bool)(pConfigItem->EnFlod),false);
outJson["Config"].Add(SWITCHFRONTBACK, (bool)(pConfigItem->EnSwitchFrontBack), false);
outJson["Config"].Add(BRIGHTNESS,(float)(pConfigItem->Brightness));
outJson["Config"].Add(AUTOCONTRAST,(bool)(pConfigItem->EnAutoContrast),false);
outJson["Config"].Add(CONTRAST,(float)(pConfigItem->Contrast));
outJson["Config"].Add(GAMMA_,(int)(pConfigItem->Gamma));
outJson["Config"].Add(FILTERTYPE,(int)(pConfigItem->Filter));
outJson["Config"].Add(SHARPENTYPE, (int)(pConfigItem->Sharpen));
outJson["Config"].Add(AUTODESCREW,(bool)(pConfigItem->EnAutoDescrew),false);
outJson["Config"].Add(FILLBLACK,(bool)(pConfigItem->EnFillBlack),false);
outJson["Config"].Add(MULTIOUTPUT,(bool)(pConfigItem->EnMultiOutPutR),false);
outJson["Config"].Add(OUTHOLE,(bool)(pConfigItem->EnOutHole),false);
outJson["Config"].Add(OUTHOLERATIO,(int)(pConfigItem->OutHoleRatio));
outJson["Config"].Add(ULTRADETECT,(bool)(pConfigItem->EnUltrasonicDetect),false);
outJson["Config"].Add(BINDINGDETECT,(bool)(pConfigItem->EnBindingDetect),false);
outJson["Config"].Add(SCANCOUNT,(int)(pConfigItem->ScanCount));
outJson["Config"].Add(DOCORIENTATION,(int)(pConfigItem->Orentation));
outJson["Config"].Add(BACKROTATE180,(bool)(pConfigItem->EnBackRotate180),false);
outJson["Config"].Add(SCREWDETECT,(bool)(pConfigItem->EnScrewDetect),false);
outJson["Config"].Add(SCREWLEVEL,(int)(pConfigItem->ScrewDetectLevel));
if (isConfigItem)
{
outJson["Config"].Add(ITEMCAPTION,(string)(pConfigItem->Caption));
outJson["Config"].Add(SAVEPATH,(string)(pConfigItem->SavePath));
}
std::ofstream os;
os.open(fileNames.c_str());
os<<outJson.ToFormattedString();
os.close();
}
void JsonConfig::WriteJsonData(const std::string fileName)
{
//Json::Reader reader;
//Json::Value root;
//std::ifstream is;
//is.open(fileName.c_str(),std::ios::binary);
//if (reader.parse(is,root))
//{
//
//}
}
//PCONFIGPARAMS JsonConfig::ReadJsonFromFile(const char* fileNames)
//{
//}
void JsonConfig::WriteJsonArrayToFile(std::vector<CONFIGPARAMS> cfgArray,const std::string filename)
{
//Json::StyledWriter sw;
neb::CJsonObject root;
root.AddEmptySubObject("Config");
root["Config"].AddEmptySubArray(PIXTYPE);
root["Config"].AddEmptySubArray(PAPARSIZE);
root["Config"].AddEmptySubArray(AUTOCROP);
root["Config"].AddEmptySubArray(RESOLUTION);
root["Config"].AddEmptySubArray(DUPLEX);
root["Config"].AddEmptySubArray(DISCARBLANK);
root["Config"].AddEmptySubArray(DISCARBLANKVINCE);
root["Config"].AddEmptySubArray(DB_AREANUM);
root["Config"].AddEmptySubArray(DB_DEVNMAX);
root["Config"].AddEmptySubArray(FLOD);
root["Config"].AddEmptySubArray(SWITCHFRONTBACK);
root["Config"].AddEmptySubArray(BRIGHTNESS);
root["Config"].AddEmptySubArray(AUTOCONTRAST);
root["Config"].AddEmptySubArray(CONTRAST);
root["Config"].AddEmptySubArray(GAMMA_);
root["Config"].AddEmptySubArray(FILTERTYPE);
root["Config"].AddEmptySubArray(SHARPENTYPE);
root["Config"].AddEmptySubArray(AUTODESCREW);
root["Config"].AddEmptySubArray(FILLBLACK);
root["Config"].AddEmptySubArray(MULTIOUTPUT);
root["Config"].AddEmptySubArray(OUTHOLE);
root["Config"].AddEmptySubArray(OUTHOLERATIO);
root["Config"].AddEmptySubArray(ULTRADETECT);
root["Config"].AddEmptySubArray(BINDINGDETECT);
root["Config"].AddEmptySubArray(SCANCOUNT);
root["Config"].AddEmptySubArray(DOCORIENTATION);
root["Config"].AddEmptySubArray(BACKROTATE180);
root["Config"].AddEmptySubArray(SCREWDETECT);
root["Config"].AddEmptySubArray(SCREWLEVEL);
root["Config"].AddEmptySubArray(ITEMCAPTION);
root["Config"].AddEmptySubArray(SAVEPATH);
for (int i = 0; i < cfgArray.size(); i++)
{
root["Config"][PIXTYPE].Add(cfgArray[i].Pixtype);
root["Config"][PAPARSIZE].Add(cfgArray[i].PaperSize);
root["Config"][AUTOCROP].Add(i, cfgArray[i].EnAutoCrop);
root["Config"][RESOLUTION].Add(cfgArray[i].Resolution);
root["Config"][DUPLEX].Add(cfgArray[i].Duplex);
root["Config"][DISCARBLANK].Add(i, cfgArray[i].EnDiscardBlank);
root["Config"][DISCARBLANKVINCE].Add(i, cfgArray[i].EnDiscardBlankVince);
root["Config"][DB_AREANUM].Add(cfgArray[i].DBlank_AreaNum);
root["Config"][DB_DEVNMAX].Add(cfgArray[i].DBlank_DevnMax);
root["Config"][FLOD].Add(i,cfgArray[i].EnFlod);
root["Config"][SWITCHFRONTBACK].Add(i, cfgArray[i].EnSwitchFrontBack);
root["Config"][BRIGHTNESS].Add(cfgArray[i].Brightness);
root["Config"][AUTOCONTRAST].Add(i,cfgArray[i].EnAutoContrast);
root["Config"][CONTRAST].Add(cfgArray[i].Contrast);
root["Config"][GAMMA_].Add(cfgArray[i].Gamma);
root["Config"][FILTERTYPE].Add(cfgArray[i].Filter);
root["Config"][SHARPENTYPE].Add(cfgArray[i].Sharpen);
root["Config"][AUTODESCREW].Add(i,cfgArray[i].EnAutoDescrew);
root["Config"][FILLBLACK].Add(i,cfgArray[i].EnFillBlack);
root["Config"][MULTIOUTPUT].Add(i,cfgArray[i].EnMultiOutPutR);
root["Config"][OUTHOLE].Add(i,cfgArray[i].EnOutHole);
root["Config"][OUTHOLERATIO].Add(cfgArray[i].OutHoleRatio);
root["Config"][ULTRADETECT].Add(i,cfgArray[i].EnUltrasonicDetect);
root["Config"][BINDINGDETECT].Add(i,cfgArray[i].EnBindingDetect);
root["Config"][SCANCOUNT].Add(cfgArray[i].ScanCount);
root["Config"][DOCORIENTATION].Add(cfgArray[i].Orentation);
root["Config"][BACKROTATE180].Add(i,cfgArray[i].EnBackRotate180);
root["Config"][SCREWDETECT].Add(i,cfgArray[i].EnScrewDetect);
root["Config"][SCREWLEVEL].Add(cfgArray[i].ScrewDetectLevel);
if (cfgArray[i].Caption.c_str()!=NULL)
{
root["Config"][ITEMCAPTION].Add(cfgArray[i].Caption);
}
if (cfgArray[i].SavePath.c_str()!=NULL)
{
root["Config"][SAVEPATH].Add(cfgArray[i].SavePath);
}
}
std::ofstream os;
os.open(filename.c_str());
os<<root.ToFormattedString();
os.close();
}
CONFIGPARAMS JsonConfig::ReadDefaultConfig()
{
TCHAR szIniFile[MAX_PATH] = { 0 };
SHGetSpecialFolderPath(NULL, szIniFile, CSIDL_LOCAL_APPDATA, TRUE);
_tcscat(szIniFile, HUAGAO_SCAN);
_tcscat(szIniFile,TWAIN_INIPATH);
_tcscat(szIniFile, TEXT("\\"));
std::string dirpath = TCHAR2STRING(szIniFile);
bool is_exist = isFolderExist((char*)dirpath.c_str());
if (!is_exist) {
createDirectory((char*)dirpath.c_str());
_tcscat(szIniFile, TWAIN_JSON_NAME);
std::string dstpath = TCHAR2STRING(szIniFile);
vector<CONFIGPARAMS> vc;
vc.push_back(GetDefaultConfigParams());
WriteJsonArrayToFile(vc, dstpath);
return vc[0];
}
_tcscat(szIniFile, TWAIN_JSON_NAME);
std::string s_default = TCHAR2STRING(szIniFile);
vector<CONFIGPARAMS> vc;
vc=ReadJsonArrayFromFile(s_default.c_str());
if (vc.size()!=0)
{
return vc[0];
}
return GetDefaultConfigParams();
}
bool JsonConfig::DeleteJsonFile(std::string path)
{
return (remove(path.c_str()));
}
std::vector<CONFIGPARAMS> JsonConfig::ReadJsonArrayFromFile(const std::string filename)
{
std::vector<CONFIGPARAMS> re;
FILE* file=fopen(filename.c_str(),"rb");
if (!file)
{
return re;
}
fseek(file,0,SEEK_END);
long size=ftell(file);
fseek(file,0,SEEK_SET);
std::string text;
char* buffer=new char[size+1];
buffer[size]=0;
if (!fread(buffer,1,size,file)==(unsigned long)size)
{
return re;
}
text=buffer;
fclose(file);
delete []buffer;
re=parseJsonFromString(text);
return re;
}
CONFIGPARAMS JsonConfig::GetDefaultConfigParams()
{
CONFIGPARAMS params;
params.Pixtype=1;//灰度
params.PaperSize=0;//A3
params.EnAutoCrop=FALSE;//自动裁切
params.Resolution=2;//200dpi
params.Duplex=1;//双面
params.EnDiscardBlank=FALSE;//自动丢弃空白页
params.EnDiscardBlankVince=FALSE;
params.DBlank_AreaNum = 8;
params.DBlank_DevnMax = 200;
params.EnFlod = FALSE;
params.EnSwitchFrontBack = FALSE;
params.Brightness=0.0f;//亮度
params.EnAutoContrast=FALSE;//自动对比度
params.Contrast=0;//对比度
params.Gamma=1.0f;//伽玛值
params.Filter=0;//除色 无
params.Sharpen = 0;//不锐化
params.EnFillBlack=FALSE;//不填黑框
params.EnAutoDescrew=TRUE;//不自动纠偏
params.EnMultiOutPutR=FALSE;//不多流输出除红
params.EnOutHole=FALSE;//不去除孔洞
params.OutHoleRatio=10;//默认值0.10
params.EnUltrasonicDetect=TRUE;//超声检测开关 开
params.EnBindingDetect=FALSE;//装订检测开关 开
params.ScanCount=-1;//扫描张数
params.Orentation=0;//旋转方向0度
params.EnBackRotate180=FALSE;//背面旋转180度 不旋转
params.EnScrewDetect=TRUE;//歪斜检测 开
params.ScrewDetectLevel=3;//歪斜检测等级 3级
return params;
}
std::vector<CONFIGPARAMS> JsonConfig::parseJsonFromString(const std::string str)
{
neb::CJsonObject root(str);
vector<CONFIGPARAMS> vcConfig;
int size=0;
neb::CJsonObject itmPaparSize;
root["Config"].Get(PAPARSIZE,itmPaparSize);
size=itmPaparSize.GetArraySize();
if (size>0)
{
neb::CJsonObject itmPixType;
root["Config"].Get(PIXTYPE,itmPixType);
neb::CJsonObject itmAutoCrop;
root["Config"].Get(AUTOCROP,itmAutoCrop);
neb::CJsonObject itmRes;
root["Config"].Get(RESOLUTION,itmRes);
neb::CJsonObject itmDulpex;
root["Config"].Get(DUPLEX,itmDulpex);
neb::CJsonObject itmDiscardBlk;
root["Config"].Get(DISCARBLANK,itmDiscardBlk);
neb::CJsonObject itmDiscardBlkVince;
root["Config"].Get(DISCARBLANKVINCE,itmDiscardBlkVince);
neb::CJsonObject itmDBAreaNum;
root["Config"].Get(DB_AREANUM, itmDBAreaNum);
neb::CJsonObject itmDBDevnMax;
root["Config"].Get(DB_DEVNMAX, itmDBDevnMax);
neb::CJsonObject itmEnFlod;
root["Config"].Get(FLOD, itmEnFlod);
neb::CJsonObject itmEnSwitchFrontBack;
root["Config"].Get(SWITCHFRONTBACK, itmEnSwitchFrontBack);
neb::CJsonObject itmBrtnes;
root["Config"].Get(BRIGHTNESS,itmBrtnes);
neb::CJsonObject itmAutoCrnt;
root["Config"].Get(AUTOCONTRAST,itmAutoCrnt);
neb::CJsonObject itmContrast;
root["Config"].Get(CONTRAST,itmContrast);
neb::CJsonObject itmGamma;
root["Config"].Get(GAMMA_,itmGamma);
neb::CJsonObject itmFilter;
root["Config"].Get(FILTERTYPE,itmFilter);
neb::CJsonObject itmSharpen;
root["Config"].Get(SHARPENTYPE, itmSharpen);
neb::CJsonObject itmAutoDescrew;
root["Config"].Get(AUTODESCREW,itmAutoDescrew);
neb::CJsonObject itmFillBlack;
root["Config"].Get(FILLBLACK,itmFillBlack);
neb::CJsonObject itmMultiOutput;
root["Config"].Get(MULTIOUTPUT,itmMultiOutput);
neb::CJsonObject itmOutHole;
root["Config"].Get(OUTHOLE,itmOutHole);
neb::CJsonObject itmOutHoleRatio;
root["Config"].Get(OUTHOLERATIO,itmOutHoleRatio);
neb::CJsonObject itmUltDetect;
root["Config"].Get(ULTRADETECT,itmUltDetect);
neb::CJsonObject itmBingdingDetect;
root["Config"].Get(BINDINGDETECT,itmBingdingDetect);
neb::CJsonObject itmScanCount;
root["Config"].Get(SCANCOUNT,itmScanCount);
neb::CJsonObject itmDocOrientation;
root["Config"].Get(DOCORIENTATION,itmDocOrientation);
neb::CJsonObject itmBackRotate;
root["Config"].Get(BACKROTATE180,itmBackRotate);
neb::CJsonObject itmScrewDetct;
root["Config"].Get(SCREWDETECT,itmScrewDetct);
neb::CJsonObject itmScrewLevel;
root["Config"].Get(SCREWLEVEL,itmScrewLevel);
neb::CJsonObject itmCaption;
if (!root["Config"][ITEMCAPTION].IsEmpty())
{
root["Config"].Get(ITEMCAPTION,itmCaption);
}
neb::CJsonObject itmSavePtah;
if (!root["Config"][SAVEPATH].IsEmpty())
{
root["Config"].Get(SAVEPATH,itmSavePtah);
}
for (int i=0;i<size;i++)
{
CONFIGPARAMS cfp;
int i_value;
double f_value;
bool b_value;
std::string s_value;
itmPixType.Get(i,i_value);
cfp.Pixtype=i_value;
itmPaparSize.Get(i,i_value);
cfp.PaperSize=i_value;
itmAutoCrop.Get(i,b_value);
cfp.EnAutoCrop=b_value;
itmRes.Get(i,i_value);
cfp.Resolution=i_value;
itmDulpex.Get(i,i_value);
cfp.Duplex=i_value;
itmDiscardBlk.Get(i,b_value);
cfp.EnDiscardBlank=b_value;
itmDiscardBlkVince.Get(i,b_value);
cfp.EnDiscardBlankVince=b_value;
itmDBAreaNum.Get(i, i_value);
cfp.DBlank_AreaNum = i_value;
itmDBDevnMax.Get(i, i_value);
cfp.DBlank_DevnMax = i_value;
itmEnFlod.Get(i, b_value);
cfp.EnFlod = b_value;
itmEnSwitchFrontBack.Get(i, b_value);
cfp.EnSwitchFrontBack = b_value;
itmBrtnes.Get(i, f_value);
cfp.Brightness= f_value;
itmAutoCrnt.Get(i,b_value);
cfp.EnAutoContrast=b_value;
itmContrast.Get(i,i_value);
cfp.Contrast=i_value;
itmGamma.Get(i,i_value);
cfp.Gamma=i_value;
itmFilter.Get(i,i_value);
cfp.Filter=i_value;
itmSharpen.Get(i, i_value);
cfp.Sharpen = i_value;
itmAutoDescrew.Get(i,b_value);
cfp.EnAutoDescrew=b_value;
itmFillBlack.Get(i,b_value);
cfp.EnFillBlack=b_value;
itmMultiOutput.Get(i,b_value);
cfp.EnMultiOutPutR=b_value;
itmOutHole.Get(i,b_value);
cfp.EnOutHole=b_value;
itmOutHoleRatio.Get(i, i_value);
cfp.OutHoleRatio= i_value;
itmUltDetect.Get(i,b_value);
cfp.EnUltrasonicDetect=b_value;
itmBingdingDetect.Get(i,b_value);
cfp.EnBindingDetect=b_value;
itmScanCount.Get(i,i_value);
cfp.ScanCount=i_value;
itmDocOrientation.Get(i,i_value);
cfp.Orentation=i_value;
itmBackRotate.Get(i,b_value);
cfp.EnBackRotate180=b_value;
itmScrewDetct.Get(i,b_value);
cfp.EnScrewDetect=b_value;
itmScrewLevel.Get(i,i_value);
cfp.ScrewDetectLevel=i_value;
if (!root["Config"][ITEMCAPTION].IsEmpty())
{
itmCaption.Get(i,s_value);
cfp.Caption=s_value;
}
if (!root["Config"][SAVEPATH].IsEmpty())
{
itmSavePtah.Get(i,s_value);
cfp.SavePath=s_value;
}
vcConfig.push_back(cfp);
}
}
else
{
CONFIGPARAMS cfp;
int index;
bool bvalue;
std::string svalue;
root["Config"].Get(PIXTYPE,index);
cfp.Pixtype=index;
root["Config"].Get(PAPARSIZE,index);
cfp.PaperSize=index;
root["Config"].Get(AUTOCROP,bvalue);
cfp.EnAutoCrop=bvalue;
root["Config"].Get(RESOLUTION,index);
cfp.Resolution=index;
root["Config"].Get(DUPLEX,index);
cfp.Duplex=index;
root["Config"].Get(DISCARBLANK,bvalue);
cfp.EnDiscardBlank=bvalue;
root["Config"].Get(DISCARBLANKVINCE,bvalue);
cfp.EnDiscardBlankVince=bvalue;
root["Config"].Get(DB_AREANUM, index);
cfp.DBlank_AreaNum = index;
root["Config"].Get(DB_DEVNMAX, index);
cfp.DBlank_DevnMax = index;
root["Config"].Get(FLOD, bvalue);
cfp.EnFlod = bvalue;
root["Config"].Get(SWITCHFRONTBACK, bvalue);
cfp.EnSwitchFrontBack = bvalue;
root["Config"].Get(BRIGHTNESS,index);
cfp.Brightness=index;
root["Config"].Get(AUTOCONTRAST,bvalue);
cfp.EnAutoContrast=bvalue;
root["Config"].Get(CONTRAST,index);
cfp.Contrast=index;
root["Config"].Get(GAMMA_,index);
cfp.Gamma=index;
root["Config"].Get(FILTERTYPE,index);
cfp.Filter=index;
root["config"].Get(SHARPENTYPE, index);
cfp.Sharpen = index;
root["Config"].Get(AUTODESCREW,bvalue);
cfp.EnAutoDescrew=bvalue;
root["Config"].Get(FILLBLACK,bvalue);
cfp.EnFillBlack=bvalue;
root["Config"].Get(MULTIOUTPUT,bvalue);
cfp.EnMultiOutPutR=bvalue;
root["Config"].Get(OUTHOLE,bvalue);
cfp.EnOutHole=bvalue;
root["Config"].Get(OUTHOLERATIO,index);
cfp.OutHoleRatio=index;
root["Config"].Get(ULTRADETECT,bvalue);
cfp.EnUltrasonicDetect=bvalue;
root["Config"].Get(BINDINGDETECT,bvalue);
cfp.EnBindingDetect=bvalue;
root["Config"].Get(SCANCOUNT,index);
cfp.ScanCount=index;
root["Config"].Get(DOCORIENTATION,index);
cfp.Orentation=index;
root["Config"].Get(BACKROTATE180,bvalue);
cfp.EnBackRotate180=bvalue;
root["Config"].Get(SCREWDETECT,bvalue);
cfp.EnScrewDetect=bvalue;
root["Config"].Get(SCREWLEVEL,index);
cfp.ScrewDetectLevel=index;
if (!root["Config"][ITEMCAPTION].IsEmpty())
{
root["Config"].Get(ITEMCAPTION,svalue);
cfp.Caption=svalue;
}
if (!root["Config"][SAVEPATH].IsEmpty())
{
root["Config"].Get(SAVEPATH,svalue);
cfp.SavePath=svalue;
}
vcConfig.push_back(cfp);
}
return vcConfig;
}

View File

@ -1,24 +0,0 @@
#pragma once
#include "PublicFunc.h"
#include <vector>
using namespace std;
class JsonConfig
{
public:
JsonConfig(void);
~JsonConfig(void);
public:
void WriteToJson(PCONFIGPARAMS pConfigItem,const std::string fileName,bool isConfigItem=true);
//PCONFIGPARAMS ReadJsonFromFile(const char* fileNames);
void WriteJsonData(const std::string fileName);
void WriteJsonArrayToFile(std::vector<CONFIGPARAMS> cfgArray,const std::string filename);
CONFIGPARAMS ReadDefaultConfig();
bool DeleteJsonFile(std::string path);
std::vector<CONFIGPARAMS> ReadJsonArrayFromFile(const std::string filename);
CONFIGPARAMS GetDefaultConfigParams();
private:
std::vector<CONFIGPARAMS> parseJsonFromString(const std::string str) ;
};

View File

@ -22,6 +22,7 @@ using namespace std;
//<!基本选项卡
#define PIXTYPE "iPixType"
#define PAPARSIZE "iPaparSize"
#define ENSIZECHECK "iEnSizeCheck"
#define PAPERALIGN "iPaperAlign"
#define RESOLUTION "iResolution"
#define DUPLEX "iDuplex"
@ -81,6 +82,7 @@ typedef struct tagCONFIGPARAMS
/*基本选项卡参数*/
int Pixtype;
int PaperSize;
bool EnSizeCheck;
bool EnAutoCrop;
int Resolution;
int Duplex;
@ -180,6 +182,7 @@ struct GScanCap
{
byte papertype; /**< the current paper source ADF or Flatbed*/
PaperAlign paperAlign;
byte en_sizecheck;
float imageRotateDegree;
byte is_duplex; /**< True to use duplex false for simplex, ignored if flatbed*/
byte en_fold;

View File

@ -22,7 +22,9 @@ hgConfigClass::hgConfigClass(GScanCap param)
#ifdef G200
m_param.pc_correct = 0;
#endif
m_param.unused_one = m_param.unused_two = 0;
m_param.enable_sizecheck = param.en_sizecheck == 1 ? 1 : 0;
m_param.unused_one = m_param.sizeerror_errorratio = 0;
m_param.enabledsp_cache = param.resolution_dst >= 240.0f?1:0;
}
bool hgConfigClass::ContainspaperTypesKey(PaperStatus key)

View File

@ -22,6 +22,8 @@ GScanCap GscanJsonConfig::GetDefaultGscancapValue()
gcap.pixtype = 2;//ĬÈϲÊÉ«
gcap.paperAlign = PaperAlign::Rot0;
gcap.papertype = 0;//TwSS::NONE
gcap.en_sizecheck = FALSE;
gcap.en_sizecheck = FALSE;
gcap.is_autocrop = TRUE;//ĬÈÏ×Ô¶¯²ÃÇÐ
gcap.is_duplex = TRUE;
gcap.is_autodiscradblank_normal = FALSE;
@ -80,6 +82,7 @@ void GscanJsonConfig::SaveGscanCapConfig(const GScanCap & gcap, const std::strin
outJson["Config"].Add(PIXTYPE, (int)gcap.pixtype);
outJson["Config"].Add(PAPARSIZE, (int)(gcap.papertype));
outJson["Config"].Add(PAPERALIGN, (int)(gcap.paperAlign));
outJson["Config"].Add(ENSIZECHECK, (bool)(gcap.en_sizecheck), false);
outJson["Config"].Add(AUTOCROP, (bool)(gcap.is_autocrop), false);
outJson["Config"].Add(RESOLUTION, (int)(gcap.resolution_dst));
outJson["Config"].Add(DUPLEX, (bool)(gcap.is_duplex),false);
@ -136,6 +139,7 @@ void GscanJsonConfig::WriteJsonArrayToFile(std::vector<GScanCap> cfgArray, const
root["Config"].AddEmptySubArray(PIXTYPE);
root["Config"].AddEmptySubArray(PAPARSIZE);
root["Config"].AddEmptySubArray(PAPERALIGN);
root["Config"].AddEmptySubArray(ENSIZECHECK);
root["Config"].AddEmptySubArray(AUTOCROP);
root["Config"].AddEmptySubArray(RESOLUTION);
root["Config"].AddEmptySubArray(DUPLEX);
@ -189,6 +193,7 @@ void GscanJsonConfig::WriteJsonArrayToFile(std::vector<GScanCap> cfgArray, const
root["Config"][PIXTYPE].Add((int)cfgArray[i].pixtype);
root["Config"][PAPARSIZE].Add((int)cfgArray[i].papertype);
root["Config"][PAPERALIGN].Add((int)cfgArray[i].paperAlign);
root["Config"][ENSIZECHECK].Add(i, (bool)cfgArray[i].en_sizecheck);
root["Config"][AUTOCROP].Add(i, (bool)cfgArray[i].is_autocrop);
root["Config"][RESOLUTION].Add((int)cfgArray[i].resolution_dst);
root["Config"][DUPLEX].Add(i,(bool)cfgArray[i].is_duplex);
@ -323,6 +328,8 @@ std::vector<GScanCap> GscanJsonConfig::parseJsonFromString(const std::string str
root["Config"].Get(AUTOCROP, itmAutoCrop);
neb::CJsonObject itmPaperAlign;
root["Config"].Get(PAPERALIGN, itmPaperAlign);
neb::CJsonObject itmSizeCheck;
root["Config"].Get(ENSIZECHECK, itmSizeCheck);
neb::CJsonObject itmRes;
root["Config"].Get(RESOLUTION, itmRes);
neb::CJsonObject itmDulpex;
@ -426,6 +433,8 @@ std::vector<GScanCap> GscanJsonConfig::parseJsonFromString(const std::string str
cfp.papertype = (byte)i_value;
itmPaperAlign.Get(i, i_value);
cfp.paperAlign = (PaperAlign)i_value;
itmSizeCheck.Get(i, b_value);
cfp.en_sizecheck = b_value ? 1 : 0;
itmAutoCrop.Get(i, b_value);
cfp.is_autocrop = b_value ? 1 : 0;
itmRes.Get(i, i_value);
@ -533,6 +542,8 @@ std::vector<GScanCap> GscanJsonConfig::parseJsonFromString(const std::string str
cfp.papertype = index;
root["Config"].Get(PAPERALIGN, index);
cfp.paperAlign =(PaperAlign) index;
root["Config"].Get(ENSIZECHECK, bvalue);
cfp.en_sizecheck = bvalue ? 1 : 0;
root["Config"].Get(AUTOCROP, bvalue);
cfp.is_autocrop = bvalue?1:0;
root["Config"].Get(RESOLUTION, index);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 458 KiB

View File

@ -49,6 +49,7 @@ enum class CapTypeEx : unsigned short {
TwEx_CroporDesaskewThreshold=0x8100,
TwEx_IDetachNoise = 0x8101,
TwEx_IDetachNoiseValue = 0x8102,
TwEx_SizeDetect
};
using namespace Twpp;
@ -910,7 +911,10 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
if (contains) {
m_scanparam->papertype = (byte)paper;
if (paper == (byte)PaperSize::None || paper == (byte)PaperSize::UsStatement)
{
m_scanparam->paperAlign = PaperAlign::Rot0;
m_scanparam->en_sizecheck = 0;
}
if(paper== (byte)PaperSize::UsStatement)
{
@ -923,6 +927,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_autosize = (paper == (byte)PaperSize::None) ? (UInt16)AutoSize::Auto : (UInt16)AutoSize::None;
m_autoboarderdetcet = paper == (byte)PaperSize::None;
m_scanparam->is_autocrop = paper == (byte)PaperSize::None ? 1 : 0;
}
return success();
}
@ -933,6 +938,34 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
}
};
#ifdef G200
#ifndef ISG100
m_query[(CapType)(CapTypeEx::TwEx_SizeDetect)] = msgSupportGetAllSetReset;
m_caps[(CapType)(CapTypeEx::TwEx_SizeDetect)] = [this](Msg msg, Capability& data)->Result {
switch (msg) {
case Msg::Get:
data = Capability::createEnumeration<Bool>((CapType)(CapTypeEx::TwEx_SizeDetect), { Bool(),Bool(true) }, Bool(m_scanparam->en_sizecheck), 0);
return success();
case Msg::Reset:
case Msg::GetDefault:
m_scanparam->en_sizecheck = false;
data = Capability::createOneValue<Bool>((CapType)(CapTypeEx::TwEx_SizeDetect), Bool(false));
return success();
case Msg::GetCurrent:
data = Capability::createOneValue<Bool>((CapType)(CapTypeEx::TwEx_SizeDetect), m_scanparam->en_sizecheck);
return success();
case Msg::Set: {
auto mech = data.currentItem<Bool>();
m_scanparam->en_sizecheck = mech;
return success();
}
default:
return capBadOperation();
}
};
#endif // !ISG100
#endif // G200
m_query[CapType::IOrientation] = msgSupportGetAllSetReset;
m_caps[CapType::IOrientation] = [this](Msg msg, Capability& data) -> Result {
switch (msg) {

Binary file not shown.

Binary file not shown.

Binary file not shown.