使用Zebra TC520K触摸电脑条形码扫描仪扫描条形码时遇到问题。在我的情况下,有几个条形码打印得很近。但这只是我感兴趣扫描的条形码之一。问题是,如果我的目标不完全正确,扫描仪会在我感兴趣的条形码旁边扫描错误的条形码。我要扫描的特定条形码是特定的值格式,该格式是由9位数字(0-9(组成的值。一些例子:;123456789";或";012301231";。安卓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
解码器吗?或者出了什么问题?
是的,这可以使用EMDK在每个符号的基础上完成。在解码器参数下,选择解码器,例如代码128,并将长度1和长度2设置为相同的值,在您的情况下为9。