diff --git a/HKCardOUT/HKCardOUT.csproj b/HKCardOUT/HKCardOUT.csproj
index fea55d1..eacd408 100644
--- a/HKCardOUT/HKCardOUT.csproj
+++ b/HKCardOUT/HKCardOUT.csproj
@@ -14,9 +14,9 @@
1.0.0.0
AnyCPU;x86
-
+
TRACE;Core
diff --git a/HKCardOUT/ViewModels/RootViewModel.cs b/HKCardOUT/ViewModels/RootViewModel.cs
index a2b2010..6d9ee7a 100644
--- a/HKCardOUT/ViewModels/RootViewModel.cs
+++ b/HKCardOUT/ViewModels/RootViewModel.cs
@@ -82,9 +82,9 @@ namespace HKCardOUT.ViewModels
if (DataBus.StoreInfo != null)
{
DKoutput res = null;
- Monitor.TryEnter(async, 2000);
+ //Monitor.TryEnter(async, 2000);
res = UHF_RS485_Helper.GetInstance().ReadCard(item.Address.AsInt());
- Monitor.Exit(async);
+ //Monitor.Exit(async);
if (res != null)
{
HKLog.HKLogImport.WriteInfo($"{DateTime.Now.ToString("HH:mm:ss")} 卡号地址:{res.Address}----------卡号数据:{res.ResData}");
@@ -236,35 +236,43 @@ namespace HKCardOUT.ViewModels
{
if (Info != null)
{
- var Core = Container.Get();
- HKLogImport.WriteInfo("队列读取成功:" + Info.ToJson());
- if (Info.Date >= DataBus.Times.AMStartTime && Info.Date < DataBus.Times.AMEndTime)
+ if (!HKControl.Main.GetInstance.GetIsSwipe(Info.Location.AsInt()))
{
- Core.DeviceSaleAM(new SaleLog
- {
- CardNo = Info.CardNo,
- Location = Info.Location,
- IsSync = false
- });
+ Stacks.Enqueue(Info);
}
- if (Info.Date >= DataBus.Times.PMStartTime && Info.Date < DataBus.Times.PMEndTime)
+ else
{
- Core.DeviceSalePM(new SaleLog
+ var Core = Container.Get();
+ HKLogImport.WriteInfo("队列读取成功:" + Info.ToJson());
+ if (Info.Date >= DataBus.Times.AMStartTime && Info.Date < DataBus.Times.AMEndTime)
+ {
+ Core.DeviceSaleAM(new SaleLog
+ {
+ CardNo = Info.CardNo,
+ Location = Info.Location,
+ IsSync = false
+ });
+ }
+ if (Info.Date >= DataBus.Times.PMStartTime && Info.Date < DataBus.Times.PMEndTime)
{
- CardNo = Info.CardNo,
- Location = Info.Location,
- IsSync = false
- });
+ Core.DeviceSalePM(new SaleLog
+ {
+ CardNo = Info.CardNo,
+ Location = Info.Location,
+ IsSync = false
+ });
- }
- if (Info.Date >= DataBus.Times.ATStartTime && Info.Date < DataBus.Times.ATEndTime)
- {
- Core.DeviceSaleAT(new SaleLog
+ }
+ if (Info.Date >= DataBus.Times.ATStartTime && Info.Date < DataBus.Times.ATEndTime)
{
- CardNo = Info.CardNo,
- Location = Info.Location,
- IsSync = false
- });
+ Core.DeviceSaleAT(new SaleLog
+ {
+ CardNo = Info.CardNo,
+ Location = Info.Location,
+ IsSync = false
+ });
+
+ }
}
}
}
diff --git a/HKCardOUT/options.pro.json b/HKCardOUT/options.pro.json
index f628c99..0f1b2cb 100644
--- a/HKCardOUT/options.pro.json
+++ b/HKCardOUT/options.pro.json
@@ -3,7 +3,7 @@
//服务地址
"SaasRoute": "https://witt.black-pa.com/kitchen/",
//启动设备调试
- "StartDevice": false,
+ "StartDevice": true,
//串口
"COM": "COM8",
//定时任务时间表达式 每隔6小时推送一次
diff --git a/UHFHelper/UHF_RS485_Helper.cs b/UHFHelper/UHF_RS485_Helper.cs
index 089b948..ef5b8b4 100644
--- a/UHFHelper/UHF_RS485_Helper.cs
+++ b/UHFHelper/UHF_RS485_Helper.cs
@@ -72,7 +72,7 @@ namespace UHFHelper
_serialPort = null;
}
-
+ private object async = new object();
///
/// 读卡方法,返回读卡器数据
///
@@ -80,36 +80,47 @@ namespace UHFHelper
///
public DKoutput? ReadCard(int adr)
{
- if (_serialPort == null) return null;
- DKoutput dKoutput = new();
- var readByte = ReadByte(adr);
- _serialPort.Write(readByte, 0, readByte.Length);
- var result = SendMessage(readByte, 150, 18);
- if (result == null)
- {
- return null;
- }
- else
+ lock (async)
{
- //获取校验码
- var crc = result.Skip(16).Take(2).ToArray();
- //获取卡号
- var cardNo = result.Skip(6).Take(10).ToArray();
- //获取读卡器数据
- var readData = result.Skip(0).Take(16).ToArray();
- //获取读卡器地址
- var address = result.Skip(1).Take(1).ToArray();
- //判断数据是否合法
- var temcrc = CRC16.ToCRC16(readData);
- if (crc.ByteArrayToHexString() == temcrc.ByteArrayToHexString())
+ try
{
- dKoutput.Address = address.ByteArrayToHexString();
- dKoutput.ResData = cardNo.ByteArrayToHexString();
- return dKoutput;
+ if (_serialPort == null) return null;
+ DKoutput dKoutput = new();
+ var readByte = ReadByte(adr);
+ _serialPort.Write(readByte, 0, readByte.Length);
+ var result = SendMessage(readByte, 150, 18);
+ if (result == null)
+ {
+ return null;
+ }
+ else
+ {
+ //获取校验码
+ var crc = result.Skip(16).Take(2).ToArray();
+ //获取卡号
+ var cardNo = result.Skip(6).Take(10).ToArray();
+ //获取读卡器数据
+ var readData = result.Skip(0).Take(16).ToArray();
+ //获取读卡器地址
+ var address = result.Skip(1).Take(1).ToArray();
+ //判断数据是否合法
+ var temcrc = CRC16.ToCRC16(readData);
+ if (crc.ByteArrayToHexString() == temcrc.ByteArrayToHexString())
+ {
+ dKoutput.Address = address.ByteArrayToHexString();
+ dKoutput.ResData = cardNo.ByteArrayToHexString();
+ return dKoutput;
+ }
+ else
+ {
+ return null;
+ }
+
+ }
}
- else
- {
- return null;
+ catch (Exception ex) {
+ return null;
+
}
}
}