Compare commits
10 Commits
14a82589ca
...
07009e121e
Author | SHA1 | Date |
---|---|---|
luoliangyi | 07009e121e | |
luoliangyi | fbcec26fea | |
luoliangyi | 969b20a232 | |
yangjiaxuan | da38f0ac86 | |
yangjiaxuan | 2dbc06c008 | |
yangjiaxuan | 430ca27688 | |
yangjiaxuan | 3817da5347 | |
yangjiaxuan | e08ea7e88e | |
yangjiaxuan | d22297f950 | |
yangjiaxuan | 80a6f907aa |
|
@ -4727,7 +4727,7 @@ QRect HGImgThumb::getNullScrollPos()
|
|||
|
||||
void HGImgThumb::Show()
|
||||
{
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
|
||||
void HGAPI HGImgThumb::ThreadFunc(HGThread thread, HGPointer param)
|
||||
|
|
|
@ -2497,5 +2497,5 @@ QRect HGImgView::getNullScrollPos()
|
|||
|
||||
void HGImgView::Show()
|
||||
{
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -106,10 +106,6 @@ MainWindow::MainWindow(const QString& appLang, QWidget *parent)
|
|||
m_versionDll = new VersionDll;
|
||||
HGBase_RegisterCrashFunc(CrashFunc, this);
|
||||
|
||||
HGChar logFilePath[512];
|
||||
HGBase_GetLogFilePath(logFilePath, 512);
|
||||
deleteOverdueLogFile(QString::fromStdString(getStdString(logFilePath)));
|
||||
|
||||
HGChar cfgFilePath[512];
|
||||
HGBase_GetConfigPath(cfgFilePath, 512);
|
||||
deleteUpgradePkg(QString::fromStdString(getStdString(cfgFilePath)));
|
||||
|
@ -1754,7 +1750,10 @@ void MainWindow::on_dialog_sideBar_finish(bool ok)
|
|||
}
|
||||
}
|
||||
m_widget_sideBar->enableUI(false);
|
||||
emit m_pbtn_push->clicked();
|
||||
|
||||
/* Important!!! Modified on 2024-09-18, caused windows cannot be responsed when clicked "X" button on loongarch64 kylin v10P1. */
|
||||
//emit m_pbtn_push->clicked();
|
||||
on_m_pbtn_push_clicked();
|
||||
}
|
||||
|
||||
void MainWindow::on_act_thumbnailBar_triggered(bool checked)
|
||||
|
@ -2984,7 +2983,7 @@ void HGAPI MainWindow::CrashFunc(HGPointer crashAddr, HGPointer param)
|
|||
|
||||
|
||||
HGChar crashName[256];
|
||||
HGBase_GetLogFilePath(crashName, 256);
|
||||
HGBase_GetConfigPath(crashName, 256);
|
||||
strcat(crashName, "crash.dmp");
|
||||
if (HGBASE_ERR_OK == HGBase_MakeCrashFile(crashName))
|
||||
{
|
||||
|
@ -3361,7 +3360,7 @@ void MainWindow::on_act_help_triggered()
|
|||
#endif
|
||||
#else
|
||||
std::string osName = GetOSName();
|
||||
if ("UnionTech" == osName)
|
||||
if ("UnionTech" == osName || "UOS" == osName)
|
||||
{
|
||||
#if defined(OEM_HANWANG)
|
||||
filename = QApplication::applicationDirPath() + "/../../entries/help/HanvonScan_App_Help_manual.pdf";
|
||||
|
@ -3538,7 +3537,7 @@ void MainWindow::on_act_about_triggered()
|
|||
|
||||
#if !defined(HG_CMP_MSC)
|
||||
std::string osName = GetOSName();
|
||||
if ("UnionTech" == osName)
|
||||
if ("UnionTech" == osName || "UOS" == osName)
|
||||
{
|
||||
buildVersion += 20;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,10 @@ Dialog_Add::Dialog_Add(SANE_Handle devHandle, class MainWindow *mainWnd, const s
|
|||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
||||
this->setWindowTitle(tr("Add") + " (" + QString(deviceType.c_str()) + ")");
|
||||
|
||||
#if defined (x86_64)
|
||||
ui->comboBoxButtonId->setMinimumWidth(90);
|
||||
#endif
|
||||
|
||||
ui->comboBoxButtonId->addItem(tr("Manual"));
|
||||
SANE_Int buttonCount = 0;
|
||||
sane_control_option(devHandle, (SANE_Int)0x886E, SANE_ACTION_GET_VALUE, &buttonCount, NULL);
|
||||
|
@ -46,6 +50,10 @@ Dialog_Add::Dialog_Add(SANE_Handle devHandle, class MainWindow *mainWnd, const S
|
|||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
||||
this->setWindowTitle(tr("Modify") + " (" + QString(scanParam.deviceType.c_str()) + ")");
|
||||
|
||||
#if defined (x86_64)
|
||||
ui->comboBoxButtonId->setMinimumWidth(90);
|
||||
#endif
|
||||
|
||||
ui->comboBoxButtonId->addItem(tr("Manual"));
|
||||
SANE_Int buttonCount = 0;
|
||||
sane_control_option(devHandle, (SANE_Int)0x886E, SANE_ACTION_GET_VALUE, &buttonCount, NULL);
|
||||
|
|
|
@ -354,8 +354,8 @@ void Form_DeviceConfig::Init(const std::vector<DeviceConfig>& deviceConfigs)
|
|||
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(on_int_sliderClicked(int)));
|
||||
|
||||
QSpinBox* spinBox = new QSpinBox;
|
||||
spinBox->setMinimumWidth(75);
|
||||
spinBox->setMaximumWidth(75);
|
||||
spinBox->setMinimumWidth(85);
|
||||
spinBox->setMaximumWidth(85);
|
||||
spinBox->setRange(deviceConfigEx.intValueMin, deviceConfigEx.intValueMax);
|
||||
spinBox->setValue(deviceConfigEx.intValue);
|
||||
spinBox->installEventFilter(this);
|
||||
|
@ -384,8 +384,8 @@ void Form_DeviceConfig::Init(const std::vector<DeviceConfig>& deviceConfigs)
|
|||
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(on_double_sliderClicked(int)));
|
||||
|
||||
QDoubleSpinBox* doubleSpinBox = new QDoubleSpinBox;
|
||||
doubleSpinBox->setMinimumWidth(75);
|
||||
doubleSpinBox->setMaximumWidth(75);
|
||||
doubleSpinBox->setMinimumWidth(85);
|
||||
doubleSpinBox->setMaximumWidth(85);
|
||||
doubleSpinBox->setRange(deviceConfigEx.doubleValueMin, deviceConfigEx.doubleValueMax);
|
||||
doubleSpinBox->setDecimals(2);
|
||||
doubleSpinBox->setSingleStep(0.01);
|
||||
|
@ -421,8 +421,8 @@ void Form_DeviceConfig::Init(const std::vector<DeviceConfig>& deviceConfigs)
|
|||
else if (2 == deviceConfigEx.valueType)
|
||||
{
|
||||
QSpinBox* spinBox = new QSpinBox;
|
||||
spinBox->setMinimumWidth(75);
|
||||
spinBox->setMaximumWidth(75);
|
||||
spinBox->setMinimumWidth(85);
|
||||
spinBox->setMaximumWidth(85);
|
||||
spinBox->setRange(1, 1000);
|
||||
spinBox->setValue(deviceConfigEx.intValue);
|
||||
spinBox->installEventFilter(this);
|
||||
|
|
|
@ -1225,7 +1225,7 @@ void MainWindow::ocrMsgPumpFunc(HGMsgPump msgPump, const HGMsg *msg, HGPointer p
|
|||
void MainWindow::CrashFunc(HGPointer crashAddr, HGPointer param)
|
||||
{
|
||||
HGChar crashName[256];
|
||||
HGBase_GetLogFilePath(crashName, 256);
|
||||
HGBase_GetConfigPath(crashName, 256);
|
||||
strcat(crashName, "crash.dmp");
|
||||
if (HGBASE_ERR_OK == HGBase_MakeCrashFile(crashName))
|
||||
{
|
||||
|
|
|
@ -56,7 +56,7 @@ HGBase_GetModuleName
|
|||
HGBase_GetUuid
|
||||
HGBase_GetTmpFileName
|
||||
HGBase_GetConfigPath
|
||||
HGBase_GetLogFilePath
|
||||
HGBase_GetCacheFilePath
|
||||
HGBase_GetDocumentsPath
|
||||
HGBase_GetProcessName
|
||||
HGBase_GetFilePath
|
||||
|
|
|
@ -273,32 +273,6 @@ HGResult HGAPI HGBase_GetConfigPath(HGChar* configPath, HGUInt maxLen)
|
|||
return HGBASE_ERR_INVALIDARG;
|
||||
}
|
||||
|
||||
HGChar moduleName[256];
|
||||
HGBase_GetModuleName(NULL, moduleName, 256);
|
||||
HGChar modulePath[256];
|
||||
HGBase_GetFilePath(moduleName, modulePath, 256);
|
||||
strcat(modulePath, "first.cfg");
|
||||
|
||||
HGChar dataPath[256] = {0};
|
||||
HGBase_GetProfileString(modulePath, "constraints", "local_data_path", "", dataPath, 256);
|
||||
if ('\0' != *dataPath)
|
||||
{
|
||||
#if defined(HG_CMP_MSC)
|
||||
if (dataPath[strlen(dataPath) - 1] != '\\')
|
||||
strcat(dataPath, "\\");
|
||||
strcat(dataPath, "Cfg\\");
|
||||
#else
|
||||
if (dataPath[strlen(dataPath) - 1] != '/')
|
||||
strcat(dataPath, "/");
|
||||
strcat(dataPath, "Cfg/");
|
||||
#endif
|
||||
|
||||
if (maxLen < strlen(dataPath) + 1)
|
||||
return HGBASE_ERR_FAIL;
|
||||
strcpy(configPath, dataPath);
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
CHAR cfgPath[MAX_PATH] = { 0 };
|
||||
BOOL ret = SHGetSpecialFolderPathA(NULL, cfgPath, CSIDL_APPDATA, FALSE);
|
||||
|
@ -331,69 +305,43 @@ HGResult HGAPI HGBase_GetConfigPath(HGChar* configPath, HGUInt maxLen)
|
|||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
HGResult HGAPI HGBase_GetLogFilePath(HGChar* logFilePath, HGUInt maxLen)
|
||||
HGResult HGAPI HGBase_GetCacheFilePath(HGChar* cacheFilePath, HGUInt maxLen)
|
||||
{
|
||||
if (NULL == logFilePath || 0 == maxLen)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDARG;
|
||||
}
|
||||
|
||||
HGChar moduleName[256];
|
||||
HGBase_GetModuleName(NULL, moduleName, 256);
|
||||
HGChar modulePath[256];
|
||||
HGBase_GetFilePath(moduleName, modulePath, 256);
|
||||
strcat(modulePath, "first.cfg");
|
||||
|
||||
HGChar dataPath[256] = { 0 };
|
||||
HGBase_GetProfileString(modulePath, "constraints", "local_data_path", "", dataPath, 256);
|
||||
if ('\0' != *dataPath)
|
||||
{
|
||||
#if defined(HG_CMP_MSC)
|
||||
if (dataPath[strlen(dataPath) - 1] != '\\')
|
||||
strcat(dataPath, "\\");
|
||||
strcat(dataPath, "Cfg\\");
|
||||
#else
|
||||
if (dataPath[strlen(dataPath) - 1] != '/')
|
||||
strcat(dataPath, "/");
|
||||
strcat(dataPath, "Cfg/");
|
||||
#endif
|
||||
|
||||
if (maxLen < strlen(dataPath) + 1)
|
||||
return HGBASE_ERR_FAIL;
|
||||
strcpy(logFilePath, dataPath);
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
if (NULL == cacheFilePath || 0 == maxLen)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDARG;
|
||||
}
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
CHAR logPath[MAX_PATH] = { 0 };
|
||||
BOOL ret = SHGetSpecialFolderPathA(NULL, logPath, CSIDL_APPDATA, FALSE);
|
||||
if (!ret)
|
||||
return HGBASE_ERR_FAIL;
|
||||
if (logPath[strlen(logPath) - 1] != '\\')
|
||||
strcat(logPath, "\\");
|
||||
CHAR cachePath[MAX_PATH] = { 0 };
|
||||
BOOL ret = SHGetSpecialFolderPathA(NULL, cachePath, CSIDL_APPDATA, FALSE);
|
||||
if (!ret)
|
||||
return HGBASE_ERR_FAIL;
|
||||
if (cachePath[strlen(cachePath) - 1] != '\\')
|
||||
strcat(cachePath, "\\");
|
||||
|
||||
HGChar procName[64];
|
||||
HGBase_GetProcessName(procName, 64);
|
||||
strcat(logPath, procName);
|
||||
strcat(logPath, "\\Log\\");
|
||||
HGChar procName[64];
|
||||
HGBase_GetProcessName(procName, 64);
|
||||
strcat(cachePath, procName);
|
||||
strcat(cachePath, "\\Cache\\");
|
||||
#else
|
||||
char logPath[512] = { 0 };
|
||||
struct passwd* pw = getpwuid(getuid());
|
||||
strcpy(logPath, pw->pw_dir);
|
||||
if (logPath[strlen(logPath) - 1] != '/')
|
||||
strcat(logPath, "/");
|
||||
char cachePath[512] = { 0 };
|
||||
struct passwd* pw = getpwuid(getuid());
|
||||
strcpy(cachePath, pw->pw_dir);
|
||||
if (cachePath[strlen(cachePath) - 1] != '/')
|
||||
strcat(cachePath, "/");
|
||||
|
||||
strcat(logPath, ".");
|
||||
HGChar procName[64];
|
||||
HGBase_GetProcessName(procName, 64);
|
||||
strcat(logPath, procName);
|
||||
strcat(logPath, "/Log/");
|
||||
strcat(cachePath, ".");
|
||||
HGChar procName[64];
|
||||
HGBase_GetProcessName(procName, 64);
|
||||
strcat(cachePath, procName);
|
||||
strcat(cachePath, "/Cache/");
|
||||
#endif
|
||||
|
||||
if (maxLen < strlen(logPath) + 1)
|
||||
return HGBASE_ERR_FAIL;
|
||||
strcpy(logFilePath, logPath);
|
||||
return HGBASE_ERR_OK;
|
||||
if (maxLen < strlen(cachePath) + 1)
|
||||
return HGBASE_ERR_FAIL;
|
||||
strcpy(cacheFilePath, cachePath);
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
HGResult HGAPI HGBase_GetDocumentsPath(HGChar* documentsPath, HGUInt maxLen)
|
||||
|
|
|
@ -46,9 +46,9 @@ HGEXPORT HGResult HGAPI HGBase_GetTmpFileName(const HGChar *suffix, HGChar* file
|
|||
*/
|
||||
HGEXPORT HGResult HGAPI HGBase_GetConfigPath(HGChar* configPath, HGUInt maxLen);
|
||||
|
||||
/* 获取日志文件路径
|
||||
/* 获取缓存文件路径
|
||||
*/
|
||||
HGEXPORT HGResult HGAPI HGBase_GetLogFilePath(HGChar* logFilePath, HGUInt maxLen);
|
||||
HGEXPORT HGResult HGAPI HGBase_GetCacheFilePath(HGChar* cacheFilePath, HGUInt maxLen);
|
||||
|
||||
/* 获取文档路径
|
||||
*/
|
||||
|
@ -77,4 +77,4 @@ HGEXPORT HGResult HGAPI HGBase_GetFileSuffix(const HGChar *fileName, HGChar* suf
|
|||
/* 将文件名标准化 */
|
||||
HGEXPORT HGResult HGAPI HGBase_StandardiseFileName(const HGChar* fileName, HGChar *result, HGUInt maxLen);
|
||||
|
||||
#endif /* __HGUTILITY_H__ */
|
||||
#endif /* __HGUTILITY_H__ */
|
||||
|
|
|
@ -38,7 +38,7 @@ HGResult HGOCRTesseract::Init()
|
|||
}
|
||||
|
||||
HGChar moduleName[256];
|
||||
HGBase_GetModuleName((void*)HGImgProc_CreateOCRMgr, moduleName, 256);
|
||||
HGBase_GetModuleName((void*)HGImgProc_ImageOCR, moduleName, 256);
|
||||
HGChar dataPath[256];
|
||||
HGBase_GetFilePath(moduleName, dataPath, 256);
|
||||
strcat(dataPath, "tessdata");
|
||||
|
|
|
@ -2497,5 +2497,5 @@ QRect HGImgView::getNullScrollPos()
|
|||
|
||||
void HGImgView::Show()
|
||||
{
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -426,7 +426,7 @@ HGResult HGAPI HGVersion_GetAppStatus(const HGChar* appName, const HGChar* oemNa
|
|||
}
|
||||
|
||||
printf("osName=%s\n", osName.c_str());
|
||||
if (osName.find("UnionTech") != std::string::npos)
|
||||
if (osName.find("UnionTech") != std::string::npos || osName.find("UOS") != std::string::npos)
|
||||
{
|
||||
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
||||
{
|
||||
|
@ -575,7 +575,7 @@ HGResult HGAPI HGVersion_RunApp(const HGChar* appName, const HGChar* oemName)
|
|||
}
|
||||
|
||||
printf("osName=%s\n", osName.c_str());
|
||||
if (osName.find("UnionTech") != std::string::npos)
|
||||
if (osName.find("UnionTech") != std::string::npos || osName.find("UOS") != std::string::npos)
|
||||
{
|
||||
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
||||
appPath = "sh /opt/apps/com.hanvonchina.hanvonscan/files/bin/HanvonScan.sh &";
|
||||
|
|
|
@ -444,7 +444,7 @@ static std::string GetCurrVersion(const std::string& appName, const std::string&
|
|||
#else
|
||||
std::string appName;
|
||||
std::string osName = GetOSName();
|
||||
if ("UnionTech" == osName)
|
||||
if ("UnionTech" == osName || "UOS" == osName)
|
||||
{
|
||||
if (oemName == HGVERSION_OEMNAME_HANVON)
|
||||
appName = "com.hanvonchina.hanvonscan";
|
||||
|
|
|
@ -1388,12 +1388,10 @@ namespace ver_1
|
|||
std::string ManagerV1::GetFilePath(const std::string& devId)
|
||||
{
|
||||
HGChar docsPath[256];
|
||||
HGBase_GetDocumentsPath(docsPath, 256);
|
||||
HGChar procName[256];
|
||||
HGBase_GetProcessName(procName, 256);
|
||||
HGBase_GetCacheFilePath(docsPath, 256);
|
||||
|
||||
HGChar imgPath[512];
|
||||
sprintf(imgPath, "%s%s/%s/", docsPath, procName, Utf8ToStdString(devId).c_str());
|
||||
sprintf(imgPath, "%s%s/", docsPath, Utf8ToStdString(devId).c_str());
|
||||
HGChar stdImgPath[512];
|
||||
HGBase_StandardiseFileName(imgPath, stdImgPath, 512);
|
||||
|
||||
|
|
|
@ -34,12 +34,8 @@ namespace ver_2
|
|||
m_lock = NULL;
|
||||
HGBase_CreateLock(&m_lock);
|
||||
|
||||
HGChar docsPath[256];
|
||||
HGBase_GetDocumentsPath(docsPath, 256);
|
||||
HGChar procName[256];
|
||||
HGBase_GetProcessName(procName, 256);
|
||||
HGChar defSavePath[256];
|
||||
sprintf(defSavePath, "%s%s/", docsPath, procName);
|
||||
HGChar defSavePath[256];
|
||||
HGBase_GetCacheFilePath(defSavePath, 256);
|
||||
|
||||
m_globalCfg.fileSavePath = GetCfgStringValue("global", "fileSavePath", defSavePath);
|
||||
m_globalCfg.fileNamePrefix = GetCfgStringValue("global", "fileNamePrefix", "");
|
||||
|
|
|
@ -43,7 +43,7 @@ HGMsgPump msgPumpV2 = NULL;
|
|||
static void HGAPI CrashFunc(HGPointer crashAddr, HGPointer param)
|
||||
{
|
||||
HGChar logPath[256];
|
||||
HGBase_GetLogFilePath(logPath, 256);
|
||||
HGBase_GetConfigPath(logPath, 256);
|
||||
strcat(logPath, "crash.dmp");
|
||||
HGBase_MakeCrashFile(logPath);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test!</title>
|
||||
<meta charset="utf-8"/>
|
||||
<script src="hgwebsdk.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h1>Test!</h1>
|
||||
<input id="scan" type="button" value="扫描" onclick="scan()" />
|
||||
</p>
|
||||
<script>
|
||||
|
||||
function scan()
|
||||
{
|
||||
hgwebsdk.scan('192.168.10.19', 8001, '/upload.php');
|
||||
}
|
||||
|
||||
window.onload = function()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
window.onbeforeunload = function()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,182 @@
|
|||
function hgwebsdk()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
hgwebsdk.socket = null;
|
||||
|
||||
hgwebsdk.scan = function(host, port, path)
|
||||
{
|
||||
if (hgwebsdk.socket != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
hgwebsdk.socket = new WebSocket("ws://127.0.0.1:38999");
|
||||
|
||||
hgwebsdk.socket.onopen = function(msg)
|
||||
{
|
||||
hgwebsdk.socket.send(JSON.stringify({
|
||||
'func':'is_device_init'
|
||||
}));
|
||||
|
||||
hgwebsdk.socket.onmessage = function(msg)
|
||||
{
|
||||
console.log(msg.data);
|
||||
|
||||
var message = JSON.parse(msg.data);
|
||||
if ("is_device_init" == message['func'])
|
||||
{
|
||||
if (message['ret'] != 0)
|
||||
{
|
||||
hgwebsdk.socket.send(JSON.stringify({
|
||||
'func':'init_device'
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
hgwebsdk.socket.send(JSON.stringify({
|
||||
'func':'get_curr_device_name'
|
||||
}));
|
||||
}
|
||||
}
|
||||
else if ("init_device" == message['func'])
|
||||
{
|
||||
if (0 == message['ret'])
|
||||
{
|
||||
hgwebsdk.socket.send(JSON.stringify({
|
||||
'func':'get_curr_device_name'
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
hgwebsdk.socket.close();
|
||||
}
|
||||
}
|
||||
else if ("get_curr_device_name" == message['func'])
|
||||
{
|
||||
if (0 != message['ret'])
|
||||
{
|
||||
hgwebsdk.socket.send(JSON.stringify({
|
||||
'func':'open_device'
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
hgwebsdk.socket.send(JSON.stringify({
|
||||
'func':'is_device_scanning'
|
||||
}));
|
||||
}
|
||||
}
|
||||
else if ("open_device" == message['func'])
|
||||
{
|
||||
if (0 == message['ret'])
|
||||
{
|
||||
hgwebsdk.socket.send(JSON.stringify({
|
||||
'func':'is_device_scanning'
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
hgwebsdk.socket.close();
|
||||
}
|
||||
}
|
||||
else if ("is_device_scanning" == message['func'])
|
||||
{
|
||||
if (0 != message['ret'])
|
||||
{
|
||||
var setDeviceParamJsonData = {};
|
||||
setDeviceParamJsonData.func = 'set_device_param';
|
||||
setDeviceParamJsonData.device_param = [];
|
||||
|
||||
var ele1 = {};
|
||||
ele1.name = '颜色模式';
|
||||
ele1.value = '24位彩色';
|
||||
setDeviceParamJsonData.device_param.push(ele1);
|
||||
|
||||
var ele2 = {};
|
||||
ele2.name = '扫描页面';
|
||||
ele2.value = '双面';
|
||||
setDeviceParamJsonData.device_param.push(ele2);
|
||||
|
||||
var ele3 = {};
|
||||
ele3.name = '分辨率';
|
||||
ele3.value = 200;
|
||||
setDeviceParamJsonData.device_param.push(ele3);
|
||||
|
||||
//alert(JSON.stringify(setDeviceParamJsonData));
|
||||
hgwebsdk.socket.send(JSON.stringify(setDeviceParamJsonData));
|
||||
}
|
||||
else
|
||||
{
|
||||
hgwebsdk.socket.close();
|
||||
}
|
||||
}
|
||||
else if ("set_device_param" == message['func'])
|
||||
{
|
||||
if (0 == message['ret'])
|
||||
{
|
||||
var startScanJsonData = {};
|
||||
startScanJsonData.func = 'start_scan';
|
||||
startScanJsonData.get_base64 = false;
|
||||
|
||||
//alert(JSON.stringify(startScanJsonData));
|
||||
hgwebsdk.socket.send(JSON.stringify(startScanJsonData));
|
||||
}
|
||||
else
|
||||
{
|
||||
hgwebsdk.socket.close();
|
||||
}
|
||||
}
|
||||
else if ("start_scan" == message['func'])
|
||||
{
|
||||
if (0 != message['ret'])
|
||||
{
|
||||
hgwebsdk.socket.close();
|
||||
}
|
||||
}
|
||||
else if ("scan_begin" == message['func'])
|
||||
{
|
||||
//
|
||||
}
|
||||
else if ("scan_end" == message['func'])
|
||||
{
|
||||
hgwebsdk.socket.close();
|
||||
}
|
||||
else if ("scan_info" == message['func'])
|
||||
{
|
||||
//
|
||||
}
|
||||
else if ("scan_image" == message['func'])
|
||||
{
|
||||
var uploadJsonData = {};
|
||||
uploadJsonData.func = 'upload_local_file';
|
||||
uploadJsonData.file_path = message['image_path'];
|
||||
uploadJsonData.upload_mode = 'http';
|
||||
uploadJsonData.http_host = host;
|
||||
uploadJsonData.http_port = port;
|
||||
uploadJsonData.http_path = path;
|
||||
|
||||
//alert(JSON.stringify(uploadJsonData));
|
||||
hgwebsdk.socket.send(JSON.stringify(uploadJsonData));
|
||||
|
||||
var deleteJsonData = {};
|
||||
deleteJsonData.func = 'delete_local_file';
|
||||
deleteJsonData.file_path = message['image_path'];
|
||||
|
||||
//alert(JSON.stringify(deleteJsonData));
|
||||
hgwebsdk.socket.send(JSON.stringify(deleteJsonData));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hgwebsdk.socket.onclose = function(msg)
|
||||
{
|
||||
hgwebsdk.socket = null;
|
||||
}
|
||||
|
||||
hgwebsdk.socket.onerror = function(msg)
|
||||
{
|
||||
//alert('socket.onerror');
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
|
@ -0,0 +1,365 @@
|
|||
function sane()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
sane.socket = null;
|
||||
sane.printlog = false;
|
||||
|
||||
sane.onInit = null;
|
||||
sane.onGetDevices = null;
|
||||
sane.onScanOneFileDone = null;
|
||||
sane.onErrorMessage = null;
|
||||
|
||||
sane.showbase64 = 0;
|
||||
sane.source = "Adf-duplex";
|
||||
sane.mode = "Color";
|
||||
sane.resolution = 200;
|
||||
|
||||
sane.init = function(port, printlog)
|
||||
{
|
||||
if (sane.socket != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sane.socket = new WebSocket("ws://127.0.0.1:" + port.toString());
|
||||
sane.printlog = printlog;
|
||||
|
||||
sane.socket.onopen = function(msg)
|
||||
{
|
||||
sane.socket.send(JSON.stringify({
|
||||
'func':'is_device_init'
|
||||
}));
|
||||
|
||||
sane.socket.onmessage = function(msg)
|
||||
{
|
||||
if (sane.printlog)
|
||||
console.log(msg.data);
|
||||
|
||||
var message = JSON.parse(msg.data);
|
||||
if ("is_device_init" == message['func'])
|
||||
{
|
||||
if (message['ret'] != 0)
|
||||
{
|
||||
sane.socket.send(JSON.stringify({
|
||||
'func':'init_device'
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (typeof sane.onInit === 'function')
|
||||
{
|
||||
sane.onInit();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("init_device" == message['func'])
|
||||
{
|
||||
if (0 == message['ret'])
|
||||
{
|
||||
if (typeof sane.onInit === 'function')
|
||||
{
|
||||
sane.onInit();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (typeof sane.onErrorMessage === 'function')
|
||||
{
|
||||
sane.onErrorMessage(message['err_info']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sane.socket.onclose = function(msg)
|
||||
{
|
||||
//alert('socket.onclose');
|
||||
}
|
||||
|
||||
sane.socket.onerror = function(msg)
|
||||
{
|
||||
//alert('socket.onerror');
|
||||
}
|
||||
}
|
||||
|
||||
sane.deinit = function()
|
||||
{
|
||||
if (sane.socket === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sane.socket.close();
|
||||
sane.socket = null;
|
||||
}
|
||||
|
||||
|
||||
sane.registerevent = function(eventName, callback)
|
||||
{
|
||||
if ("OnInit" == eventName)
|
||||
{
|
||||
sane.onInit = callback;
|
||||
}
|
||||
else if ("OnGetDevices" == eventName)
|
||||
{
|
||||
sane.onGetDevices = callback;
|
||||
}
|
||||
else if ("OnScanOneFileDone" == eventName)
|
||||
{
|
||||
sane.onScanOneFileDone = callback;
|
||||
}
|
||||
else if ("OnErrorMessage" == eventName)
|
||||
{
|
||||
sane.onErrorMessage = callback;
|
||||
}
|
||||
}
|
||||
|
||||
sane.getdevices = function()
|
||||
{
|
||||
if (sane.socket === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sane.socket.send(JSON.stringify({
|
||||
'func':'get_device_name_list'
|
||||
}));
|
||||
|
||||
sane.socket.onmessage = function(msg)
|
||||
{
|
||||
if (sane.printlog)
|
||||
console.log(msg.data);
|
||||
|
||||
var message = JSON.parse(msg.data);
|
||||
if ("get_device_name_list" == message['func'])
|
||||
{
|
||||
if (0 == message['ret'])
|
||||
{
|
||||
if (typeof sane.onGetDevices === 'function')
|
||||
{
|
||||
sane.onGetDevices(message['device_name_list']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (typeof sane.onErrorMessage === 'function')
|
||||
{
|
||||
sane.onErrorMessage(message['err_info']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sane.clear = function()
|
||||
{
|
||||
if (sane.socket === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sane.socket.send(JSON.stringify({
|
||||
'func':'clear_global_file_save_path'
|
||||
}));
|
||||
|
||||
sane.socket.onmessage = function(msg)
|
||||
{
|
||||
if (sane.printlog)
|
||||
console.log(msg.data);
|
||||
|
||||
var message = JSON.parse(msg.data);
|
||||
if ("clear_global_file_save_path" == message['func'])
|
||||
{
|
||||
if (0 != message['ret'])
|
||||
{
|
||||
if (typeof sane.onErrorMessage === 'function')
|
||||
{
|
||||
sane.onErrorMessage(message['err_info']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sane.scan = function(devname)
|
||||
{
|
||||
if (sane.socket === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (devname === "" || typeof devname === 'undefined')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sane.socket.send(JSON.stringify({
|
||||
'func':'get_curr_device_name'
|
||||
}));
|
||||
|
||||
sane.socket.onmessage = function(msg)
|
||||
{
|
||||
if (sane.printlog)
|
||||
console.log(msg.data);
|
||||
|
||||
var message = JSON.parse(msg.data);
|
||||
if ("get_curr_device_name" == message['func'])
|
||||
{
|
||||
if (0 != message['ret'])
|
||||
{
|
||||
var openDeviceJsonData = {};
|
||||
openDeviceJsonData.func = 'open_device';
|
||||
openDeviceJsonData.device_name = devname;
|
||||
|
||||
//alert(JSON.stringify(openDeviceJsonData));
|
||||
sane.socket.send(JSON.stringify(openDeviceJsonData));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (message['device_name'] != devname)
|
||||
{
|
||||
sane.socket.send(JSON.stringify({
|
||||
'func':'close_device'
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
sane.socket.send(JSON.stringify({
|
||||
'func':'is_device_scanning'
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("close_device" == message['func'])
|
||||
{
|
||||
if (0 == message['ret'])
|
||||
{
|
||||
var openDeviceJsonData = {};
|
||||
openDeviceJsonData.func = 'open_device';
|
||||
openDeviceJsonData.device_name = devname;
|
||||
|
||||
//alert(JSON.stringify(openDeviceJsonData));
|
||||
sane.socket.send(JSON.stringify(openDeviceJsonData));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (typeof sane.onErrorMessage === 'function')
|
||||
{
|
||||
sane.onErrorMessage(message['err_info']);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("open_device" == message['func'])
|
||||
{
|
||||
if (0 == message['ret'])
|
||||
{
|
||||
sane.socket.send(JSON.stringify({
|
||||
'func':'is_device_scanning'
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (typeof sane.onErrorMessage === 'function')
|
||||
{
|
||||
sane.onErrorMessage(message['err_info']);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("is_device_scanning" == message['func'])
|
||||
{
|
||||
if (0 != message['ret'])
|
||||
{
|
||||
var setDeviceParamJsonData = {};
|
||||
setDeviceParamJsonData.func = 'set_device_param';
|
||||
setDeviceParamJsonData.device_param = [];
|
||||
|
||||
var ele1 = {};
|
||||
ele1.name = '颜色模式';
|
||||
ele1.value = '24位彩色';
|
||||
if (sane.mode == 'Gray')
|
||||
ele1.value = '256级灰度';
|
||||
else if (sane.mode == 'Lineart')
|
||||
ele1.value = '黑白';
|
||||
setDeviceParamJsonData.device_param.push(ele1);
|
||||
|
||||
var ele2 = {};
|
||||
ele2.name = '扫描页面';
|
||||
ele2.value = '双面';
|
||||
if (sane.source == 'Adf-front')
|
||||
ele2.value = '单面';
|
||||
setDeviceParamJsonData.device_param.push(ele2);
|
||||
|
||||
var ele3 = {};
|
||||
ele3.name = '分辨率';
|
||||
ele3.value = sane.resolution;
|
||||
setDeviceParamJsonData.device_param.push(ele3);
|
||||
|
||||
//alert(JSON.stringify(setDeviceParamJsonData));
|
||||
sane.socket.send(JSON.stringify(setDeviceParamJsonData));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (typeof sane.onErrorMessage === 'function')
|
||||
{
|
||||
sane.onErrorMessage('设备正在扫描中...');
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("set_device_param" == message['func'])
|
||||
{
|
||||
if (0 == message['ret'])
|
||||
{
|
||||
var startScanJsonData = {};
|
||||
startScanJsonData.func = 'start_scan';
|
||||
startScanJsonData.get_base64 = false;
|
||||
if (sane.showbase64)
|
||||
startScanJsonData.get_base64 = true;
|
||||
|
||||
//alert(JSON.stringify(startScanJsonData));
|
||||
sane.socket.send(JSON.stringify(startScanJsonData));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (typeof sane.onErrorMessage === 'function')
|
||||
{
|
||||
sane.onErrorMessage(message['err_info']);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("start_scan" == message['func'])
|
||||
{
|
||||
if (0 != message['ret'])
|
||||
{
|
||||
if (typeof sane.onErrorMessage === 'function')
|
||||
{
|
||||
sane.onErrorMessage(message['err_info']);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("scan_begin" == message['func'])
|
||||
{
|
||||
//
|
||||
}
|
||||
else if ("scan_end" == message['func'])
|
||||
{
|
||||
//
|
||||
}
|
||||
else if ("scan_info" == message['func'])
|
||||
{
|
||||
if (message['is_error'] && typeof sane.onErrorMessage === 'function')
|
||||
{
|
||||
sane.onErrorMessage(message['info']);
|
||||
}
|
||||
}
|
||||
else if ("scan_image" == message['func'])
|
||||
{
|
||||
if (typeof sane.onScanOneFileDone === 'function')
|
||||
{
|
||||
sane.onScanOneFileDone("string", "jpg", message['image_path'], message['image_base64']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test!</title>
|
||||
<meta charset="utf-8"/>
|
||||
<script src="sane.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h1>Test!</h1>
|
||||
<select id="devicenames" style="width:200px; height:25px;">
|
||||
</select>
|
||||
<input id="getdevices" type="button" value="获取设备列表" onclick="getdevices()" /><br>
|
||||
<label for="showbase64">转换成Base64:</label>
|
||||
<input type="checkbox" id="showbase64"><br>
|
||||
<label for="source">单/双面:</label>
|
||||
<select id="source">
|
||||
<option value="Adf-front">Adf-front</option>
|
||||
<option value="Adf-duplex" selected>Adf-duplex</option>
|
||||
</select><br>
|
||||
<label for="mode">颜色模式:</label>
|
||||
<select id="mode">
|
||||
<option value="Lineart">Lineart</option>
|
||||
<option value="Gray">Gray</option>
|
||||
<option value="Color" selected>Color</option>
|
||||
</select><br>
|
||||
<label for="resolution">分辨率:</label>
|
||||
<input type="number" id="resolution" min="1" max="600" value="200" step="1"><br>
|
||||
<input id="scan" type="button" value="扫描" onclick="scan()" /><br>
|
||||
<input id="cleardata" type="button" value="清理" onclick="cleardata()" />
|
||||
</p>
|
||||
<p>
|
||||
<img id="myCanvas" width='640' height='480' style="background-color: black;"/>
|
||||
</p>
|
||||
<p>
|
||||
<input type="text" id="pathinfo" style="width:640px; height:40px;" />
|
||||
</p>
|
||||
<p>
|
||||
<input type="text" id="errinfo" style="width:640px; height:40px;" />
|
||||
</p>
|
||||
<script>
|
||||
|
||||
function onInitFunc()
|
||||
{
|
||||
getdevices();
|
||||
}
|
||||
|
||||
function onGetDevicesFunc(devs)
|
||||
{
|
||||
//alert(JSON.stringify(devs));
|
||||
|
||||
var select = document.getElementById('devicenames');
|
||||
select.innerHTML = "";
|
||||
for (var i = 0; i < devs.length; ++i)
|
||||
{
|
||||
var option = document.createElement('option');
|
||||
option.value = devs[i];
|
||||
option.textContent = devs[i];
|
||||
select.appendChild(option);
|
||||
}
|
||||
}
|
||||
|
||||
function onScanOneFileDoneFunc(datatype, imgtype, imgpath, imgbase64data)
|
||||
{
|
||||
if (imgpath)
|
||||
{
|
||||
var pathinfo = document.getElementById('pathinfo');
|
||||
pathinfo.value = imgpath;
|
||||
}
|
||||
|
||||
if (imgbase64data)
|
||||
{
|
||||
var myCanvas = document.getElementById("myCanvas");
|
||||
myCanvas.src = imgbase64data;
|
||||
}
|
||||
}
|
||||
|
||||
function onErrorMessageFunc(errormsg)
|
||||
{
|
||||
var errinfo = document.getElementById('errinfo');
|
||||
errinfo.value = errormsg;
|
||||
}
|
||||
|
||||
function getdevices()
|
||||
{
|
||||
var errinfo = document.getElementById('errinfo');
|
||||
errinfo.value = "";
|
||||
|
||||
sane.getdevices();
|
||||
}
|
||||
|
||||
function scan()
|
||||
{
|
||||
var pathinfo = document.getElementById('pathinfo');
|
||||
pathinfo.value = "";
|
||||
var errinfo = document.getElementById('errinfo');
|
||||
errinfo.value = "";
|
||||
var myCanvas = document.getElementById("myCanvas");
|
||||
myCanvas.src = 'placeholder.png';
|
||||
|
||||
sane.showbase64 = document.getElementById('showbase64').checked;
|
||||
sane.source = document.getElementById('source').value;
|
||||
sane.mode = document.getElementById('mode').value;
|
||||
sane.resolution = parseInt(document.getElementById('resolution').value, 10);
|
||||
|
||||
sane.scan(document.getElementById('devicenames').value);
|
||||
}
|
||||
|
||||
function cleardata()
|
||||
{
|
||||
var errinfo = document.getElementById('errinfo');
|
||||
errinfo.value = "";
|
||||
|
||||
sane.clear();
|
||||
}
|
||||
|
||||
window.onload = function()
|
||||
{
|
||||
var pathinfo = document.getElementById('pathinfo');
|
||||
pathinfo.value = "";
|
||||
var errinfo = document.getElementById('errinfo');
|
||||
errinfo.value = "";
|
||||
var myCanvas = document.getElementById("myCanvas");
|
||||
myCanvas.src = 'placeholder.png';
|
||||
|
||||
sane.registerevent("OnInit", onInitFunc);
|
||||
sane.registerevent("OnGetDevices", onGetDevicesFunc);
|
||||
sane.registerevent("OnScanOneFileDone", onScanOneFileDoneFunc);
|
||||
sane.registerevent("OnErrorMessage", onErrorMessageFunc);
|
||||
|
||||
sane.init(38999, true);
|
||||
}
|
||||
|
||||
window.onbeforeunload = function()
|
||||
{
|
||||
sane.deinit();
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue