feat(java): add new enum values and update scan method parameters
- Added new enum values HGLIB_OPTION_ENUMVALUE_SMZS_LXSM and HGLIB_OPTION_ENUMVALUE_SMZS_SMZDZS to HGScannerConstants - Updated startScan method parameter from 'param' to 'imageCaller' in HGScannerWrapper - Modified native library call to use separate caller parameters for event and image callbacks - Updated JavaDoc to reflect the parameter name change
This commit is contained in:
@ -207,4 +207,13 @@ public class HGScannerConstants {
|
||||
|
||||
public static final int HGLIB_OPTION_ENUMVALUE_SMZS_LXSM = 64;
|
||||
public static final int HGLIB_OPTION_ENUMVALUE_SMZS_SMZDZS = 65;
|
||||
|
||||
public static final int HGLIB_DEVSCAN_EVENT_BEGIN = 1; /* 扫描开始 */
|
||||
public static final int HGLIB_DEVSCAN_EVENT_END = 2; /* 扫描结束 */
|
||||
public static final int HGLIB_DEVSCAN_EVENT_INFO = 3; /* 扫描信息 */
|
||||
|
||||
// "单面"
|
||||
public static final int HGLIB_OPTION_ENUMVALUE_SMYM_DM = 45;
|
||||
// "双面"
|
||||
public static final int HGLIB_OPTION_ENUMVALUE_SMYM_SM = 46;
|
||||
}
|
||||
|
||||
@ -9,6 +9,9 @@ import com.sun.jna.ptr.IntByReference;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* 扫描仪JNA封装类
|
||||
@ -16,6 +19,8 @@ import java.util.List;
|
||||
*/
|
||||
public class HGScannerWrapper {
|
||||
|
||||
private static final Logger log = Logger.getLogger(HGScannerWrapper.class.getName());
|
||||
|
||||
private static final int STRING_BUFFER_SIZE = 256;
|
||||
private static HGScannerLib scannerLib;
|
||||
|
||||
@ -235,6 +240,18 @@ public class HGScannerWrapper {
|
||||
return scannerLib.HGLib_StartDeviceScan(device, eventCallback, eventCaller, imageCallback, imageCaller);
|
||||
}
|
||||
|
||||
public static Future<Boolean> startScanAsync(HGScannerLib.HGLibDevice device, HGScannerLib.HGLibDeviceScanImageFunc imageFunc) {
|
||||
CompletableFuture<Boolean> future = new CompletableFuture<>();
|
||||
scannerLib.HGLib_StartDeviceScan(device, (ignore, event, operateCode, info, param) -> {
|
||||
log.info(String.format("[图片扫描] [event: %d] [operateCode=%d]: %s", event, operateCode, info));
|
||||
if (event == HGScannerConstants.HGLIB_DEVSCAN_EVENT_END) {
|
||||
future.complete(true); // 或适当的返回值
|
||||
}
|
||||
}, null, imageFunc, null);
|
||||
return future;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 停止扫描
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user