HGScannerLib增加获取设备状态的接口

This commit is contained in:
luoliangyi 2023-02-14 11:16:15 +08:00
parent 058999c7c9
commit eb5f0f95c4
5 changed files with 26 additions and 0 deletions

View File

@ -22,6 +22,7 @@ HGLib_ReleaseDeviceParamGroupList
HGLib_ReleaseDeviceParam
HGLib_ResetDeviceParam
HGLib_DeviceIsPaperOn
HGLib_GetDeviceStatus
HGLib_DeviceRestart
HGLib_DeviceShutDown
HGLib_StartDeviceScan

View File

@ -948,6 +948,16 @@ HGBool HGLibDeviceImpl::IsPaperOn()
return HGFALSE;
}
HGInt HGLibDeviceImpl::GetStatus()
{
SANE_Bool isOn = SANE_FALSE;
unsigned int len = sizeof(SANE_Bool);
SANE_Status status = sane_io_control(m_devHandle, IO_CTRL_CODE_GET_PAPER_ON, &isOn, &len);
if (SANE_STATUS_GOOD == status)
return isOn ? 1 : 0;
return -1;
}
HGBool HGLibDeviceImpl::Restart()
{
SANE_Power stat = SANE_POWER_RESTART;

View File

@ -32,6 +32,7 @@ public:
static HGBool ReleaseParam(HGLibDeviceParam* param);
HGBool ResetParam();
HGBool IsPaperOn();
HGInt GetStatus();
HGBool Restart();
HGBool ShutDown();
HGBool StartScan(HGLibDeviceScanEventFunc eventFunc, HGPointer eventParam,

View File

@ -252,6 +252,17 @@ HGBool HGAPI HGLib_DeviceIsPaperOn(HGLibDevice device)
return deviceImpl->IsPaperOn();
}
HGInt HGAPI HGLib_GetDeviceStatus(HGLibDevice device)
{
if (NULL == device)
{
return -1;
}
HGLibDeviceImpl* deviceImpl = (HGLibDeviceImpl*)device;
return deviceImpl->GetStatus();
}
HGBool HGAPI HGLib_DeviceRestart(HGLibDevice device)
{
if (NULL == device)

View File

@ -527,6 +527,9 @@ HGEXPORT HGBool HGAPI HGLib_ResetDeviceParam(HGLibDevice device);
/* 设备是否有纸 */
HGEXPORT HGBool HGAPI HGLib_DeviceIsPaperOn(HGLibDevice device);
/* 获取设备状态, -1表示异常0表示无纸1表示有纸 */
HGEXPORT HGInt HGAPI HGLib_GetDeviceStatus(HGLibDevice device);
/* 重启设备 */
HGEXPORT HGBool HGAPI HGLib_DeviceRestart(HGLibDevice device);