1
This commit is contained in:
@@ -18,6 +18,8 @@ namespace RIZO_Application.Modules.ModuleName.ViewModels
|
||||
private ComScanHelper _scanHelper;
|
||||
private bool _isDisposed;
|
||||
private bool _isConnected;
|
||||
private string _lastLabel;
|
||||
private DateTime _lastScanTime;
|
||||
// 串口连接状态属性
|
||||
public bool IsConnected
|
||||
{
|
||||
@@ -110,6 +112,15 @@ namespace RIZO_Application.Modules.ModuleName.ViewModels
|
||||
// 定义事件处理方法
|
||||
private void HandleMessage(object sender, string labelCode)
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
// 短时间内重复扫了同一个标签(时间间隔小于500毫秒)
|
||||
if (_lastLabel!= null && _lastLabel == labelCode && (now - _lastScanTime).TotalMilliseconds < 500)
|
||||
{
|
||||
_eventAggregator.GetEvent<SystemLogEvent>().Publish($"重复扫码过滤: {labelCode}");
|
||||
return;
|
||||
}
|
||||
_lastLabel = labelCode;
|
||||
_lastScanTime = now;
|
||||
// 打印接收到的消息信息
|
||||
//_eventAggregator.GetEvent<SystemLogEvent>().Publish($"收到串口信息: {labelCode}");
|
||||
_eventAggregator.GetEvent<ScanEvent>().Publish(labelCode);
|
||||
|
||||
Reference in New Issue
Block a user