我想读取两个霍尼韦尔扫描仪的输入,即航行者1202克 and 轨道7190克。对于某些业务需求,需要在同一台计算机上使用这两种设备。Both扫描仪使用 Honeywell POS4NET 驱动程序。
我需要知道,which扫描仪正在传送数据。
The Scanner
对象创建如下
// This code is only for illustrating how my application works
// and may therefore be incomplete.
Microsoft.PointOfService.PosExplorer posExp = new PosExplorer(this);
DeviceCollection devices = posExp.GetDevices("Scanner",
DeviceCompatibilities.OposAndCompatibilityLevel1);
var listOfScanners = { Voy1202g , Orbit7190g }; // symbolical code
foreach (string device in listOfScanners)
{
var scanningDevice = posExp.CreateInstance(device) as Microsoft.PointOfService.Scanner;
if (scanningDevice != null)
{
scanningDevice.Claim(1000);
scanningDevice.DeviceEnabled = true;
scanningDevice.DataEvent += ScanningDevice_DataEvent;
scanningDevice.DecodeData = true;
scanningDevice.DataEventEnabled = true;
scanningDevice.ErrorEvent += ScanningDevice_ErrorEvent;
}
}
Problem:在事件处理程序内读取数据时ScanningDevice_DataEvent
,我无法再区分它们,因为对于这两种扫描仪,相同的事件被触发,无论哪个扫描仪实际读取条形码。
void ScanningDevice_DataEvent(object sender, DataEventArgs e)
{
Scanner scanner = (Scanner)sender; // <--- sender is always the last one
// in listOfScanners, i.e.
// Orbit7190g in this case.
// Additional code here ...
}
仅当两个扫描仪使用相同的驱动程序时才会出现此问题。如果我使用两个或多个不共享驱动程序的不同扫描仪,它会按预期工作。如果我启动应用程序的 2 个不同实例,每个实例都从一台扫描仪读取数据,情况也会如此。
问题:如何让我的应用程序触发正确的事件?
Remark:对我来说,看起来好像Microsoft.PointOfService
保存处理程序的单个实例每个服务对象类型,在这种情况下,总是HHP.PointOfService.ServiceObjects.Scanner.HandHeldScanner
。更改事件分配的顺序时,
识别的扫描仪也会发生变化。
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)