Browse Source

添加断网

undefined
xxe 2 years ago
parent
commit
3bf1b8e35c
1 changed files with 13 additions and 44 deletions
  1. +13
    -44
      HKCardOUT/ViewModels/RootViewModel.cs

+ 13
- 44
HKCardOUT/ViewModels/RootViewModel.cs View File

@@ -79,16 +79,21 @@ namespace HKCardOUT.ViewModels
{ {
if (UHF_RS485_Helper.GetInstance().GetSerialPortState()) if (UHF_RS485_Helper.GetInstance().GetSerialPortState())
{ {
DataBus.StoreInfo.Devices.ForEach(item =>
if (DataBus.StoreInfo != null)
{ {
var res = UHF_RS485_Helper.GetInstance().ReadCard(item.Address.AsInt());

if (res != null)
DataBus.StoreInfo.Devices.ForEach(item =>
{ {
if (!res.ResData.IsMatch(new Regex("0{20}")))
ReadFunc?.Invoke(res);
}
});
var res = UHF_RS485_Helper.GetInstance().ReadCard(item.Address.AsInt());

if (res != null)
{
if (!res.ResData.IsMatch(new Regex("0{20}")))
ReadFunc?.Invoke(res);
}
});
}
else
HandyControl.Controls.Growl.InfoGlobal("系统已离线,请连接网络,并重启程序!");
} }


Thread.Sleep(10); Thread.Sleep(10);
@@ -112,42 +117,6 @@ namespace HKCardOUT.ViewModels
}), "打开串口"); }), "打开串口");


} }
/// <summary>
/// 读取信息
/// </summary>
public void GetData()
{
//开启循环监听数据
timer1.Interval = 500;
timer1.Elapsed += (o, a) =>
{
if (!UHF_RS485_Helper.GetInstance().GetSerialPortState())
{
HandyControl.Controls.Growl.InfoGlobal("串口打开失败");
timer1.Stop();
return;
}
else
{
if (DataBus.NetWordState)
{
DataBus.StoreInfo.Devices.ForEach(item =>
{
var res = UHF_RS485_Helper.GetInstance().ReadCard(item.Address.AsInt());

if (res != null)
{
if (!res.ResData.IsMatch(new Regex("0{20}")))
ReadFunc?.Invoke(res);
}
});
}
else
HandyControl.Controls.Growl.InfoGlobal("系统已离线,请连接网络,并重启程序!");
}
};
timer1.Start();
}
protected override void OnViewLoaded() protected override void OnViewLoaded()
{ {
//广告初始化 //广告初始化


Loading…
Cancel
Save