【发布时间】:2020-12-02 00:23:35
【问题描述】:
我在使用 Zebra TC520K 触摸式计算机条码扫描器扫描条码时遇到问题。就我而言,有几个条形码彼此靠近打印。但这只是我有兴趣扫描的条形码之一。问题是,如果我没有准确地瞄准,扫描仪会在我有兴趣扫描的条形码旁边扫描错误的条形码。我要扫描的具体条码是一个具体的值格式,格式是一个由9位数字(0-9)组成的值。一些示例:“123456789”或“012301231”。 Android Java EMDK 中是否有内置功能、方法或属性可用于过滤我感兴趣的特定条形码?我该怎么做?
我看到有一个选择不同解码器的选项,但我认为这还不够具体,只能针对值为 9 位的条形码。
谢谢!
更新:
我尝试使用length1 和length2 将解码器code128 设置为长度9。但条码扫描器仍能扫描所有条码,而不仅仅是 9 位长度的条码。以下是我如何初始化扫描仪并设置扫描仪配置:
// Method to initialize and enable Scanner and its listeners
public void initializeScanner() throws ScannerException {
if (scanner == null) {
// Get the Barcode Manager object
barcodeManager = (BarcodeManager) this.emdkManager
.getInstance(EMDKManager.FEATURE_TYPE.BARCODE);
// Get default scanner defined on the device
scanner = barcodeManager.getDevice(BarcodeManager.DeviceIdentifier.DEFAULT);
// Add data and status listeners
scanner.addDataListener(this);
scanner.addStatusListener(this);
// Hard trigger. When this mode is set, the user has to manually
// press the trigger on the device after issuing the read call.
// scanner.triggerType = Scanner.TriggerType.HARD;
scanner.triggerType = Scanner.TriggerType.SOFT_ALWAYS;
// Enable the scanner
scanner.enable();
// Scan Mode set to Multi Barcode
ScannerConfig sc = scanner.getConfig();
sc.readerParams.readerSpecific.imagerSpecific.scanMode = ScannerConfig.ScanMode.SINGLE_BARCODE;
sc.decoderParams.code128.length1 = 9;
sc.decoderParams.code128.length2 = 9;
sc.readerParams.readerSpecific.imagerSpecific.beamTimer = 0;
sc.readerParams.readerSpecific.imagerSpecific.aimTimer = 0;
scanner.setConfig(sc);
// Starts an asynchronous Scan. The method will not turn ON the
// scanner. It will, however, put the scanner in a state in which
// the scanner can be turned ON either by pressing a hardware
// trigger or can be turned ON automatically.
try {
scanner.addDataListener(this);
// Scan Mode set to Multi Barcode
//ScannerConfig sc = scanner.getConfig();
sc.readerParams.readerSpecific.imagerSpecific.scanMode = ScannerConfig.ScanMode.SINGLE_BARCODE;
// Thread.sleep(100);
sc.decoderParams.code128.length1 = 9;
sc.decoderParams.code128.length2 = 9;
sc.readerParams.readerSpecific.imagerSpecific.beamTimer = 0;
sc.readerParams.readerSpecific.imagerSpecific.aimTimer = 0;
// Thread.sleep(100);
scanner.setConfig(sc);
// scanner.read();
} catch (Exception e) {
e.printStackTrace();
}
}
}
我是否必须禁用所有其他解码器才能使其正常工作?我只需要启用code128 解码器还是有什么问题?
【问题讨论】:
-
您用于解码的设备上的哪个扫描仪/成像仪 - 后置摄像头或带瞄准灯的扫描仪?
标签: java android barcode-scanner motorola-emdk